Category Archives: lab

Juggler v0.5.2: Wallpaper Changer for Windows Vista and XP (Update 6)

Update 6: Wallpaper downloads are not available from InterfaceLIFT anymore. Read details here.

Update 5: Updated InterfaceLIFT downloader to work with the changed code at interfacelift.com.

Even though the first basic version of Juggler pretty much did what it was supposed to do, there were few ‘nice to have’ things which were missing. So I updated it as soon as I got some free time. :)

Feature set:

Here is the list of features (existing+new) which are now included.

  • Its coded and unit tested to work on Vista and XP SP2 with .Net 3.5. It should work (not tested though) on Server 2008/2003 as they borrow UI code base from Vista/XP. No words for any other OS.
  • It runs in background and can be controlled from System Tray.

  • It can be configured to:
      • start with Windows.
      • look for wallpapers in multiple folders including/excluding sub-folders. Best results when used with matching resolution wallpapers.
      • change wallpaper once every preferred duration between 1 min and 500 hrs. It will understand “000 Hrs/Mins 000 Min” format. It can interpret M/Min/Mins/Minutes and H/Hr/Hrs/Hour as Minutes and Hours respectively.
      • confirm before changing wallpaper
      • adjust image positioning for odd size wallpapers.

  • You can also change wallpaper manually by clicking ‘Juggle Now’ menu or by double clicking the icon.
  • It allows only one instance at a time.
  • It also displays the last updated wallpaper and the time stamp when the next change will occur.
  • It displays a confirmation dialog before automatically changing wallpaper. Its configurable to show a confirmation dialog and for how long the message should be displayed.

  • “Active” option to enable/disable wallpaper juggling while program is running.
  • Last changed wallpaper is a clickable menu which opens the wallpaper in windows explorer.
  • You can download stunning wallpapers from interfaceLIFT.com and WallpaperStock.com using “Download Wallpapers” screen right within juggler.

Download:

This version uses .Net 3.5. Also, the downloads are posted at codeplex.com.

  1. Download and install .Net framework v3.5 if its not installed already.
  2. Navigate to Juggler release page at codeplex to download application and/or source code. The downloads are in Files section.

Implementation:

Most of the stuff is pretty straightforward. It uses Timer class to invoke code to change wallpaper. The invoked code then uses Win APIs to do the job. But there are few things which may interest you.

  1. There are all kind of anonymous method illustrations. You can also find basic as well as complex lambda expressions which, I think, are nothing but fancy anonymous methods invented for LINQ.
  2. It also demonstrates how to use System.Threading.Mutex to find and avoid if user is trying to run multiple instance of same application. This is the simplest and most accurate approach to create single instance application in C# (VB has some out of the box functionality). There is a catch in this approach which may disqualify this in certain cases.
  3. While implementing single instance functionality, I needed to warn user that the application is already running. Simplest way is to just display a message box. But I thought if the already running (first) instance can get a notification from second instance then it can show a balloon tip which will tell user where exactly the application is running. This may sound simple but its not.
    1. As both instance are separate processes, we are talking about inter process communication (IPC) here.
    2. There is no other way than remoting in .Net 1.0-2.0 for IPC. And opening a tcp(forget about http) port seems overkill to me in this situation.
    3. So I chose a self hosted simple wcf service with named pipe binding. May be I’ll post about using named pipes in WCF for IPC later some time.

As always, please use it at your own risk. Feel free to rant in comments. :)

Enjoy!


Spectacular Wallpapers from InterfaceLIFT; Tool to download them all;

Before I say anything else, I have to admit that InterfaceLIFT has the best high resolution wallpapers. There are handful of artists who post their work on this site. Look at the fabulous samples:

 image    image

 image    image

There are thousands of them like these and in all possible resolutions. So the next question is how to get them. I tried the traditional way (read browsing) but it was really difficult to click on each one of them and save manually.

I though it would be really great if I can automate this or some kind of tool that can do this for me. So yesterday night, without wasting anymore time, I decided to code one up. Here is how it looks:

Wallpaper Crawler

Its simple. Choose the resolution you want, choose the location to want to save images to and hit “Search and Download Wallpapers”. You may also want to change the sorting to Ratings or Downloads to get community rated wallpapers first.

And here is how it works: On the website, interfacelift uses javascript to prepare the links for actual images. I checked the HTML source and thought I could exploit that approach.

  • It get the HTML markup for first page.
  • Search for javascript method calls and get the unique identifiers for wallpapers on current page and prepare a list of actual image names.
  • Loop through all images on current page.
  • Download one at a time and save to local disk.
  • Get markup for the the next page.
  • Go to step 2.
  • Keep doing this until user hits Stop or we run out of pages.

And that’s it. Its pretty simple. I ran it on Vista and XP against .Net 2.0. You can download the independent executable and/or source (C#). See update below to download.

WallpaperCrawler.exe.zip [Independent Executable]

WallpaperCrawler.source.zip [Complete Source Code, VS 2005]

I know it can be enhanced or make more robust. But hey I just coded it in couple of hours for the functionality I needed. I haven’t even tested it properly but it did what I was looking for.

Enjoy!

PS 1. If you find any issues with it, put your sleeves up and change the code. And yes, please don’t forget to tell/send me the updates you made so that I can add them for others. :)

PS 2. By no means its a tested and final app. I don’t take any responsibilities for the issues you may run into by using this.

Update: This program is now part of Juggler (another app I created for changing wallpapers). Please navigate to the description page to download the latest version.


Trigger Gotchas

I found these weird behaviors in SQL Server. Well, weird because I never expected it this way. And whoever I asked, even they thought its weird.

1. Let’s say you have an INSERT statement something like this:

INSERT INTO SomeTable VALUES (Col1, Col2)

SELECT Val1, Val2 FROM SourceTable WHERE 11

Now, the select statement is never going to return any row due to the where clause (always false) therefore, no new row in SomeTable table. So, if there is an AFTER INSERT trigger on SomeTable, what do you think about it. Should it fire? Remember, there is not going to be any insert.

If your answer is NO ( as it was mine and few others too), think again. Because it DOES fire. And that’s why I call it weird.

2. Another situation. Lets have the same INSERT statement but without any WHERE clause. So the query will be something like this:

INSERT INTO SomeTable VALUES (Col1, Col2)

SELECT Val1, Val2 FROM SourceTable

Now, if SourceTable has, say, 100 records and there is an AFTER INSERT trigger, how many times that trigger should fire. Remember, there are going to be 100 new rows in SomeTable.

If you answer is 100 (as it was mine too, again), check Books Online once more. The trigger is going to fire ONLY once.

 

One thing to note in both situations is that the LOGICAL tables have the correct information. That said, INSERTED logical table is going to be empty in first example and it will have 100 rows in second one. So, these logical table are your best bet. This behavior is same for DELETE and UPDATE after trigger too. Means, if you execute a delete or update statement which will not affect any row, triggers will fire regardless and it will fire once per statement NOT per affected row.

Hope this will help you to avoid this trap. :)

Enjoy!


To hell with USB! Way to go eSATA!

By now, I have been struggling long enough to run a Virtual Machine whose Virtual HDD is on external drive. I really can’t use the internal HDD (but had to) due to couple of reasons. First, storage limit as thats only 100 gigs (maximum available for laptops). Second, OS is running on internal disk and PC almost freezes at times. Third, I have to run minimum 2 virtual machines, one for Domain controller and another for SQL and TFS. It hardly works with one so forget about two.

But as the post title says it all, the bandwidth USB offers was an annoying bottleneck. Even though I managed an external HDD, it was useless. Theoretically, USB 2.0 supports 60 MB/s but the maximum speed I ever got is 12 MB/s.


There are a million people (at least) who have a lot to say (good and bad) about features in Vista. I really like few of them (but no praising now). The enhancements they did in file copying UI is one of them. First, it tells you the speed and second, it tells you the correct remaining time. This was something MS coudn’t do right since Windows 95. It takes a while to calculate the remaining time thats different story. :)

Now back to that USB pain. Well I guess gone are the days when I had to put virtual HDD on internal drive. Few days back I found that the SATA standard is upgraded to external SATA (eSATA). Technically it means a lot but for me, it was something which could pull me out of that USB hell. Theoretically, eSATA supports 350 MB/s. This is what I got.

I have read in some reviews that people got up to 60-70 MB/s. I have no idea whats that in my PC which is reducing it to 43. But still, its not bad at all.

What do you need to get this speed? For all of you who are frustrated with USB speed, you need an external drive which supports eSATA port. There are companies (Seagate and iOmega) who are selling these out of the box. But where Seagate is a bit costly, iOmega is only SATA and not SATA-II. Be care full when you buy stuff as SATA is half at speed compared to SATA-II. So, I bought an ICY DOCK eSATA External Enclosure and Seagate 500GB HDD. It saved me around 50 bucks.

Thats for the source of the juice but to connect it to your PC, you need one more component. You have to have an Express Card slot. Then you can get a SIIG SATA II ExpressCard. I am not sure if these controller are available for any other kind of slots. Don’t be sad if you have desktop. All you need is a spare SATA port on your motherboard. The eSATA drives and enclosures comes with an eSATA bracket.

Once you have these three components, you are all set to cruise.

Enjoy!

PS: The links in this post are for the components I selected. There are alternates available for all of them. Leave a comment if you have any question.


Follow

Get every new post delivered to your Inbox.