Want to create a Gist from your editor, the command line, or the Services menu? Here's how.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # How to hook into Resque's `enqueue` method from a plugin. | |
| module EnqueuePlugin | |
| # Only enqueues subclasses of GitHub::Job | |
| def enqueue(klass, *args) | |
| looks_okay?(klass) ? super : false | |
| end | |
| def looks_okay?(klass) | |
| klass < GitHub::Job |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # List what ports are in use on OS X | |
| sudo lsof -iTCP -sTCP:LISTEN -P |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| ## Usage: memrate.rb [-l <lib>] [-i <num>] [-t <threshold>] [-k <size>] [<host>] | |
| ## Measure memcached server read time. | |
| ## | |
| ## Options | |
| ## -l, --library=<lib> Memcached client library to use. memcache-client by | |
| ## default. memcached also supported. | |
| ## -i, --iterations=<num> Number of times to read the value. If not set, read | |
| ## until interrupted. | |
| ## -t, --threshold=<time> Report iterations that take longer than <time> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Resque.after_fork do |job| | |
| # How many jobs should we process in each fork? | |
| jobs_per_fork = [ ENV['JOBS_PER_FORK'].to_i, 1 ].max | |
| # Set hook to nil to prevent running this hook over | |
| # and over while processing more jobs in this fork. | |
| Resque.after_fork = nil | |
| # Make sure we process jobs in the right order. | |
| job.worker.process(job) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| The Beatles were: | |
| {{#names}} | |
| * {{to_s}} | |
| {{/names}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <title>{{title}}</title> | |
| </html> |
Previously you'd do this:
set :namespace, Haystack
set :views, 'templates/'
set :mustaches, views/'
Now you do this:
set :mustache, {
:namespace => Haystack,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ rip-dependency-tree test/fixtures/complex.rip | |
| test/fixtures/complex.rip | |
| |-- git://github.com/ezmobius/redis-rb.git | |
| |-- git://github.com/brianmario/yajl-ruby.git (0.6.3) | |
| |-- sinatra (0.9.4) | |
| | |-- rack (1.0) | |
| | | `-- url_escape | |
| | | |-- cgi_escape | |
| | | `-- url_parser (0.4.3) | |
| | `-- haml (1.0.0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # Usage: rcat [file ...] | |
| # | |
| # Reads files sequentially, writing them to the standard output. The | |
| # file operands are processed in command-line order. If file is a | |
| # single dash (`-') or absent, rcat reads from the standard input. | |
| # | |
| # Like cat(1), but dumber. | |
| puts ARGF.read |