Friday, December 12, 2008

Download YouTube videos using Powershell

Now that I'm back home in Sri Lanka, I'm getting re-accustomed to the slow Internet speeds over here. Slow internet speeds was the reason for me to write the YouTube downloader back in April.

So I spent a lazy afternoon today trying to port that code into Powershell. And here's the result:

How it works

The script first figures out the direct download link and then hands it off to a download manager which performs the actual download. You should be able to plug-in any download manager that supports command line arguments but I prefer to use wget for its simplicity.

Information on how the direct link is extracted can be found in my original post.

Use $downloaderPath and $downloaderArguments to configure the path of wget and its arguments respectively. The script also supports traversal through proxies and can be configured using the $proxy and $proxyPort variables.

The script accepts one parameter; the watch url of the video.

.\psVDownloader.ps1 http://www.youtube.com/watch?v=N_c60Sp7Gtc

.

Please be aware that this script is purely for research purposes only. And I believe that you will be violating the YouTube TOS by trying to use its streams in ways other than intended.

Tuesday, December 09, 2008

SSRS - Unable to load client print control

One of the customer sites I work at was suddenly unable to print SSRS reports any more. This issue was occurring for only a few of their client boxes, so this rules out the possibility that it might have been a server issue.

It turns out that SSRS uses an activex control to provide some enhanced printing options. Here's some more information on it (taken from the MSDN site):

The Microsoft ActiveX control, RSPrintClient, provides client-side printing for reports viewed in a browser. The control displays a custom print dialog box that supports features common to other print dialog boxes, including print preview, page selections for specifying specific pages and ranges, page margins, and orientation.

After some investigating it looks like a conflict with KB956391. More information on it here:

http://support.microsoft.com/kb/956391

I'm guessing that this hot fix may have been pushed out by windows update, which explains it's sudden manifestation.

This is the proper way of fixing the issue; as explained in Brian Hartman's blog:

http://blogs.msdn.com/brianhartman/archive/2008/11/05/client-print-fails-to-load-after-microsoft-update-956391.aspx

Or alternatively just uninstall KB956391.

More useful discussions on the "Unable to load client print control" issue:

http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=332145&SiteID=1

http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=4006280&SiteID=17

http://wills-blog.com/?p=220

http://forums.microsoft.com/msdn/showpost.aspx?postid=4006172&siteid=1&sb=0&d=1&at=7&ft=11&tf=0&pageid=4

Sunday, October 12, 2008

Abstracting underlying data sources for SSIS packages using Views

In a perfect world, we'd never have changes to the schema once it has been defined. But in practice this is almost never the case.

I stumbled upon this excellent article which provides a solution to minimize the effects of change.

http://bi-polar23.blogspot.com/2008/09/views-as-for-ssis.html

Retrieving SQL Server 2005 Product Version

Here’s the query used to retrieve the SQL Server Production Version information.

Pretty useful when diagnosing problems in multiple environments.

SELECT  SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')

Storm, replacement for the aging WebServiceStudio

I am frequently required to work with 3rd party Web Services. These web services are often underdevelopment as well and more often than not tend to break our applications after each update.

I’ve been using WebServiceStudio for a while now to diagnose problems that arise after each update. WebServiceStudio was available on GotDotNet until it got shutdown and haven’t seen much updates since.

Luckily there’s a new open source tool that I discovered that replaces this aging application; Storm.

Here’s a description taken from the project site:

STORM is a free and open source tool for testing web services.

It is written mostly in F#. (I love this language!)

STORM allows you to

  1. Test web services written using any technology (.NET , Java, etc.)
  2. Dynamically invoke web service methods even those that have input parameters of complex data types
  3. Save development time and money. Creating throw-away test client apps just to test the web service is just too wasteful
  4. Test multiple web services from within one UI.
  5. Edit/Manipulate the raw soap requests.
  6. Others (Try out the tool and find out yourself!)

 http://www.codeplex.com/storm

Friday, September 05, 2008

Unable to restore Virtual PC Console

Well, I've had this happen to me more than a few occasions now. This is where the console appears to remain minimized. Doesn't seem to affect functionality but can get really annoying. I'm not sure what exactly causes it but I'm going to post the fix here so I don't have to look for it every time happens.

Virutal PC has an aptly named file called options.xml to maintain settings related to the console. Its located here:

C:\Documents and Settings\{windows account name}\Application
Data\Microsoft\Virtual PC\Options.xml

(Replace {windows account name} with your windows account name)

What we're interested is in this set of tags:

<window>
    <console>
        {...snip...}
        <left_position type="integer">0</left_position>
        <top_position type="integer">0</top_position>
        {...snip...}
    </console>
        {...snip...}
</window>

You should have some obscene values for the above keys. Just reset them to 0, restart Virtual PC and you're good to go.

Tuesday, August 05, 2008

Using Powershell to Query and Integrate MP3 Album Art

I've been trying to update my mp3 collection with album art since I got the P2. There are many tools out there that allow you to achieve this, but none that provide an easy and flexible way to automate the whole tagging process. That's why I wrote a quick and dirty Powershell script to do the job for me. Plus, it gives me a chance to play around with Powershell.

How it works:
The script can be executed in the following manner:
.\Mp3AlbumArt.ps1 .\mp3\*def*.mp3
or
.\Mp3AlbumArt.ps1 .\mp3\*\*.mp3
(recurse through sub folders)

The only parameter takes in the paths of the files that need to be processed. The script uses Greg Keogh's excellent NTag library for integrating the album art into the ID3 Tag. The album art itself is retrieved by querying the Amazon Web Service using the Artist and Album Tags. Obviously it doesn't work very well if the Meta tags are not set up properly.

Some assembly required:
You would need to register for an Amazon Web Service Account to get an key to query the service. Replace your key in the commented area to get stared.

Future:
I was in a rush to get something working so didn't spend too much time error handling or on any best practices. As I gain more experience with powershell, I will eventually re-write this script to take advantage of powershell functionality. But for now it serves is purpose.

References:

Download:

Comments and constructive criticism appreciated.

Sunday, August 03, 2008

The Microsoft Habu - 2000 dpi of gaming goodness

As most of you would know, I like to waste most of my free time gaming online. So it wouldn't come as a surprise that I've been hunting for the perfect business/gaming mouse for a while now. I was pretty excited when I finally got my hands on one of these babies. And what makes it sweeter is that I got it at real good price as well.

Like every other input device, its still taking me some time to get used to it. Its not an overly complicated mouse as far as gaming mice are concerned(this is a good thing). It feels solid and fills your hand pretty good (I still don't understand how and why some people use micro laptop mice). The on-the-fly dpi changer might come in handy. Haven't played any games with it yet, since I'm away from my main gaming rig at the moment, but I'm sure it would bump up my frags by a few kills at least :).

Get the Full Reviews and Specifications:

Debugging XSLT using Visual Studio 2005 / 2008

Visual Studio has the ability to debug XSL stylesheets. This a extremely useful feature that a few seem to know exist and use regularly.

Most of the projects I'm involved with use XSLT in one way or another. And the VS debugger along with other tools have saved me countless hours of frustration.

Here's a quick guide to get you started:

  1. Create / Open up the XSL file using Visual Studio
  2. Setup break points as necessary
    breakpoints
  3. Make sure that the XML Editor toolbar is visible
    XML Toolbar
  4. Click on the Debug XSLT button to start debugging
    debug_xsl
  5. A warning message would appear asking you to setup an input file. This would be the XML file that needs to be transformed. Click YES and select the input file.
    filename
  6. Step through the code.
    stepthrough

The only disadvantage or limitation rather is that you can't specify values for xsl:param variables. The workaround I use is to re-define the parameter as an xsl:variable , set the expected input value.

xsl_variable

On a related note, XslCompiledTransform class supports stepping into the stylesheet while debugging. The only pre-requisite is that the class should be instantiated with the debug parameter value set to true . Detailed instructions provided here.

Friday, August 01, 2008

New Site Column as a Managed Property

I was trying to create a Managed property from a newly created site column. What I didn't realize was that the column has to have content and crawled at least once (incremental/full, it doesn't matter) for it to be available in the "Crawled property Selection". It does makes sense if you think about it. So yeah.

More detailed information here.

Remember Kids, Google! is your friend.

Saturday, May 03, 2008

Warning: Grand Theft Auto is addictive!

I had a good laugh with this, thought I'd pass it along.

GTA 4 Liberty City Google Map

Its a coincidence that I found this today, as lately I've been messing around with Google maps myself.

http://grandtheftauto.ign.com//maps/1/Liberty-City-Map

Looking at the map,  I see only one airport ???!!! Is flying not that important anymore? Surely I must be mistaken.

Playing San Andreas, the Hydra (Harrier clone) was one of the more entertaining forms of transport and I have wasted so many hours just blowing up stuff with it.

Friday, May 02, 2008

MOSS Single Sign-On

I've started diving into the world of Sharepoint recently. One of our requirements of the project I am working on was for the user to be able to access content off existing external systems. MOSS provides SSO as an out of the box solution to enable this functionality.

What is SSO?

The default SSO service simply put, is a secure, pluggable storage mechanism for credential mapping between Sharepoint and other external systems.

Microsoft Office SharePoint Server 2007 provides a default single sign-on (SSO) service for the storage and mapping of credentials for use in connecting with third-party or back-end systems.

You can even plug-in an existing credential mapping system by implementing the ISSOProvider interface.

Setting up the SSO Service

using the service account to initially create the SSO database.

Using SSO

Now setup the application definitions and you're pretty much setting up the service. There are a few different ways we can use SSO:

Retrieving Credentials
http://mcse-blogs.com/certification/implementing-single-sign-on-sso-with-moss-2007.html

Logging into SQL Server as a data source for a DVWP http://blogs.msdn.com/sharepointdesigner/archive/2007/08/27/an-introduction-to-single-sign-on-sso-with-data-views.aspx

Logging into SQL Server using Windows Authentication
http://blogs.msdn.com/edhild/articles/377362.aspx

Forms Authentication and Screen scraping
http://odetocode.com/articles/162.aspx

To what extent is the out of the box functionality?

http://technet.microsoft.com/en-us/library/cc262932.aspx

Sunday, April 27, 2008

Find the System Uptime of your Windows/Linux Box

Ever wanted to find how long your Windows/Linux Box has been running?

For Windows

The Microsoft site suggests the following methods:

use the net statistics server command. Which can be re-written as net stats srv | Find "Statistics since" so we just get the info we are concerned about.

Or use a UpTime tool which does just that.

And my personal favorite method:

systeminfo | Find "Up Time"

Again, extracting only the information relevant to us.
For Linux

For the Linux environment we have the Uptime command:

uptime gives a one line display of the following information. The current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.

Saturday, April 26, 2008

Halotography - Photo realistic Halo

Taken off the destructoid website.

Joshua used a combination of Halo 3 and Photoshop CS to give some of these images a more photorealistic look, with some impressive results. "I think this gives a much needed breath of fresh air to Halo," he writes to us. Anyone agree?

Check out his Filcker Page. The attention to detail is just super!

Useful XSLT / XML tools

I've worked on a XSLT based ad-hoc reporting solution a few months back. I don't think could have made much progress without the following tools at my side. Just thought I'd give them an honorable mention.


You guys got any favourite XML tools?

Sunday, April 20, 2008

Karateka and the IBM 8086

Karateka was the first game I ever played. I think I started playing this when I was like 5. Produced and Published by Brøderbund Software, Inc. this game would be the stepping stone for them to later create the famed Prince of Persia.
Sadly I was never really able to finish the game or rescue the princess. I used to get stuck at this position of the game (shown below), not crash or freeze, my character would literary just stand there not responding. Where the "evil-ninja" would then proceed to kick my ass.



I'll blame this on a hardware limitation or some software glitch or maybe it was just a shareware version I had. I used to play the same level over and over until I got bored. What else can a 5 year old to do?

And speaking of hardware, this is the beast I used to run it off:


The great IBM 8086. Oh man! I have so many fond memories around this machine. I guess my love(addiction :) ) for programming and computers as whole started out from here.

And just so you know here are the specs of this beast!
The first IBM PC ran on a 4.77 MHz Intel 8088 microprocessor. The PC came equipped with 16 kilobytes of memory, expandable to 256k. The PC came with one or two 160k floppy disk drives and an optional color monitor. The price tag started at $1,565, which would be nearly $4,000 today.

Saturday, April 19, 2008

Direct Download YouTube Video

So why download a YouTube video when you can just stream it?
Sri Lanka is not best known for it's blazing internet speed (especially the "home" packages). I for one just got tired of looking at choppy video.

Works great if you want to use your videos with your own home brew player/organizer.


Why don't you just go to keepvid.com or use a browser plug-in?

What? Where's the fun in that?
Think command line, think quick launchers, think batch process. Exactly!

Screen scraping
101

This is what I needs to be done to get the download url:
http://www.walkernews.net/2008/02/25/youtube-video-direct-download-link/

This is how we go about doing it in C#:
Download Watch Video page


Parse it for the download Url (this is where the magic happens)

Parse it for the page title (more magic!)


Construct your final URL and That's It!

Download the source and try it out for yourself.

Look forward to a powershell version in the future.