Skip to content

Instantly share code, notes, and snippets.

View relistan's full-sized avatar

Karl Matthias relistan

View GitHub Profile
@relistan
relistan / compress_requests.rb
Last active April 18, 2023 23:54 — forked from subdigital/compress_requests.rb
Rack Middleware to automatically unzip gzipped/deflated POST data
class CompressedRequests
def initialize(app)
@app = app
end
def method_handled?(env)
!!(env['REQUEST_METHOD'] =~ /(POST|PUT)/)
end
def encoding_handled?(env)
@relistan
relistan / ssh-config
Created March 22, 2012 16:36
proxy ssh through a jump host without breaking all other ssh connections
Host *
ForwardAgent yes
ProxyCommand ~/bin/ssh-proxy.sh %h %p username@jump-host
ServerAliveInterval 10
ServerAliveCountMax 600
@relistan
relistan / git_commands.md
Created March 31, 2012 11:45
Deployment with Git detection of pending migrations

Helpful Git Commands

These are some useful git commands for implementing this in your own deployment setup.

Detecting if we're running on a clean checkout:

  • git fetch
  • git diff --shortstat [branch]

Determining if there are pending migrations:

@relistan
relistan / ssh_config
Created July 7, 2012 09:45
Keep SSH Alive Even on Virgin Media
Host *
ServerAliveInterval 10
ServerAliveCountMax 600
@relistan
relistan / captureio.coffee
Created December 1, 2012 16:59 — forked from pguillory/gist:729616
Hooking into Node.js stdout
class CaptureIO
# Coffeescript port of: https://gist.github.com/729616
#
# Usage:
# test = new CaptureIO()
# unhook = test.hookStdout((string, encoding, fd) ->
# util.debug('stdout: ' + util.inspect(string))
# )
# Restoring stdout:
@relistan
relistan / dnsd.rb
Last active December 9, 2015 23:39 — forked from peterc/dnsd.rb
A Ruby 1.8.7 (for MagLev) port of Peter Cooper's DNS server example.
# Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# By Peter Cooper
# Ruby 1.8.7/MagLev version by Karl Matthias
#
# MIT license
#
# * Not advised to use in your production environment! ;-)
# * Supports A and CNAME records
# * See http://www.ietf.org/rfc/rfc1035.txt for protocol guidance
# * All records get the same TTL
@relistan
relistan / histo.rb
Last active December 14, 2015 04:29
Draw a histogram from a CSV on the command line
#!/usr/bin/env ruby
COLUMNS_TO_USE = 40.0
histo = []
0.upto(9) { |i| histo[i] = 0 }
field_to_parse = ARGV.shift.to_i
ARGF.each do |line|
fields = line.split(/,/)
@relistan
relistan / mydrive.rb
Created September 3, 2013 19:31
RTanque bot for SRUG code night
class Mydrive < RTanque::Bot::Brain
NAME = 'mydrive'
include RTanque::Bot::BrainHelper
CORNERS = [:NW, :NE, :SE, :SW]
TURRET_FIRE_RANGE = RTanque::Heading::ONE_DEGREE * 1.0
def tick!
self.hide_in_corners
if (target = self.acquire_target)
@relistan
relistan / memtest
Created November 7, 2013 23:21
Machine burn-in script
#!/bin/bash
#
# memtest
#
# A general purpose memory tester script, with options for enabling extra
# simultaneous tests in an attempt to test the capacity of the power supply
# in the machine. You can find the original source of this script and
# additional documentation on its usage by visiting my work web page at
# http://people.redhat.com/~dledford/
#
@relistan
relistan / upstart_completion.sh
Created November 14, 2013 17:31
Upstart bash auto-completion that works on RHEL/CentOS with older versions of Upstart.
# bash-completion for the upstart event-based init replacement
# (http://upstart.ubuntu.com / https://launchpad.net/upstart)
#
# We don't provide completion for 'init' itself for obvious reasons.
# Original is from: https://bugs.launchpad.net/ubuntu/+source/upstart/+bug/672067/+attachment/1765103/+files/upstart.sh
_upstart_conf_events()
{
initctl list|awk '{print $1}'