Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
Simple Particle Engine for a shooter game
Snake / Nibbles clone in C and Ncurses
Please improve
Parsing of XML data has high CPU usage
Convert simple Javascript to jQuery plugin
Active Record getting unique records
List the files in a directory without the directory name or the extension
clean the code
ohs system, recruitment software, hr software, oh&s software, human resources software, ohs software
Array parsing in a block
Popular
Parsing of XML data has high CPU usage
Please improve
Snake / Nibbles clone in C and Ncurses
List the files in a directory without the directory name or the extension
Convert simple Javascript to jQuery plugin
Simple Particle Engine for a shooter game
Active Record getting unique records
Breadth first cartesian product iterator
php refactoring
first BST
Pastable version of
Hash#switchify
<pre class='prettyprint' language='ruby'>class String def dasherize to_s.gsub '_', '-' end def switchify length > 1 ? "--#{dasherize}" : "-#{self}" end end class Hash def switchify inject [] do |args, (key, value)| next args unless value args << key.to_s.switchify args << (value === String ? value.inspect : value.to_s) unless value === true args end end end h = { :config => 'foo.ini', :verbose => true, :with_foo_bar => false, :with_some_coolness => true, :T => true } p h.switchify # => ["--config", "foo.ini", "--verbose", "--with-foo", "-T"] p h.switchify.join(' ') # => --config foo.ini --verbose --with-foo -T</pre> <a href="http://www.refactormycode.com/codes/817-hash-switchify" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>