Welcome To Snipplr


Everyone's Recent Ruby Snippets



1 ... 5 6 7 8 9 ... 12
https://www.chrisjmendez.com/2008/06/04/ruby-open-a-text-file-and-re-write-its-contents-into-a-new-text-file/
1 2125 posted 18 years ago by chrisaiv
alternative to using DateTime.now.to_s
1 1870 posted 18 years ago by jhenry
Simple command line option parser snippet
1 1956 posted 18 years ago by mikegreen
Hat tip: Allan Odgaard
1 1693 posted 18 years ago by breakerjump
Generates a ChangeLog from git repository.
1 1608 posted 18 years ago by felipec
1 1918 posted 18 years ago by lakedenman
1 1402 posted 18 years ago by crazylion
This is an example of how to search within a Ferret index (based upon http://kasparov.skife.org/blog/src/ruby/ferret.html).
1 1657 posted 18 years ago by narkisr
This is a simple example for building a search index with the Ferret library (based upon http://kasparov.skife.org/blog/src/ruby/ferret.html).
1 1828 posted 18 years ago by narkisr
I didn't create this but I use it all the time. Just drop it in lib/tasks/fixtures.rake
1 1361 posted 18 years ago by markpercival
This example shows how to release artifacts into Artifactory by using Buildr, the origin of this code is http://groups.google.com/group/buildr-talk/
1 1301 posted 18 years ago by narkisr
1 1355 posted 18 years ago by dbug13
Command line currency convertor, just copy and paste. I named mine 'coin'. Make sure you have Ruby, Rubygems and Hpricot (gem install hpricot). e.g. ~$ coin 100 eur usd 158.3300 Uses the site xurrency.com.
1 1669 posted 18 years ago by plexus
1 1526 posted 18 years ago by inkdeep
2 1492 posted 18 years ago by inkdeep
1 1715 posted 18 years ago by neil
provides a tidy way to add initialization by hash to new classes
1 1426 posted 18 years ago by neil
Useful for speeding up searches.
1 2992 posted 18 years ago by jarnaldich
Note: most of these will be available to the shell and Rails' console too.
2 2005 posted 18 years ago by cczona
"When using haml, an HTML tag is represented using %tagname, but in the case of an HTML tag with attributes, the representation is %tagname{:attribute => value}. It turns out there must be no whitespace between %tagname and {:attribute => value}....
1 1548 posted 18 years ago by cczona
See also p. 348 ("Invoking a Method") of Pickaxe 2nd edition
1 1638 posted 18 years ago by cczona
Following a
2 1600 posted 18 years ago by cczona
This is handy for testing, when you need to simulate an open file or open URI. Why, and the Pickaxe book, have better examples
1 1674 posted 18 years ago by cczona
You can turn off warnings for a section of your code by setting $VERBOSE to nil. Even better is to codify this in a method. Since this method takes a block as its parameter, you can now pass it arbitrary chunks of code to execute without warnings.
1 1573 posted 18 years ago by cczona
1 ... 5 6 7 8 9 ... 12