# Sunday, June 20, 2010

Over the past while I’ve found that I’ve been writing code for myself over and over again to do a bunch of generic tasks in WPF (drag and drop, etc). So, I’ve decided to combine all this generic code into a project called Elias’ WPF Libraries!

Head over to http://eliaswpflibs.codeplex.com/ to check it out.

Coding | WPF
Sunday, June 20, 2010 10:19:02 PM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, June 02, 2010

 PodTower
a podfetcher, sucking less, one day at a time.

Today, I’ve done a little more work on PodTower. It’s addictive, I tell you.

New Features

  • Pause, Stop, Next Track, Previous Track
    • Mandatory features of any playback client
  • Volume Control
    • Another obvious omission

Coming Next

I’ve ordered a code certificate for myself, so in the next few days PodTower will be signed, which will enable automatic updates, along with giving you a warm fuzzy feeling when you run PodTower, knowing it’s a trusted, signed app. Hopefully that’ll also prove that I actually care about PodTower (and you, the user).

Additional features from this point? Setting the download directory. After that, who knows. Leave a comment and let me know what you’d like to see in PodTower!

Wednesday, June 02, 2010 9:01:41 PM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, June 01, 2010

PodTower the podcast client that sucks less each day.

Today, I’ve done a little more work on PodTower, and I feel that it’s got enough features that it warrants a beta release of sorts. I’ve been posting updates on a daily basis for the past few days, but I think from this point the stream of major updates will be a little slower.

What is PodTower?

PodTower is a cross-platform podcast client for Microsoft Windows and Macintosh OS X. It’s meant to be a simple client – it updates the various feeds once per hour (or when you click the refresh button), and can play back the downloaded podcasts, if they’re in WMA or MP3 format.

How was it made?

PodTower is built using Microsoft Silverlight 4 and Visual Web Developer Express 2010. In order to install PodTower, you’ll have to install the Silverlight 4 plugin, which is available here. It runs as a standalone application on your desktop. I’ve spent about three days so far on it, and used the Silverlight Toolkit for theming (as I’m not a visual designer).

Features

  • Subscribe to podcast/RSS feeds
    • As long as your feeds have an enclosure tag, it’ll work
  • Play downloaded podcasts
    • Plays MP3 and WMA podcasts from your local machine
  • Low memory footprint
    • It’s Silverlight – it’s small
  • Fast, one-click install

PodTower downloads your podcasts to your “My Music” directory in your home directory. When downloads are complete, PodTower notifies you both by the status bar text, and by toast notifications by the bottom of your screen.

image

The three buttons along the top-right represent the three major features of PodTower – adding RSS feeds, refreshing current feeds, and playing the selected podcast.

image

Clicking the add button will give you a dialog to add your podcast feed.

image 

Expanding any of the feeds will give you a list of podcasts available for download. Clicking the button next to the name will begin the download. A progress bar beneath the item will show how much of the podcast has downloaded.

image

When the podcast finishes downloading, PodTower will alert you with a toast notification. It automatically closes after about four seconds of inactivity.

image

Clicking a podcast item, then clicking the play button up at the right will begin the playback of the podcast. Clicking inside the gauge below the title will adjust the position within the podcast.

So what are you waiting for?

Go download a copy of PodTower! You might just like it. It’s licensed under the New BSD License, so it’s totally free. Tell a friend about it too.

Want to help contribute?

I’m mainly doing this as a fun little project. However, it’d be awesome if PodTower caught on and actually became supported by you. If you think this program is nifty or useful, I’d appreciate a donation. PodTower is totally free and licensed under the New BSD (3-clause) license.

Tuesday, June 01, 2010 9:07:02 PM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 
# Monday, May 31, 2010

Tonight, I was too lazy to set up CVS or Git, so I somehow deduced that writing my own Powershell script to do basic source control made more sense. Just in case anyone else is looking for something similar, here it is.

The script works as follows: You pass in a list of folders you wish to "check-in", and it copies them, excluding bin and obj directories, to .\.es\yyyyMMddHHmmss\(Names). Optionally, if you want to mark something as "stable", you can include the "-stable" flag. If you want to give the folder a more descriptive name, you can include the "-tag" flag, and the script will ask for a name.

$checkinfolder = get-date -format "yyyyMMddHHmmss"
$currentloc = get-location
$promoteAsStable = $FALSE

foreach($arg in $args)
{
    if($arg.ToLower().Equals("-tag"))
    {
        $checkinfolder = read-host "Check-in as tagged revision path"
    }
}

new-item $currentloc\.es\$checkinfolder -type Directory | out-null

foreach($arg in $args)
{
    if($arg.ToLower().Equals("-stable"))
    {
        $promoteAsStable = $TRUE
    }
    else
    {
        echo "Checking in $arg..."
        get-childitem .\$arg -Exclude "Bin","Obj" | copy-item -Destination .es\$checkinfolder\$arg
    }
}

$comment = read-host "Check-in Comment for $checkinfolder"

if($promoteAsStable -eq $TRUE)
{
    $checkinfolder | out-file -filepath ".\.es\STABLE" -append
}
$comment | out-file -filepath ".\.es\$checkinfolder.txt"

$checkinfolder | out-file -filepath ".\.es\CHECKINS" –append

Hopefully you’ll find it useful.

Monday, May 31, 2010 10:51:26 PM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 

PodTowerthe podcast client that eventually won’t suck.

PodTower-Next

Added: ability to actually remove podcasts. Playback is nicer, and downloading should work now. The progress bar under the Now Playing box now displays the progress.

Coming next: Volume control, toast notifications when minimized. Hey, maybe I should get this onto the WinPhone 7!

Get it at http://puurunen.ca/podtower

Monday, May 31, 2010 9:06:35 PM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 
# Sunday, May 30, 2010

Over the past couple of days, I’ve been lamenting over the fact that iTunes isn’t my ideal podcast client. To further compound problems, no podcast fetcher I’ve found has supported exactly the features I’ve wanted.

image

Enter PodTower – my answer to the sucko podcast fetchers currently in existence. Does it suck? Sure. It’s totally untested with about 99% of the podcasts out there right now, and doesn’t have the “remove-this-podcast-from-my-list” feature. Right now, it’s simply a nice way to download and play podcasts. I plan on improving it over the next while though.

image

Head over here to install PodTower. It requires Silverlight 4 in order to work. I’m using the Silverlight 4 Toolkit Expression Dark theme to make it look semi-good. I know it looks like a dogs breakfast right now, but it’ll get better. Just give it time.

Sunday, May 30, 2010 11:36:25 PM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 
# Friday, April 16, 2010

Tonight, I worked some more on Ubox. Since having been introduced to demos, there has been one effect I’ve always wanted to try coding – the LED-sign style scroller. In theory, it’s easy enough – plot pixels. However, I tried to take it a step further.

My first attempt involved testing copying one array of integers to another, column by column, to simulate the effect of scrolling. While this worked, I quickly realized how inefficient it is. To store the 26 letters of the alphabet as arrays of integers, size 8x8 would require on a 32-bit machine, 4 x 64 x 26 = 6656 bytes, or around 6KB. Doesn’t sound like a lot of memory? It might not be these days, but it’s inefficient as hell. After doing some thinking, I realized that for the scroller, I only wanted two colors – a light red and a dark red. With this in mind, I realized I could do some primitive compression. If we have 8x8 scroller character data, we need to store 64 bits, or 8 bytes of information per character. That works out to two 32-bit integers on a Win32 machine. With this in mind, I cut the space requirement from 6656 bytes to 208 bytes.

To implement this, I built a separate helper program in C#. Enter the worlds worst monochrome graphics editor.

image

Yes, it’s done in WinForms. Yes, I know how to use WPF. Yes, the program is a total hack. But it works. Basically, the checkboxes represent what one would expect to be an “on” state. Output gives me the integer array representing the character data. For instance,

int stuff[53] =
{
0x66663C3C, 0x66667E66, 0x7E82827E, 0x7E82827E, 0x6063C78, 0x783C0606, 0x42427E3E, 0x3E7E4242, 0x3E023E7E, 0x7E3E021E, 0x3E023E7E, 0x202021E, 0x6067E3C, 0x7C7E4676, 0x7E666666, 0x6666667E,
0x18187E7E, 0x7E7E1818, 0x3730FCFC, 0x1E3E3237, 0x1E366606, 0x66361E0E, 0x6060606, 0x3C7E0606, 0xD6FEEEC6, 0xC6C6C6C6, 0xCFC7C3C3, 0xC3E3F3DB, 0x66667E1C, 0x3C7E6666, 0x6666663E, 0x606063E,
0x66667618, 0xD8FE7676, 0x46467E3E, 0x66361E3E, 0x606063C, 0x3C60603C, 0x18183C7E, 0x18181818, 0x66666666, 0x387E6666, 0xC3C3C300, 0x183C66C3, 0xC3C3C3C3, 0x66FEDBDB, 0x183CE7C3, 0xC3C3663C,
0x3C666666, 0x18181818, 0x30607C7E, 0x7E3E0C18, 0x0, 0x0
};

…represents my horribly-drawn 26-character-plus-space alphabet.

Next came the implementation. I keep track of the current “column” being displayed in the scroller, along with the ASCII string being displayed. The ASCII string is used to plot each character.

  1: for(int i = 0; i < 96; i++)
  2: {
  3:   // Drawing routine for pixel scroller.
  4: 
  5:   //  PSet(xLet + (x << scale), 50 + (y << scale), pixDt[2], pixDt[1], pixDt[0], screen);
  6: 
  7:   int currCol = (col + i) % len;
  8:   char letter = scroller[currCol / 8];
  9:   if(letter == 32)
 10:   {
 11:     for(int y = 0; y < 8; y++)
 12:     {
 13:       // col
 14:       PSet(xLet + (i << scale), 125 + (y << scale), 140, 0, 0, screen);
 15:     }
 16:   }
 17:   else
 18:   {
 19:     for(int y = 0; y < 4; y++)
 20:     {
 21:       int realLetter = letter - 0x41;
 22: 
 23:       // Idea: top half is in MSB of stuff[realLetter]
 24:       // bottom in LSB of stuff[realLetter + 1]
 25: 
 26:       int t1 = ((8 * y) + (currCol % 8));
 27:       int t2 = stuff[realLetter * 2] >> t1;
 28:       Uint8 g1 = (t2 & 0x1) == 0x1 ? 255 : 140;
 29:       Uint8 g2 = ((stuff[(realLetter * 2) + 1] >> ((8 * (y + 4)) 
 30:         + (currCol % 8))) & 0x1) == 0x1 ? 255 : 140;
 31:       // col
 32:       int x1 = xLet + (i << scale);
 33:       int y1 = (y << scale);
 34:       int x2 = xLet + (i << scale);
 35:       int y2 = ((y + 4) << scale);
 36: 
 37:       y1 = 125 + y1;// * cos((double)sAngle*3.14/180.0);
 38:       y2 = 125 + y2;// * cos((double)sAngle*3.14/180.0);
 39:       PSet(x1, y1, g1, 0, 0, screen);
 40:       PSet(x2, y2, g2, 0, 0, screen);
 41:     }
 42:   
 43:   }
 44: }
 45: 

That’s the entire source listing for the scroller. The horrible mess of bit-shifts and modulo translates the stored integer into a simple 0x1 or 0x0 for display.

The result looks like this:

Ubox3

Friday, April 16, 2010 1:36:20 AM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, April 14, 2010

Ubox – Enter the Hello World

Ubox1

Ubox-Preview

Music was totally ripped from the Razor 1911 Chipdisk #3. I plan on changing that. The bouncing head is Bob Barker from Robot Chicken. Totally not posting until I find a way to not have to deal with DLL hell. The source is 463 lines long, including whitespace, written in C++ (so it’s no speed demon). I think for a hello-world sort of demo it’s not bad at all. Just need to watch more demos and get inspiration for this.

Did I mention this is only my second completely unmanaged C++ application that isn’t trivial? (The first was my Physics project for grade 12 – a GameBoy Advance ROM. That was some serious fun to work on.)

Wednesday, April 14, 2010 4:23:19 AM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 

Today, after studying for a CS exam for four hours straight, I decided that it would be a good judgment call to write some code. After all, there’s only so much theory one can absorb until code calls. So, I decided to write my first (official) demo. I’m still working on it, and want to compose my own music to it (and make it suck a little less), so it’ll be released later.

I ran into a fun snag along the way, though. I used the SDL libraries to power the graphics of the demo. One library, SDL_Gfx, is not distributed precompiled – you have to compile it yourself. Fortunately, the author includes a Visual C++ Project file that builds just fine. Now, I’ve done some SDL work in the past and had built SDL_Gfx a while ago.

At this point, some readers might see where this is going. As I put some of the hacking finishing touches on the demo, I sent it out to a couple of friends. Of course, it didn’t run on either machine. One was Windows 7, one was Windows XP, and both failed with the same error: The application was unable to start correctly (0x0150002).

A little digging, and the problem pointed to a few solutions – reinstall Windows (yuck), install Visual C++ Express 2008 (double-yuck), or redistribute the debug DLL for Visual C++ 2008 (triple-yuck). This seemed odd to me; I had compiled the demo as a release, non-debug Windows EXE. Why on earth would it need the debug runtime?

Further digging in the event log brought us this error: "Activation context generation failed for "c:\…\release\SDLGFX.DLL". Dependent Assembly Microsoft.VC90.DebugCRT, processorArchitecture="x86", publicKeyToken="1fc8b3b9a1e18e3b", type="win32", version="9.0.21022.8" could not be found. Please use sxstrace.exe for detailed diagnosis."

After a couple of hours of fiddling with manifest files, swearing at SxS, and no luck with the various builds, I stared at the path above. SDLGFX.dll. Then it hit me.

I had built SDL_Gfx as a Debug library in Visual C++ 2008. Crap.

Some swearing and frantic coding later, it works, and runs on other machines. The moral of the story? Always check to make sure your library build type matches your solution type.

I just wish I could have that two hours of my life back.

Wednesday, April 14, 2010 4:12:11 AM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, March 02, 2010

I’ve been on a cooking kick recently and have come up with a series of recipes that are tasty, cheap, and nutritious. Here’s one such dish.

  • Skinless, boneless chicken breast
  • Whole-wheat spaghetti noodles
  • Red chili pepper flakes
  • Garlic (either powder or fresh)
  • Salt

Here’s how to prep:

  1. Cook up the chicken breasts. Since I’ve got a Costco membership, I like to buy the bags of Kirkland frozen chicken breasts, as they yield 2kg worth. I’d recommend buying at least 400g worth of chicken breasts and cooking them all up at the same time. From frozen, bake in the oven for approx. 30 minutes at 400F.
  2. At the same time, cook up the spaghetti noodles. As with the chicken, I like to cook a lot of it up at the same time so it’s ready to go when I need to throw a meal together quickly. Whole wheat noodles boiled should take 8-10 minutes.
  3. After cooking the noodles, strain them. Once the excess water is removed, set aside and (optionally) let cool.
  4. After cooking the chicken breasts, take one or two and cut into thin pieces, width-wise.
  5. Get out the frying pan, put in some olive oil, and crank the heat to approximately medium (electric). When the oil is up to temperature, throw in some noodles, and the sliced up chicken.
  6. Sprinkle on some red chili pepper flakes, garlic, and salt. Cook 3-5 minutes.
  7. Plate, and serve.

I’ll post some pictures of this dish the next time I make it. Enjoy!

(Note: the directions to making this dish are a little vague, I know. It’s moreso a dish I threw together when I ran out of spaghetti sauce. It’s delicious though.)

Tuesday, March 02, 2010 7:10:34 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |