Detect if your running on windows
# Returns true if we are running on a MS windows platform, false otherwise. def Kernel.is_windows? processor, platform, *rest = RUBY_PLATFORM.split("-") platform == 'mswin32' end
12388 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
# Returns true if we are running on a MS windows platform, false otherwise. def Kernel.is_windows? processor, platform, *rest = RUBY_PLATFORM.split("-") platform == 'mswin32' end
# Returns a random alphanumeric string of arbitrary size. def String.random_alphanumeric(size=16) s = "" size.times { s << (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr } s end