Welcome To Snipplr


Everyone's Recent Snippets Tagged ruby



1 2 3 4 5 6 7 ... 13
requires Rails libraries. could be rewritten to just use core Ruby libs, but I'm too lazy right now and I use this entirely in my Rails apps.
0 2096 posted 16 years ago by mepatterson
Ruby provides a platform independent way of displaying file paths. Here are a few common ways to show absolute and relative paths.
0 1899 posted 16 years ago by chrisaiv
0 1647 posted 16 years ago by benjaminpearson
This could be further abstracted to work with other db's. Also, it really should be using Ruby's Tempfile class instead of assuming the local machine is *NIX based, but it works :)
0 1831 posted 16 years ago by nate63179
In this instance, used as an after-deploy hook to create a symlink to a shared db config file
0 1914 posted 16 years ago by nate63179
0 1552 posted 16 years ago by tobewan
This shows how we can find objects inside code blocks (aka data sets).
0 2552 posted 16 years ago by chrisaiv
0 1620 posted 16 years ago by almazom
1 1398 posted 16 years ago by shiftyjelly
Inserted at the top of the method body, this line creates instance variables for each of the method parameters and sets them to their respective argument values.
0 2116 posted 16 years ago by pmadden
Put the following in your controller to define the content-type for *that* specific controller.
0 1506 posted 16 years ago by chrisamini
The shell command which provides documentation for Ruby's classes and methods is:
0 1591 posted 16 years ago by deepsoul
Sample log line: [INFO] 2009-03-06 20:47:35 | controller::bla | user: vincentvega | ip: 127.0.0.1
0 1916 posted 16 years ago by benjay
A monkey patch splitting a string into sentences.
0 2342 posted 16 years ago by cocomo
Groovy has the as keyword which enables the implementation of a Java interface by using the as keyword, its quite easy to mimic this in JRuby.
0 2126 posted 16 years ago by narkisr
0 1828 posted 16 years ago by AzizLight
1 2082 posted 16 years ago by AzizLight
To run, save as twitterbackup.rb: ruby twitterbackup.rb yourtwittername
1 2140 posted 16 years ago by beandr
Code for a Rake task that allows compiles all LESS stylesheets (.less) contained within a single directory.
0 1881 posted 16 years ago by brettbergeron
0 1515 posted 16 years ago by kungfoo
1 1474 posted 17 years ago by webstic
0 1406 posted 17 years ago by kungfoo
Probably not the most elegant solution, but it works. Needed this for a capistrano deploy task which shows the most recent tagged releases in my repository. Very bare bones, and needs tweaking if your versions are not in X.X.X.X format.
1 2085 posted 17 years ago by bananastalktome
0 1554 posted 17 years ago by hlubek
1 2 3 4 5 6 7 ... 13