Skip to content

Instantly share code, notes, and snippets.

@insom
insom / gist:0070d6dd9c3d18f3c8db
Created May 25, 2014
Add ASCII-art underlines to H2's
View gist:0070d6dd9c3d18f3c8db
// 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
View keybase.md

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 Jun 6, 2014
PyMongo BSON encodes the same object differently if C or Python version is used
View test.py
(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 Jul 17, 2014
Example UEC Build with QEMU image file support in Packer
@insom
insom / container.json
Created Jun 24, 2015
container.json for a vivid guest
View container.json
{
"version": "0.1",
"os": "linux",
"arch": "amd64",
"processes": [
{
"tty": false,
"user": "root",
"args": [
"/doit.sh"
@insom
insom / my.cnf
Created Jun 29, 2015
Very low memory MySQL
View my.cnf
[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 Aug 29, 2015
Decode a VirtualWire encoded thingy
View decode-wav.py
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 Dec 24, 2010
Create an ALSA midi output which changes pitch according to the position of a Griffin Powermate.
View powermate-to-midi.c
/*
* 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 Jan 19, 2011
Check if any process is running that we're not expecting.
View check_horsebolted
#!/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 Jun 13, 2011
Icinga CGI Defines
View icinga.h
#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
You can’t perform that action at this time.