Skip to content

Instantly share code, notes, and snippets.

@yob
yob / socket_stats_logger
Last active June 9, 2017 11:01 — forked from toolmantim/socket_stats_logger
sending unicorn socket data to statsd
#!/bin/env ruby
# Logs the number of queued and active connections on the unicorn socket to statsd.
# There's a cap on the number of queued connections. If we hit it then nginx will
# start serving 504 pages
#
# There is no visible output, but data is sent to statsd each second
#
# Props to Tim Lucas for the basic structure:
#
@yob
yob / gist:10012899
Last active August 29, 2015 13:58 — forked from schacon/gist:942899
Delete remote git branches that have been merged into origin/master
$ git branch -r --merged origin/master |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
cut -d "/" -f 2 |
xargs git push origin --delete
@yob
yob / gist:465239
Created July 6, 2010 10:41 — forked from pat/gist:465237
urls = Hash.new("jquery-1.4.2.min.js")
urls["production"] = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
ActionView::Helpers::AssetTagHelper.register_javascript_expansion(:jquery => urls[Rails.env])
irb(main):005:0> n = "James"
=> "James"
irb(main):006:0> n.strip!
=> nil
irb(main):007:0> n
=> "James"
# that's just plain weird
>> n = "john "
=> "john "
# assume we're passing the values from the file below as arguments to the following:
# WTF is name always nil?
# I'm not sure off the top of my head, but maybe just avoid regexp's all together?
# - jh
def filtered_filenames(paths)
paths ||= []
paths.collect { |path|
File.basename(path)