Monday, August 03, 2009

Today I decided to install the new beta version of Google Chrome. I have used some previous versions and didn't like it so much and so far feel the same way about the beta (version 3.0.193.2). My main gripes about Chrome are the following.

Bookmarks:

I really don't like the way bookmarks work in Chrome. I can't seem to find the bookmark I want as fast as I could in Firefox. There seems to only be the bookmarks bar at the top of the screen for browsing bookmarks which is something I don't like. Most screens are wider then they are tall so it makes a lot more sense to me to have the bookmarks on the side of the screen which is a better use of the space. This is another feature I like better in Firefox.

When opening a new tab why is there not a way to search bookmarks? Currently the search function on the new blank tab only allows for searching of the history which I never use as it's not very useful to me. How about an option to change the search location?

Tabs:

Why is there no options for adjusting how tabs work. This is another feature that I really like about Firefox that seems to be missing from Chrome. I want the Firefox options like "When I open a link in a new tab, switch to it immediately" and "Open new windows in a new tab instead". In short, why are there no options for how tabs work?

I don't know if anyone else feels this way about Chrome but these issues continue to stop me from using it very much. If anyone has anything to add to this please share. Can we get some new features added to Chrome if enough people ask?

Friday, March 20, 2009

I've been using the Infragistics ASP.NET controls a bit recently and wanted to share a bit of code that I wrote. This code is used to take a Rate (could be a price), a discount, and calculate a Total using the Infragistics javascript client object model. How the calculation is done is up to you. I used a calculation that let's the end user enter a value like 5 (for 5%) and then the calculation converts to a decimal and calculate the total.



function beforeCellUpdate(gridClientId, cellId, newValue) {
var grid = igtbl_getGridById(gridClientId);
var band = igtbl_getBandById(cellId);
var bandKey = band.Key;

if (bandKey == 'Invoice') {
var invoiceRow = igtbl_getRowById(cellId);
var invoiceCell = igtbl_getCellById(cellId);
if (invoiceCell.Column.Key == 'Discount') {
var invoiceDiscount = newValue;
var childRowCount = invoiceRow.ChildRowsCount;
// Iterate over Invoice Items and update cell values.
for (var i = 0; i < childRowCount; i++) {
// Get InvoiceItem row from Invoice row.
var invoiceItemRow = invoiceRow.getChildRow(i);
// Get current rate value from InvoiceItem.Rate cell.
var rate = invoiceItemRow.getCellFromKey('Rate').getValue();
// Set InvioceItem.Discount cell to value entered into Invoice.Discount cell.
invoiceItemRow.getCellFromKey('Discount').setValue(invoiceDiscount);
// Get calculated InvoiceItem.Total.
invoiceItemTotal = getItemTotal(rate, invoiceDiscount);
// Set InvoiceItem.Total cell value to calculated value.
invoiceItemRow.getCellFromKey('Total').setValue(invoiceItemTotal);
}
// Get calculated Invoice total.
var invoiceTotal = getInvoiceTotal(invoiceRow);
// Set Invoice.Total cell value to calculated value.
invoiceRow.getCellFromKey('Total').setValue(invoiceTotal);
}
}

if (bandKey == 'InvoiceItem') {
var invoiceItemRow = igtbl_getRowById(cellId);
var invoiceItemCell = igtbl_getCellById(cellId);
var rate = invoiceItemRow.getCellFromKey('Rate').getValue();
var discount = invoiceItemRow.getCellFromKey('Discount').getValue();

if (invoiceItemCell.Column.Key == 'Rate') {
// If rate changed use newValue for rate.
rate = newValue;
}
else if (invoiceItemCell.Column.Key == 'Discount') {
// If discount changed use newValue for discount.
discount = newValue;
}

// Get calculated InvoiceItem.Total.
var invoiceItemTotal = getItemTotal(rate, discount);
invoiceItemRow.getCellFromKey('Total').setValue(invoiceItemTotal);

var invoiceRow = invoiceItemRow.ParentRow;
var invoiceTotal = getInvoiceTotal(invoiceRow);
// Set InvoiceItem.Total cell value to calculated value.
invoiceRow.getCellFromKey('Total').setValue(invoiceTotal);
}

if (bandKey == 'InvoiceItemCharge') {
var itemChargeRow = igtbl_getRowById(cellId);
var itemChargeCell = igtbl_getCellById(cellId);
var rate = itemChargeRow.getCellFromKey('Rate').getValue();
var discount = itemChargeRow.getCellFromKey('Discount').getValue();

if (itemChargeCell.Column.Key == 'Rate') {
// If rate changed use newValue for rate.
rate = newValue;
}
else if (itemChargeCell.Column.Key == 'Discount') {
// If discount changed use newValue for discount.
discount = newValue;
}

var itemTotal = getItemTotal(rate, discount);
itemChargeRow.getCellFromKey('Total').setValue(itemTotal);
}
}
// Calculates the total from the rate and discount.
function getItemTotal(rate, discount) {
var total = 0;
total = rate * (1 - discount / 100);
return total;
}
// Iterates over the InvoiceItem rows to sum the item totals.
function getInvoiceTotal(invoiceRow) {
var invoiceTotal = 0;
var invoiceItemCount = invoiceRow.ChildRowsCount;
// Iterate over the current Invoice.InvoiceItem row collection.
for (var i = 0; i < invoiceItemCount; i++) {
var invoiceItemRow = invoiceRow.getChildRow(i);
invoiceTotal += invoiceItemRow.getCellFromKey('Total').getValue();
}
return invoiceTotal;
}

This is specific to the Infragistics UltraWebGrid but it might not be too hard to change out for another grid.

InfoQ has a good article on Isolation Levels that I think is a good read. This is especially true for this who are not so familiar with them.

http://www.infoq.com/articles/eight-isolation-levels

Enjoy!

Monday, August 18, 2008

Here is a really nice simple way of seeing how big the data in your table/column is. I often use this for maintenance to see over time how much data is being entered into a column. If the database has been in use for a while and you see that the majority of the data being entered is smaller then the size of the column you can go back and change the varchar/char data columns. This will save you space and performance over the lifetime of your application.
SELECT
ColumnName, LEN(ColumnName) Length
FROM
dbo.EventLog
GROUP BY
ColumnName
ORDER BY
Length DESC

Friday, March 14, 2008

Hello all,

I just found out about this and have to post a comment just to get more attention for it. I'm a Google gmail user and love the gmail system, except that there isn't a way to create sub-folders/labels. In any case it's my favorite online mail system. When I found this article talking about emails, large numbers of them just disappearing from peoples inbox I was very disappointed to find that Google is not concerned with it. I really hope Google gets on this and finds out what's happening. At least by more helpful to the people using the service and be real about it.

Thursday, February 07, 2008

I just thought this little piece of code was useful and I didn't find much in my google searches for doing this cleanly so here you go.

Creating a drop down list of the months in a year with their name and numeric value.

for (int i = 1; i <= 12; i++)
{
DateTime datetime = new DateTime(1, i, 1);
string month = datetime.ToString("MMMM");
dropdownlist.Items.Add(new ListItem(month, i.ToString()));
}

Thursday, January 10, 2008

I've stumbled across another asp.net related problem that I think should be easier then it is. I've started using the SqlDataSource control which can be great because it allows you to do a sort of "Live" edit of the selected data. This is all great except for the fact that the only way I can get it to work is if the data I'm selecting and binding to a grid is bound on when the page is loaded the first time.

The problem this creates is that there is no way to enter some search criteria and then click a button to execute the search, bind the results to the grid and then edit the results. The edit part of the functionality is now broken. I don't know why Microsoft designed the DataSource controls like this because it makes them useful in only the simplest of scenarios.

I've started a Google Groups post here if you want to see the progress on this. You can always post comments here as well.

Maybe I'm just missing the point of the DataSource controls and maybe there are newer more advanced controls that I am not aware of. Microsoft has been developing new technologies at such a fast rate that I can't keep up with everything.

Wednesday, January 09, 2008

I just had to share this photo of Yosemite I took the day before Christmas. I would highly recommend that you visit Yosemite in the winter time and when there is snow on the ground. It's a magical place.