Browsing articles in "Code"

Creating UNIX Time in Windows Script

Jan 9, 2007   //   by Mike McMurray   //   Code, Sys Admin  //  No Comments

I recently found myself needing to convert a date/time in a Windows vbs script to UNIX time and struggled to find an example of how to do this. Correct me if I’m wrong, but there doesn’t seem to be any built-in function to change 20070109161723+720 to 1168359443.

After fine-tuning a few Google queries I found using the DateDiff function the easiest way and came up with,

Function WMIDateToUNIX(strDate)
ConvertedDate = CDate(Mid(strDate, 7, 2) & "/" & _
Mid(strDate, 5, 2) & "/" & Left(strDate, 4) _
& " " & Mid (strDate, 9, 2) & ":" & _
Mid(strDate, 11, 2) & ":" & Mid(strDate,13, 2))

WMIDateToUNIX = DateDiff(“s”, “01/01/1970 00:00:00″,ConvertedDate)
End Function

Not the prettiest code I’ll admit, but if someone else can use it that’s all well and good.

Decent Docs for Prototype

Apr 28, 2006   //   by Mike McMurray   //   Code, Web Apps  //  No Comments

Recently stumbled across some decent documentation for the AJAX framework Prototype. Didn’t help me with what I was after but it’ll be useful in the future and to many others I’m sure.
I’m sure there’s more good stuff out there so leave a comment if there’s anything better.

Using Prototype v1.4.0

Want to mix PHP with AJAX?

Apr 23, 2006   //   by Mike McMurray   //   Code, Web Apps  //  No Comments

AJAX is of course the current web development buzz-word and has been for the last few months. Really it’s some fancy Javascript that runs when actions happen (like moving out of a form field) and talks back to the server end of things.

In it’s basic form, your code then runs on the server and throws some XML (the X in AJAX) data back to the client-side to act on. But where can I use all my PHP code you ask? Well that’s where xajax comes into play.

xajax is one of many libraries/frameworks that has sprung up in the last 12 months. For PHP it’s one of the best in my limited experience and certainly one of the most straight forward to use.

What xajax does is wrap calls back to your PHP functions in JavaScript, hence taking most of that translation out of the way. You include the xajax libraries, declare your PHP functions you want to use on that page and then link them to the actions you want to make stuff happen.

In more detail,

The xajax PHP object generates JavaScript wrapper functions for the PHP functions you want to be able to call asynchronously from your application. When called, these wrapper functions use JavaScript’s XMLHttpRequest object to asynchronously communicate with the xajax object on the server which calls the corresponding PHP functions. Upon completion, an xajax XML response is returned from the PHP functions, which xajax passes back to the application. The XML response contains instructions and data that are parsed by xajax’s JavaScript message pump and used to update the content of your application.

Using UTF8 in PHP

Apr 4, 2006   //   by Mike McMurray   //   Code, Web Apps  //  No Comments

Harry Fuecks from SitePoint has put together what looks to be a very handy library to allow PHP manipulation of UTF8 strings.

Historically whenever PHP has been given the task of changing UTF8 encoded strings (ie. form entries that your users input) it's not given out any nice in return. Full support is due in PHP6 but that is still a wee way off (and I bet there are a few of you still using PHP4).

So for the PHP coder who has been missing out until now got and grab Harry's new library.

Subversion via Apache on Ubuntu

Apr 3, 2006   //   by Mike McMurray   //   Code  //  No Comments

After using Subversion and different Linux servers (now Ubuntu) for quite a while this is the only How-To that I’ve found that is easy to follow and works straight away.
David Winter

Now I can access my code repository from work and come home to work from the same system here.

Update: Except I now find that our corporate firewall block the Report requests. Lucky we have an open line in our office to get around that. ;-)

Move to the Light

Apr 3, 2006   //   by Mike McMurray   //   Code, Web Apps  //  No Comments

Very cool work with photos and then extended for other objects outside the norm, like div’s. And there’s even a WP plugin.

Lightbox JS
The WordPress version

Being a Tidy Kiwi

Feb 21, 2006   //   by Mike McMurray   //   Code, Web Apps  //  No Comments

Harry Fuecks blogs about cleaning up form input which is something every web developer needs to watch.

One of the comments points to PHP Input Filter which looks like it does things the simple way, i.e. I may be able to follow it.

Pages:«12