Refactor my Code

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

Filed under rails, refactormycode, ruby, web 2.0

30 responses to “Refactor my Code

  1. Hey, that’s sounds pretty cool to me! Kudos for that great realisation

  2. Hey, Thanks Frank

    I hope you find this usefull and fun as much as I do!

  3. Wow, great idea.

    I think it would be cool to analyze submissions with a tool like saikuro for the cyclomatic and token complexity. It would give you some metrics on improvements in your refactoring.

    Can’t wait to try it out!

  4. Hey Ben,
    Thx for the good words!

    Saikuro looks great! But it’s only for Ruby code! I’ll look into it, I like the idea!

    Looking forward to see some of your code on refactormycode.com!

  5. It finally launched!! I’m so excited.

    Playing with this tool has been so much fun. I can’t wait to see some adoption.

    And, right now, I’m the #1 Refactorer!

  6. Nice. Very very nice! and cool and sexy!

    So, where’s the Textmate bundle?😉

  7. Actually, if I have time this weekend, I might try to start a simple bundle.

    Two small details:
    1. What’s the difference between comments and refactorings? (ok, I understand now. the first time I tested it, it was for a code sample with no refactorings, so both links took me to the same spot.)

    2. You should change the name on the input for openId to openid_url. I think it’s the standard so most people will have autocomplete on their browser. Yes, I’m lazy.

  8. Thx James for your feedback and ideas while “beta testing” it! The blog badge with the ranking was your idea and a great one, hope you like it!

    JF, glad you like it! Actually it uses TextMate bundles for highlighting the code, so it’s in there😉

    Thx for the great comments and don’t forget to get your blog badge y’all🙂

  9. JF: I changed the Comment link to ‘Refactor it!’ to remove confusion and changed OpenId input name to ‘openid_url’ like all the other sites (pushing the changes now).

    Thanks a lot for pointing this out!

    What will your TM bundle do ?

  10. A command to send the selected code to rfm.
    And when I’m writing a blog post, a command to get the formatted code back in my post. Something like that.

    That should be a good start for a textmate bundle.

  11. I might need to support more formats in the API. Right now it’s just plain HTML.

    Let me know what you need to do and I’ll make it happen.

    Perhaps plain/text format should be perfect, something like

    POST http://…/codes – to create the code
    GET http://…/codes/1.txt;pastable – to get the pastable version

  12. Mat

    Nice project MAC!🙂 Congrats…

  13. Darius Damalakas

    silly question, but where to get open id account?😀

    does gmail account fit?

  14. Cool🙂
    But I’ve take a look here… http://refactormycode.com/help/code
    no c#😦
    no boo :(((
    no NVelocity/Brail :(((((

    How about extending support for those languages?

  15. Alain Pilon

    Super!

    Mais ca prend des onglets pour chaque langage, histoire d’eviter la polution visuelle!

  16. Thanks Mat🙂

    Darius, you can get one at http://myopenid.com or you can use your WordPress.com blog url if you got one.

    Diego, yeah Im really sorry that there’s no support for these at this time! The plugin I use does not support those languages. I’ll see what I can do! I use this to do it: http://ultraviolet.rubyforge.org/

    Alain, je suis pas sur de comprendre comment ajouter des onglets enleverait la polution et quel polution au juste, pcq tu veux pas voir les autres languages ? Je vais y reflechir. Merci du feeback

    Thx all for the comments! Hope to see your code in there soon!

  17. Very cool. Love the idea & concept.

  18. thx a lot Austin!

    Thank you all for the feedback, really appreciated. This means a lot to me!

    And I hope this will help lots of ugly code disapear FOREVER EVER EVER EVER AND EVER!!!!

  19. Hi Marc-Andre,

    I love the idea! I wish I had something like this earlier, that would have help me to share code instead of hitting my head on the walls.

    Congrats!

  20. Hi Fred!

    I hope it’s not too late, can you still share some code ;P

    Thanks for the props and don’t forget to get your blog badge all !

  21. Pingback: blognation Canada » Blog Archive » RefactorMyCode Crowdsources Tweaking and Cleaning Your Code

  22. Ok marc-andrè, maybe all .net developers out there we could send a request to http://ultraviolet.rubyforge.org/, or still continue to use C sintax… in any case this service is wonderful😉

  23. d

    wanted to join, but where the hell do i get an openid ???

  24. Darius Damalakas

    Thanks for adding C# !

    Would be good if you add Boo too. http://boo.codehaus.org/
    I believe many use that too, either for scripting or coding (me including).

  25. kalve

    Just so bad all the links from the frontpage gives me a 404 now.. I’m looking forward to playing with RmC when it’s working again.🙂

  26. Hi kalve!

    Yeah I’m sorry for that, all the site is down! I putted a static HTML file on the front page for now, that’s all I can do on my poor Dreamhost account now…

    Glad you like it! Thanks for droping by🙂

  27. ruby

    haha at ruby on rails failing

    what a retarded framework

  28. You’re right, let’s all code our own framework in Haskell!!! OMG^^!!

  29. Pingback: RefactorMyCode Crowdsources Tweaking and Cleaning Your Code | A View from the Isle

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s