Skip to content

Instantly share code, notes, and snippets.

View danp's full-sized avatar

Dan Peterson danp

View GitHub Profile
@danp
danp / gist:8159995
Created December 28, 2013 14:22
gem install trouble with ruby 2.1.0 + rubygems 2.2.0
[#<URI::HTTPS:0x007fe39b4c8110 URL:https://api.rubygems.org/latest_specs.4.8.gz>, nil, false, 0]
GET https://api.rubygems.org/latest_specs.4.8.gz
302 Moved Temporarily
[#<URI::HTTPS:0x007fe39b4b2e00 URL:https://s3.amazonaws.com/production.s3.rubygems.org/latest_specs.4.8.gz>, nil, false, 1]
GET https://s3.amazonaws.com/production.s3.rubygems.org/latest_specs.4.8.gz
200 OK
[#<URI::HTTPS:0x007fe39bea81f8 URL:https://api.rubygems.org/quick/Marshal.4.8/rails-4.0.2.gemspec.rz>, nil, false, 0]
GET https://api.rubygems.org/quick/Marshal.4.8/rails-4.0.2.gemspec.rz
302 Moved Temporarily
[#<URI::HTTPS:0x007fe39ef61808 URL:https://s3.amazonaws.com/production.s3.rubygems.org/quick/Marshal.4.8/rails-4.0.2.gemspec.rz>, nil, false, 1]
@danp
danp / _running.txt
Last active December 20, 2015 04:39
Detect remote connection closing
% go run main.go
2013/07/24 13:47:30 accepted
2013/07/24 13:47:31 closing
2013/07/24 13:47:31 watcher read error EOF
2013/07/24 13:47:31 write error write tcp 127.0.0.1:5000: broken pipe
stop on (stopping <%= @name %> or <%= @name %>.stop TYPE=$TYPE)
respawn
respawn limit 10 5
kill timeout 20
<% if !@open_file_descriptor_limit.to_s.empty? %>
limit nofile <%= @open_file_descriptor_limit %> <%= @open_file_descriptor_limit %>
<% end %>
@danp
danp / x.md
Last active December 17, 2015 03:19
Using postgression with travis-ci

Using postgression with travis-ci

Using postgression with travis-ci is easy if all you need to do is set $DATABASE_URL. Relying on the fact that things in the env section of .travis.yml are evaluated by a shell, you simply need:

env:
- DATABASE_URL=$(curl http://api.postgression.com)

in your .travis.yml and $DATABASE_URL will be set properly for each build and available to all other parts of the build (before_script, script, etc).

@danp
danp / line_based_hexdump_c.rb
Created April 12, 2013 02:07
line-based `hexdump -C` like thing
puts $_.chars.map {|c| if !/\A[[:graph:]]\z/.match(c) then c = "" end; "%2s" % c }.join(" ")
puts $_.chars.map {|c| "%02x" % c.ord }.join(" ")
@danp
danp / _running.md
Last active December 16, 2015 01:39
debsign for darwin

at the build site:

$ debuild -i -us -uc -S # don't sign stuff

on your local machine:

# download debsign.sh
@danp
danp / memstats.rb
Last active December 14, 2015 22:49 — forked from kenn/memstats.rb
#!/usr/bin/env ruby
#------------------------------------------------------------------------------
# Aggregate Print useful information from /proc/[pid]/smaps
#
# pss - Roughly the amount of memory that is "really" being used by the pid
# swap - Amount of swap this process is currently using
#
# Reference:
# http://www.mjmwired.net/kernel/Documentation/filesystems/proc.txt#361
@danp
danp / gist:4133599
Created November 23, 2012 01:27
go-pq-test on heroku
% heroku create -b https://github.com/kr/heroku-buildpack-go.git
Creating boiling-island-3654... done, stack is cedar
BUILDPACK_URL=https://github.com/kr/heroku-buildpack-go.git
http://boiling-island-3654.herokuapp.com/ | git@heroku.com:boiling-island-3654.git
Git remote heroku added
% heroku addons:add heroku-postgresql:dev
Adding heroku-postgresql:dev on boiling-island-3654... done, v4 (free)
Attached as HEROKU_POSTGRESQL_YELLOW_URL
Database has been created and is available
! This database is empty. If upgrading, you can transfer
require "queue_classic"
module QC
module Later
TABLE_NAME = "queue_classic_later_jobs"
module Setup
extend self
@danp
danp / gist:1897546
Created February 24, 2012 04:13
bundler as virtualenv!
mkdir -p bin
bundle exec bash -c 'cat > bin/activate <<EOF
#!/bin/sh
export BUNDLE_BIN_PATH="$BUNDLE_BIN_PATH"
export PATH="$PATH"
export BUNDLE_GEMFILE="$BUNDLE_GEMFILE"
export RUBYOPT="$RUBYOPT"
EOF'
source bin/activate