Opgenorth.NET

Mindless missives of a developer from the North.

Gifts for Dogs

| Comments

image

Casey the Samoyed gets a spring gift - a portable steam cleaner for small parts of your carpet.

Picking Apart PDF With Ruby and Linux

| Comments

I ran into a curious problem for a side problem of mine where I had some information in PDF files, both text and images.  What I want to do is display the information from the PDF’s on a mobile (Android) device.  PDF isn’t exactly a mobile friendly format, so I got the idea use HTML.  The next trick then becomes how to get the content out of the PDF’s I want into HTML.  Tux to the rescue!

As luck would have the, the utilities pdftotext and pdfimage will allow you to extract your text and images from a PDF (respectively).  pdftotext was even nice enough to extract the text from the PDF and put it into an HTML document for me. (To get these on your Ubuntu box:   sudo apt-get install xpdf-utils).  Once I had these apps installed, I used a bit of Ruby to automate the process - I had 65 PDF’s to convert and wasn’t crazy about the keystrokes involved for all 65 files.  Net time to do all this was a comfortable couple of hours in front of my TV catching up on the backlog of shows on the PVR.  How is that for multi-tasking?

Here is the Ruby script I wrote.  I welcome suggestions / improvements / enhancements / comments / cash donations / bottles of scotch:

#!/usr/bin/ruby
Dir.glob("*.txt") do |file| File.delete(file) end
Dir.glob("*.jpg") do |file| File.delete(file) end
Dir.glob("*.pdf") do |file|
	basename = File.basename(file,'.*')
	if (File.directory?(basename))
		Dir.glob("./#{basename}/*.*") do |file2| File.delete(file2) end
	else
	  Dir.mkdir basename unless File.directory?(basename)
	end
	system("pdftotext", "-htmlmeta", file, "./#{basename}/#{basename}.html")
	system("pdfimages", "-j",  file, "./#{basename}/")
	puts "Converted #{file} to text and extracted images to #{basename}."
end

Purging Your Privates (MSMQ With Powershell)

| Comments

A project I’m currently on makes heavy use of MSMQ and private queues.  Every so often, it’s necessary to purge messages from the queue during development. I got tired of always using the MMC snap-in to perform this task, so I whipped up this quick PowerShell script to handle the dirty work for me.  Granted, it’s pretty crude, but it gets the job done.  Any suggestions or improvements, feel free to let me know.
$queuename = ".\private$\myprivatequeue"
[Reflection.Assembly]::LoadWithPartialName("System.Messaging") | Out-Null 
$queue = New-Object -TypeName "System.Messaging.MessageQueue"
$queue.Path = $queuename
$messagecount = $queue.GetAllMessages().Length 
$queue.Purge() 
Write-Host "$queuename has been purged of $messagecount messages." -ForegroundColor Yellow

WIND Mobile and My Nexus One

| Comments

Just recently I switch my mobile carrier from Rogers to WIND Mobile. Their Holiday Miracle plan was just to good to pass up - even paying the penalty to break my Rogers contract I will still save money in the long run. Anyway, once the number got transferred over, I didn’t have a 3G connection, even after selecting the WIND Home APN.  After a bit of google, it seems that what I had to do is to setup an APN.  In case I can’t find it later, here are the APN settings:

APNmms.WINDmobile.ca
Proxy<Not Set>
Port<Not Set>
Username<Not Set>
Password<Not Set>
Server<Not Set>
MMSChttp://mms.WINDmobile.ca
MMS proxy74.115.197.70
MMS port8080
MMC302
MNC490
Authentication type<Not set>
APN typemms

After setting this up, bingo, got my 3G connection going.

TFS 2010, VS2010 Database Projects, and CI

| Comments

I’m currently working on a project where there are some functional tests that require a SQL Server database. Before in the past I’ve always handled this by using Redgate’s excellent SQL Server tools to create a monolithic script that would deploy the DB Schema, and then another set of scripts to set up the data.  Then it’s pretty trivial to use OSQL.EXE to run the scripts and setup the database.

However, in this case, I’m constrained to use the VS2010 database project and TFS Build.  So, the trick for me became how to use TFS 2010 Team Build to deploy a fresh copy of the database before the functional tests are run.  After a bit of jiggery-pokery, here is what I ended up doing.  I’m sure that at some point in my future, I will have to do this again, and nothing helps my failing memory like writing it down.

First a rough overview:

  1. Declare some variables to hold the physical path of my .dbproj and the default data path for SQL Server.
  2. Convert the source code control path of my .dbproj to the physical path on disk.
  3. To help with debugging and diagnostics, write a build message with the location of the physical path of the .dbproj
  4. Add an MSBuild task to my workflow that would deploy the .dbproj.

Without further adieu, here is more details breakdown of the steps involved.

Declare Variables

So, first things first – declare the two variables I need to hold the physical path to the .dbproj file, and the directory for my SQL Server databases.  This should be pretty simple and straight forward (assuming that the POS that is the “Workflow Designer” isn’t crashing VS2010 constantly).

image

Once that is out of the way I scrolled down the pretty, crashy, workflow designer until I came across the Compile and Test sequence.  At the very start of it I added a sequence that I called Deploy Database.  Inside this sequence I added the following Team Foundation Build Activities:

ConvertWorkspaceItem

The point to this BuildActivity is to figure where the hell on the file system TFS put one of the files.  Pretty straight forward:

image

WriteBuildMessage

Always nice to have a message in your log file to help with troubleshooting.  Here’s what my WriteBuildMessage activity looks like.  Notice that the message makes use of the “DbProjectPath” variable that we set above in the ConvertWorkspaceItemActivity.

image

MSBuild

This the working part of the the sequence.  In here we use MSBuild to call the .dbproj and deploy a fresh copy of the database to SQL Server. Key properties to set:

  • CommandLineArguments : this contains the properties to pass on the command line when deploying.  You’ll want to provide these properties
    • /p:TargetDatabase=YOUR_DATABASE_NAME
    • /p:”DefaultDataPath=DIRECTORY_OF_DATABASE_FILES”
    • /p:”TargetConnectionString=YOUR_CONNECTION_STRING_FOR_THE_TARGET_DATABASE”
    • /p:DeployToDatabase=True
  • Configuration : just specify which configuration in the solution to use.
  • DisplayName : what ever you want, this is how the MSBuild activity will be displayed in your sequence
  • LogFile : the name of the log file for the deploy
  • OutDir : the output directory
  • Project : Notice that this is the value of DbProjectPath, which we set above in our ConvertWorkItem
  • RunCodeAnalysis : Set this to CodeAnalysisOption.Never.  Doesn’t make much sense to do code analysis on a database project.
  • Targets :

Here is what the properties look like for this particuar Build Activity:

image

Now all of this has to live somewhere.  You might want to have this live somewhere else depending on when or how you want the database to deploy.  In my case, as I wanted to deploy the database BEFORE my tests ran, I hunted through the workflow and found the sequence called Run Tests.  I modified one side of the If condition to include a new sequence call Deploy DB and Run Tests:image

Here is an overview of what my Deploy DB and Run Tests sequence looks like

image

 

After Thoughts

To be honest, I found the whole process annoying and awkward.  Sure, I didn’t have to edit a bunch of XML by hand, but the Workflow Designer in Visual Studio 2010 wasn’t exactly a joy to work with either.  I don’t know exactly what the problem was, but it kept crashing while I was trying to edit this Build Process Template. It was always the same error, an Out of Memory Exception.  On a Dell Latitude E6510 with 4GB of memory, this shouldn’t be happening.  As well, the whole editing process for the work flow was awkward at best.

As much as I dislike XML based build tools, at least text editors don’t get all crashy and such.  As well, I found the overall experience of trying to create and piece together the workflow for Team Build to be sluggish and tedious.  It’s great to have a GUI editor to hide the crummy XML, but honestly, I think the way FinalBuilder works is far superior to how VS2010 in terms of easy of use and readability(application crashes aside).

Next is to setup my Release build definition, and to tackle the issue of updated the version number in AssemblyInfo.cs and creating a zip file of all the deployment artifacts.  But first I’ve got to go and buy a bottle or two of Talisker to help numb the pain that will follow as I go done down that path.

First Impressions: Windows Phone 7 Development

| Comments

I’ve spent a bit of my spare time in the past week looking at Windows Phone 7 from a developer’s point of view.  I’d have started sooner, but honestly, I didn’t see the point until there were actually devices that I could hold and use.  I know that in the U.S., some guys got developer phones from Microsoft, but I don’t think that anybody up here in Canada was that lucky. So, over the past year or so I’ve been dabbling with Android and I actually like programming for Android.  The biggest issues I’ve run into with Android are my lack of Java skills – I keep doing things the C# way (you really don’t realize how handy Linq is until you don’t have it) and the fact that Android doesn’t have a decent UI designer.  But otherwise, I like Android. So, I was curious what the developer experience was for WP7.  In a nutshell – it’s not bad, and in some ways better than that of Android. Things I like about WP7 development:
  • Being a C# guy, it was pretty easy and fast for me to get going with WP7.  Of course, Novell now has MonoDroid which in theory should lessen the learning curve for a C# guy to create Android applications.
  • It’s nice to have good tooling to help with creating my UI’s.  Blend and Cider are pretty decent. Android does have DroidDraw, but I’ve never really found that tool to be good to work with.  Eclipse has some sort of an GUI designer thingy, but again, I’ve found it to be kind of lack-lustre at best.  That, and I don’t use Eclipse – I prefer IntelliJ.
  • The Emulator seems to start up faster to me that the Android emulator – but that could just be me.
  • The MVVM pattern.  I know the theory, and am now learning the more practical side of it.  Was worried that WP7 was going to decent into the path of darkness and pain that was/is Web Forms.
  • I think that the debugger integrates better with the WP7 emulator.  Not that, generally speaking, I spend a lot of time in the debugger, but when you need it, it does seem to be more natural to me.  Again, this could just be because by day I do a lot of C# development so I’m more used to the Microsoft tooling to begin with.
Some things I didn’t like about WP7 development:
  • You have to have Vista or Windows 7.  Yes, I know, XP is almost 10 years old, time to move on.  Call me an O/S curmudgeon.  I don’t mind Windows 7, but Vista sucks/sucked.
  • It seems like to build your apps, you have to use Visual Studio 2010.  Not a problem for a developer, but I’m old school when it comes to compiling applications, and your build server shouldn’t be tainted by your IDE.
  • I’m use to the relatively easy going Google marketplace and the fact I have numerous avenues available to me to distribute Android applications.  No such joy with WP7 apps.
  • Editing XAML by hand.  But, I suppose it’s no worse that the XML resource files that Android uses.
  • Not seeing a lot of projects whose code I can read.  Granted it’s still early, so hopefully that will change.  Or not.  .NET doesn’t seem to have the same OSS community spirit that Java does.
Microsoft has always tried to be pretty good to developers (sometimes to their own detriment), but I think Windows Phone 7 does have some things going for it, from a developer’s point of view anyway.  Here’s to hoping that strategy pays off – that cool apps will get written for WP7, and that it will be commercially viable.  Competition is good – it will keep Apple and Google on their toes.  Smile

YEG Open Data, the 2010 Edmonton Municipal Election, and Android

| Comments

(Or, things to do when you have a sick kid)

election

One of the new data catalogues that the City of Edmonton has put up is the 2010 Election Results.  This Thanksgiving Long Weekend I was kind of “grounded” at home when my son came down with a nasty inner ear infection.  I was hanging out with him, and thought I could use the time to see how hard it would be and how quickly I could put together an Android application that would poll these results and show leading candidate in each contest for a given ward.  Turns out it was not that hard at all.  Development time was less than one day, and then I had the application running on my phone for a couple of days.

If you search the Android market place for YEG Vote, and you’re running Android 1.6 or higher you should able to find the application and install it (assuming, of course, you care about the election results).  The application itself is pretty bare bones.  It will get the results every five minutes, and then show the leading candidate.

I think my next trick will be to duplicate the application in C# and MonoDroid just to get a feel for the differences and such.  I’d wager that it will take even less time in MonoDroid for me, given that I’m much more fluent in C# than I am in Java.  I’d have done this in MonoDroid to being with, but MonoDroid is currently in a limited preview and one of the conditions of being in the preview program is that you can’t distribute applications written in MonoDroid yet. I would have tried a Windows Phone 7 port, but it just doesn’t make much sense, given that the number of people in Alberta with actually WP7 devices is probably less than 10.  Maybe next election.

If you have any suggestions or ideas, feel free to let me know. If I can scrounge up some time this weekend before the election I’ll see if I can implement them.

And, it goes without saying, regardless of what you think about this application, if you live in Alberta, make sure you get out and vote this Monday (October 18th, 2010).

screenshot1

Looking for a Job?

| Comments

If you happen to be a .NET type, knowledgeable/interested in MVC and Agile, QuestionMark is looking for .NET developers (F/T only, no contractors) here in Edmonton, Alberta.  Below is the job description.  If you’re interested, send your resume to Kaitlyn Lardin at QuestionMark (kaitlyn AT questionmark DOT com):

 

Senior Software Developer

Background

Questionmark is a company with a 20 year history recognised global presence in e-learning and assessment automation with software covering all aspects of this field, from authoring to delivery and reporting. Our software is used by over 3 million people in 15 different countries throughout the world. Questionmark is a fast-growing company, with a dedicated, passionate, and global workforce. We have offices in London, UK, Norwalk, CT and Tubize, Belgium. We care about the satisfaction of our employees and we reward them for meeting or exceeding expectations. The company promotes a relaxed, fun and highly productive approach to work. We have recently moved location to a vibrant office in the heart of downtown surrounded by software development companies.

Role of the Senior Developer

We are looking for a talented senior developer to join our development team in designing and creating the next generation of on-line assessment delivery software. This role will work closely with a Product Owner and other team members in a SCRUM environment, and be responsible for delivering potentially shippable functionality each Sprint. It also includes the mentoring of other team members through peer review. Our development team works in a Continuous Integration environment with automated builds and testing.

Essential skills:

· At least 5 years commercial experience development experience.

· You will be highly skilled in software development using our core technologies of C#, ASP.NET, XML, JavaScript, SQL Server and/or Oracle.

· Experience of jQuery very desirable

· Experience of working with .NET 2.0 or later

· Expertise in object oriented programming and relational databases

· Expertise in T-SQL and/or PL/SQL

· Good written and verbal communication. You must be able to write specifications

· Experience working in a SCRUM environment is desirable

Attributes of the Senior Software Developer:

The successful candidate will be highly skilled in software development using our core technologies, as above. You will be a self starting, self motivated individual who is enthusiastic and passionate about developing innovative software solutions.

Candidates must be eligible to work within Canada and relocate to Edmonton.


The package:

We offer excellent salary and benefits that include flexible working hours, starting 14 days annual leave, company bonus scheme, generous health coverage, and subsidized gym membership.

Informal Poll: Next Android Phone

| Comments

My trusty old ADP1 is beginning to show it’s age, and I’m thinking that it’s time to get a new Android based smart phone.  So, what should a guy get?  My criteria (to be modified as thoughts come to mind):

  • Not carrier locked
  • Would prefer it compatible with the frequencies used by Rogers (I’ve got about 18 months left on my contract with them).
  • I can install CyanogenMod on it.  More to the point:  I can install the latest versions of Android as they become available.  CyanogenMod seems to be the handiest way to do so.

Personally, I’m thinking either an HTC Desire or a Samsung Galaxy S.

I’m not against a Windows Phone 7 device, but there aren’t any on the market now, and I’m thinking that I don’t want to take the pain of a first generation Windows based device.

If you’ve got any thoughts/suggestions/comments/tips, feel free to post them in the comments.