Welcome To Snipplr


Everyone's Recent Snippets Tagged ruby



1 2 3 4 5 6 7 ... 14
Used to create checkboxes to select multiple categories for a post or any other type of applicable situation.
1 75 posted 10 years ago by smoothdzion
0 55 posted 10 years ago by kerpunk
Don't forget to use require 'directory/name_of_class'
0 124 posted 10 years ago by chrisaiv
0 83 posted 10 years ago by chrisaiv
1 158 posted 10 years ago by endorfin
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 84 posted 10 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 84 posted 10 years ago by chrisaiv
0 63 posted 10 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 85 posted 10 years ago by nate63179
In this instance, used as an after-deploy hook to create a symlink to a shared db config file
0 97 posted 10 years ago by nate63179
0 56 posted 10 years ago by tobewan
I had an XML file that I needed to convert to CSV. In order to make things easier for myself, I used a pipe | symbol instead of a comma so that there would be no parsing errors later. I also ended up writing the file to a Txt file and importing it...
1 167 posted 10 years ago by chrisaiv
This shows how we can find objects inside code blocks (aka data sets).
0 125 posted 10 years ago by chrisaiv
0 77 posted 10 years ago by almazom
1 65 posted 10 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 89 posted 10 years ago by pmadden
Put the following in your controller to define the content-type for *that* specific controller.
0 57 posted 10 years ago by chrisamini
The shell command which provides documentation for Ruby's classes and methods is:
0 62 posted 10 years ago by deepsoul
Sample log line: [INFO] 2009-03-06 20:47:35 | controller::bla | user: vincentvega | ip: 127.0.0.1
0 97 posted 10 years ago by benjay
A monkey patch splitting a string into sentences.
0 159 posted 10 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 96 posted 10 years ago by narkisr
To run, save as twitterbackup.rb: ruby twitterbackup.rb yourtwittername
1 127 posted 10 years ago by beandr
1 2 3 4 5 6 7 ... 14