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 / 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 / postgres_queries_and_commands.sql
Created November 22, 2016 14:54 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'