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
Snake / Nibbles clone in C and Ncurses
Please improve
List the files in a directory without the directory name or the extension
Convert simple Javascript to jQuery plugin
Active Record getting unique records
Simple Particle Engine for a shooter game
Breadth first cartesian product iterator
php refactoring
first BST
Pastable version of
Tag ordering code
<pre class='prettyprint' language='ruby'>class Item def raw_tag_list; "one, two, three, four, five"; end def public_tags; [<#Tag name=two>, <#Tag name=five>, <#Tag name=one>, <#Tag name=four>, <#Tag name=three>]; end def tags return Array.new if raw_tag_list.nil? # Get the raw tag list, split, squish (removed whitespace), and add each to raw_tag_array # Make sure we skip if the array already has that tag name (remove any duplicates that occur) raw_tag_array = Array.new raw_tag_list.split(',').each do |raw_tag| next if raw_tag_array.include?(raw_tag.squish) raw_tag_array << raw_tag.squish end tags = Array.new # grab all the tag objects tags_out_of_order = public_tags if tags_out_of_order.size > 0 # resort them to match raw_tag_list order raw_tag_array.each do |tag_name| tag = tags_out_of_order.select { |tag| tag.name == tag_name } tags << tag end # at this point, we have an array, with arrays of object [[tag], [tag], [tag]] # use compact to remove any nil objects, and flatten to convert it to [tag, tag, tag] tags = tags.compact.flatten end tags end end</pre> <a href="http://www.refactormycode.com/codes/807-tag-ordering-code" 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>