Archive for Software Dev & Productivity

22 Sep 2009

Expression Superpreview and IE6 transparent PNG images

No Comments Software Dev & Productivity

Up until a few months ago, the best way to ruin a developer pc was to install IE7. 

As much as developers and web designers want the world to move away from IE6, there are still lots of machines that still run it.  These computers are typically in enterprise environments, where staff are prohibited from upgrading their browser and some in-house applications would stop working if they did.  I recently worked in an environment like this.

In the old days (back when all you could see was farmland for miles around), it was easy to load several versions of Netscape and run them concurrently.  I used to be able to code a web page and tell you how it looked in Netscape 3, Netscape 4, Firefox, and . . . whatever version of IE I had installed. 

Because there was no way to install multiple IE versions, you pretty much had to stick with the lowest common denominator—otherwise, there was no way to tell what your site would look like to the luddites.

It was possible to run different browser version in different virtual machines, but this was really tough on a slow pc.  image

Some developers don’t bother checking their code in other browsers at all—especially in a corporate environment, but I encourage it anyway.

A few months ago, Microsoft released the Expressions Superpreview application which renders your pages in  IE6 and IE7 in a side-by-side comparison.  This really makes life a lot easier.  While working on some changes for the Overpass site, I was able to view my site in Firefox, Safari, and IE8 on my workstation—and in IE6 and IE7 with Superpreview.  I found that my transparent PNG files were not transparent in IE6 and was able to correct this.

Superpreview is one of those tools that would have come in handy so many times in the past.  If you do cross-browser design, you should have a look at it.

The Superpreview application can be downloaded here.

And about the transparent png problem I had (in case you found this post while Googling the issue) . . .

I spent most of the morning and part of yesterday trying to get my transparent png files working.  They worked on the local PC, but not from the server.  I spent ages Googling problems with PNG and Ubuntu, PNG and Apache, etc, but couldn’t find the problem.  In the end, I found that the problem I first had was due to the fact that I was uploading the images as ASCII instead of binary. 

To fix the problem with png transparency rendering in IE6, I used a fantastic script written by Drew Diller called DD_belatedPNG which renders PNG files as VML.  That script can be found here.  What a huge help it was.

18 Sep 2009

Automate Skype Status with PowerShell

14 Comments PowerShell, Software Dev & Productivity

One of the big problems I have with Skype is its lack of a scheduling feature.  I have a Skype dual phone which will ring when someone calls me on Skype, but I don’t want the phone ringing in the middle of the night because someone from another time zone sees my status as “Online” decides to call.  I use Skype frequently for work with virtual teams, so I can’t just turn it off because I don’t want to forget to turn it back on.  My status should show as “Away” when I haven’t used my PC for a while, but this isn’t always consistent and it doesn’t cater for insomnia-induced tinkering on the pc.

Wireless Skype Phone
Creative Commons License photo credit: iBjorn

Ideally, Skype would have a feature to set “Opening Hours” on your account—I only want to show up as available between 8am and 8pm.  I bought the Pamela extra which does some scheduling, but you can set only one event per day—ie. I can set it to go offline at 8pm, but not to turn back on at 8am.

Since Skype offers a client API component, it is possible to create a scheduler to set your online status at different times using Windows Scheduler and a scripting tool.  I wrote this before in VBScript, but this being the dawn of Windows 7 with pre-installed PowerShell, I rewrote it as a PowerShell script.

If you are on XP or Vista and haven’t installed PowerShell, you will need to do this before you can run these scripts.  Installation instructions for PowerShell are here.  You will also need to set the execution policy.  You can find instructions for this here.  I am running XP.

I hope this helps . . .

Step 1: Install the Skype4Com component

Skype still uses a COM component called Skype4Com which needs to be downloaded and registered on your local PC.  The component can be found at https://developer.skype.com/Download.  I’m using version 1.0.32, but you can probably use a later version.

Download the component, extract it to a directory (ie. “c:skype”) and type the following into the Run window:

regsvr32  c:skypeSkype4COM-1.0.32Skype4COM.dll

Make sure the directory point to the actual dll file to you downloaded.  You should get a response that it was registered successfully:

image

Step 2: Write the PowerShell script

Now, write the PowerShell script to use the component.  I’ve created two scripts—one sets my status to “Online”, the other sets it to “Offline”.  You can probably create a single script with a parameter passed in if you wish (but I couldn’t be bothered to figure out how to do this).

In the script, you have to create the Skype object, identify the current user, and change the status.

In my first script, I use the following code:

   1: #Create Skype Object

   2: $skype = New-Object -COM "Skype4COM.Skype"

   3:

   4: #Get the logged in user

   5: $currentUser = $skype.CurrentUserProfile

   6:

   7: #Get the Status vars

   8: $onlineStatus = $skype.Convert.TextToUserStatus("ONLINE")

   9:

  10: #Now Change your status

  11: $skype.ChangeUserStatus($onlineStatus)

The main Skype call here is the “ChangeUserStatus” method.  I named the first script “SetSkypeStatus_on.ps1”.

The second script is almost identical, but it sets the status to “Offline”:

   1: #Create Skype Object

   2: $skype = New-Object -COM "Skype4COM.Skype"

   3:

   4: #Get the logged in user

   5: $currentUser = $skype.CurrentUserProfile

   6:

   7: #Get the Status vars

   8: $offlineStatus = $skype.Convert.TextToUserStatus("OFFLINE")

   9:

  10: #Now Change your status

  11: $skype.ChangeUserStatus($offlineStatus)

I named the second script “SetSkypeStatus_off.ps1”.

There are several other parameters you can pass into the “ChangeUserStatus” method.  Here are the values I know about:

Status Code Sample
OFFLINE $skype.Convert.TextToUserStatus(“OFFLINE”)
ONLINE $skype.Convert.TextToUserStatus(“ONLINE”)
RINGING $skype.Convert.TextToUserStatus(“RINGING”)
INPROGRESS $skype.Convert.TextToUserStatus(“INPROGRESS”)
BUSY $skype.Convert.TextToUserStatus(“BUSY”)

Of course, you can automate most actions on the Skype client using the component (not just setting your online status).  You can schedule calls, send text messages, etc.  But I’m only concerned with my online status.

Step 3: Set up Windows Scheduled Tasks

Now you have two scripts to go Offline and Online.  You just need to have something trigger them.  I use Windows Scheduled Tasks.  In Control Panel, go to the Scheduled Tasks window.  You’ll see a list of scheduled tasks for your pc.  Right client and select “Add”—>”Scheduled Task” (Don’t go through the “Add Scheduled Task” wizard).  Name your task “SkypeStatusOn”.  Right-click the task and choose “Properties”.

Now, in the “Run:” box, type the following command:

powershell -command “& ‘c:tempSetSkypeStatus_on.ps1′ “

Make sure the path is pointed to you PowerShell script you’ve created.

image

You can now use the “Schedule” tab to schedule when you want the script to run.  Click “OK”.

Now do the same for the other script.  You can test these scripts by right-clicking the task and selecting “Run”.  You should be able to watch your Skype status go from offline to online.

By the way, the first time you run this, Skype will ask if you want PowerShell to have access to Skype.  Click “Allow”.

If everything works successfully, your pc should set your online status and give you the “Opening Hours” that Skype forgot.

I hope you find this useful.

18 Sep 2009

Line Breaks in Webby

2 Comments Software Dev & Productivity

For the past few weeks, I’ve been using a tool called Webby for static html pages.  Webby is a Ruby-based tool which produces static html pages based on templates you create.  Think of it as using master pages in ASP.Net, except that the final product is files with a .html extension instead of .aspx (and you don’t get the asp.net processor kicking in each time this static page is called).

It’s a great tool, because most of my sites need to have a consistent look and feel.  I don’t want to copy html from one file to another and I can use a master page-like concept.  And it gives me the chance to toy around with Ruby a little bit (but not much).

In Webby, you create a layout page and the other pages as .txt files with html.  Run the command “webby autobuild” in a command window and each time you make a change to any of the files, it will create a folder called output with all of your processed html pages.

A problem I did have with the tool is that it was adding <br /> tags into my html where the line breaks where in my files.  I absolutely hate it when something tries to inject html into my code.  This is why I didn’t use Frontpage and won’t use tools like Dreamweaver.  I know html is a lost art but . . .

So, in my files, I would type

<p>I would type a paragraph that might be
lengthy, so I use multiple lines in the code
but don't expect the browser to interpret these.
I just want it to look for the tags.</p>

What I got back in return was

<p>I would type a paragraph that might be <br />
lengthy, so I use multiple lines in the code<br />
but don't expect the browser to interpret these.<br />
I just want it to look for the tags.</p><br />

It took me a few hours to figure out why this was happening (I couldn’t find anything on Google with a “BR tags in Webby” search).

The problem is not with Webby, but with a tool called RedCloth, which Webby uses.  Redcloth does the html processing with something called Textile.  This is not a problem, but a feature in Redcloth from very 4 onwards.

After searching for hours (and contemplating whether to just transfer everything to aspx pages), I found that Webby was automatically adding a “- textile” filter to all of the pages:

---
title:      <%= title %>
created_at: <%= Time.now.to_y %>
filter:
  - erb
  - textile
---

The simple solution, was the remove the textfile flag from all pages.  Remove the flag from the “templates/page.erb” file in the project and you should remove it from all pages in the project.  Then you are master of all your html, my son.

I hope this

31 Jul 2009

Some thoughts on the ASP.Net MVC Framework

No Comments Agile, C# Coding, Software Dev & Productivity

A few months ago, I got tired of ASP.Net.  I was tired of developers who depended on server-side controls, the Microsoft ajax implementations (as opposed to under-the-hood javascript ajax), excessive use of session and view state.  My preferred method of coding which relies more on the html than on the “runat=server” attribute, was considered old fashioned.

pics 006
Creative Commons License photo credit: paulb

So, I wanted to look at something else.  In my mind, Asp.net was getting too bloated and heavy.  I started learning Ruby on Rails.  RoR is a fantastic framework which integrates testability and maintainability.  Rails is the framework—Ruby is the language.  It’s easy to set up an Model View Controller site very quickly.  I love Rails, but I hate Ruby.  I had to lean how to do everything over again in Ruby.  It was like learning to speak a new language—even the simple things were hard.

Then, I looked at the ASP.net MVC framework that was released earlier this year.  The MVC framework is like Rails for ASP.  It keeps aspects of ASP.Net that I really like (like master pages and C#) and moves away from the bulky server-side, viewstate heavy, controls (like the DataGrid) that slow down ASP.Net performance.

My faith in ASP.Net is restored.  My brief foray into the hip and trendy world of Ruby development has given way to working on Microsoft code again.

I’ve been using the MVC framework in a few projects now.  I’ve started writing a Chinese Dictionary application (using the CEDict database) and am enjoying every minute of it.  I don’t know if I’ll every put this site live, but coding it is helping me learn the finer points of the framework.

There are some great MVC tutorials here:

http://www.asp.net/mvc/learn/

The best video tutorial (to start off with) is “Creating a Movie Database Application with ASP.NET MVC”.

28 Jul 2009

Spotify online music service is pretty good

2 Comments Miscellaneous Rants, Software Dev & Productivity

I like to listen to music while coding.  I always have.  Sometimes I’ve worked at jobs where they allow this (media companies like BBC never mind developers with headphones) and some that don’t (investment banks never allow this).  So it’s nice when I get to do some coding at home on my own pc with my own set-up (Visual Studio 2008, twin monitors, etc) and my own music.  So when I’m at the desktop PC, I usually have iTunes open in another window.

So I have a pretty big music collection—not tied to a specific genre.  I’m hardly a connoisseur of music and would be out of place in any conversation about music, but I know what I like.

Yesterday I heard about Spotify from a friend who raved about it.  I downloaded the app and gave it a try.  I think I found my new background-music application for writing code.image

Spotify is a desktop application which streams music to the desktop. You can chose any song they have in their library (I have found most that I’ve looked for) and listen to whole albums, etc.  When I heard about it, I thought is sounded a lot like Last.fm, which is an okay personalised-radio station service application.  But Spotify seems to have no lag or buffering.  It seems to download the tracks as needed in one go, without streaming.  Not sure how the technology works underneath, but by watching the network usage on task manager, I see the network usage spikes only when a new track starts to play.

My only concerned with listening to music on the internet is that Orange broadband is already complaining about how much bandwidth I’m using in the evenings (since I spend a lot of time watching mlb.com, iplayer, and youtube videos).

I’ve found some articles online that refer to Spotify as an iTunes-killer.  I hardly think that’s the case.  If I was tied to this desk and never listened to music on my iPod in the car or while running, that would be the case, but you don’t keep the music, you just listen.  You can listen to albums or tracks and set up playlists.

Spotify is also being referred to as a legal alternative to piracy.  I can see that.

I’ve only started using it a few days ago, but am very pleased with it.  I’m using the free account (ad-supported), but they have pro accounts for £10 a month.  There are some adds inserted between the tracks, but I’ve listed by about 5 hours now and have only heard one.

It’s a nice service available in the UK now if you have a chance to take it out.

06 Jul 2009

My domain is being used for spamming

4 Comments Blogging
ASCII Art Junk Mail
Creative Commons License photo credit: Yandle

I woke up this morning to about a hundred out-of-office replys in my inbox and junk mail folder.  It turns out, someone is using my Overpass.co.uk domain in an email reply-to and sending out loads of sex-related spam.

I’ve been searching for what to do about this, and it turns out that there’s not much I can do.  Since the spammers are not sending from my server and only using the reply-to, all I can do is hope that it stops soon.

Apprently, this is a pretty common problem.

If you get an email from Overpass, it wasn’t sent by me.

05 Jul 2009

Nike+ API Revisited

1 Comment C# Coding, Running, Software Dev & Productivity

One of the highest traffic posts I get on this blog is the brief post on accessing the Nike+ API with C#. I’m pretty proud of that post, but I don’t keep up with how the API works.Running Shoes

The Nike+ API is not published, so it’s not public.  It can change at any time.

If you are interested in the Nike+ iPod API, there is a much more up-to-date blog you may want to have a look at.  It’s called Running Tracker.  I’ve been subscribed to the RSS feed of this site.  They’ve created a cross-platform desktop application to examine the data stored with Nike.  I know about their API changes through Running Tracker.

If you have come to this site about the API, by all means, use the code if you can– but also check out the Running Tracker site as it is more up-to-date on the subject than I have been.  Their application doesn’t use C#, but it might be able to help you out with more information.

Creative Commons License photo credit: marksteelenz

03 Jul 2009

What Twitter is becoming

No Comments Blogging, Social Media

I enjoy Twitter.  It’s easy to update.  The low character limit, rather than being a hindrance, encourages people to start using it who would never think of started a self-serving blog.  It’s easy to put off a quick statement without having to think too much about it.  I find I update Twitter far more than this blog.

I’m getting lots of followers.  This is good for the ego until I look at who they are.  On any given day, I will get a few email like the following:

SomebodyYouDontKnow is following you on Twitter.
Followers: 300
Status Updates: 121
Following: 1421

Now, I ask you . . . how can someone follow the status updates of over 1400 people?  How is it even possible?  Why would someone want to do it?

I get two or three of these type of followers a day.

I’m also seeing a lot of articles on the web titled “How to increase you followers in Twitter”.  It’s like the new SEO.  There are people now calling themselves “Social Media Consultants”.

I suspect that people follow thousands of people so that those people will in turn follow them.  It makes sense I guess– you send more mail when you want to get more mail.  However, there is just something spammy about this.  Maybe they are looking for the top spot in the Twitter stats.

Twitter is not like Facebook where you have to give permission to people so they can see your status.  You can search all tweets (unless the author specifically selects to option to make it private)– so there is no reason to follow 14k or more people. 

A few years ago, I kept getting contacted by SEO charlatans saying things like “I can get your company in the top 10 on Google.”  It was a ridiculous statement.  I asked if they knew what my business did or what keywords I wanted, but they didn’t. 

I now soon expect to be told, “I can get you 20k followers on Twitter. “  But who wants that?

10 Jun 2009

Why I would never host with Re-Invent Technologies again

1 Comment Blogging, Software Dev & Productivity

A couple of years ago, I bought some web-space from a company called Re-Invent Technologies (http://www.re-invent.com/) for some ASP.Net web space with SQL Server hosting.  I paid for a 2 year contract. 

I didn’t realise they had set me up with the dreaded auto-renew option.

About six months ago, I migrated my site to a dedicated server because I had converted it into PHP.  I knew the Re-Invent contract was due to run out anyway.

I noticed a few weeks ago that I had been charged for another year of server (about £60).  I never received an invoice or an email notifying me this would happen.  The last correspondence I had from the company was two years ago. 

So, I sent a polite email to them explaining that I didn’t use the webspace anymore.  I said that there should be no traffic coming through and that I did not get an email notifying me of the new charge.  I also, in an effort to get them to be more responsive, thanked them for the service and said I would recommend them to others.  Could they please refund my money, or at least the money for the rest of the year from now?

What I got back was as follows:

Hello

Notices are sent automatically to the email address on file about 2 weeks prior to billing.  Customers are responsible for maintaining their current contact information.

To cancel your account you would need to log into the customer portal (NOT control panel)  and click on the account cancellation link on the left.  This is the only means of cancellation as per the hosting contract.
Refunds are given only if the cancellation is within 15 days of the renewal date, as per the hosting agreement also.

Thank You

Re-invent Technologies LLC
http://www.re-invent.com

Now, I know they are not legally required to refund my money (not sure about this, actually)– but if they wanted me to host my .Net stuff with them in the future, they would have.  They could have been a little more client focused in how they dealt with this issue.  It is not signed by a person.  There is no one I can talk to.  They have not addressed my genuine issue of not getting the emails or the invoices.  There is no empathy at all in this email.  Even if it had said, “I’m so sorry, our policy is that we . . .” whatever, it would still suck, but it would soften the blow.

So, I would NOT recommend this company.  They blew it.  I’ve paid them money to host with them, and I can’t even talk to anyone.  I’m a little annoyed.

So I’m posting this for anyone who is Googling Re-Invent. Anyone who is doing a little research before hosting with them, I am giving you warning.    In fact, let me just include this for SEO: “Re-Invent Technologies Review”.

I’ve hosted with lots of companies.  When I’ve had issues, I usually get a ticket back with someone’s name on it.  This was a legal response.

My Review of Re-Invent: Very poor customer service.  They got my money this time, but they will NEVER get another penny from me. 

There.  I feel better.

08 Jun 2009

Creating a daily Database backup for MySql (and self-hosted WordPress blogs)

2 Comments Blogging, Software Dev & Productivity

Most of the professional work I do is with Microsoft SQL Server and .Net platform.  For my own pet projects, I prefer using MySql as a db engine.  WordPress (and most PHP projects use it primarily).  It’s cheap and efficient to host.

One of the features I always found SQL Server to lack is the ability to generate insert scripts.  Sure, it’s easy to script out tables, views, and stored procs– but you still have to get tricky with transferring data from one database to another.  I know people say “you can just back up the database and restore it to a new server”, but they obviously have never worked in a tight change-controlled enterprise environment where you need everyone under the sun to approve this a dedicated dba overlooking everything.  This method is overkill if you just want to replace the a record that a user has “accidentally deleted”.

MySql has a very handy feature that use frequently called mysqldump.  This will create an sql file of all db objects and store them in an sql file — data structures and data too.  Mysqldump will create one script with table create statments (and drop statements) along with insert statements for all of your data.

I use mysqldump to store local backups of my remote databases.  For example, this blog is backed up every morning– just in case my server goes down and is unrecoverable.   I occasionally back up web code with an FTP routine, but the database needs to be done more often– since it is frequently updated by me or readers of this blog with comments.

Here’s how it’s done using my WordPress database and local XP account:

1.  Make sure you can connect to your remote database from your local pc

To do this, you need to have MySql client tools installed on you local pc.  Just try to log into our remote site using MySQL Administrator. 

image

If you can connect from you local pc, you can use mysqldump from the command line.

2.  Write a batch script to create a folder for each day

I have a folder called “backups” with a date-stamped folder for each day of backup (ie.  2009-06-08).  Here is my code for that batch file (with my db details removed):

rem backup blog

rem create new folder name
set DD=%DATE:~0,2%
set MM=%DATE:~3,2%
set YY=%DATE:~8,2%
set YYYY=%DATE:~6,4%
set FOLDER=%YYYY%-%MM%-%DD%

rem make the new folder
cd g:backups
mkdir %FOLDER%

rem go to folder
cd %FOLDER%

rem create the data dump
mysqldump -h 111.222.111.222 -u username -ppassword wpDBName > blogdump.sql

For the mysqldump line, use the ip address (or host name) of the remote server and user name and password.  In the example above, I am connecting to my db called “wpDBName” on host 111.222.111.222 with the user name “username” and password “password”.  It is writing out to a file on my local pc called “blogdump.sql” in a folder with a date stamp.

NOTE: the -p switch does not have a space between it and the password.  This is bizarre, but that’s how it works.

Save to the above code to a file with a .bat extension.  I called mine “backup.bat”.

3.  Create a scheduled task to run this job.

Use Windows Scheduled Tasks to automatically run your batch job.  This can be found in Control Panel and is easy to use (Wizard Generated).  I run my job at 4:10 am.  To save the environment, I shut down my pc at night, but a bios task wakes it back up at 4.  At 10 minutes past 4, my databases are backed up (just before I sit at the keyboard with my coffee to catch the final innings of a Padres game).  Once a week, I have a similar job that will back up all web code via ftp.

image

 

That’s it, the majority of my disaster recovery problems taken care of.  I have the data stored on my local pc and on the server.  It would be easy to run the same script from another pc if I need to, also.

As you can imagine, this daily backup can take a good deal of disk space.  Each sql dump is about 3mb for this site.  I usually clear things down every few weeks and delete backups that are over a week old.  I don’t replace my backup file every day because it could be a few days before I realise anything has gone wrong.  I may script this at some point in the future.

I’m blogging about this because a few days ago I was playing around with my Plesk settings on my Ubuntu VPS and everything stopped working.  I had to restore to my last VPS backup– which was a few weeks old.  That would have meant losing all my WordPress blog posts and (more importantly) the comments I’ve received from them.  Luckily, I have this backup method in place so I didn’t lose anything.

If you are not backing up your databases (even if they are hosted with a web host), you should really consider it.  It is a trivial task to set this up and could save you in the future.

I hope someone out there finds this useful.  Drop me a line (or post a comment) if you found this to be of any help.