Skip to content

Instantly share code, notes, and snippets.

Aaron Brady insom

Block or report user

Report or block insom

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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'}
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 / 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
@insom
insom / gist:8008090
Created Dec 17, 2013
How old are inetd's children? #badpython
View gist:8008090
import os
import stat
from os.path import dirname
from glob import glob
import time
for cmdline in glob('/proc/*/cmdline'):
f = open(cmdline).read()
if f.startswith('/usr/sbin/inetd'):
inetd_pid = int(cmdline.split('/')[2])
@insom
insom / get-blog-post-as-markdown.py
Created Nov 29, 2013
Get a post from a WP blog and render as an ASCII Markdown file
View get-blog-post-as-markdown.py
import sys, urllib
from pyquery import PyQuery as pq
from html2text import html2text
from unidecode import unidecode
d = pq(urllib.urlopen(sys.argv[1]).read())
print unidecode(html2text(d(".entry-content").html()))
@insom
insom / insom.zsh-theme
Created Oct 16, 2013
My oh-my-zsh theme.
View insom.zsh-theme
function box_name {
[ -f ~/.box-name ] && cat ~/.box-name || hostname -s
}
local current_dir='${PWD/#$HOME/~}'
local git_info='$(git_prompt_info)'
function virtualenv_info_2 {
[ $VIRTUAL_ENV ] && (
echo "%{$terminfo[bold]$fg[red]%}v:%{$fg[yellow]%}`basename $VIRTUAL_ENV`%{$reset_color%}"
@insom
insom / trc.py
Created Oct 4, 2013
Manually control a Python Turtle with the keyboard.
View trc.py
#!/usr/bin/env python
# Adapted from David Llewellyn-Jones's code
# http://www.flypig.co.uk/?page=list&list_id=363&list=blog
# By Aaron Brady
# http://insom.me.uk/
import turtle as t
import sys
import tty
@insom
insom / parse-cg.py
Last active Dec 24, 2015
Parse a PHP-format callgrind file and produce a summary of what time was spent in what files.
View parse-cg.py
import re
import sys
states = ('DEFAULT', 'HAVE_FILE')
fl = re.compile('^fl=(.*)')
num = re.compile('^\d+ (\d+)')
state = 0
current_file = ''
inclusive = False
View fix-magento-vulnerability.diff
diff -ru magento-17/app/code/core/Mage/Core/Helper/Cookie.php magento-patched/app/code/core/Mage/Core/Helper/Cookie.php
--- magento-17/app/code/core/Mage/Core/Helper/Cookie.php 2012-07-05 11:49:29.000000000 +0100
+++ magento-patched/app/code/core/Mage/Core/Helper/Cookie.php 2013-09-26 10:52:24.701527319 +0100
@@ -69,7 +69,7 @@
{
$acceptedSaveCookiesWebsites = $this->_getAcceptedSaveCookiesWebsites();
$acceptedSaveCookiesWebsites[Mage::app()->getWebsite()->getId()] = 1;
- return serialize($acceptedSaveCookiesWebsites);
+ return json_encode($acceptedSaveCookiesWebsites);
}
@insom
insom / git-annex-ftp.py
Created Sep 24, 2013
Git Annex FTP backend, particularly for iWeb FTP (create a space called "Annex" and include your username and password in the source to use, for now).
View git-annex-ftp.py
#!/usr/bin/python
# git config annex.ftp-hook = "/usr/local/bin/git-annex-ftp.py"
# git annex initremote iwebftp type=hook hooktype=ftp encryption=none
from ftplib import FTP
import os
f = FTP('prefix.iweb-storage.com', 'prefix-admin', 'password')
f.set_pasv(True)
You can’t perform that action at this time.