Skip to content

Instantly share code, notes, and snippets.

@solomon081
Created June 9, 2012 03:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save solomon081/2899304 to your computer and use it in GitHub Desktop.
Save solomon081/2899304 to your computer and use it in GitHub Desktop.
GID
class GID
# Filters out naughty words
def self.filter! str
words = ["fuck", "shit", "bitch", "cunt", "fag", "douche", "ass", "a55", "b1tch", "f4g", "5h1t"]
substitutes = ["faxf", "spwo", "bawpr", "capf", "fpa", "dclax", "aic", "a21", "b5sea", "f8m", "1z8l"]
words.each do |x|
str.gsub!(x, substitutes[words.index(x)])
end
return str
end
# Generates a new GID
def self.generate length=32, lean=String
str = ""
letters = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
types = [Fixnum, String]
types.push(lean)
length.times do
if types.sample == Fixnum
str << "#{rand(10)}"
else
str << letters.sample
end
end
filter! str
return str
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment