This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/inflections.rb | |
ActiveSupport::Inflector.inflections do |inflect| | |
inflect.singular(/^(.*ss)$/i, '\1') | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I always manage to end up with different capitalizations on artist names, | |
# which causes some mp3 players to see them as different artists. | |
# So I use ruby-mp3info to rename them | |
# gem install ruby-mp3info | |
require 'rubygems' | |
require 'ruby-mp3info' | |
# in the directory of the artist, with albums as subdirectories (change as needed) | |
files = Dir['*/*.mp3'] | |
files.each do |f| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I use this to find double words in a text file | |
# for example, "Give it to the kid." gets typoed as "Give it the the kid." | |
# this regex will find "the the" and help me track down those double word typos | |
egrep '(\b\w+)\s\1\b' *.txt --color -n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a simpler version in javascript that actually zero-pads numbers in | |
// the strings so we can sort properly | |
// this one uses underscore.js, but you get the picture | |
// in this example, we have a bunch of text_document objects to sort | |
sorted = _(text_documents).sortBy( | |
// the zero padding is to make "Chap 9" come before "Chap 10" | |
function(td) { return [td.name.replace(/\d+/, function(m) { return zeroPad(m, 99) } )]; } | |
); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get rid of weird characters from pasting from Word and stuff | |
def cleanup(text) | |
if text | |
text. | |
gsub(/&/, '&'). | |
gsub(/&[lr]?quot;/, '"'). | |
gsub(/'/, "'"). | |
gsub(/'/, "'"). | |
gsub(/>/, '>'). | |
gsub(/</, '<'). |