PowerShell is just awesome

I’ve known for a while that PowerShell is useful but I never got myself to take that two hours to learn to actually use it. Today I did just that. And it’s simply awesome!

Tasks like reading a remote RSS feed can be done with just few lines of code. However the cool part is that these small programs (or cmdlets) can be easily used together.

Maybe the most powerful feature of PowerShell is it’s ability to pipe any collection of objects to an other program as they are. No need for parsing string streams. I would really like to see a portable version of that kind of piping shell — that works on *nix as well as in Windows!

Here’s my test application. It takes an URL for RSS feed as an argument and will return items from it.

param ([string]$url)
$wc = New-Object Net.WebClient
[xml]$resp = $wc.DownloadString($url)
$resp.rss.channel.item

Then you can use it like:

.\rssreader.ps1 http://www.jhh.me/blog/feed/

The raw output from this command to the console is quite detailed since it includes everything:

console

You can pipe the results to Out-GridView to get more graphical presentation of it:

.\rssreader.ps1 http://www.jhh.me/blog/feed/|Out-GridView

Notice that the table is formatted nicely. That’s because the piping is done with real objects instead of outdated string streams.

gridview

Maybe one reason why PowerShell takes time to learn is that it has quite strict security model by default. For example you cannot just write and run that example on your system without signing it or changing default security model. Read more about it from an article Running Scripts at TechNet.

PS: I bought also an ebook of O’Reilly’s PowerShell for Developers. I think it’s much softer crash course to PowerShell than most online articles.

Fork me on GitHub
Posted in Programming, Software, System Administration, Web development & design | Leave a comment

Setting up HTTP server on Windows with Node.js

Some years ago I dreamed about running JavaScript applications on Windows systems as easy as it was on Linux. It seems the future is here.

Today it’s really easy to setup Node.js and install NPM apps on Windows systems. Here’s a guide how to setup a HTTP server. No programming skills required! (Basically it’s the same process for any OS!)

  1. First you must install NodeJS.
  2. Open the command prompt to run following commands.
    • Windows 7: Open Start and write cmd into the search and press enter.
    • Windows XP: Open Start and select Run and write cmd and press enter.
  3. Run this command to install a HTTP server: npm install http-server -g
  4. And start the HTTP server: http-server /path/to/docroot with a path to the folder you want to share. Your folder must have some files before it works.
  5. Now just open http://localhost:8080/ in your browser.

I wonder if there is a GUI for NodeJS/NPM yet. However I don’t think running some simple commands is so hard thing to do.

NPM isn’t just for installing HTTP servers. There’s a lot of apps and libraries available and ready to be installed with APT-like interface. You can even publish your own software there!

Posted in Programming, Software, Web development & design | Tagged , , , , , , , , | 1 Comment

HBO started at Finland

This month great things happened. HBO launched HBONordic.com for customers at Finland.

That’s great improvement because we haven’t been able to watch these series instantly (not legally at least) before now — without waiting months or years for a DVD release or until our national TV stations bought those series — if they had enough money or interest to do so. Now we can pay directly to the source and watch them (almost) instantly — HBO is promising to publish their own series within 24 hours of US premiere.

We got Netflix some months ago, too, and I also have account there. However biggest problem with Finnish Netflix is that there isn’t much new content available and most of it is really old. Most content is so old that even our national TV stations have newer content. Of course that’s also a good thing — some of those are hard to find from elsewhere. (And yes, I know about the trick to watch US Netflix here but I don’t count it nor support doing that.)

Last week I got my invite to HBO. Of course there isn’t as much content as Netflix has but there certainly is newer content to watch — especially HBO’s own series.

Here’s a list of content available at HBO Nordic. Please note that it might have some mistakes because I made it with automated scripts.

HBO Nordic Series

HBO Nordic Movies

Posted in Movies, Series | Tagged , | Leave a comment