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
%% use sync log so we can check if it caused a wrap event
%% and record the timestamp/num entries for the new wrapfile
%% (ie, collect metadata about each wrapfile.N, for faster seeking)
disk_log:blog(State#state.log, Line),
%% Fun used to write index marker, if we need to this insertion:
WriteIndexFun = fun(FileOffset) ->
Info = disk_log:info(State#state.log),
NoItems = proplists:get_value(no_items, Info),
CurrFile = proplists:get_value(current_file, Info),
%% Just stores an in #state{}
-module(leadertest).
-behaviour(gen_leader).
%% API
-export([start_link/1, start_link/2, get_num/0, set_num/1, info/0]).
%% gen_leader callbacks
-export([init/1,
import sys, os, pgq, skytools, json
class IRCLogger(pgq.Consumer):
def logIrcEvent(self, row):
"""log to disk"""
obj = json.loads(row['json'])
self.log.info("LOGGED EVENT JSON: %s", obj['msg'])
return True
def process_batch(self, src_db, batch_id, ev_list):
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:
%% 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:
-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,
@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,
@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 / 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 / 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,