Skip to content

Instantly share code, notes, and snippets.

View RJ's full-sized avatar
💤

Richard Jones RJ

💤
View GitHub Profile
@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
@RJ
RJ / fake-erlang.sh
Last active April 5, 2018 13:13
Use ESL erlang deb, provide fake erlang-nox package so deps behave
#!/bin/bash
# Install fake erlang packages, then the ESL package
# Afterwards, installing packages that depend on erlang, like rabbitmq,
# will use the ESL packaged erlang without installing the older disto ones
#
apt-get install equivs
# Create fake erlang packages, since we are using esl-erlang instead
cd /tmp
apt-get install -y equivs
@RJ
RJ / github-postcommit.php
Created March 15, 2012 10:37
Crusty old php 3 or 4 from back in the day
<?php
// test str/*{{{*/:
$str = <<<EOF
{
"before": "5aef35982fb2d34e9d9d4502f6ede1072793222d",
"repository": {
"url": "http://github.com/defunkt/github",
"name": "github",
"description": "You're lookin' at it.",
"watchers": 5,
-module(sc).
-define(DEBUG(S,A), io:format(S++"\n",A)).
-behaviour(gen_server).
%% API
-export([start_link/0, start/0]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
%% Start a connection to the server
{ok, Connection} = amqp_connection:start(#amqp_params_network{}),
%% Once you have a connection to the server, you can start an AMQP channel
{ok, Channel} = amqp_connection:open_channel(Connection),
%% Now that you have access to a connection with the server, you can declare a queue and bind it to an exchange
%% Routing topology:
%%
%% All msgs go to irc_x (fanout exchange)
%% exchange-to-exchange bindings spread msgs to these exchanges:
net.ipv4.conf.all.rp_filter=1
net.ipv4.icmp_echo_ignore_broadcasts=1
kernel.shmmax = 1500000000
net.ipv4.ip_local_port_range = 1024 65535
vm.overcommit_memory = 1
fs.file-max = 1000000
# General gigabit tuning: