Skip to content

Instantly share code, notes, and snippets.

View jaymzcd's full-sized avatar
🍜
Maybe cooking some pad thai

jaymz campbell jaymzcd

🍜
Maybe cooking some pad thai
View GitHub Profile
@jaymzcd
jaymzcd / mailbomb.py
Created February 14, 2012 17:38
Quick'n'dirty mailbomb of user X when annoying
import smtplib
import os
import sys
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders
from random import randint
@jaymzcd
jaymzcd / nicereadme.sh
Created February 13, 2012 16:39
Use documentup.com to prettify your markdown files from the commandline
function nicereadme {
TARGET_DOC=${1:-/tmp/doc.html}
INFILE=${2:-README.md}
curl -s -X POST --data-urlencode content@$INFILE http://documentup.com/compiled > $TARGET_DOC;
echo "$INFILE is pretty at file://$TARGET_DOC";
}
@jaymzcd
jaymzcd / resolve_301.sh
Created February 3, 2012 13:59
resolve a list of 301'ing links to a file
while read line;
do curl -Is $line | egrep "Location" | awk -F": " '{print $2}' >> urls-resolved.txt;
done < urls-2.txt
@jaymzcd
jaymzcd / formpost.php
Created January 31, 2012 17:45
for seb
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script>
$(document).ready(function() {
$('#add_more').click(function(e) {
$('form:first fieldset:first').clone().appendTo($('form:first'));
});
});
</script>
<pre>
@jaymzcd
jaymzcd / parser.py
Created January 30, 2012 08:53
creating prefs.xml for droid via lxml
#!/usr/bin/env python2
# http://www.voidspace.org.uk/python/articles/configobj.shtml
from configobj import ConfigObj
# http://stackoverflow.com/a/7703144
from lxml.etree import Element, SubElement, tostring
def parse_file(f):
cfg = ConfigObj(f, encoding='UTF-8')
@jaymzcd
jaymzcd / mod_table.py
Created January 24, 2012 23:43
use sage & pylab to plot a finite field's multiplication table for given f_size prime
#!/usr/bin/env sage
import pickle
from math import *
from pylab import *
"""
See: http://goo.gl/y2A78 for information
and how this was put together/concepted
@jaymzcd
jaymzcd / gist:1433676
Created December 5, 2011 14:06
log uptime via bash, plot results via pylab
# Bash command in a loop:
while true; do uptime >> /tmp/uptime.log; sleep 5; done
# Use awk to strip it out and grab 1min figure
awk -F\ '{print $9}' la.txt | tr "," " " > uptime_1min.csv
# In pylab (via:) run:
ipython --pyab
d = numpy.genfromtext('uptime_1min.csv')
plot(d)
@jaymzcd
jaymzcd / gitlog-timesheet.sh
Created December 5, 2011 11:31
Gets git logs for all folders below current for the past week - handy for timesheets!
#!/bin/bash
# This isn't nice with spaces, but then why you cloning a repo to a folder
# with spaces!? could use IFS: http://goo.gl/dEkQU
f=`find . -maxdepth 2 -type d -name ".git" | sed 's/\/.git//'`
a=$(echo $f | tr " " "\n")
for folder in $a;
do
cd $folder;
@jaymzcd
jaymzcd / ack.sh
Created December 1, 2011 12:11
ack commands
#!/usr/bin/env bash
bases=( "href" "src" "action" )
for base in ${bases[@]}
do
ack --ignore-dir "fleheaders" -l "$base=\"/" | xargs -n1 --replace sed -i "s/$base=\"\//$base=\"{{ url_base }}\//g" {} | grep url_base;
done;
@jaymzcd
jaymzcd / monokaitheme.xml
Created November 28, 2011 18:32
monokai theme (customized)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Monokai</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>