Skip to content

Instantly share code, notes, and snippets.

@insom
insom / gist:0070d6dd9c3d18f3c8db
Created May 25, 2014 22:13
Add ASCII-art underlines to H2's
// Happy "I can copy and paste and write enough JavaScript to get the thing that I wanted to do done" Day
// - Aaron
String.prototype.repeat = function(times) {
return (new Array(times + 1)).join(this);
}; // from http://stackoverflow.com/questions/4549894/how-can-i-repeat-strings-in-javascript
function insertAfter(referenceNode, newNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}; // from http://stackoverflow.com/questions/4793604/how-to-do-insert-after-in-javascript-without-using-a-library

Keybase proof

I hereby claim:

  • I am insom on github.
  • I am insom (https://keybase.io/insom) on keybase.
  • I have a public key whose fingerprint is 30D9 81E4 DEB1 FF5D 8CAA D832 8CCE 2412 3B8F 78F8

To claim this, I am signing this object:

@insom
insom / test.py
Created June 6, 2014 14:14
PyMongo BSON encodes the same object differently if C or Python version is used
(cextensionvenv)% python test.py
{u'foo': [u'bar'], u'bacon': [u'cheeseburger']}
(pythonvenv)% python test.py
{u'foo': u'bar', u'bacon': u'cheeseburger'}
@insom
insom / httpdir_latest_meta-data_index.html
Created July 17, 2014 14:12
Example UEC Build with QEMU image file support in Packer
instance-id
@insom
insom / container.json
Created June 24, 2015 08:54
container.json for a vivid guest
{
"version": "0.1",
"os": "linux",
"arch": "amd64",
"processes": [
{
"tty": false,
"user": "root",
"args": [
"/doit.sh"
@insom
insom / my.cnf
Created June 29, 2015 08:23
Very low memory MySQL
[mysqld]
skip-innodb
default-storage-engine=myisam
default-tmp-storage-engine=myisam
query_cache_size=0
max_connections=10
key_buffer_size=8
thread_cache_size=0
host_cache_size=0
thread_stack=131072
@insom
insom / decode-wav.py
Last active August 29, 2015 14:26
Decode a VirtualWire encoded thingy
import wave, struct, sys
sixtofour = [ 0xd, 0xe, 0x13, 0x15, 0x16, 0x19, 0x1a, 0x1c, 0x23, 0x25, 0x26, 0x29, 0x2a, 0x2c, 0x32, 0x34 ]
data = []
states = ['START', 'PREAMBLE', 'GOTMAGIC', 'GOTLENGTH']
state = states[0]
bits = []
lengthbits = []
radiodata = []
@insom
insom / powermate-to-midi.c
Created December 24, 2010 23:17
Create an ALSA midi output which changes pitch according to the position of a Griffin Powermate.
/*
* Create an ALSA midi output which changes pitch according to the position
* of a Griffin Powermate.
*
* Copyright 2007 - Aaron Brady <bradya@gmail.com>
*/
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
@insom
insom / check_horsebolted
Created January 19, 2011 14:33
Check if any process is running that we're not expecting.
#!/usr/bin/python
from glob import glob
import re, sys
okay_re = [re.compile(x) for x in [ r'proftpd', r'apache2', r'upload.py', r'getty', r'munin-node', r'inetd', r'init', r'check_horsebolted', r'upstart.udev', r'portmap', r'irqbalance', r'puppet', r'nrpe', r'udevd', r'sshd', r'atd', r'mdadm', r'rsync', r'fail2ban', r'exim4', r'rsyslogd', r'cron', r'ntpd', r'mcollective', r'mysqld', r'bash', r'sleep', r'sync.php', r'queue.php', r'CRON', ]]
res = ([z for z in [open(x,'r').read() for x in glob('/proc/*/cmdline')] if not [y for y in okay_re if y.search(z)] and z])
print res
@insom
insom / icinga.h
Created June 13, 2011 16:27
Icinga CGI Defines
#define HOST_SCHEDULED_DOWNTIME 1
#define HOST_NO_SCHEDULED_DOWNTIME 2
#define HOST_STATE_ACKNOWLEDGED 4
#define HOST_STATE_UNACKNOWLEDGED 8
#define HOST_CHECKS_DISABLED 16
#define HOST_CHECKS_ENABLED 32
#define HOST_EVENT_HANDLER_DISABLED 64
#define HOST_EVENT_HANDLER_ENABLED 128
#define HOST_FLAP_DETECTION_DISABLED 256
#define HOST_FLAP_DETECTION_ENABLED 512