8 Dec 2010

Jobs Feed for NI Developers

Sorry for the break in blogging recently, I’ve been busy!! 

I have finally gotten around to publishing an RSS feed delivering details of all current job vacancies for developers in Northern Ireland.  This initial draft includes permanent job vacancies from the following sites:

In future, I hope to add the following sources:

  • Job feeds based on the careers pages of the major local IT and software companies, taken from here and other sources.

I also would like to add the following functionality:

  • Detect and remove duplicate entries.
  • Record details of the vacancies in a publically accessible database to allow people to generate custom reporting on key skills, the number and frequency of vacancies in particular companies, etc.
  • Add a temporary jobs feed.

The idea for this feed came from a personal RSS feed I have put together a few years ago.  This initial draft is using Yahoo Pipes to aggregate the various feeds together, and Feed43 for monitoring pages that do not have RSS feeds enabled.  In my personal feed, I use Page2RSS in my personal feed, but unfortunately it generates spurious RSS items if a site uses a revolving image background.

If you have any suggestions for the feed (companies to add, additional functionality), please let me know.  The Jobs feeds can be found here, or via the menu option above.  The list of job sites/companies I’m tracking via the feed can be seen here.

14 Sept 2010

Face Off - Code Syntax Highlighters Battle to the Death!

Or maybe not.  A while back, I blogged about the code syntax highlighter I was using and the various issues I had with it.  Over the past two months, I have tried several other code syntax highlighters, and thought I would summarize my experiences with them now.

Code Syntax Highlighter Looks OK in Blog? Looks OK in RSS feed? Client -side Processing? Modify after posting? Blog Post
Insert Code – a Windows Live Write plugin.

Send Outlook Email Via Powershell

BlogTrot Code Window – An online tool to generate HTML for your code snippet. Sending Gmail via PowerShell
NeatHighlighter - Similar to BlogTrot.

Send Outlook Email Via Powershell – since updated to use BlogTrot.

Google Code Prettify – A JavaScript library. PowerShell and Arrays
Source Code Formatter – Another Windows Live Write plugin. Fevered Coding

The overall winner is the Google Code Prettify library.  It is the easiest highlighter to use and allows you to quickly modify the display of your code snippets after posting by updating the relevant CSS file.  As it makes use of JavaScript processing on the client-side to produce the highlighting effect, the code is simple plaintext in the RSS feed, but still of an acceptable appearance:

I’ll be using the Google Code Prettify library to highlight all code snippets going forward.

The BlogTrot Code Window rendered the code on screen the best of all the highlighters tried, and the options to print and view as plaintext were also useful. The rendering in the RSS feed was poor, however, and the HTML produced could not be easily modified after posting.

It is worth noting that Scott Hanselman has recently blogged about using Syntax Highlighters again.  The one option he considers that I haven’t yet tried is hosting my code somewhere like GitHub, or Snipplr.  If you have tried one of these repositories to store and display your code snippets on a blog, please add a comment below!

12 Sept 2010

PowerShell and Arrays

I came across a strange feature of PowerShell recently.  When dealing with an array that held a single item, I was very surprised to see that the count of items was over 1000.  To illustrate the problem, consider the code below:

		
$files = Get-ChildItem C:\Temp
# Single file present in target folder

Write-Host "Total number of files: $files.Length"
# $files.Length returns value in 1000s
		
for ($i = 0; $i -lt $files.Length; $i++)
{
	$file = $files[$i].Name
	Write-Host "Processing $file"
}

When the code was run for the case when there was single file in the target directory, the count came back in the 1000s. The script then raised an exception for each of the 1000s of times it attempted to reference files[i], when no such array index existed.

It took some digging to realise that what was actually happening was that when PowerShell returns a collection with one or zero items in the collection, it unpacks the array and returns the item (or $null), and not an array.  So in the instance above, by calling $files.Length, the script was returning the length of the file object in bytes, and not the size of the array. 

To correct this behaviour, simply wrap the call generating the array with @(), as shown below:

		
$files = @(Get-ChildItem C:\Temp)

This will have no effect if the call returns an array with more than one item (i.e. you will not have an array wrapped in an array). See this StackTack answer from Keith Hill for a more detailed response:

Also, just to note that the code for this post was highlighted using the Google Code Prettify JavaScript library.

26 Aug 2010

Another Day, Another StackTack Issue

I came across a couple of problems with the StackTack jQuery plug-in today.  I tried to use it with a more advanced Blogger template, but it would require a significant effort to rework the StackTack style sheet.  As I just don’t have the necessary time to update the style sheet at the moment, I reverted to basic blue styled Blogger template.  I then also noticed that StackTack was not displaying the question in IE8, and that there was a script error:

I looked at the relevant section of the (minimized) StackTack plug-in code and found that it was breaking on this IF statement:

if(e.indexOf(classTokens[0].toLowerCase())>-1){ ... }

Where e is a variable consisting of  an array of strings.  A quick Google took me to a StackOverflow question that indicated that Internet Explorer (including version 8) does not support the method indexOf onarrays.

The answer also indicated that adding a reference to the Prototype JavaScript library could resolve the issue. So I modified the includes statements in the header to be as follows:

   1:  <script src='http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js' type='text/javascript'/>
   2:  <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' type='text/javascript'/>
   3:  <script src='http://app.stacktack.com/jquery.stacktack.min.js' type='text/javascript'/>

This allowed the plug-in to correctly work in IE8.  I created a new issue against the plug-in on BitBucket.  You can view screenshots of my blog on browsershots.org – a great tool for web developers.

23 Aug 2010

Send Outlook Email Via PowerShell

Just to complete the topic of sending emails via PowerShell, [Lies, I still have to blog about the Send-MailMessage cmdlet.] I thought I would include a quick look at sending emails from Outlook via PowerShell.  Again, this script could be replaced by using the PowerShell cmdlet, Send-MailMessage

The script below is based on a script submitted to TechNet by Kent Finkle:

   1:  param 
   2:  (        
   3:      [string]$email = $(read-host "Enter a recipient email"),
   4:      [string]$subject = $(read-host "Enter the subject header"), 
   5:      [string]$body = $(read-host "Enter the email text (optional)")
   6:  )   
   7:   
   8:  # Functions
   9:   
  10:  function Send-Email
  11:  (
  12:      [string]$recipientEmail = $(Throw "At least one recipient email is required!"), 
  13:      [string]$subject = $(Throw "An email subject header is required!"), 
  14:      [string]$body
  15:  )
  16:  {
  17:      $outlook = New-Object -comObject  Outlook.Application 
  18:      $mail = $outlook.CreateItem(0) 
  19:      $mail.Recipients.Add($recipientEmail) 
  20:      $mail.Subject = $subject 
  21:      $mail.Body = $body   # For HTML encoded emails 
  22:      # $mail.HTMLBody = "<HTML><HEAD>Text<B>BOLD</B>  <span style='color:#E36C0A'>Color Text</span></HEAD></HTML>"   
  23:      # To send an attachment 
  24:      # $mail.Attachments.Add("C:\Temp\Test.txt")    
  25:      $mail.Send() 
  26:      Write-Host "Email sent!"
  27:  }   
  28:   
  29:  # Main Script Body
  30:   
  31:  Write-Host "Starting Send-MailViaOutlook Script."   
  32:  # Send email using Outlook
  33:  Send-Email -recipientEmail $email -subject $subject -body $body     
  34:  Write-Host "Closing Send-MailViaOutlook Script."   
  35:   
  36:  # End of Script Body

Download the script from here.  If you have any comments, I would appreciate all feedback.  Thanks.

Also, just to note that the code for this post was highlighted (badly!) using the Neat Highlighter website. Unfortunately, the code snippet produced by the Neat Highlighter website was so poor that I couldn’t use it, and I have updated this post to use a snippet generated by the Insert Code for Windows Live Writer plugin. I also tried to use the Code Formatter Plugin, as recommended by Scott Hanselman, but it constantly froze Windows Live Writer. Also, I discovered how to use the <strike> HTML tag!

New Look for Blog

You will have noticed a new look to the blog.  I’ve finally got around to updating the template to make use of two column layout.  The old site looked very cluttered and did not present code snippets very well. I have updated past posts containing code snippets and images to make use of the increased width of the content column. This template is a default Google Designer template. 

Let me know what you think. 

17 Aug 2010

StackTack

I came across StackTack over the weekend, a great jQuery plugin used to display questions and answers from StackOverflow and the other sites in the Stack trilogy.  It is intended for bloggers and writers who want to post Stack questions in their blogs or articles and have them kept up to date.

I immediately updated my last article on sending GMail via PowerShell to make use of the plugin, but noticed that there was an issue filtering the answers to display a single question that is not the accepted answer.  I have raised an issue against the project on BitBucket; we will wait and see what the response is. 

Regardless of this minor bug, StackApp is a great way to link to the amazing content on the StackOverflow site.  I’m certainly going to keep an eye on the other StackApps that are being built.