Jason Leveille’s Blog

Beauty’s where you find it

Displaying The Correct Timezone Time

Yes, I know, displaying the time with JavaScript. Something that’s been written about since the dawn of time. Following is a trivial bit of code, but one that I thought others might find useful. We are working with a client whose application broadcasts meetings (and screen captures from those meetings) to client computers. A very cool project that I’d like to write about some day. With regard to time, there are 2 requirements:

  1. Time must be in Eastern Standard Time (or Eastern Daylight Time)
  2. They shouldn’t have to configure any settings to adjust for daylight savings time

Read the rest of this entry »

The Power of Virtualization

I’ve spent a considerable amount of time lately creating virtual machines on my work and home computers. In an effort to come up with a set of environments that make developing and testing applications easier I initially setup Microsoft Virtual PC 2007. In the few weeks that I’ve used it I have found that I need more than just Windows options in my virtual environments. This weekend I decided to give VMware Server a test drive … and just as quickly decided to uninstall MS Virtual PC. VMware Server is a free download, and according to the vmware website:

VMware Server installs on any existing server hardware and partitions a physical server into multiple virtual machines by abstracting processor, memory, storage and networking resources, giving you greater hardware utilization and flexibility. Streamline software development and testing and simplify server provisioning as you utilize the ability to “build once, deploy many times.”

Read the rest of this entry »

My Classes Back Online

It only took 6 months or so, but I have finally taken the time to get my old teaching site (http://my-classes.org) back online. When I was teaching I knew that a lot of people were visiting the site, specifically for the assignments that I had posted online. Believe me, teachers are always trying to find good lesson plans. After the 5th email this week regarding when the site would be back I finally broke down and found the time.

Thanks to my employer, Blue Atlas Interactive, for providing the hosting, not only for this blog, but now also for my-classes.org. Thanks to Dave for taking the time during work to get me the root shell password and my ftp information.

What’s up with CakePHP?

I’ve had my focus in a lot of other areas for a few weeks, and in that time is seems like quite a bit has happened on the CakePHP front. It seems that there has been a subtle shift in how the framework will evolve from here forward. gwoo puts it much better than I can in his recent bakery article, “After 3 years, looking back and moving ahead“. In the grand scheme of things there are much more interesting things between the lines of what gwoo has written, however the thing that got me most excited was located at the very end:

Stay tuned for more new developments and expect the next 1.2 release in the coming weeks.

JavaScript parseInt Usage

I have had a bit of a hair pulling experience over the last few hours, until finally I got some sense and looked at the Definition and Usage of parseInt. Here’s the example:

<script type="text/javascript">
   var data = new Array('007', '008', '009', '010');
   for(var x in data)
   {
      console.log(data[x] + ' -> ' + parseInt(data[x]));
   }
</script>

And the result:

007 -> 7
008 -> 0
009 -> 0
010 -> 8

What I wanted was the result 7, 8, 9, and 10. The result seen above comes from the fact that, because I have a leading 0 in my strings, parseInt is reverting to a base 8 (octal) radix. The solution of course is to specify a base 10 (decimal) radix.

<script type="text/javascript">
   var data = new Array('007', '008', '009', '010');
   for(var x in data)
   {
      console.log(data[x] + ' -> ' + parseInt(data[x], 10));
   }
</script>

And the result:

007 -> 7
008 -> 8
009 -> 9
010 -> 10

A Simple REST API Toolkit

Last week Dave and I were trying to figure out the best way to synchronize member data from an asp application with a WordPress installation. I don’t remember how it came up in conversation, but in a flurry of chatter we decided that we should build a RESTful API to allow the applications in question to communicate. In the interest of re-usability we also decided that we should build a generic toolkit. One that could easily be used to expose an API for any supported database, through PHP. So, using this toolkit you should quite easily get your Lasso application talking with your PunBB software, if that’s what you need.

So was born rest-toolkit. We have released an alpha version of the project, so download it and give it a try. I hope you don’t mind a lack of formal documentation. Depending on how things go documentation will follow. Read the rest of this entry »

Avectra Member Management API

Recently I worked on a project where all member data was being managed through a third party member management service, provided by a company named Avectra. The product does more than manage member data from the looks of things, but all I cared about was interaction with the member management API.

I had to authenticate against an external data source, as well as query the data source for member information when needed. Avectra does have a web service API which it has named xWeb. Here is a quote from their Wiki:

xWeb is netFORUM’s XML web services application. netFORUM is an enterprise level Association Management System (AMS) developed by Avectra that allows associations to manage their customers and related activities. netFORUM is used by association staff, members, and the public at large.

Read the rest of this entry »

Remove www Subdomain

It seems that more and more people are moving away from the inclusion of www in their url. SitePoint recently wrote about the subject, and this past February Roger Johansson also wrote an article on the topic. Roger’s article was really more about making sure your site works with our without www (I couldn’t agree more). You wouldn’t get any more from me than you could get from taking a look at the articles I’ve referenced, therefore I’ll just skip to the good stuff. In general I feel that the inclusion of www is just a waste of address bar space. For this blog I have decided to throw it to the dogs. If I remember correctly, “Removing the Ws from URLs“, an article from 2002, was a big help for me on my path to www enlightenment.

Removing WWW through VirtualHost

<VirtualHost ipaddress>
ServerAdmin root@localhost
ServerAdmin webmaster@blueatlas.com
DocumentRoot /path/to/public_html/
ServerName jasonleveille.com
ErrorLog /path/to/logs/jasonleveille.com/error_log
TransferLog /path/to/logs/jasonleveille.com/access_log
</VirtualHost>

<VirtualHost ipaddress>
ServerName jasonleveille.com
ServerAlias www.jasonleveille.com
ServerAlias ww.jasonleveille.com
Redirect permanent / http://jasonleveille.com/
</VirtualHost>

Removing WWW through .htaccess

Perhaps you don’t have access to your VirtualHost block. Not a problem if your host/server/whatever allows you to override directives via .htaccess. This article on using .htaccess from Daring Fireball is a good reference regarding this topic.

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com$
RewriteRule (.*) http://yourdomain.com/$1 [R=Permanent]

Permanent Redirects and CakePHP

I recently had the need to set up some permanent redirects for an application built on CakePHP. My first thought was to use a simple .htaccess Redirect at the top of my www .htaccess file, like such:

Redirect 301 /foo /bar

However, the result of the redirect was actually the following url:

http://foobar.com/bar?url=foo

This has to do with the QSA flag in the last RewriteRule of the root htaccess file. The QSA flag indicates that a query string should be appended to the url. In our case, foo is recognized as the query string and it ultimately is appended at the end of the bar redirect. Not what I wanted, as the appending of foo to bar results in a 404 error. Read the rest of this entry »

My Comment Story is Better than Yours

So, of all the comments you may have ever received on your blog, who provided the comment that made you say, “holy sheat, xxxx yyyyy just commented on my blog”? In early 2007 I was working with Jeff Brown of Jeff Brown Designs. We had recently launched his new site and Jeff had written a post on the use of CSS grids. Now, I know this doesn’t count for me, and Jeff is probably going to call me up and ask why the hell I stole Eric from him, but I’m writing about it anyway. The day of Jeff’s post who should place a comment on the blog? Eric Meyer himself. I felt all tingly and warm inside, and I had to breathe into a small paper bag to catch my breath. Read the rest of this entry »