September 26, 2007...5:24 pm

Refactor my Code

Jump to Comments

If there’s one thing that current blogs suck at it’s sharing code. Ok, some have plugins to highlight code in your post, but what about the comments? Blogging is all about having conversations! How many times have you seen on blogs the author asking to replace > and < with something else. Oh! and forget about indentation HTML eats those, WordPress replace " with some weird character, etc, etc and etc! (etc)

Wouldn’t it be great to have a site that cares about your code ? That threats it as a piece of art and at the same time, encourage people to make it better and more beautiful ?


RefactorMyCode.com logo

That’s why I created RefactorMyCode.com. You submit your code, people refactor it!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Behave like +link_to_remote+, but shows a spinner while the request is processing.
#   link_to_remote_with_spinner 'Hi', :url => hi_path
# You can specify the spinner and the container to hide
#   link_to_remote_with_spinner 'Hi', :url => hi_path, :container_id => 'container', :spinner => 'spinner'
def link_to_remote_with_spinner(title, options)
  element_id = options.delete(:id) || ('link_to_' + title.underscore.tr(' ', '_'))
  container_id = options.delete(:container_id) || element_id

  returning '' do |out|
    unless spinner = options.delete(:spinner)
      spinner = "#{element_id}_spinner"
      out << image_tag('spinner.gif', :id => spinner, :style => 'display:none')
    end
    options[:complete] = "$('#{spinner}').hide(); " + (options[:complete] || "$('#{container_id}').show()")

    out << link_to_remote(title, { :loading => "$('#{container_id}').hide(); $('#{spinner}').show()" }.merge(options),
                                 { :id => element_id })
  end
end

Small_logo

On RefactorMyCode, you’ll find:

  • Gorgeous syntax highlighting to show your code in all its glory!
  • Split your code in sections with more then 150 supported syntaxes.
  • Have the honour of being the best refactorer of the net.
  • Pastable version of your beautifully highlighted code to put on your blog.
  • Trackback support for sending comments back to your blog (hey! why not drive traffic to your blog at the same time ?)
  • Atom Feeds for everything you should care about.
  • Spam filtering on comments (by Defensio) so you know it stays clean
  • No account creation! Enter your OpenID and you’re done! How’s that? Plus you get an avatar if your email is registered on Gravatar. All that in one step!
  • And when you get to be one of the best refactorers out there, be sure to put your badge on your blog! (See mine on the side =>, Boooo! I’m 5th :( )

But apart from all those Web-2.0-AJAX-semantic-aggregated compliant features, good things happened since I started using it with Daniel, Gary, James and Hampton (!). I learned new tricks, refactored some poor and ugly code in my apps and shared what I knew at the same time. It’s the best learning tool ever, but mostly it’s the best place to brag about your skills and have fun while doing what we love: coding!

I have a dream! That someday, ugly code will be no more! I know we can do it. This is a call for action to kill all ugly code that pollute our lives! Spread the news and help bad code disappear forever!

Now on to some refactoring!

Update: Help spread the word, Digg RefactorMyCode, Reddit it and Hacker News it (what?) !

30 Comments


Leave a Reply