Thursday, October 22, 2009

MBTA BingVis WPF Application

I've been working on a side project with some recently released data from the MBTA (Boston Transit Authority). The goal of the application is to take some fare files with individual transactions throughout the day and visualize them in some way.

I've released a preliminary version after a week of work. I'm hoping to do some improvements to the loading of fare files. But, shipping is a feature.

If you want to install the application, this link should work. Then check your Start Menu -> Programs -> MBTA BingVis folder to start the application.

Check out the project page on CodePlex for updates in the future.

Now Playing - Jay-Z - On To the Next One

Monday, October 12, 2009

Real Estate Rant

The following is an email correspondence between me and our real estate agent after having received a list of petty repairs to be made before closing, which we eventually conceded to do. I think it sums up our frustration with selling our house pretty well.

On a side note, we are getting very frustrated by all of this and we found the letter that was forwarded to be disrespectful and rude. I don't know why such a vague emotional appeal should ever have been brought into this negotiation. It certainly didn't make us want to help them out, if anything it made us want to walk-away from such disrespectful and greedy buyers. I always find numbers objective and appealing, here are some numbers so you know what our perspective is:

112000 - What we paid for the house
2000 - Cost of closing at purchase
3000 - Price of new furnace
400 - Cost of new dishwasher
1000 - Cost of new refrigerator and Oven
3500 - Cost of new Deck
3000 - Cost of new Kitchen
124900 Total

Their offer: 113500 after us conceding 1500 from our asking price.

What we get after agents fee and warranty: Approx. 108000.

Approx. Actual Loss by Mr. and Mrs. Gable: 16900.

But that has absolutely no bearing on how they make their decision, does it? We are not so stupid as to try and write up a nice letter that will make some vague emotional appeal about why they should just go ahead and concede. What I can do is complain to my agent, because you are the buffer between us and them so that emotions don't cloud the fact that we need to sell the house. So, we appreciate being able to vent a little bit right now.

We are ready to close on this house. Let's get it done.

Now Playing: Starship - We Built This City

Wednesday, September 23, 2009

Handling Pessimism - Douchebag Coexistence

I tend to have what I call a douchebag coexistence problem; meaning when I perceive someone as a douchebag, all I seem to think about is their douchebagginess instead of listening to anything they have to say. They could just have created an awesome framework that builds enterprise applications in less than 10 lines of code AND makes me toast in the morning but the second they start talking to me this little voice in my head just starts repeating "douchebaggity doo douchebaggity doo...". Needless to say, this is not a healthy response to what is probably just a pessimistic person. It's something I'm working on.

So I read books like The No-Asshole Rule, Managing Humans and How to Win Friends and Influence People... and I still hear the voices. Honestly, the "How To Win Friends..." book is great for dealing with people in general and I recommend it to anyone who has to talk to people on a regular basis. Yes, anyone who has to talk to people in any capacity, at all, should read that book.

I also just read an interesting article on the Harvard Business Review website about How to Handle the Pessimist on Your Team. I recommend reading the full article, but I'll paraphrase shortly three approaches that are described:
1. Create awareness. This is best done by pulling the team member aside and explaining how his comments are received.

2. Reposition negative statements. Don't let negative comments linger; ask for clarification and maybe even require a follow up "But..." statement.

3. Involve the whole team. Set team norms and ask that everyone observe them.
So anyway, the first step is admitting you have a problem, right? Like I said, I'm working on it.

Now Playing - Jay-Z - Run This Town

Tuesday, September 15, 2009

DelegableEqualityComparer Dirtiness...

Occasionally I like to just get something done with some Lambda expressions that probably should be more properly architected.

In case someone else feels like doing something a little naughty with Lambda expressions, here is an example of what I call a DelegableEqualityComparer that will take as parameters the equality function to use and the function to generate a HashCode.

Disclaimer:  I didn't say it's the right way, just that it might be useful sometime.

    public class DelegableEqualityComparer<T> : IEqualityComparer<T> 


        private Func<T, T, bool> equalsFunc; 

        private Func<T, int> hashFunc; 


        public DelegableEqualityComparer(Func<T,T,bool> EqualityFunction, Func<T, int> HashFunction) 


            equalsFunc = EqualityFunction; 

            hashFunc = HashFunction; 



        #region IEqualityComparer<T> Members 


        public bool Equals(T x, T y) 


            return equalsFunc.Invoke(x, y); 



        public int GetHashCode(T obj) 


            return hashFunc.Invoke(obj); 





// Example of inheriting for simple comparers. 

    public class ValidationResultMessageComparer : 



        public ValidationResultMessageComparer() 

            : base( 

                // Equality Comparer 

                (x, y) => String.Equals(x.Message, y.Message), 

                // HashCode 

                (o) => o.Message.GetHashCode() 






// Example of using in-line 

foreach ( var result in results.Distinct(new DelegableEqualityComparer<ValidationResult>((x,y) => x.Message.Equals(y.Message), o => o.Message.GetHashCode()))) 


        // Your distinct results... 


Now Playing: Rick Ross - Hustlin' Remix

Sunday, September 6, 2009

Bind HTML To Textblock with HTML to XAML Converter

I was recently looking for an easy way to get some existing HTML content resources into a WPF / Silverlight application. Now, in retrospect, it looks like I could have done something with a FlowDocument Viewer that might have been a little easier, but I figured I would post my solution in case it helps out someone else.

There are basically 3 pieces to binding HTML to a Textblock in WPF.
  1. Some HTML and a TextBlock to bind the HTML to.
  2. An HTML to XAML Converter (Provided by MSDN, adapted slightly)
  3. An Attached Property for the TextBlock.
The HTML to XAML Converter comes from a sort of proof of concept over on MSDN. I basically took the converter sample project and combined it all into one file so I could easily incorporate it into my project (or any other project for that matter; you can download the code below). The converter will parse the HTML, tokenize it, and convert it to a collection of Inline XAML elements that we can add to the TextBlock Inlines property.

All that's left is adding an Attached Property for us to bind to and replace the TextBlock's Inline elements. The way this works is to use a standard Attached Property and whenever our Attached Property changes, convert the bound HTML to a collection of Inline elements and add them to our TextBlock. The majority of the hard stuff is done by the HTML to XAML converter, but here is the code for the Attached Property and an example of the XAML to use it in your application.

Download Sample App / Code

// Attached Property to facilitate Binding HTMLto a TextBlock
    public static class HtmlTextBoxProperties 
        public static string GetHtmlText(TextBlock wb) 
            return wb.GetValue(HtmlTextProperty) as string; 
        public static void SetHtmlText(TextBlock wb, string html) 
            wb.SetValue(HtmlTextProperty, html); 
        public static readonly DependencyProperty HtmlTextProperty = 
            DependencyProperty.RegisterAttached("HtmlText", typeof(string), typeof(HtmlTextBoxProperties), new UIPropertyMetadata("", OnHtmlTextChanged)); 

        private static void OnHtmlTextChanged( 
            DependencyObject depObj, DependencyPropertyChangedEventArgs e) 
            // Go ahead and return out if we set the property
on something other than a textblock, or set a value that is not a string.
            var txtBox = depObj as TextBlock; 
            if (txtBox == null) 
            if (!(e.NewValue is string)) 
            var html = e.NewValue as string; 
            string xaml; 
            InlineCollection xamLines; 
                xaml = HtmlToXamlConverter.ConvertHtmlToXaml(html,
                xamLines = ((Paragraph)((Section)System.Windows.Markup.XamlReader.Parse(xaml)).Blocks.FirstBlock).Inlines; 
                // There was a problem parsing the html, return
            // Create a copy of the Inlines and add them to the
            Inline[] newLines = new Inline[xamLines.Count]; 
            xamLines.CopyTo(newLines, 0); 
            foreach (var l in newLines) 

   behaviors:HtmlTextBlockProperties.HtmlText="{Binding Path=MyHtml}"

Now Playing - Matt & Kim - Daylight

Saturday, March 28, 2009

Nonverbal Communication: Experiences in Parking Cars

According to the almighty Wikipedia;

A gesture is a non-vocal bodily movement intended to express meaning. They may be articulated with the hands, arms or body, and also include movements of the head, face and eyes, such as winking, nodding, or rolling ones' eyes.

A gesture is just one of the many forms of Nonverbal communication that we use everyday. What you may not know is just how important Nonverbal communication is in directing traffic in a parking lot of 200+ cars.

I recently had the pleasure of volunteering with the Mass Audubon Society during their local Woolapalooza extravaganza, and extravaganza it certainly turned out to be. We couldn't have asked for better weather, 60 and Sunny all day; I myself am returning to my Kentucky roots sporting a nice red-neck to show for my work today.

After a quick meeting with our Boston Cares team leaders I headed out to the parking lot to meet up with the rest of the team, which consisted of: One tall lanky Oakley sunglass sporting middle aged man named Tony who is the head parking guy, another shorter wiry balding man named Bob but referred to as "Bo" by other staff members, a lovely blonde female twenty something staffer who exudes happy-go-luckyness from every ounce of her being, and the other volunteer assigned to this team, a congenial middle aged Scottish man wearing a Patriots hat and some sporty sunglasses.

I'm given a vibrant orange vest to wear, like everybody else, "So I don't get run over" says Tony. The vest is the start of our Nonverbal communication, it clashes with the pale verdant shades of the new found Spring that has arrived this very day as if in anticipation of this very extravaganza. After a bit of a dry run in a smaller parking lot, we start seeing a major influx of cars around 10:30 AM.

Every parking car is just looking for some direction. Naturally, the Orange Vested are here to help in any way we can. Here is the first lesson I learn about Nonverbal communication while parking cars: Keep a smile, you are the first contact of this extravaganza for these people. It seriously all starts with you, if someone has a bad experience parking, they are going to be pissed off when they get to the gate and have to wait in line to get in, etc... I, the Orange Vested, am here to help you park in an efficient and economical way, the problem is, I can't share that feeling with you, the parking person, except through limited gestures involving hands, smiles, thumbs-ups, occasional leg-kicks and maybe a fist pump or two (okay, maybe I squeezed a wink in every now and then).

Let me break down the normal communication cycle while parking a car. First, there is the communication confirmation. This is normally a head-nod or direct eye-contact with the driver of the vehicle. What were doing here is setting up this nonverbal conversation between the Orange Vested and the parking party. What we want to convey here is that we see them, they are important, worthy of our attention and we are going to get them in a spot as quick as possible.

Next we want to start with a direction impression. The direction impression is usually a grandiose gesture with the hands that indicates a particular direction to be followed. The direction impression is vital because it lets the parking party know where to go next. The direction impression could point towards an available parking spot or just to the next Orange Vested individual who will continue the nonverbal directions to an available parking spot.

Finally, we have the landing directives. The landing directive is usually a horizontally outstretched right hand indicating where the front of the car should end up as well as a continuous circular "come-hither" motion with the left hand. These directives are usually given out by the Orange Vested individual in the parking spot to be parked in. The directives indicate how far to pull in, and if and where they may be dangers in the spot, e.g. rough or muddy terrain.

Overall, I had a great time parking cars today. I know I have a new found respect for the people directing traffic at large events.

Now Playing: Dropkick Murphys - I'm Shipping up to Boston

Sunday, March 1, 2009

Mandating Community Service

I recently joined an organization called Boston Cares. They provide a great way for young people to find and get involved in volunteer/community service projects all across the greater Boston area. I had a great time last Saturday handing out food at the Red Cross Food Bank. It's a great way for me to meet other people in the area, get to know the city and help out in the community.

Now, normally I wouldn't bring it up.  I tend to be more of a Matthew 6:3 type of philanthropist, but I also happened across an interesting post on the Harvard Business Review Editor's Blog about mandating community service.  The author makes some interesting points about what young people get from community service organizations like City Year and why we should push for mandating community service from a business perspective:
1) A Work Ethic. My stepson, who could easily have earned a double Ph.D in Sleep and Responsibility Avoidance, now wakes up at 6:30 to face the music, puts on a uniform and works hard 50 or more hours per week.

2) Fundamental Skills. Today, too many kids are tracked to college programs to which they are not well suited; community services programs act as de facto apprenticeship and internship training programs.

3) Respect for Diversity. Companies cry a lot about the lack of diversity in their management pipelines, because they stay inside the same predictive box. By supporting community service programs that encourage young people from a variety of backgrounds, they can help to educate a new, multifaceted generation of leaders.

4) Empathy. Emotional intelligence is in huge demand these days. Companies need managers that can engage and motivate workers. I will wager that someone who has learned to work with the less fortunate knows more about right-brained, empathic leadership than anyone coming from the average MBA program.

5) Democracy 101. Finally, companies that support community service programs teach kids a lesson in real de Tocqueville-style democracy. As the great philosopher noted, democracy requires its citizens to be fully (mentally and physically) engaged. (For an impassioned "Amen," read former Senator Gary Hart's essay, "Restore the Republic").
Please check out the full article for more information and some helpful links.

Resources for Rapid Web Prototypes

Alot of times, I find myself in a position where I have to put some prototype together of some bit of functionality so I can convince either myself or someone else that we should use it in an upcoming project.  Whenever I need to do one of these "Rapid Prototype" type of projects I always end up needing to put together a little website template to show off the functionality (presentation is important when trying to get a sign-off).  I've started using some free templates I found over at Smashing Magazine to help me get to the Rapid Prototyping faster, instead of sitting around making a pretty site from scratch.  

Here are a couple useful links I've found:

100 Free High-Quality XHTML/CSS Templates - Bunches of templates ready to use, most if not all are licensed either under MIT or GPL.

Company Dark Blue Template - Nice little conservative business company template.

Free CSS Layouts and Templates - These are nice if you are just looking for the scaffolding of the site without any artwork.

Jquery - Must have for most of my current web work, also see this post at Encosia for tips on having Google Host your jQuery (all the cool kids are doing it...)

Block UI Plugin - Great for modal dialogs, even has some cool support for Growl like popups.

jTemplates Plugin - Great for client side templating of JSON data.

Encosia's Posts on jQuery and .Net nuances - Great place to start if you are new to jQuery and how best to use it with .Net

Friday, February 20, 2009

Subway Rumble - Part 3

I see this all coming in slow motion from the time he hocks the loogey and all I can think about is a straight up Yellow-Belt level straight kick to the chest, but then I remember I didn’t really ever get the Yellow-Belt so I slowly back away towards the back of the train while Butterbean starts the bull rush. I luck out and he trips over himself on some stairs and is faced down right in front of me with the other two guys behind.

At this point we are going on like a good 10 minutes of ruckus with this Butterbean behemoth and something in me snapped. I’m tired of trying to just keep this guy from hurting me and I’m ready to knock this dude out. I throw a kick that lands my lower shin to his forehead and the top of my foot slaps the side of his head, I follow up with a right hook somewhere about the face area. By this time the other two guys have come up and are a little surprised, everyone kinda is like “okay, okay, just hold him down, easy there…”

Look, I probably shouldn’t have hit the guy, but the cops weren’t there and I had already subdued the guy like 3 times, it was time to step up the alert level a little. A little bit after that the cops showed up and took him off the train. He got arrested for PI probably, but they asked if we wanted to press charges and we said no. When we were getting questioned by the cops they asked for our ID’s and I still have my Kentucky Drivers License, when I handed him my license I said “It’s my second week in the big city”. He laughed and said, “Aw $&*!, you’re from Kentucky, I’m amazed you didn’t have him strung up and skinned in here”.

So anyway, that was pretty exciting.

Subway Rumble - Part 2

So... I was holding on for dear life... to this guy

I’ve got him from the side, in side-guard if you will, while we’re both standing up. I’ve got my right hand around his chest and up under his arms and I’ve wrapped it around and grabbed a pole with both hands. So, I’ve got this guy pretty jammed up, he’s not moving and I’m not even squeezing that hard. I start saying “hey man, be cool, be cool, I don’t wanna fight you, just be cool”, but he is going nuts and fighting to get out and get after Nick. But he isn’t trying to hit me. In the mean time, the hot chick (who I might add, is the starter of this whole thing because of her being a Skinny Rich Hot White Girl) is freaking out and has run to the very back of the train.

There are only 4 people on the train at this point, Me, Nick, Hot Chick, Butter Bean, and some College student who was passed out in the front of the train at the beginning of the fight. This is when the most cowardly train driver known to man decides to get involved. The train driver is like 50 with gray hair and a bushy mustache like some kinda Russian circus ring leader. He’s got big glasses and he keeps repeating throughout the entire ordeal “aww geez” almost like that voice of the turtle in Rocko's Modern Life. So he comes back to the middle of the train and he starts telling me to just let him go so I start to ease up, but then Butterbean starts to try and bite my arm and then he takes off after Nick.

Sometime right before this the college kid has woken up and is stumbling back to figure out what is going on, right as Nick is running past him to the front of the train and Butter bean is hot on his tails. So the bleary-eyed college kid kinda clotheslines butterbean and just tries to keep him down. Meanwhile, I’m having flashbacks of being punched in the face at Jason’s Party and I run up and am like “I’m here brother, I got you, I got you” like me and the college kid are sharing salads or something. And so me and the college kid are keeping him down and Butter Bean is En-Raged, getting madder by the second. Meanwhile the “Aw Geez”’in train driver is like “just let him up and he will get off the train” so we eventually let the guy up and he runs after Nick out the train.

Nick played lacrosse in California before moving out here to work for the Red Sox as an intern, so needless to say, he has some moves. Nick throws down a sweeeeet double deek swoop-dooper and scoots back on the bus with Butter Bean left in the dust outside the train. So now we’re yelling at the driver, “Close the door, close the door” but this guy is like “I can’t do that” and he stands at the top of the stairs trying to do what I can only think of as Jedi Mind Tricks… “You will get off the train…”, “These are not the boys you are mad at…” and all the mean while this guy is looking right at me now all cross-eyed and drooling going “I’m gonna kill you… Then I’m gonna kill you…” looking over to Nick and the college kid like all of a sudden were on WWE Monday Night Raw or something. Then he hocks a big loogey in the Cowardly Jedi-Master train drivers face who then ducks outta the way so frickin butter bean has a nice path to bull rush at Nick and I.

I start thinking about my youth... specifically the Karate Lessons I started to get tired of and never finished...

Now Playing - Bon Iver - Skinny Love

Subway Rumble - Part 1

Alright so, let me tell you about this fight I got in on the subway the 2nd week I was here. It’s nuts. Me and one of my roommates Nick went to a bar to watch the UFC fight. We went to this bar right next to Fenway, where the red sox play. The bar is right behind the “Green Monster”, the big wall in left field. Anyway, we watched the fight and I drank some beers but I was pretty straight (That’s another great thing about the subway, you can be totally blasted and still have a ride home, just make sure you take a piss before you leave… you may even wanna take two pisses).

Nick doesn’t drink, so he was sober the whole night and we headed back to the subway station about 12:30 at night. We watched some dude take a piss on the floor in the station, and get arrested… (Obviously he did not take two pisses before he left) Then the train came and we hopped on it to get home.

Let me kind of describe the trains, the Green Line (A,B,C,D are all Green Lines) is where I live, I live at the end of the C line (Called Cleveland Circle) but you can also take the B Line to Reservoir and there’s a little side dip that will get you home… or raped… it’s 50/50. The trains on the green line are more like trolley cars, but enclosed. The C line runs in the middle of this long road called Beacon that runs right into downtown. C Line trains have to stop at stop lights and shit, but they are riding on rails, the rails just run in the middle of the street, kind of like where the median would be. So, there is usually two cars to a train, and there is like a little middle part that is like an accordion so it can flex between the cars when the train goes through a curve.

When me and Nick got on the train the only spots left to sit were on the middle part and there was a kinda hot girl and this bald Butter Bean looking dude kinda dressed up. He had like a tweed sport coat and tie on with some dress pants and dress shoes. This guy was wasted, and he was trying to holler at this girl. Asking people for a pen on the train and being all obnoxious. So me and Nick were trying to kind of diffuse the situation, because we could tell this girl was uncomfortable and she was all by herself.

So anyway, we were just talking to this guy, asking where he came from, how much did he drink tonight and kinda laughing at him. The girl started to chirp in with little comments and he probably thought we were making fun of him. So this goes on for about 15 minutes and the ride home from the bar is about 25 minutes. All of a sudden this guy is just stone cold quiet for like 4 stops on the train, it was a good 5 minutes. I look over and this guy is like super-duper mean mugging Nick who is sitting across the aisle from me in a separate seat by the girl. Nick notices it too and so he starts smiling and is like “Hey man, you’re being awful quiet over there”, but this dude is still just super mean mugging him so eventually Nick is like “Alright man, you win the staring contest” and he looks back at me across the aisle. I smiled a little bit and started to change the subject, I asked if any of the other stops on that line were faster than just going all the way down to the end of the C-Line like I always did.

So all of a sudden while we are talking this big Butter Bean dude gets up and is like “fuck you fuckin boston college kids,” and starts walking toward Nick and leans back and throws the slowest haymaker I have ever seen in my life. It was like slow motion it went so slow. Nick just kind of moved out of the way and the guy hit the window and fell on top of him so I got up and somehow put this guy in some kinda 1/8th Nelson and grabbed onto the pole.

I was holding on for dear life...

Now Playing - Kanye West - Stronger