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 / grabProfilePics.sh
Created August 12, 2010 14:24
grabProfilePics.sh
#!/bin/bash
# Takes the XML file from Dan with UIDs & Profile pic urls and turns it into
# a CSV which we then run through AWK to populate some variables. These then
# pass through to wget to save out the profile in the format UID.EXT
TMP_CSV=/tmp/photos.csv;
PROFILE_FILE=/home/jaymz/documents/vans/vans-usa/data-export/20100811/user_photos.xml;
cat $PROFILE_FILE | sed -e 's/.*uid="\(.*\)" url="\(.*\)".*/\1,\2/g' > $TMP_CSV;
/* Add a blank column at the start for the id field */
sed -e 's/\(.*\)/,\1/g' zipcodes.txt > /tmp/codes.txt && mv /tmp/codes.txt zipcodes.txt
/* Table structure for the zipcode data from
http://www.populardata.com/zipcode_database.html */
BEGIN;
CREATE TABLE `zipsearch_zipcodeentry` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`zipcode` varchar(5) NOT NULL,
`latitude` numeric(9, 6) NOT NULL,
#!/bin/bash
# Finds all ASP files in the current folder and below and turns the include
# definition into a PHP format one. The converted file is renamed to FILE.php
# and the original file removed. Links in the format 'href="file.asp"' *only*
# are changed to 'href="file.php"'. It then loops through to fix .asp
# links in plain HTML files - this fits my use-case.
for FILE in $(find ./ -name "*.asp")
do
from django import forms
from django.utils.safestring import mark_safe
from django.conf import settings
class SimpleBBWidget(forms.Textarea):
widget_buttons = u"""
<button class="default" onclick="return surround('[b]','[/b]');"><b>B</b></button>
<button class="default" onclick="return surround('[i]','[/i]');"><i>I</i></button>
<button class="default" onclick="return insert_link();"><u>link</u></button>
"""
[10:43][wario][jaymz][/var/www/vanscom]$ cat /media/2739ccac-7602-425f-a1dd-52423c54faf0/home/jaymz/scripts/bridge
sudo tunctl -t tap0 -u jaymz
sudo /usr/sbin/brctl addbr br0
sudo /sbin/ifconfig eth0 0.0.0.0 promisc
sudo /usr/sbin/brctl addif br0 eth0
sudo /sbin/ifconfig br0 10.10.91.62
sudo /usr/sbin/brctl addif br0 tap0
sudo ifconfig tap0 10.10.91.63 up
sudo bash -c 'echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp'
sudo route add -host 10.10.91.62 dev tap0
mkdir outfiles && for file in *.swf; do swfextract $file -p `swfextract $file | grep "PNG" | awk -F') ' '{print $2}' | awk -F',' '{print $1}'`; mv output.png outfiles/`basename $file .swf`.png; done
@jaymzcd
jaymzcd / geocode.py
Created October 20, 2010 16:03
Reads in some data from a database and then makes requests for the Lat/Long via googles maps API
#!/usr/bin/python2.6
# -*- coding: utf-8 -*-
from xml.dom import minidom
import MySQLdb
import urllib
import time
# Conf for the script follows
PK = 0
CREATE USER 'whatever'@'localhost' IDENTIFIED BY 'laPass';
GRANT ALL ON thedb.* TO 'whatever'@'localhost';
FLUSH PRIVILEGES;
@jaymzcd
jaymzcd / ip_decimal.py
Created November 26, 2010 13:40
Takes a list of CIDR formatted IP's and outputs the network & broadcast address in decimal format - handy to do arithmetic based queries in a database.
#!/usr/bin/env python2
import sys
import csv
import ipaddr # via code.google.com/p/ipaddr-py/
# Reads a file of ip's and spits out decimal start/end points
# http://ipinfodb.com/ip_database.php
# Then load into mysql and select the country you fancy into a file:
# SELECT ip_cidr, country_code FROM ip_group_country WHERE country_code IN ("IT", "DE") INTO OUTFILE '/tmp/eu-ips.txt';
get empty winners id's:
SELECT DISTINCT w.winner_id FROM winners w join winner_metas m on w.winner_id=m.winner_id
WHERE (m.meta_name='lastName' AND m.meta_data='') OR (m.meta_name='firstName' AND m.meta_data='') OR (m.meta_name='twitterUserName' AND m.meta_data='')
ORDER BY w.winner_id DESC;
get distinct surnames or twitter users:
SELECT m.meta_data, w.winner_id FROM winners w join winner_metas m on w.winner_id=m.winner_id
WHERE m.meta_name='twitterUserName' OR m.meta_name='lastName'