self.posts.collect { |post| post.published? }

Oct 26 2009

My Tools of the Trade

A bunch of these posts going around. Thought I’d chime in and list what using day to day. I’ve swapped a lot of software recently with what I consider better software.

Not all of it is free. Same I bought on their own, others I got as part of a bundle (like MacHeist). There are free ones out there, but these are the ones I chose and work with.

Read More

Comments (View)
Jul 06 2009

Re-resizing images with attachment_fu

The application I work on (http://kete.net.nz) has an image sizes sysem setting that allows site administrators to changes the resized dimensions when someone uploads a photo. But we ran into case where someone drastically changes the dimensions after already adding several hundred photos. Can’t upload them all again!

So we wrote a rake task. It goes through the image files table, getting the parent images (originals). It then checks the resized image dimensions against the image sizes setting. If one has changed, resize it based on the original. If one is missing, create it based on the original.

Read More

Comments (View)
May 08 2009

Getting Internet Explorer 8 on the Mac (or any other OS)

While developing Kete, maintaining cross browser compatibility is a concern for us. We need to make sure that the site runs the same on Internet Explorer 6, Internet Explorer 7, Firefox 3, and Safari 4.

The Mozilla developers do an excellent job at making Firefox available on nearly every OS. If it doesn’t exists, someone can compile it. However, for Linux/Mac users we can’t get much else. Unlike Apple, who at least offer Safari 4 on Windows, Microsoft doesn’t support IE 8 on Mac OS X or Linux.

This makes browser testing for web developers trickier, and usually means having to get a windows computer or ask someone with one to test a site for you. However, just because IE isn’t natively available, it doesn’t mean you can’t use your computer for IE testing at all though.

Using a handy virtualization program called VirtualBox, and Microsofts recent Windows 7 release candidate, you can have IE8 on your Mac, or IE8 and S4 on your Linux installation, until June 1st 2010 free of charge.

Note 1: You will need a Mac with atleast 2gig of RAM or more, and 128mb of graphics RAM or more. Any less, and the operating system will be unusably slow. It also isn’t great at testing flash or shockwave based sites. But its perfect for standard XHTML rendering.

Note 2: A program for Windows XP, titled Multiple IE, by TredoSoft, is not currently available for Windows 7. So you still won’t be able to access IE6/IE7 easily just yet. However, sources (cnet, washington post, and more) state that Microsoft will be pushing IE8 as an update for Windows XP/Vista through auto update, rather than an optional update approach they took for IE7 when it was released. So if your site works with IE8, it should hopefully be good for a majority of computers within 3-6 months.

Step 1 - Download VirtualBox

Install VirtualBox (VBox). If there isn’t a version available for your operating system, then you might try one of the alternatives like VMWare, however, the rest of this post details instructions for VBox. Installation requires root priveledges.

Step 2 - Download Windows 7

Get a Microsoft passport (if you have a hotmail account, or use MSN, you already have one). Then select the type of download you want (I’m using the 32bit english version). You’ll be prompted to login to your Microsoft Passport account. Once you’ve done that, copy the product key and save it to your computer, or print it off. You will need it later. Then select ‘Download Now’.

The download is about 2.36GB, and took about 35 minutes on my connection using Folx, a Mac download manager.

Step 3 - Configure VirtualBox for Windows 7

If you haven’t yet, read the VBox documentation. Create a new Virtual Machine (VM), with a new Virtual Hard Disk (VDH), add your Windows 7 ISO file to Vbox, and then configure your new VM to boot from that ISO. Before you start your virtual machine, the configuration should look something like this:


Step 4 - Setup Windows 7

I’m not going to explain step by step because it guides you through the process. Basically, when you load up, select your settings, choose a partition and it’ll install (with a few restarts in between). Fill in some login details afterwards and your in.

Other Steps

Not quite done. You’ll need to install an anti virus. I recommend http://free.avg.com . Update it regularly. Update windows by typing ‘Windows Update’ into the start bar. And install guest additions. Consult VBox documentation for that. Doing do will make the OS faster, allow full screen usage, and allow you mouse to go from the Mac to Windows and back without needing to focus on or the other.

Questions?

If you have any issues/suggestions, post a comment.

Comments (View)
+
Final configuration for my windows 7 VM before installing.

Final configuration for my windows 7 VM before installing.

Comments (View)
+
Settings for my Windows 7 VM.

Settings for my Windows 7 VM.

Comments (View)
Apr 13 2009

Spotlight, Quicksilver, or Google Desktop?

Lately I’ve been trying out various application launchers for my new Macbook. For a long time, I’ve used Spotlight, the Mac’s build in ‘searcher’. But after a bit of searching, I found two other contenders. Quicksilver and Google Desktop.

But I’m wondering what other people use… perhaps there is a neat app that combines the arithmetic functions of Spotlight (running ‘5*10’ in spot light for example), the multi-action capability of Quicksilver (open with, move to trash, rename etc), and the GUI/Speed of Google Desktop.

If you know of one, do let me know in the comments.

Comments (View)
+

Capistrano Configuration - My first gem

For my work, we needed an easy way of configuring sites per deployment, but didn’t want the hassle of multiple yml files to manage. We needed an easy to use ruby syntax that didn’t require much more than including the code and writing the configurations.

Enter Capistrano Configuration. I wrote the code in a lib file and decided to move it to a gem so that others could benefit from it. It’s especially useful when you have multistage deployments from the same repository, because you can define configurations per deployment.

You can grab the source by running:

sudo gem install kete-capistrano-configuration


Then in your config/deploy.rb or config/deploy/production.rb files, add something like this:

require 'capistrano-configuration'
configure :database do
environment 'development' do
config 'username', 'app'
config 'password', 'secret'
end
environment 'production' do
config 'username', 'app_production'
config 'password', 'secret_production'
end
end
configure :google_map_key do
config 'map_key', 'u232398b208x9830x30xb383'
end

Simple aye? If you have any suggestions, let me know on my Github account.

Comments (View)
+

System Wide Capistrano Colorization

I recently discovered the handy little gem capistrano_colors. It adds color to your capistrano deployment, which makes it easier to spot where things went wrong. But the problem was that it required a change to the deploy.rb code, which meant that if you used it, everyone who deployed the code needed it to. What if you wanted it without adding the new dependancy for everyone?

Well the first way I thought of was to edit the capistrano gem, and ass the necessary require line to the end of lib/capistrano.rb, but this wasn’t ideal because if you update the gem, you’d have to re-add that line each time.

Well, with the help from the capistrano_colors author (Mathias), system wise capistrano colorization is now possible, without editing a single deploy.rb file. The solution lies with Capistrano. When you run a capistrano task, after it’s finished initializing, it then loads up ~/caprc. How does this help us?

Very simple actually. Instread of adding the require line into deploy.rb, add the same line to ~/.caprc, and you’re done. Colorized output, without the hassel of dependancies, or upgrading reseting it.

Thanks for the help on this Mathias. Has made things so much eaiser now.

Edit: Mathias has updated his plugin to include customizable filters, for hiding certain messages that come from deployments. He’s also updated the README to include the .caprc trick mentioned above.

Comments (View)
+

Phusion Passenger and Ruby Enterprise Edition Supporter

So I finally decided to donate to a project on the web, and I chose two to start with. Firstly, Phusion Passenger. They’ve done some awesome work, making Ruby on Rails websites much easier to deploy, and run with less memory. Secondly, Ruby Enterprise Edition. It’s made by the same people as Phusion Passenger. I’ve used it for some time too, and it’s much easier to install, upgrade, and manage than any other ruby implementation I’ve looked at. Another excellent project.

Got a neat little Phusion Passenger Special Edition logo too.

Keep up the great work guys!

Comments (View)
+

Unintuitive Ruby feature... or is it?

The fact that ruby variables reference objects was one of the first things I read about in the differences between PHP and Ruby, but over time, not having actually run into problems, recently this fact took me by surprise so I thought I’d share. Take this code sample for example:

» a1 = %w{ 1 2 3 }
» a2 = a1
» a1 = %w{ 4 5 6 }
» puts a1.inspect
[“4”, “5”, “6”]
» puts a2.inspect
[“1”, “2”, “3”]

As you can see, the code would seem to indicate that a1 and a2 are separate, and working as you’d expect (making a copy of the a1 and assigning it to a2). But then take this code for example:

» a1 = %w{ 1 2 3 }
» a2 = a1
» a1.delete(‘1’)
» puts a1.inspect
[“2”, “3”]
» puts a2.inspect
[“2”, “3”]

As you can, a2 was affected by the change to a1. Why? Well it’s those references I mentioned at the beginning of the post. When you use an assignment (=), it makes a new object and makes that variable reference it, but when you run methods on a1 (like delete), it doesn’t delete from the variable, but from the object it references, which a2 is also referencing at that point.

Now the fix for this is quite simple. Instead of just

a2 = a1

you replace it with

a2 = a1.dup

which works exactly the same way as before, but it points a2 at a new object (a duplicate of a1), rather than making a2 point at an existing object. This is pretty common stuff (anyone using Ruby for a period of time has come across this and knows how it works). But is it really intuitive?

Wouldn’t it make more sense to create duplicates by default and create a new a2 = a1.ref type syntax? Afterall, if someone wanted to call a reference, they might as well just call the original (I cannot think of any logical reason to have duplicate variables pointing to the same thing).

Or perhaps, if references were to stay the default, changing the implementation so that any write actions happen on a copy of it, but read actions happen on the original?

Any thoughts?

Comments (View)
Page 1 of 2