Skip to content

Instantly share code, notes, and snippets.

View RJ's full-sized avatar
🥱
parenting toddlers

Richard Jones RJ

🥱
parenting toddlers
View GitHub Profile

Keybase proof

I hereby claim:

  • I am RJ on github.
  • I am RJ (https://keybase.io/RJ) on keybase.
  • I have the public key with fingerprint 0EDD ED5C 68CB 98A2 222D  F327 1CB6 5397 9D96 56FD

To claim this, I am signing this object:

@RJ
RJ / 6pinger.py
Created November 19, 2013 18:10
Send an empty icmp6 echo packet from python, having bound to a specific source ipv6 address
#!/usr/bin/env python
import socket
import sys
## ipv6.google.com:
PING_TARGET = '2604:8300:100:200b:6667:3:0:4d1f'
source_ip = sys.argv[1]
addresses = [addr for addr in socket.getaddrinfo(source_ip, None) if socket.AF_INET6 == addr[0]]
src_address = addresses[0][-1][0]
@RJ
RJ / Makefile-erlang.mk
Last active November 2, 2019 07:29
Makefile fragment that generates makefile targets to call make with a given target on all apps/* subdirs. Useful for erlang projects using erlang.mk that have apps/{app1,app2,app3..} structure (which rebar doesn't mind). Eg: call "make app" and it will call "make -C apps/app1 app; make -C apps/app2 app; ..." for you.
APPDIRS := $(wildcard apps/*)
## Example hack to filter one out:
## APPDIRS := $(filter-out apps/fooapp, $(APPDIRS))
define PROXY_TARGET
$(1):
$(foreach appdir,$(APPDIRS),$(MAKE) -C $(appdir) $(1) ;)
endef
@RJ
RJ / haproxy.cfg
Created August 21, 2013 13:30
haproxy websockets config snippet
## GENERATED BY CHEF, DONT EDIT DIRECTLY
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 10000
user haproxy
daemon
defaults
log global
@RJ
RJ / .slate
Created January 8, 2013 10:36
bit of my .slate config file
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
# Shows app icons and background apps, spreads icons in the same place.
config windowHintsShowIcons true
config windowHintsIgnoreHiddenWindows false
config windowHintsSpread true
config windowHintsBackgroundColor 50;53;58;0.6
@RJ
RJ / apache2-proxy-graphite.conf
Created December 21, 2012 01:23
Apache2 conf snippit to proxy and rewrite URLs for graphite. https://graphite-admin.example.com ---> https://admin.example.com/graphite Used on a dashboard page that includes graphs from various other domains, and it was annoying typing basic-auth passwords all the time.
SSLProxyEngine on
# Graphite URLs that are buried in JS that we can't easily rewrite, we issue an http redirect
# - /content/js/ext/resources/images/default/s.gif
# - /render
RewriteEngine On
RewriteCond %{HTTP_HOST} ^admin\.example\.com [NC]
RewriteRule ^/content/js/ext/resources/images/default/s.gif https://graphite-admin.example.com/content/js/ext/resources/images/default/s.gif [L,R]
RewriteRule ^/render https://graphite-admin.example.com/render [L,R]
@RJ
RJ / rabbit_boot_system.erl
Created November 8, 2012 22:38
RabbitMQ boot_step system
%% Boot system extracted from rabbitmq-server source code
%% The RabbitMQ license banner follows:
%%
%% The contents of this file are subject to the Mozilla Public License
%% Version 1.1 (the "License"); you may not use this file except in
%% compliance with the License. You may obtain a copy of the License
%% at http://www.mozilla.org/MPL/
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
@RJ
RJ / max_fs_limit_osx
Created September 21, 2012 14:18
can't open more than 1024 tcp ports on osx / erlang
$ uname -a
Darwin RJ3000.local 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64
$ launchctl limit
cpu unlimited unlimited
filesize unlimited unlimited
data unlimited unlimited
stack 8388608 67104768
core 0 unlimited
rss unlimited unlimited
@RJ
RJ / slowproxy.js
Created June 8, 2012 16:51
Add lag in both directions to tcp connection
// Generic TCP proxy that adds delay on packets in both directions
var net = require('net'),
repl = require('repl'),
sys = require('sys');
var listenPort = 19999,
@RJ
RJ / shitplans.txt
Created May 4, 2012 09:35
Postgresql (9.1) partitions query plans with constraint exclusion
*** CLICK "RAW" LINK ABOVE TO GET IT LINE WRAPPED ETC ***
\d+ ircevents
Column | Type | Modifiers
-----------+---------+------------------------
buffer | integer | not null
id | bigint | not null <---------------- unixtime in microsecs (since epoch*1,000,000)
type | text | not null