house9

random code and what not

ruby 1.9.2 and rails 3rc with rvm

Get up and running with rails 3 release candidate on ruby 1.9.2

First step install rvm (ruby version manager) - note that rvm does not work on windows, for windows try pik

You will need to wait between each step as installation times will vary

# install 1.9.2 using rvm
 rvm install 1.9.2  
# this installed the official release 1.9.2-p0

# switch to 1.9.2
 rvm 1.9.2 
# gem install rails rc
 gem install rails –pre 

# create a new rails app, in this case ‘sample-r3’, this differs from older versions of rails; new is a required arg 
 rails new sample-r3 
# navigate to the root of your new rails app
 cd sample-r3 
# install the app dependencies - in this case sqlite3, see Gemfile in the root dir
 bundle install 

# generate a user scaffold, note g is shortcut for generate
 rails g scaffold User name:string email:string 
# create the database table users
 rake db:migrate 
# start up the rails server, note s is shortcut for server
 rails s 

Browse to http://localhost:3000/users and we are up and running and yes the scaffold pages still have the same old look and feel






In the past I have tried installing and running rails3 beta and rc on different versions of ruby and ran into some serious difficulties; but it has been painless on the official release of ruby 1.9.2

As a final step we want to add a .rvmrc file to the root of the rails project, this will force rvm to load the correct ruby version when we are in this directory. This can be quite handy, if we were on a different version of ruby running ‘rails s’ would create a new rails app directory named ‘s’ instead of running the server; from the terminal run

 echo “rvm 1.9.2” > .rvmrc 

I learned about the .rvmrc file from this post

Updated Look!

Just switched to a different Blogger Template - much wider and mo better!

Also consolidated my posting, I had 20+ code samples on another blog. Used the Blogger import / export tool which was pretty seamless; needed to move a few code blocks over to gists to get proper formatting but that was it!

valid? vs errors.any? in rails

Recently got bit by checking valid? in some rails code, thought I would share.

In this situation I was manually adding to the errors collection of an ActiveRecord object and then calling valid? to see if the object was ok; this is not the normal style of validation on ActiveRecord objects, if I had been playing by the rules valid? would have done what I needed; it would check the current state of my objects attributes and ‘re-validate’ the object.

This screen shot of an irb console session shows the issue I was running into


valid-v-errors-any

Taking a look at the source code for valid? it becomes obvious why the manually added errors get cleared, just not what I expected to happen


valid-source

Comments

Vladimir A. Rybas
wow. thanks!

Adjustable Height Desks

Both of these look like pretty sweet adjustable height desks;

- Geek Desk electronic and runs $750 to $800

or

- Airtouch uses air and no electronics - twice the price at $1500

hopefully I’ll be able to try one of these out soon

Pomodoro Timer application

After reading an article on infoQ, I started using the Pomodoro technique. It works pretty good, but I do still strugle with making my self take a break after the 25 minutes is up.

I recently spent a few days and created a simple timer application to monitor my pomodoros, it is pretty rough around the edges, but good enough for a first release.

I wanted to check out Appcelerator and their Titanium framework, this seemed like a simple enough app to get started with. Titanium allows you to build an app using html, css and javascript then the Titanium framework will ‘compile’ your code into a desktop application that targets all major operating systems; Windows, Mac and Linux.

In the end I did not really use any of the Titanium Api in my code, just jquery, css and html.


or download the binaries here:

Comments

_b1
not so helpfull as I think.
but thanks for work.

On win7 x64 work fine
House 9
I just tried it on my ubuntu 9.04 64-bit machine. Seemed to work fine - NOTE there is no 'install' required. Download and extract tar file. Then you should be able to just double click the tick-tock-desktop.exe from the root of the extracted directory (tick-tock-desktop-0.3.0) - I think you are trying to run the installer.exe from the installer directory? That doesn't work for me either, not sure why Appcelerator includes that directory?
28
64 Bit linux install error "Not enough information"

jsfiddle is awesome!



I had seen some blog posts on jsfiddle before, but just checked it out for the first time, a great way to experiment with javascript code, comes built in with jquery, mootools and more






Snag-it for the Mac

I have used Snag-it on Windows for many years - it is a great product!

During the last year I have been using Ubuntu and Mac and been missing Snag-it; Shutter on Ubuntu is ‘ok’, but not quite on the same level as Snag-it

I was happy to discover that there was a beta of Snag-it for the Mac


Free right now, been using it for the last month - it seems even better than the version for windows!

Uptime and performance monitoring made easy - pingdom.com

This is a nice service - http://pingdom.com/

Get an email or SMS alert if your site is not responding. They ping your site from multiple servers in both North America and Europe.

They offer one free account where you can ping a single url or get one of their payed monthly plans if you have additional sites to monitor.

Need to find real estate comps? www.redfin.com

Need to find real estate comps? www.redfin.com is a sweet site. Not only can you search for new homes on the MLS listings but you can also search previous Sale Records. I don’t know of any other site that offers the same functionality. Click the ‘More Options’ link by the ‘Search Listings’ button.

Another really nice feature, If you find a bunch of homes for sale in a viewable area on the map, click the ‘DOWNLOAD’ link to get all of the info in excel (csv).