Joyent Shared Accelerator Gems + Specs

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Wednesday, 22 April 2009

ruby -v
=> ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-solaris2]

python --version
=> 2.5.2

mysql --version
=> mysql  Ver 14.12 Distrib 5.0.67, for sun-solaris2 (i386) using readline 5.2

sqlite -version
=> 2.8.16

postgres --version
=> postgres (PostgreSQL) 8.3.5

git --version
=> git version 1.6.0.2

hg --version
=> Mercurial Distributed SCM (version 1.0.2)

svn --version
=> svn, version 1.5.2 (r32768)

ulimit -s
=> 10240 (stack size)

memory
=> 32GB (real)

*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (2.1.1)
actionpack (2.1.1)
activemerchant (1.3.2)
activerecord (2.1.1)
activeresource (2.1.1)
activesupport (2.1.1)
BlueCloth (1.0.0)
builder (2.1.2)
camping (1.5)
capistrano (2.2.0)
cgi_multipart_eof_fix (2.5.0)
columnize (0.1)
daemons (1.0.10)
datamapper (0.3.2)
diff-lcs (1.1.2)
erubis (2.5.0)
eventmachine (0.12.0)
extensions (0.6.0)
fast_xs (0.6)
fastthread (1.0.1)
fcgi (0.8.7)
ferret (0.11.6)
filesystem (0.1.0)
flexmock (0.8.3)
gem_plugin (0.2.3)
gettext (1.93.0)
gruff (0.3.1)
haml (1.8.2)
heckle (1.4.1)
highline (1.4.0)
hoe (1.7.0)
hpricot (0.6)
json (1.1.3)
json_pure (1.1.3)
linecache (0.4.3)
log4r (1.0.5)
logging (0.7.1)
mailfactory (1.4.0)
markaby (0.5)
merb (0.9.2)
merb-action-args (0.9.2)
merb-assets (0.9.2)
merb-builder (0.9.2)
merb-cache (0.9.2)
merb-core (0.9.2)
merb-gen (0.9.2)
merb-haml (0.9.2)
merb-mailer (0.9.2)
merb-more (0.9.2)
merb-parts (0.9.2)
merb_activerecord (0.9.2)
merb_datamapper (0.9.2)
merb_has_flash (0.9.2)
merb_helpers (0.9.2)
merb_param_protection (0.9.2)
merb_sequel (0.9.2)
merb_stories (0.9.2)
merbful_authentication (0.9.3)
metaid (1.0)
mime-types (1.15)
mini_magick (1.2.3)
mongrel (1.1.5)
mongrel_cluster (1.0.5)
mongrel_config (0.3.1)
mongrel_console (0.2.1)
mongrel_upload_progress (0.2.2)
needle (1.3.0)
needle-extras (1.0.0)
net-sftp (1.1.1)
net-ssh (1.1.2)
nokogiri (1.0.7)
ParseTree (2.2.0)
postgres (0.7.9.2008.01.28)
postgres-pr (0.4.0)
rack (0.4.0)
rails (2.1.1)
rake (0.8.2)
ramaze (0.3.9.1)
rcov (0.8.1.2.0)
rdiscount (1.3.4)
RedCloth (4.0.4)
rfuzz (0.9)
rmagick (2.7.0)
rspec (1.1.4)
rubigen (1.3.2)
ruby-debug (0.10.2)
ruby-debug-base (0.10.2)
ruby-json (1.1.2)
ruby-openid (2.0.4)
ruby-yadis (0.3.4)
ruby2ruby (1.1.9)
rubyforge (1.0.0)
RubyInline (3.7.0)
sequel (1.5.1)
sequel_core (1.5.1)
sqlite3-ruby (1.2.4)
syntax (1.0.0)
thin (0.8.1)
tzinfo (0.3.10)
validatable (1.6.7)
ZenTest (3.10.0)
Update

Got an email from Joyent, they're doing upgrades tomorrow, good stuff!

Perl 5.10.0
Rails 2.3.2
Ruby 1.8.6 patchlevel 368
most gems updated to their most recent versions

Cucumber Cheat Sheet

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Tuesday, 14 April 2009

install cucumber
sudo gem sources -a http://gems.github.com
sudo gem install cucumber
install webrat
sudo apt-get install libxslt1-dev libxml2-dev
  ..needed by linux
sudo gem install webrat

In your test_helper.rb or env.rb (for Cucumber) add:
  require "webrat"
  Webrat.configure do |config|
    config.mode = :rails
  end
install rspec
sudo gem install rspec rspec-rails
gem dependencies + rake commands
add to: config/environments/test.rb

config.gem "rspec", :lib => false, :version => '>=1.2.2'
config.gem "rspec-rails", :lib => false, :version => '>=1.2.2'
config.gem "webrat", :lib => false, :version => ">=0.4.3"
config.gem "cucumber", :lib => false, :version => '>=0.2.2'

sudo rake gems:install                :install gems
sudo rake gems:install RAILS_ENV=test :install gems for [test] env
sudo rake gems:build                  :build gems needing native extensions
sudo rake gems:unpack                 :unpack gems
sudo rake gems:unpack GEM=hpricot     :unpack specific gem
cucumber commands
script/generate cucumber    :setup cucumber in your app
cucumber features -n        :test against /features

script/generate rspec_model Article title:string content:text
  ..generate rspec model + db migrations

rake db:migrate             :migrate database
rake db:test:clone          :clone migrations to test database

script/generate rspec_controller articles index
  ..generate rspec controller
webrat commands
script/generate integration_test authentication
  ..generate integration test 'authentication'

rake test:integration       :run integration tests
tutorials

beginning with cucumber

webrat

look inside the /examples directory for help on specific scenarios

commands

rake features     :run this to list each scenarios rake tasks
cucumber --help   :list cucumber help

...and no, a cucumber is a fruit, not a vegetable

10 Cool Things in Rails 2.3

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Friday, 03 April 2009

Posted by Luke Franci, this is an excellent article on the new & startling features within this latest release of the Ruby on Rails framework.

Great work,

Rails 2.3.2 + Ruby 1.8.8

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Sunday, 22 March 2009

Have plans to virtualize my server so the blog and all other important parts are getting pushed over to a new temporary home while I map it all out. With that I thought it might be great time to see how things cope with Rails 2.3.2 and the latest stable snapshot of Ruby 1.8.8.

Points to note, I had to change my application.rb file to application_controller.rb for the new 2.3.2 layout, done simply with;

rake rails:update:application_controller

And when compiling Ruby 1.8.8 (1.8.7 is the official stable mind), had to edit line 5 of version.h

from...
  #define RUBY_PATCHLEVEL -1
to...
  #define RUBY_PATCHLEVEL 1

Without this, RubyGems won't install, complaining about the version (1.8.8dev). This changes it to 1.8.8p1 for which RubyGems will no longer complain at.

So far, memory & speed are churning out good, used linode for this one as they offer 32-bit builds which are perfect for the job.

Ruby vs Python

"Each have a culture that defines them. Python is built around 'There's one way to do it' unlike Ruby which takes Perl's mantra 'There's more than one way to do it.'"

Thanks TopFunky for this,

Rails Examples

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Friday, 20 March 2009

'RAKE ROUTES'
  • Rake Routes by Ryan
Don't Repeat Yourself (DRY)
Has And Belongs to Many vs :Through
  • Differences between HABTM and :THROUGH by Josh Susser
Securing Feeds
SSL in Rails
Blocks & Closure
  • Conversation with Yukihiro Matsumoto on Blocks and Closures in Ruby by Bill Venners
On a less serious note...

Woah little NSFW with the language but those are some pretty striking IE6 splash pages Joe Lifrieri. Don't think they'd pass approval, but worthy of a friday post ;-)

Colourful Testing

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Saturday, 07 March 2009

So I don't forget more than anything, here's how to colourize your testing output in ZenTest (thanks PeepCode)

sudo gem install ZenTest redgreen

Next go into your rails project and create a file called .autotest

gedit ~/.autotest

And add some styling to AutoTest

require 'redgreen/autotest'

Now everytime you're testing, passed tests will be in green and failures will be in red.

Kick off ZenTest with

autotest

More here

Social Bookmarking added to Matilda

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Monday, 05 January 2009

Along with all the other things, I couldn't let Digging and Submitting my posts go by without adding a feature for this to the Matilda engine.

The idea was simple, follow what others have done but put it in a way so it's not in-your-face and doesn't detract the user from the content.

So with some googling I found Yoast's Sociable Wordpress plugin, that basically adds a nice social bookmarking bar to all you're posts.

So with some hard work I quickly ported this over from PHP and minimized the JS needed (I really didn't want another js file sitting on my interface and slowing the loading so it had to be dynamic and off of Rails, the pages are all cached so speed isn't a problem).

After which that left me with a clean & simple partial, I then tiend that to Rails 2.1's new Locals feature which allows you to send local variables across as parameters to your partials which made things much more dynamic.

<%= render :partial => 'sociable', 
:locals => {:s_url => @article.article_url_full, 
    :s_title => URI.escape(CGI.escape(@article.title.to_s),'.')}%>

Put in some escaping with the URI library, css improvements and you're done.

Site Tuning Tools

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Saturday, 15 November 2008

Wired

Rails Gems
Linux Tools
Web Sites
Apache
Firefox
Internet Explorer

Textile & Markdown in Ruby

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Thursday, 13 November 2008

Textile

Simple to implement with the redcloth gem

sudo gem install RedCloth

Usage,

require 'redcloth'
s = RedCloth.new "p. format this with textile"
puts s
Markdown

With markdown you've got three implementations to try,

  • bluecloth gem (last maintained 2005, slow)
  • rdiscount gem (better c implementation, fast!)
  • maruku gem (pure ruby implementation)

To implement with BlueCloth

sudo gem install bluecloth

Then,

require 'bluecloth'
s = BlueCloth::new("# format this with markdown")
puts s

Or RDiscount

sudo gem install rdiscount

Then,

require 'rdiscount'
s = RDiscount.new("# format this with markdown")
puts s

Escaping in Ruby

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Saturday, 08 November 2008

Really simple example for escaping your strings

require 'uri'
str = URI.escape(str) if str.length > 0

Ubuntu Setup

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Sunday, 11 May 2008

After grabbing and installing Ubuntu 8.04 I then had to put together and setup the baby, luckily I wrote down most of everything I did in case I'd have to do it again and to help out you guys.

What follows are my findings and what I did to fix them. The machine I used is an HP Pavillion dv2000 model dv2742 special edition. It's got a built-in intel graphics card, 3gb memory, sata 250gb drive, wifi, bluetooth and an intel dual core 2 processor.

I installed the o/s using the 64-bit edition of Ubuntu 8.04 Hardy Heron, all what you see below are workable settings which provided the right setup; hope they help your situation if you go down this route.

Update System

First port of call, check for any new updates post-install,

sudo aptitude update
sudo aptitude upgrade

Dependencies / Software / Setup

Next, install Ruby, FlashPlayer, GCC Compiler, MySQL, JAVA, SqlLite,

sudo aptitude install mysql-server flashplugin-nonfree ruby-full libsqlite3-dev build-essential libmysqlclient15-dev sun-java6-jdk

Volume Mixer,

sudo aptitude install gnome-alsamixer

ImageMagick,

sudo aptitude install imagemagick

Ruby Gem Handler

I could get GEM from the repositories but because with each new update it breaks away from the in-built Linux installer it's best to install it from source,

wget http://rubyforge.org/frs/download.php/34638/rubygems-1.1.0.tgz 
tar xzvf rubygems-1.1.0.tgz
cd rubygems-1.1.0
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

Had problems updating the GEM system initally, so logged in as root to finish it off,

su root 
sudo gem update --system

Now when you type gem --version you should see GEM ready to roll,

Gem Libraries

The slow bit, ran this as root just to make sure it worked,

sudo gem install rails rake mongrel mongrel_cluster thin capistrano mysql termios sqlite3-ruby mini_magick will_paginate ZenTest liquid rcov

How to update RubyGem's later

Later on you'll want to update the gem system, which by going this way won't be possible with the usual 'sudo gem update --system', but this:

sudo gem install rubygems-update
sudo update_rubygems

VLC + GIT

Next VLC to play videos,

sudo aptitude install vlc

Transmission for torrents, most important bit,

sudo aptitude install transmission

And GIT to handle code versioning,

sudo aptitude install git-core

Firefox + MS Fonts

Next I need Firebug for Firefox 3. Ubuntu 8.04 comes with Firefox 3 beta 5, the one available thru Tools / Add-ons won't work with it; but thankfully it's in the repositories

sudo aptitude install firebug

And you'll probably need Microsoft Fonts later down the line,

sudo aptitude install msttcorefonts

Pimp GEDIT

The default Gnome Text Editor Isn't bad but let's add some extra's to really kick it in gear,

sudo aptitude install gedit-plugins

And tweak it,

wget http://robzon.kapati.net/rails/rhtml.lang && sudo mv rhtml.lang /usr/share/gtksourceview-2.0/language-specs/
wget http://robzon.kapati.net/rails/rails.xml && sudo mv rails.xml /usr/share/mime/packages
sudo update-mime-database /usr/share/mime

Follow the guide here to get the TextMate look,

Now when you open rails source files they'll actually look right, thanks Grigio.

PostGreSql + Thunderbird

Pretty easy to install the most powerful db system, and the better email handler

sudo aptitude install postgresql thunderbird

Wine for Windows

Thanks to Google for their support the Wine project is going great, to get Windows software running natively on your machine,

First add the key,

wget -q http://wine.budgetdedicated.com/apt/387EE263.gpg -O- | sudo apt-key add -

Then add the repository to your default repository list,

sudo wget http://wine.budgetdedicated.com/apt/sources.list.d/hardy.list -O /etc/apt/sources.list.d/winehq.list

And finally install it,

sudo apt-get install wine

Effects

To enable compiz effects make sure Appearance / Visual Effects is set to 'Extra', then install the Advanced Effects Manager,

sudo aptitude install compizconfig-settings-manager

This will give you access to the 3d cube, skydome effect and a host of other cool addons.

My desktop dpi is set to 100dpi, fonts set to 'Bitstream Vera Sans Roman 8pt', with 'Bitstream Vera Sans Bold 8pt' for Windows Title; and 'Liberation Mono 8pt' for fixed width font. Using subpixel smoothing for LCD.

Sound

For my laptop (hp pavillion dv2000 / dv2742se model), i had to use a different sound mixer to make sure the quickplay volume and mute buttons talked to the sound system.

So from the top menu bar, System / Preferences / Sounds, then set the Default Mixer Tracks hander device to: Conexant CX20561 (hermosa) (oss mixer).

Cleanup

To get any temp files carried on from the install, clean with,

sudo aptitude clean

Job done, however I had a problem with Hibernate & Suspend which was lucky fixed with some advice from here

Record Grouping

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Tuesday, 01 April 2008

Example to go thru your User model and return all the signups by month / year, doing conditionals on them and grouping,

@users = User.find(
  :all, 
  :select => "MONTH(created_at) as month, YEAR(created_at) as year, COUNT(*) AS records",
  :conditions => ["admin = 0'"], 
  :group => "year, month")

You can use this in your view like,

<% for @user in @users %>
  <%=@user.month%>
  <%=@user.year%>
  <%=@user.records%> signups
<% end %>