Skip to content

Instantly share code, notes, and snippets.

View piotrmurach's full-sized avatar
:shipit:
Working on tty-markdown

Piotr Murach piotrmurach

:shipit:
Working on tty-markdown
View GitHub Profile
@vitobotta
vitobotta / resque-recovery.sh
Created May 24, 2012 18:53
Resque: automatically kill stuck workers and retry failed jobs
#!/bin/bash
# Also see: http://vitobotta.com/resque-automatically-kill-stuck-workers-retry-failed-jobs/
[[ -f /tmp/retry-failed-resque-jobs ]] && rm /tmp/retry-failed-resque-jobs
ps -eo pid,command |
grep [r]esque |
grep "Processing" |
while read PID COMMAND; do
$ bundle exec scripts/upload-dist.rb
opening connection to api.github.com...
opened
<- "POST /repos/concord-consortium/lab/downloads HTTP/1.1\r\nAuthorization: Basic c3RlcGhlbmViOm4wMGRsZQ==\r\nConnection: close\r\nHost: api.github.com\r\nContent-Length: 147\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n"
<- "{\"name\":\"lab-dist-2012-03-24-e5ce60c.tar.gz\",\"size\":9433478,\"description\":\"Latest release of Lab distribution\",\"content_type\":\"application/x-gzip\"}"
-> "HTTP/1.1 201 Created\r\n"
-> "Server: nginx/1.0.13\r\n"
-> "Date: Sun, 25 Mar 2012 18:19:18 GMT\r\n"
-> "Content-Type: application/json; charset=utf-8\r\n"
-> "Connection: close\r\n"
@ayumi
ayumi / stats.rb
Created March 23, 2012 05:20
Better rake:stats for Rails 3.x
# Originally from http://bit.ly/GIhZmg
# modified by @colour to reflect locations of assets in the asset pipeline
namespace :spec do
desc "Add files that DHH doesn't consider to be 'code' to stats"
task :statsetup do
require 'rails/code_statistics'
class CodeStatistics
alias calculate_statistics_orig calculate_statistics
@jch
jch / faraday_middlewares.rb
Created March 7, 2012 21:40
newrelic and caching middlewares for faraday
require 'new_relic'
require 'faraday'
require 'active_support'
class InstrumentationMiddleware < Faraday::Middleware
extend NewRelic::Agent::MethodTracer
def call(env)
uri = env[:url]
method = env[:method]
metrics = ["External/#{uri.host}/Faraday/#{method}", "External/#{uri.host}/all"]
anonymous
anonymous / hammer
Created March 1, 2012 07:16
hammer prototype
#!/usr/bin/env ruby
# -*- encoding: UTF-8 -*-
# Derived from <http://stackoverflow.com/questions/5663519/namespacing-thor-commands-in-a-standalone-ruby-executable>
require 'rubygems'
require 'thor'
require 'thor/group'
module Hammer
@sss
sss / executable-with-subcommands-using-thor.log
Created February 24, 2012 20:16
Revised: Namespacing thor commands in a standalone Ruby executable
$ ./executable-with-subcommands-using-thor.rb
Tasks:
executable-with-subcommands-using-thor.rb help [TASK] # Describe available tasks or one specific task
executable-with-subcommands-using-thor.rb subA [TASK] # Execute a task in namespace subA
executable-with-subcommands-using-thor.rb subB [TASK] # Execute a task in namespace subB
executable-with-subcommands-using-thor.rb test # test in CLI
$ ./executable-with-subcommands-using-thor.rb help
Tasks:
executable-with-subcommands-using-thor.rb help [TASK] # Describe available tasks or one specific task
@inkdeep
inkdeep / _pm_irbrc.rb
Created August 14, 2010 19:49
Useful method to print an objects methods in an irb/console session.
# pm - Print methods of objects in irb/console sessions.
# Goes in ~./irbrc
#
begin # Utility methods
def pm(obj, *options) # Print methods
methods = obj.methods
methods -= Object.methods unless options.include? :more
filter = options.select {|opt| opt.kind_of? Regexp}.first
methods = methods.select {|name| name =~ filter} if filter