Skip to content

Instantly share code, notes, and snippets.

@rcrowley
rcrowley / LICENSE
Last active October 31, 2017 17:21
Comparing the GPL v3 to the AGPL v3
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
@rcrowley
rcrowley / multio.rb
Created July 28, 2010 06:15
Ruby IO multiplexer
# MultIO Ruby IO multiplexer
# http://rcrowley.org/2010/07/27/multio-ruby-io-multiplexer.html
require 'stringio'
class MultIO < Array
def <<(io)
if io.respond_to?(:to_str)
io = StringIO.new(io)
#!/bin/sh
sysctl -w kern.maxproc=2048
sysctl -w kern.maxprocperuid=1024
echo kern.maxproc=2048 >>/etc/sysctl.conf
echo kern.maxprocperuid=1024 >>/etc/sysctl.conf
echo limit maxproc 1024 2048 >>/etc/launchd.conf
@rcrowley
rcrowley / gist:724970de828cb445e14e958efa5ac2f0
Created March 31, 2016 18:51
This is very important if you write shell programs
█ $ cat false-trap-true.sh
set -e -x
trap false EXIT
true
█ $ cat true-trap-false.sh
set -e -x
trap true EXIT
false
█ $ sh false-trap-true.sh; echo $?
+ trap false EXIT
[cache]
CACHE_QUERY_INTERFACE = <%= private_ipaddress || ipaddress %>
CACHE_QUERY_PORT = 7002
LINE_RECEIVER_INTERFACE = <%= private_ipaddress || ipaddress %>
LINE_RECEIVER_PORT = 2013
PICKLE_RECEIVER_INTERFACE = <%= private_ipaddress || ipaddress %>
PICKLE_RECEIVER_PORT = 2014
CONF_DIR = /etc/graphite/
@rcrowley
rcrowley / st.diff
Created November 14, 2013 22:52
Support X-Delete-After headers and fix segmented uploads in Rackspace's Swift Tool, st.
--- st.orig 2013-11-14 21:59:32.014428532 +0000 +++ st 2013-11-14 22:45:48.542834157 +0000
@@ -1455,6 +1455,8 @@
dest='leave_segments', default=False, help='Indicates that you want '
'the older segments of manifest objects left alone (in the case of '
'overwrites)')
+ parser.add_option('', '--ttl', dest='ttl', help='Set a time-to-live for '
+ 'the object via the X-Delete-After header.')
(options, args) = parse_args(parser, args)
args = args[1:]
if len(args) < 2:
@rcrowley
rcrowley / gist:6888979
Last active December 25, 2015 00:39
The things you have to do to process stdin line-by-line in Node.js and it still blows up this process' memory over blocking whatever's connected to stdin.
var readline = require('readline')
var ch = []
, closed = false
, rl = readline.createInterface({
input: process.stdin
, output: process.stdout
, terminal: false
})
@rcrowley
rcrowley / statebird.sh
Created July 18, 2013 15:04
How to get a reservation at State Bird Provisions
set -e
mail() {
echo "$@" |
/usr/bin/mail -a"From: Richard Crowley <r@rcrowley.org>" -s"State Bird Provisions" "1234567890@vtext.com"
echo "$(date): there was a reservation!" >&2
}
TMP="$(mktemp)"
trap "mail \"FAILURE\"; rm -f \"$TMP\"" EXIT INT QUIT TERM
@rcrowley
rcrowley / gist:6005614
Created July 16, 2013 03:50
Sausage balls

Sausage balls

Get your hands dirty, mixing the following in a big bowl:

  • 4 pounds sausage
  • 4 eggs, slightly beaten
  • 1 1/2 cups bread crumbs

Make 1-inch or a bit smaller balls from the sausage and brown them on all sides in a frying pan. With that done, combine the following in a slow cooker for the sauce:

@rcrowley
rcrowley / ssh.sh
Created May 23, 2013 20:53
VirtualBox-aware ssh(1)
#!/bin/sh
set -e
#/ Usage: ssh [...] [<username>@]<hostname>|<vmname> [...]
: ${BASE:="$HOME/VirtualBox VMs"}
usage() {
grep "^#/" "$0" | cut -c"4-" >&2