Welcome To Snipplr


Everyone's Recent Ruby Snippets



It's necessary to do this for each of automatic_attrs, override_attrs, normal_attrs and default_attrs
0 193 posted 10 years ago by therobot
0 141 posted 10 years ago by alexkojin
0 181 posted 10 years ago by insanedreamer
This regular expression used in Ruby will extract the characters between single or multi-character delimiters. It helps when you have strange delimiters such as \":delimeter1: text I want to grab goes here :delimiter2:\"
0 200 posted 10 years ago by webonomic
This script is a nice balance between validating data and speed.
1 169 posted 10 years ago by chrisaiv
Quick conversion from a string of binary into ascii, and back again.\r\nUse B* for MSB and b* for LSB first.
0 170 posted 10 years ago by jimbobmcfred
0 109 posted 10 years ago by rkumar
I’ve recently had to parse some pretty large XML documents, and needed a method to read one element at a time. Here’s a fairly simple solution in Ruby form.
0 191 posted 10 years ago by dom111
0 101 posted 10 years ago by rkumar
0 101 posted 10 years ago by rkumar
0 120 posted 10 years ago by rkumar
0 132 posted 10 years ago by viatropos
0 131 posted 10 years ago by therobot
0 116 posted 10 years ago by viatropos
0 129 posted 10 years ago by pdxmph
Easy way to populate a drop-down menu
3 189 posted 10 years ago by chrisaiv
validate :price_must_be_at_least_a_cent protected def price_must_be_at_least_a_cent errors.add(:price, 'should be at least 0.01') if price.nil? || price < 0.01 end
0 108 posted 10 years ago by stayce