Welcome To Snipplr


Everyone's Recent Snippets Tagged ruby



Matches text between each pair of asterisks (see URL above for demo) **Example:** Make text between asterisks bold, like in Textile (in Ruby): `test.gsub(/(\*)+([^.*?$]+)+(\*)/, '<strong>\\2</strong>')`
0 161 posted 9 years ago by inko9nito
Call a block if it's given otherwise call a method.
0 63 posted 9 years ago by Shamaoke
ruby mcm.rb >mcm.sh chmod +x mcm.sh ./mcm.sh
0 91 posted 9 years ago by hafthor
It's necessary to do this for each of automatic_attrs, override_attrs, normal_attrs and default_attrs
0 112 posted 9 years ago by therobot
This script is a nice balance between validating data and speed.
1 107 posted 9 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 107 posted 9 years ago by jimbobmcfred
0 60 posted 9 years ago by stayce
0 63 posted 9 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 116 posted 9 years ago by dom111
0 58 posted 9 years ago by rkumar
0 60 posted 9 years ago by rkumar
0 119 posted 9 years ago by alx_g
0 63 posted 9 years ago by rkumar
0 72 posted 9 years ago by viatropos
0 78 posted 9 years ago by therobot
0 95 posted 10 years ago by almazom
Just a funny, yet usefull fixture for testing users in a rails app. Using "somewhat real" fixtures, will keep testing both fun and realistic. Knowing that "Crabbe_ugly_nick" failed, is a lot easier to communicate then knowing "user_t_x01 failed"
0 54 posted 10 years ago by berkes