Friday, February 18, 2011

Mac Mini ethernet port does not work at 1 Gigabit

Today I decided to connect my Mac Mini to the router using the ethernet cable and it didn't work. It would connect and then disconnect a minute later. I tried using different cables but that didn't fix the problem. Those cables work when I connect them to my PC so it is not the cable problem. Anyway, after browsing around the support forum, I decided to down grade the connection from 1 Gigabit to 100 Mbps and it starts to work.

Thursday, February 17, 2011

It takes 3 to 5 days to load money onto a Clipper Card!!

Please note that when you add value online, it can take up to 3-5 days for the value to be available to be loaded onto your card, and you must tag your card to a card reader to load the value.
I was hit with that message when trying to load my Clipper Card tonight. On top of that, you can't actually add money onto your card online. You need to go and tag your card at a card reader before the money can be loaded. No wonder the page title is "Add value online" instead of "Add value to your Clipper Card online".

The next stupid thing is this line.
Your card balance will not be updated until you have tagged your card and loaded the value.
Of course, you don't know when to go and tag your card because it can take up to 3-5 days before the money is available. I guess you can go and tag your card everyday then go online and check your balance. If your balance went up then you have successfully loaded your card. What a dump design. I bet those engineers made a bunch of money coming up with this stupid process too. So much for trying to be more efficient.

Of course, I do have an alternative way to do this. If I walk to my local Walgreens, they can put money onto the card right away. Since I have to walk to Walgreens to load my card, I might as well just get a new one. The card is free.

Thursday, February 10, 2011

Bidirectional binding in Griffon

It took me a lot of searching to figure out how to do bidirectional binding in Griffon.

class PersonModel {
    @Bindable String firstName
}

textField(id: 'firstName', text: bind(target: model, targetProperty: 'firstName', mutual: true)

The key word is "mutual: true"

Here is where I got the info from. It is at the bottom of the article.

http://www.jroller.com/aalmiray/entry/building_rich_swing_applications_with2

Wednesday, February 02, 2011

Tuesday, February 01, 2011

Left Outer Join in Linq

I always can't quite remember how to do left outer join in Linq. Here is an example of how to do left outer join in linq using C#.

Class definitions:
class Book
{
    public int Id { getset; }
    public String Name { getset; }
}
 
class OrderItem
{
    public int BookId { getset; }
    public int Quantity { getset; }
}
Sample data:
var books = new List<Book>
{
    new Book {Id = 1, Name = "Groovy in Action"},
    new Book {Id = 2, Name = "Implementation Patterns"},
    new Book {Id = 3, Name = "C# Cookbook"}
};
var orderItems = new List<OrderItem>
{
    new OrderItem {BookId = 1, Quantity = 1},
    new OrderItem {BookId = 1, Quantity = 2},
    new OrderItem {BookId = 1, Quantity = 2},
    new OrderItem {BookId = 2, Quantity = 1},
    new OrderItem {BookId = 2, Quantity = 1},
    new OrderItem {BookId = 2, Quantity = 1}
};
Query:
var query = from b in books
            join oi in orderItems on b.Id equals oi.BookId into t
            from r in t.DefaultIfEmpty(new OrderItem())
            select new
                        {
                            BookId = b.Id,
                            BookName = b.Name,
                            Quantity = r.Quantity
                        };
 
foreach (var r in query)
{
    Console.WriteLine("Id = {0} Name = {1} Quantity = {2}",
        r.BookId, r.BookName, r.Quantity);
}
Result:
Id = 1 Name = Groovy in Action Quantity = 1
Id = 1 Name = Groovy in Action Quantity = 2
Id = 1 Name = Groovy in Action Quantity = 2
Id = 2 Name = Implementation Patterns Quantity = 1
Id = 2 Name = Implementation Patterns Quantity = 1
Id = 2 Name = Implementation Patterns Quantity = 1
Id = 3 Name = C# Cookbook Quantity = 0