Life on Rails » Technological travels in Flex, Air, RIA and life in general
Imagine a beautiful autumn park, and a bald ginger man reading books and playing guitar, and doing other stuff

1and1 does it again, great hosts

Just a short note to say that I truly love the web hosts 1and1. That’s who my server is hosted with, and who is responsible for hosting all of the sites I have.

They have great dedicated server packages that are super fast, with loads of bandwidth. I actually run visualchat.co.uk on on of their dedicated servers, which has ample bandwidth for all the audio and video of the webcam chat sessions.

In short,

  • the servers are fast,
  • they got great control panels,
  • the support is actually really good, both written, and on the phone,
  • the bandwidth is phenomenal,
  • you get free ftp backup with each dedicated server,
  • they never go down.

They really are great – I strongly recommend them… However, I’m not writing because of that – I’m writing to let you know that they have exceeded my expectations again:

In September 2007 I took up a new server package, a beefed up dedicated server, that came with 3 months free contract, then 18 months minimum term. Now, I was intending to migrate my existing dedicated server (contract expired) to the new server.

However, I started working for Adobe, and was so busy that I never got a chance to move the server, and therefore ended up paying for both dedicated servers. Now 1and1 get a few bad reviews for locking people into contracts, but I have to say – they were great with me – I called them, explained what had happened, and they simply asked me to fax them the details.

The server is now cancelled: Including the 18 month contract! Yep! they just let me back out of it, by being reasonable and human about it all – so next time someone tells you that they are monsters, and hold people in to contracts, I suggest you ask them how they spoke to their staff, and how they treated them – I know other people who have been rude, and they get what they give..

I don’t know any other host that would do this – I can definitely tell you 3 other hosts that wont budge at all on these matters (though I don’t want to name them)...

BTW, I’m not an affiliate – I haven’t joined their program, so I’m genuinely objective – check them out if you want dedicated servers- for any small-medium scale project (read as, don’t need a server farm and fail over), they’re great!

Flex unit, and asynchronous tests

Thought I’d share this with you..

If you’re using flexUnit and want to test some class or method that dispatches an asyncrhonous event, then this snippet is for you.

I’ve seen this done a few ways, but I recently discovered this neat little feature of flexUnit. If you know this already, then good for you, but if not, let me introduce you to the addAsync method.

Basically, this TestCase method acts as a proxy between you’re addEventListener call and FlexUnit, giving you a teeny bit of extra functionality on the way. The basic use is:

  1. myObject.addEventListener( eventName addAsync( handlerMethod, timeOutInMillisecs ) );

It’s quite straight forward, you provide it with a handler in your TestCase, and if a matching method is not dispatched in the prescribed amount of time, the test fails. Neato.

More...

Create new file from context menu in finder

Tags: ,

I often take this for granted, but then friends happen to see me do this and always ask me how it works…

Adding a file from the finder context menu

It’s something I missed on os x after years of windows – the ability to create a new document just by clicking the right mouse button. Thankfall Nufile is a context menu plugin which exists for this purpose, it’s donate-ware and can be downloaded here:.

I’ve used it for almost a year without problems. You can customize it to add whatever file types you like, and even provide templates. The help on the website is really thorough, so I suggest you check that out.

Enjoy.

Finder cut and paste

Tags: ,

Having come from windows, I was looking everywhere for this!

Fortunately, some dude called Illari Scheinin wrote a couple of apple scripts that do the job. A link to his website and these scripts is here

He points out some apps you can use to run these scripts, they may be good or not, I don’t know because I use the excellent Quicksilver. If you don’t know about quicksilver, well go download it!

I’ll blog about it more in the future, but needless to say you can store both of these scripts in a suitable folder somewhere, which quicksilver is scanning. I have a folder specifically for apple scripts which I’ve set quicksilver to scan. It’s simply a case of dump these 2 script files in that folder, make sure quicksilver is scanning it, then set up a trigger for cut files.scpt (I did it with CTRL + APPL + X) and one for paste files.scpt (I chose CTRL + APPL + V). You can now select one or more files/folders in finder, and use cut and paste!

HOORAY! and thanks Illari!

subversion and apache problem

My relationship with subversion has been akin to someone who drinks white lightening for several years who then, slowly, but surely sobers up, gets a life

The white lightening (super strong, semi-fuel, part of the staple diet of any leet alcoholic) was visual sourcesafe 4, 5 and 6, so I wasn’t grokking svn at all. That’s all good now though, because as a result of switching to mac, and then using darwin ports anr rails, I fell in love with subversion, and (despite some peolple worries about Berkley db) have now happily integrated it into most areas of my (techno) life

However, setting it up on windows with apache can be a bitch!

It was driving me truly mad, truly truly mad.

It kept crashing, and making apache fall over.

Turns out there are a couple of issues: 1. You have to use the correct version of subversion for your apache server (I wasn’t), and 2. it turns out that the mod_dav_svn.so module you load in your apache config, should be in the bin directory of your apache install – I found this after searching everywhere on the net for more info

Finding available modes on a webcam

I recently ended up having to find what webcam modes were supported by a webcam. The following code can be used to find out what’s available..

It turned out that my problem wasn’t anything to do with modes, which is why I didn’t expand this further – had I done, I would’ve stored an array of modes I supported, and checked to see if I had a match.

  1. fps=15;
  2. cam = Camera.getCamera();
  3. for (w=100;w<1000;w=w+20){
  4. for (h=100;h<1000;h=h+20){
  5. cam.setMode(w,h,fps);
  6. if ((w cam.width ) &amp;&amp; (h cam.height)){
  7. trace( w + " x " + h + " @ " + cam.fps);
  8. }
  9. }

popups and link_to

Turns out that link_to handles popups,

You’d know this if you looked in the rdoc, but if you’re new to rails, you might not be down with that yet.

You can write code like:

  1. <%= link_to "pop me up", { :action => "show" }, :popup => [new_window,height=300,width=600] %>

I’m happier putting a javascript function in myself, and calling that, using onclick=>”popup(‘new_window’, 300, 600);” where function is something like:.

  1. function popup(window_name, url, p_width, p_height) {
  2. var new_window = window.open( url, window_name, "status = 1, height = " + p_height +", width = " + p_width );
  3. new_window.focus();
  4. }

I do this because then I can actually bring the window to the front (or specify more args, etc), I guess it could also be a matter of taste.

In fact, these days, I’m happier not using helpers like link_to for trivial stuff anyhow.

autorun batch files, and command

I switch from mac to windows a lot. As such, I often find myself typing ls, instead of dir in a windows command shell (we’ll get onto the copy paste issue another time) and it gets really really annoying.

However, you can set up aliases in windows, much the same as you would on os x/ix systems:

doskey ls=dir $

This creates an alias of ls, equivalent to dir

You can set up other commands too, but of course, you want to run them each time you open a new command window. Do the following:

  • Create a batch file with the commands you want to run each time you start a command window
  • Save file in a sensible location
  • Change the following registry key to point to your file:
    HKEY_LOCAL_MACHINE\SOFTWARE\MICROSFOT\COMMAND PROCESSOR\AutoRun

Now that bactch file will run everytime.

Word of warning!! Don’t use cd to change dir in the autorun, as it will stop all manner of scripts, which launch their own command processes (such as rails script/server) from working correctly.

Assignment in expressions

This should be old hat to anyone using ruby for a couple of months, but if you’re fairly new to ruby, and especially if you’ve been kinda, trying to keep afloat in ruby to grok rails, you might not yet know the following

You can assign multiple variables in one expresison in ruby, and as such chain together code to do some seriously cool stuff

Here’s a really simple example:

e = (Event.get_events_in_town t= Town.find(12)).first

This not only sets e to the first event, but also initialises t as that town’s event.

I’m not suggesting you write code like this by the way, but I found this so useful when using console, to debug my apps, or play around with my models