December 28th, 2007
I’ve now had my iPhone for 50 days, so thought I’d give you all a quick review.It’s incredible!
But, I have decided to jailbreak it — which, by the way, is pretty easy to do.
The main reason for jailbreaking the iPhone, is because you can’t send a text message to multiple people, which in my opinion, is a really big oversight by Apple. Other than this small problem, the iPhone is pretty perfect… or, I thought it was pretty perfect.
Since jailbreaking, I have re-fallen in love with this gadget. It’s incredibly powerful, and now does all of the things I wish it could do from the off.
- Rule number one when buying the iPhone. Jailbreak!
- Rule number two: buy some decent headphones. I just bought the V-moda ‘phones, and they’re really, really good.
Posted in today | No Comments »
September 7th, 2007
Download lazyload.js.
Requires prototype.js version 1.6.0_rc0 or above.
Element.addMethods({
lazyload: function(element, options)
{
/**
What does it do?
It delays loading of images in (long) pages. Images below the fold (far down in the
page) won’t be loaded before the user scrolls down. This is exact opposite of image
preloading. With long pages containing heavy image content end user result is the
same. Page feels snappier. Browser is in ready state after loading visible images.
No need to wait for n pictures to load.
From Wikipedia:
Lazy loading is a design pattern commonly used in computer programming to defer
initialization of an object until the point at which it is needed. It can contribute
to efficiency in the program’s operation if properly and appropriately used.
Inspired by:
http://www.appelsiini.net/2007/9/lazy-load-images-jquery-plugin
Requires:
Prototype.js version 1.6.0_rc0 or later
A page with lots of big images below the fold (optional)
*/
function $restore()
{
// this function restores the original image source; called when above the fold
if ( true === $(element).hasAttribute('_src') )
{
$(element).writeAttribute({ src: $(element).readAttribute('_src') });
}
}
function $scroll()
{
// this function returns the amount the page is scrolled vertically
var scroll_y = self.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
return parseInt(scroll_y);
}
function $height()
{
// this function returns the height of the viewport
var window_height = window.innerHeight || document.documentElement.clientHeight;
return parseInt(window_height);
}
var element = $(element);
var options = Object.extend({
threshold : 0,
placeholder : '/images/grey.gif',
event : 'scroll',
frequency : 0.1
}, options || {});
var offset = $(element).cumulativeOffset()[1];
var activate_on = (offset - options.threshold) - $height();
var old_source = $(element).readAttribute('src');
var new_source = options.placeholder;
$(element)
.writeAttribute({ src : new_source })
.writeAttribute({ '_src' : old_source });
if ( 'scroll' === options.event )
{
new PeriodicalExecuter(function($executor)
{
if ( activate_on <= $scroll() )
{
$restore(); $executor.stop();
}
}, options.frequency);
}
else
{
$(element).observe(options.event, function(event)
{
$restore(); $(element).stopObserving();
});
}
return $(element);
}
});
document.observe('contentloaded', function()
{
$$('img').invoke('lazyload');
});
Posted in javascript, prototype | 3 Comments »
September 4th, 2007
I host all of my website with Dreamhost. I think they’re fantastic — a little slow, perhaps — but they’re full of features, and let you install all kinds of goodness on their servers.
Recently, however, I have been struggling to get Ruby on Rails working on their domains. I have been fighting an uphill battle and losing, until I worked out the Shebang! line in dispatch.fcgi…
#!/usr/bin/ruby1.8
This will magically get your RoR application working.
The full dispatch.fcgi file is below:
#!/usr/bin/ruby1.8
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
# and the GC period is nil (turned off). A reasonable number of requests
# could range from 10-100 depending on the memory footprint of your app.
#
# Example:
# # Default log path, normal GC behavior.
# RailsFCGIHandler.process!
#
# # Default log path, 50 requests between GC.
# RailsFCGIHandler.process! nil, 50
#
# # Custom log path, normal GC behavior.
# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
#
require File.dirname(__FILE__) + "/../config/environment"
require 'fcgi_handler'
RailsFCGIHandler.process!
Posted in today | 1 Comment »
August 11th, 2007
I often write about the work I create, and sometimes write about the tools I use to create it, but I have never told you how I integrate my Mac with our Windows office (small O). What is the right way™?To do this, I use Parallels, which is a fantastic tool, and have recently been using it in Coherence mode. In this magical mode I can have Internet Explorer running next to Safari with no problems at all. I can have Access open importing a spreadsheet I’ve created in Excel for the Mac. All with no problems.The best advice I can give you is buy Parallels, turn on Coherence mode, and drag your favourite applications (different Internet Explorers for testing, etc.) into the dock. It’s fantastic, and so quick.
Posted in review, work | No Comments »
July 10th, 2007
There are no CSS hacks that can get equal-sized columns, so I wrote this tiny bit of Javascript to do the work for you. Simply add a class of “column” to any <div>s and their heights will match when the page loads.
function matchColumns()
{
var columns = $A($$('div.column'));
var column_height = 0;
var max_height = 0;
columns.each(function(column)
{
column_height = column.getHeight();
max_height = ( column_height > max_height ) ? column_height : max_height;
});
columns.each(function(column)
{
column.setStyle({
height: (max_height + 10) + 'px'
});
});
}
Event.observe(window, 'load', matchColumns);
As always, this script requires prototype, and will work better if you have a DOMReady function instead of window.load.
Posted in javascript, prototype, work | 3 Comments »
June 23rd, 2007
FAQs are tedious, but we can make their usage much more enjoyable (although I use this word lightly) by imroving the User Experience slightly.
Normal FAQs jump from the list of questions to the answer; with a simple bit of Javascript the page will smoothly scroll to the answer, and then–as a bonus–the answer will flash slightly.
Event.observe(window, 'load', function()
{
$$('a[href^=#]:not([href=#])').each(function(element)
{
element.observe('click', function(event)
{
new Effect.ScrollTo(this.hash.substr(1),
{
offset: -12
});
if ( this.hash.substr(1) !== 'top' )
{
if ( Prototype.Browser.IE )
{
$(this.hash.substr(1)).setStyle({
backgroundColor: '#fff'
});
}
Effect.Pulsate(this.hash.substr(1),
{
from: 0.5,
pulses: 5
});
}
Event.stop(event);
}.bindAsEventListener(element));
});
});
This script requires script.aculo.us
Posted in javascript, prototype, scriptaculous | 1 Comment »
June 22nd, 2007
It’s amazing!
The MacBook Pro that Vuture bought me is incredible. The whole machine flies (not literally, obviously) and running Windows in real-time alongside OS X is such a boon.
If you have the money, I would definitely recommend that you buy one of these beasts.
Posted in review, today, work | No Comments »
June 11th, 2007
One week ago today I started fulltime work at Vuture.
Today, Vuture ordered me a brand new 2.4GHz Core 2 Duo MacBook Pro! (For those of you who don’t understand “Geek speak”, that means: kick-ass laptop).
I’m very excited!
Thank you Vuture!
Posted in today | No Comments »
April 25th, 2007
I have fallen in love. Seriously, I’m truly, truly smitten with Coda from Panic. It is a fantastic bit of kit, and by far better than Adobe’s Dreamweaver CS3.
The page views are stunning, the FTP integration and large Publish All button works incredibly well.
While the text editor isn’t as powerful as Textmate, and the CSS editor isn’t as flexible as CSSEdit2, the overall synergy of this tool is fantastic.
Posted in today | 1 Comment »
March 5th, 2007
Today I presented some coursework to my Multimedia Databases lectured, Dr. Kyberd.
I got an A!
The final part of this coursework is due on Wednesday, so I’d better pull my thumb out and get on with it.
Posted in php, prototype, university | No Comments »