Skip to content

Instantly share code, notes, and snippets.

@amichaelgrant
amichaelgrant / gist:71989b9fb7479a6beda7
Created January 29, 2016 20:57
Keepalive startup script for ubuntu
#! /bin/sh
#
# keepalived LVS cluster monitor daemon.
#
# Written by Andres Salomon <[email protected]>
#
### BEGIN INIT INFO
# Provides: keepalived
# Required-Start: $syslog $network $remote_fs
# Required-Stop: $syslog $network $remote_fs
@amichaelgrant
amichaelgrant / supervisord-example.conf
Created January 30, 2016 01:54 — forked from didip/supervisord-example.conf
Example configuration file for supervisord.conf
[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file
[supervisord]
logfile=/var/log/supervisord/supervisord.log ; supervisord log file
logfile_maxbytes=50MB ; maximum size of logfile before rotation
logfile_backups=10 ; number of backed up logfiles
loglevel=error ; info, debug, warn, trace
pidfile=/var/run/supervisord.pid ; pidfile location
nodaemon=false ; run supervisord as a daemon
@amichaelgrant
amichaelgrant / s3.sh
Created February 1, 2016 16:57 — forked from chrismdp/s3.sh
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@amichaelgrant
amichaelgrant / gist:44c8faa2e46055c10aaa
Created March 14, 2016 22:56
Running Lua Script in Redis from Nodejs Client
-- setnex.lua
local key = ARGV[1]
local expiry = ARGV[2]
local value = ARGV[3]
local reply = redis.call("SETNX", key, value)
if 1 == reply then
redis.call("EXPIRE", key, expiry)
end
return reply
You can call it from node_redis like this:
#!/usr/bin/env node
// ./generatelookup -l lookupkey -p somekey* -a attribute
var redis = require('redis').createClient();
var async = require('async');
var opt = require('optimist');
opt.usage('$0 -l lookup -p pattern -a attribute');
opt.demand(['l', 'p', 'a']);
var argv = opt.argv;
var iter = '0';
@amichaelgrant
amichaelgrant / dispatcher.list
Created July 29, 2016 23:05 — forked from krakatoa/dispatcher.list
Simple Kamailio round-robin configuration
# line format
# id(int,auto) setid(int) destination(string) flags(int) priority(int) attrs(string) description(string)
1 sip:10.0.0.9:5060
1 sip:10.0.0.10:5060
sudo apt-get install git-core build-essential autoconf automake libtool libncurses5 libncurses5-dev make libjpeg-dev pkg-config unixodbc unixodbc-dev zlib1g-dev libcurl4-openssl-dev libexpat1-dev libssl-dev libtiff4-dev libx11-dev unixodbc-dev python2.7-dev zlib1g-dev libzrtpcpp-dev libasound2-dev libogg-dev libvorbis-dev libperl-dev libgdbm-dev libdb-dev python-dev uuid-dev bison autoconf g++ libncurses-dev
https://kernelnewbies.org/OutreachyfirstpatchSetup?action=show&redirect=OPWfirstpatchSetup
> console.log(new Buffer("Hello World").toString('base64'));
SGVsbG8gV29ybGQ=
> console.log(new Buffer("SGVsbG8gV29ybGQ=", 'base64').toString('ascii'))
Hello World
@amichaelgrant
amichaelgrant / performance.txt
Created April 21, 2017 20:13 — forked from dstroot/performance.txt
Performance Tuning your TCP Stack
#!/bin/bash
echo "*****************************************"
echo " Based on information from Google"
echo " http://dev.chromium.org/spdy/spdy-best-practices"
echo "*****************************************"
sudo su
yum –y update
echo "*****************************************"
echo " Changing initcwnd and initrwnd"
echo " Step 1: check route settings."