This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| #!/usr/bin/env ruby | |
| # Input: Selected Text or Nothing | |
| # Output: Replace Selected Text | |
| require 'tempfile' | |
| def unindent(text) | |
| lines = text.split(/\n/) | |
| level = lines.map{|l| l[/^\s*/].size}.min |
| // suggested shell cmd line to run this: | |
| // | |
| // mongo --shell example2.js | |
| // | |
| // Note: the { out : … } parameter is for mongodb 1.8+ | |
| db.things.insert( { _id : 1, tags : ['dog', 'cat'] } ); | |
| db.things.insert( { _id : 2, tags : ['cat'] } ); | |
| db.things.insert( { _id : 3, tags : ['mouse', 'cat', 'dog'] } ); | |
| db.things.insert( { _id : 4, tags : [] } ); |
| <!-- Add the following lines to theme's html code right before </head> --> | |
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script> | |
| <script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script> | |
| <script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script> | |
| <!-- | |
| Usage: just add <div class="gist">[gist URL]</div> | |
| Example: <div class="gist">https://gist.github.com/1395926</div> | |
| --> |
| .gist-highlight { | |
| border-left: 3ex solid #eee; | |
| position: relative; | |
| } | |
| .gist-highlight pre { | |
| counter-reset: linenumbers; | |
| } | |
| .gist-highlight pre div:before { |
| $(document).ready(function() { | |
| var prefix = "https://gist.github.com/"; | |
| $('a[href^="' + prefix + '"]').each(function(i) { | |
| var $anchor = $(this), | |
| $el = $("<p></p>"); | |
| $anchor.replaceWith($el); | |
| writeCapture.html($el, '<script src="'+$anchor.text()+'.js"></scr' + 'ipt>'); | |
| $anchor.remove(); | |
| }); | |
| }); |
| #!/usr/bin/ruby | |
| =begin | |
| Usage: rtftomarkdown.rb FILENAME.rtf | |
| Uses textutil, available on Mac only (installed by default) | |
| Outputs to STDOUT | |
| Notes: | |
| Links are replaced with Markdown references (duplicate links combined). |
Solving an algorithm for a friend to be able to tell his emacs what window he wants to replace his current window when he closes it.