April 28, 2010

Famous people have strange work habits

Nate (@natelowry) pointed me at an interesting article detailing the daily routines of 25 famous thinkers. The article (from onlinecollege.org) gives a few details into the lives people like C.S. Lewis, Benjamin Franklin and Winston Churchill.

I really like articles like these. They are short, interesting and give the reader a sense of attachment with the people they are reading about. It reminds me of the book series On the John University. The books contain short passages to be read on the john (hence the name). Content in this form is intriguing, educational and just the right length.

Some of the people mentioned in the article match their routines very well. Barack Obama is on a strict schedule all day, but still eats breakfast and dinner with his family. Charles Darwin kept a very tight schedule as well. Ernest Hemingway, in contrast, is much different. He would write until he had said what he needed to say. That would be a dream job for a man of few words.

My favorite daily routine was Winston Churchill's. He would get up at 7:30 am but not leave bed until 11. during this time he would eat breakfast, read and dictate to secretaries. He would work for the rest of the day (squeezing in a 2.5 hour working lunch). After a post work nap, Churchill would have dinner and socialize until roughly midnight. He would then get some more work done before bed.

Here is how I think it went down. Churchill woke up every morning (hungover) at 7:30 am. After getting out of bed (and his first cocktail) he would work until lunch. Lunch always ran long (more drinks) and he was out of the office by 5 pm (happy hour). After a quick nap, Churchill would entertain dinner guests (Does whiskey count as a guest?) well into the night. After realizing that he should get some last minute work done, he buckles down and finishes his day (by passing out at his desk).

I had a few takeaways from this interesting article:
  • Get up early. Anyone who is getting anything done gets up very early.
  • Take time for non-work. It is surprising how much time these great thinkers spend not working.



Ignite Lincoln - April 29th, 2010

Ignite Lincoln is the inaugural Nebraska Ignite event being held in Lincoln on Thursday night. An Ignite event is a series of 5 minutes talks from people with a wide range of backgrounds and topics. Each talk is structured exactly the same. The speaker has five minutes and 20 slides. The slides auto-advance every 15 seconds. Organizers of the event in Lincoln will have the event biyearly.

Nate (@natelowry) and myself will be speaking in the event this year. Also speaking are Tom Casady, Jay Wilkinson and Mark Kornbluh to name a few. There are 16 speakers, all of which have very different topics which promise to be intriguing.

I will be speaking about cooking and the unique role that it plays in my life. Even though I am not a professional chef, I am deeply passionate about cooking. I uploaded my slides to SlideShare but there is little content on them. They are mostly pictures, but they will help me stay on track during the talk.
If you are free on Thursday night (and in Lincoln) check out Ignite Lincoln. Don't boo me too hard, because I am not used to getting heckled during presentations.

Check out Ignite Lincoln for more information about the free tickets - http://ignitelincoln.org/tickets.php.

Also, remember to checkout the site after Thursday night. I am sure that video will be uploaded after the event.

April 27, 2010

Why Walmart is the only place that will recycle plastic bags

Since moving into our house last year, we have always had some sort of recycling strategy. We recycle the most common items, like cans and bottles. One thing that we always have around are plastic grocery sacks. These are unavoidable, and can quickly pile up if you don't use reusable mesh grocery bags.

Trying to recycle these sacks is tricky, because normal recycling centers do not accept them. Recently, I have noticed that Walmart does accept plastic bags for recycling. As far as I know, that is the only item that Walmart accepts for recycling (tires and automotive batteries maybe, but that is a given).

When I went into the store earlier this evening, I found it odd that they prominently displayed the crate to recycle plastic bags. Why would they accept only plastic bags? Why not cans and plastic bottles? I formulated the following theory about why they accept plastic bags for recycling while waiting 15 minutes as the cashier rang me up. It might not seem like a long time, but he started at 10:40 pm and I left the store at five til 11.

Walmart accepts plastic bags for recycling because that is the only realistic option for them to sack groceries. Walmart check lanes are operated by one cashier and no baggers. That means that a cashier checking out a cartload of groceries needs to sack all of them. It is only efficient when using plastic sacks on the turntable. Give the cashier a bag of mesh sacks and prepare to wait.

This begs the question - why would Walmart allow people to bring their own grocery sacks? It takes the cashier nearly triple the amount of time to sack groceries in reusable sacks. They are making more work for the customer by strongly encouraging the use of plastic sacks, hoping that the customer will remember to bring them back.

When given that much time to reflect, it is easy to come up with an explanation of why things are the way they are. It is loads cheaper to have cashiers sack groceries, so Walmart has made it incredibly efficient for the use of one process (using plastic bags) and nearly impossible for another process (bringing reusable mesh bags).

April 21, 2010

The using Statement - C#

Something that I have thoroughly enjoyed when working more with C# and .NET has been data access with LINQ to SQL. It is a nice mix between using an ORM and making direct changes to a database. One issue remains with using LINQ to SQL is handling the database connection properly. I was recently told to wrap data access code in a using statement for better performance.

The using statement guarantees that resources are properly disposed of after their use. This eliminates the need to remember to close database connections and will dispose of objects wrapped in the statement as soon as they leave scope. Even though the .NET Framework has built in memory management, there is still time between when the objects are no longer needed and when their unneeded memory is released to the rest of the program.

The following is an example of data access using the using statement:
using(_ctx = new SampleDBDataContext()){

var mainQuery = (from c in _ctx.GetTable<SampleTable>()
where c.isMain == true select c);
...
}
The using statement defines the scope of _ctx. So as soon as the database operations are complete, _ctx is trashed.

Here is a more in-depth writeup of using using with data access - http://www.w3enterprises.com/articles/using.aspx

April 19, 2010

Installing Windows Services

A Windows Service is a program that runs in the background of any Windows installation. These are similar to Daemon processes in Unix. The programs are designed not to have any user interaction and be long running.

The project I am working on right now uses a Windows service to broadcast webcam video over the internet, emulating an IP Camera. Using laptops, webcams and a Window service allows a client application to view webcam video from multiple sources at the same time.

Developing the Service Application
This is not the focus of the post, but it is important to recognize where Windows services are built. Windows services are available as a project template in Visual Studio 2008. The screenshot below shows the Window Service project type.

Windows services cannot be run and debugged like any other .NET project. The project did not require extensive testing, but more information would be needed if the Windows service needed to be tested before deployment.

Installing the Service

To install the service, use a command line tool called "installutil.exe." There should be an executable in the "C:\Windows\System32" directory. If it is not there, make a copy of it from another location and paste it into the System32 directory.

Run the command prompt as an administrator and the shell will open in the System32 directory. The following command installs a Windows service from the command line:
installutil "C:\path\to\the\service\executable"
Make sure that the path to the executable is memorable to make things less confusing when uninstalling. To uninstall the service, use the same command but insert a /uninstall between installutil and the path.

To start the service, type the following into the command window:
net start ServiceName
ServiceName is the name of the service in Visual Studio. Do not confuse the path to the executable with the ServiceName. To stop the service, use the same command as above with stop instead of start.

The newly started service should be in the list of locally running services. Navigate to Control Panel\System and Maintenance\Administrative Tools\Services to see the list of running services. Services can also be started and stopped with this interface.