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 / gist:861999
Created March 9, 2011 10:26
clean up and create sep. columns of a list of CSV's - couldn't be bothered to use csvwriter for some reason
# stores is a giant list of strings of addresses comma separated
b = [[x.strip() for x in a.split(',')[0].split(' ')+a.split(',')[1:]] for a in stores];
f = open('/tmp/stores.txt', 'w');
[f.write(','.join(map(lambda x: '"'+x+'"', y))+"\n") for y in b];
f.close()
#tada!
@jaymzcd
jaymzcd / vmUserTotal.py
Created March 17, 2011 11:48
Returns the given list of users totals from Virgin Giving Money
#!/usr/bin/env python2
import urllib2
import sys
from BeautifulSoup import BeautifulSoup
# Until there is an actual API for VMG we've had to use something like this
# which will return the totals for a list of users from the command line.
# It's not too much to imagine this saving the things to a db and running
# periodically via a cron job.
@jaymzcd
jaymzcd / generateConfs.py
Created March 28, 2011 09:25
Generate server and settings configs for Vans EMEA setup
#!/usr/bin/env python2
import os
import sys
# Setup a working environment for our vans app
PROJECT_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))
sys.path.append(PROJECT_PATH)
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
# Import our sites and models we need
#!/usr/bin/env python2
import os
import sys
import paramiko
import zipfile
local_file = sys.argv[1]
KNOWN_HOSTS = os.path.join(os.getenv("HOME"), '.ssh', 'known_hosts')
@jaymzcd
jaymzcd / createSiegeUrls.py
Created May 9, 2011 14:50
Pull urls from a given address for loading into siege
#!/usr/bin/env python2
# Use BSoup to read through a given url, pull out the links and then write them
# to a file for use by siege for HTTP load testing. You can filter with a given
# class name and prepend a base url for those without http parts.
# Usage:
#
# createSiegeUrls http://127.0.0.1/site/
import urllib
@jaymzcd
jaymzcd / activate.sh
Created May 16, 2011 15:55
Sets my virtualenv so local is imported before global with a system wide site-packages in use
function activate {
export PYTHONPATH=/home/jaymz/development/virtualenvs/$1/lib/python2.7/site-packages/;
source /home/jaymz/development/virtualenvs/$1/bin/activate;
}
@jaymzcd
jaymzcd / plugin.js
Created May 17, 2011 15:07
Filter table in HTML via JS on keyup
<script type="text/javascript">
/* Can't remember where I saw this but it's quite handy/cool for tables to do filtering without posts */
$(document).ready(function(){
//add index column with all content.
$(".filterable tr:has(td)").each(function(){
var t = $(this).text().toLowerCase(); //all row text
$("<td class='indexColumn'></td>")
.hide().text(t).appendTo(this);
});//each tr
$("#FilterTextBox").keyup(function(){
@jaymzcd
jaymzcd / gist:988805
Created May 24, 2011 14:28
ciara analytics code
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-3092654-28']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
CREATE TABLE `blogger_bloggerpost` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`blog_id` integer NOT NULL,
`post_id` varchar(255) NOT NULL UNIQUE,
`published` datetime NOT NULL,
`updated` datetime NOT NULL,
`title` varchar(255),
`content` longtext NOT NULL,
`content_type` varchar(100) NOT NULL,
`link_edit` varchar(200),
@jaymzcd
jaymzcd / gist:1002644
Created June 1, 2011 16:07
Show facebook friends via graph call and click and store in a list
<html>
<head>
<title>Jaymz Facebook friend JSON click test thing</title>
<link href='http://fonts.googleapis.com/css?family=Maven+Pro' rel='stylesheet' type='text/css'>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<style>
body {
margin:20px auto;
font-family: 'Maven Pro', arial, serif;
}