Rob Kennedy's Bits

Code and Thoughts of a Software Engineer

If you’re like me, you’ve got a slew of duplicate files lurking all over your hard drive. I couldn’t find any programs for windows that would allow me to find duplicate files for free, so I decided to write this simple console application. It will take a few parameters and allow you to find files with duplicate content based on their MD5 hash. The source code is provided and could be enhanced to allow the deletion of duplicate files. I left this out for safety’s sake. :)

Download: FindDuplicate.zip

Code Version: 0.1

Example to find a list of duplicate pictures:

c:\> findduplicate -f *.* -d c:\users\rob\pictures

You can even export the results to xml for other program usage:

c:\> findduplicate -f *.* -d c:\users\rob\pictures -x > results.xml

There may exist a need to programmatically retrieve a program’s assembly attributes to provide product information to a user. This can be problematic if you are not using the System.Windows.Forms.Application library. Retrieving this information however is still possible using commands within the System.Reflection.Assembly class. I have encapsulated the most commonly used attributes in the following class called ProgramInfo. The class file can be added to your project; class properties can be called statically for ease of use.

Download:
ProgramInfo.zip

Code Version: 0.1

I use this class in almost all of my Console-based applications as it allows me to display product information for the executable as a command line option.

Example:

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("{0} {1}\n{2}",
                            Application.ProgramInfo.ProductName,
                            Application.ProgramInfo.FileVersion,
                            Application.ProgramInfo.Copyright);
        Console.ReadKey(true);
    }
}

There is a need to display a list of installed applications on a remote (or local) computer and in my hour of searching for an example found that no complete c# source existed. I decided to convert the VBscript examples I did find into a simple c# console application and the following code was created. Ideally I would like to know when the application was last used, but for now I’ll just show the application and version. There is also an xml export capability in the sample console application.

The source code can be found here: ApplicationList.zip

Note: You will need to download the command line parsing component I wrote here and reference it in your project for the sample console application to compile.

To use the ApplicationsList class from the project, simply use the following code:

ApplicationsList itemsList = new ApplicationsList(remoteHostName, userName, password);

if (itemsList.ErrorMessage.Length == 0)
{
    foreach (ApplicationItem item in itemsList)
    {
        Console.WriteLine("\t{0}\t{1}", item.Name, item.Version);
        Console.WriteLine("\tApplications");
    }
}

If you haven’t realized already your Chrome browser is slowing down. Really, it is. The culprit of this particular browser rot is caused by the inordinate amount of disk fragments generated within the Chrome browser cache.

According to the bug reference published Jan 17, 2009, several users have reported this as a growing epidemic; some completely removing the web browser from their system to resolve their overall system degradation. All seem to point to the same source of their hard drive fragments; Google Chrome browser cache.

I too found it odd that Google Chrome cache files were always at the top of my list of files reported as the most fragmented. Literally hundreds to thousands of fragments can reside within a single Google Chrome cache file.

There seems to be no definitive answer from Google Chrome developers on this issue. It also appears that the issue is worse for Mac OSX users. As of right now, I’m using build 5.0.375.126 and just defragged my drive; fragments which mostly resided in the Chrome cache folder.

So I propose a test where browsers are speed tested after initial install. Tested again after significant browser usage (over 100 websites visited). Tested a 3rd time after the browser cache has been emptied (another 100 websites). Lastly, tested a 4th time after the hard drive has been defragmented. This should give us a good baseline to determine if the Chrome browser does indeed slow down due to disk defragmentation.

Ok, so I wrote about a nifty little structure I found within the .NET framework and in doing some searching found that a BitVector64 didn’t exist anywhere. So being bored, and figuring it would only take me a couple hours, I went ahead and did an implementation of a 64-bit version of the BitVector32 structure. Mine will allow you to set a 64 bit value, and find the bit value for all 64 bits, as well as use a (ushort) Section bit mask if you really want to (not sure why) So here it is, source code included… I’m sure there’s something wrong with it, but I know the bit checking works flawlessly!

Please feel free to leave feedback if you find this code useful. Perhaps Microsoft will include it in their next C# release!

Download Here: BitVector64.zip

Code Version: 0.2

Changes since 0.1:

  • Changed UInt64 to ulong data types.
  • Fixed bug in public ulong this[BitVector64.Section section]. Thanks Saso!
  • Cleaned up code using C# StyleCop.
  • Added comments where necessary.

Example:

using RobKennedy.BitVectors;
...
// Simplest Test of BitVector64
BitVector64 newVec = new BitVector64(Convert.ToInt64(someValue));
// check to see if bit 32 is set (33rd bit if counting from 1)            
if (newVec[32])
    MessageBox.Show("We are bigger than a dword because bit 32 is on!");
...

There exists a need to have a convienient method of parsing and then organizing command line parameters passed to an application. I wrote this little bit of code to parse through command line parameters and associated values and return them in an name value pair object list.

Behold the free source code of CmdParamLib! :)

Code Version: 0.1

The source code can be downloaded here: CmdParamLib.zip

A sample is included on using the library as well.

Enjoy and write me back if you have additions or feedback.

If there’s one thing certain in life, it’s change. I’ve decided to cut back some costs and it looks like I’ll be moving sites and code to a single virtual server. This means I must choose between Windows or Linux servers. If you haven’t figured it out by now, I’ve moved this site over to word press. It’s proven and works out of the box. This should also give you a clue as to how I plan on moving sites. That is, I’ll be retiring the Windows 2003 server. I loved that thing and it served me very well, but I just can’t afford the two servers these days. Stay tuned for more info but as it stands now, I’ll be moving everything over to the Linux server. Thoughts on my server choice?

Catchy title? I just took a page out of the rapper Kayne West’s book. The worst oil spill disaster since Valdez and Obama’s administration has done virtually nothing to dedicate resources to the response of fixing that well… yet Bush doesn’t care about black people because his administration’s bureaucracy essentially did the same thing with Katrina.

Kayne West, you hypocritical sycophant to the Obama Administration. Please go eat glass and end yourself.

Aside from what you’ve heard in the news, I’m sure you’ve observed in your own town that the economy is down. That is, less spending, businesses failing, and/or prices rising. It’s taken it’s time but I’ve started to notice the physical effects of the down economy here where I live. Aside from the overstock of real estate properties in the market or dealerships fumbling around to make a sale, some other examples smaller examples I’ve observed prompted me to write this post today. The local TGIF has raised their food prices without increasing portion size. Additionally, two local restaurants have decreased portion size while keeping prices the same. On my way to one of these local establishments I noticed that all the surrounding retail spaces around it were empty. This was not the case a year ago. Black Friday wasn’t so black in some places. I read that retail sales were down by almost 40% nationally. That’s almost 1/2 the amount of sales made last year which is a huge hit for small stores who rely on the holidays to make up for their annual expenses. Because of this I would think we should expect to see major retail chains closing stores in 2010. Unemployment is working its way to almost 11%. That’s 1 out of 10 people you know is without a job. I know at least 2 people. This will get worse because everything is connected and if I stop going to TGIF because they raise their prices they will still lose money in the long run. If I stop going to the local pizza shop because they give me less food for the money, they’ll lose money too. Businesses who lose money either cut jobs or close. There’s no other alternative except angel investors which are extinct. People who lose their job become another statistic. Speaking of which, I predict 14% unemployment by end of 2010. That will mean almost 1 in 5 unemployed people. I base this on the current .4% trend forming for monthly unemployment increases. Our economy will begin to retract in the coming year. There already will be less money brought into the government in taxes this year and this trend will continue in 2010. Unfortunately you will see the current leadership raise taxes or costs on the whole rather than decrease spending in order to offset this loss of revenue. This in turn will cause more harm to the economy resulting in further unemployment and further economic growth stagnation.

So what does all this mean? I have developed a sense of doing for myself over the years and I believe that I need to be sure that I will be able to continue to do for myself even if things start to go south for me or others. I think at this point if you have a job you should start preparing for not having one. That is, stop erroneous spending and start saving. I have spent a ridiculous amount of money over the past two months on going out and having fun. This helps only my short term happiness and the club’s short-term bottom line. Long term I need to think about keeping myself afloat. We should all have at least 6 months worth of salary saved in an interest bearing account at a reliable (fiscally responsible) bank. I would go as far as to take 10% of this money and invest in physical gold or silver (not paper notes). Gold prices are a bit inflated right now because of the uncertainty of the dollar, but if the dollar collapses due to a global “F.U.” on the USA, you will at least have some physical asset that’s worth it’s weight as apposed to nothing. Even if you consider this to be a “crazy survivalist” mentality, it’s really not anything but common sense. It’s about time I start following it.

I suggest you buy a gun. Yes, I said it. The reasoning behind this is security in knowing you will be able to defend yourself, family and property for just about all possible scenarios. If you are uncomfortable owning a gun I suggest you at least get certified or training in shooting one. You can usually do this at your local range.

I suggest you make a 3 day pack bug out bag. This is in case you need to move on short notice for any reason or emergency. Everyone should have one for weather calamities anyway.

Be prepared. I think we’re still in for a bumpy ride.

With all the talk about global warming and how bad carbon dioxide is for us humans, I figured I’d think outside of the box today and write a little rant.

I hope trees fight back and spwan some shyamalan-esk attack on man. Not because I’m some pastly self-loathing human than wants to die by tree; oh no. I’m hoping they’re really going to get tired soon of the Environmentalists and their global warming agenda and snap (pun not intended). If they do fight back, I hope they will be smart enough to decern global warming “zealots” from the global warming “truthers”; understandable though if they just say f— it and attack us all. I mean seriously, wtf would you do if you were a tree? Humans have chopped down your brother in Montana; burned your mother alive to keep themselves warm last winter. They uprooted your family in Kentucky and turned them into decorative mulch to make room for a Walmart. They breath oxygen and think a minute trace gas called co2 is to blame for their summers getting +1 deg F warmer over the last 30 years. So now after all they have done to you, they turn on reducing the gas that keeps you and your fellow plants alive from the atmosphere! What do you think will happen? They killed your family, they took your land, and now they’re taking your air. If I were a tree I’d be prep’ing a tree-jihad myself!

I guess it’s a good thing for us humans trees can’t fight back.