Skip to content

Instantly share code, notes, and snippets.

View swanson's full-sized avatar
😈

matt swanson swanson

😈
View GitHub Profile
#!/usr/bin/env python
import os, shutil
PAGE_ORDER = ['header', 'banner', 'content', \
'footer', 'sidebar', 'analytics']
def createPage(content, dest = None):
page, w_target = '', 'site'
for section in PAGE_ORDER:
if section is 'content':
@swanson
swanson / AlbumArtGenerator.py
Created June 18, 2010 03:04
albumartgenerator
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtNetwork import *
import sys
import urllib2
from lxml.html import fromstring
import random, string
class AlbumCreator(QDialog):
def __init__(self, parent = None):
from setuptools import setup
APP = ['albumart.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True, "includes":["sip", "lxml._elementpath", "gzip", "PyQt4.QtNetwork"]}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
@swanson
swanson / the-cat-ate-my-source-code.py
Created June 29, 2010 17:47
The cat ate my source code...
import os
class Cat(object):
"""Any variety of feline"""
def eat(self, food):
os.remove(food)
print "Meow"
@swanson
swanson / stone-soup-and-boiled-frogs.py
Created June 29, 2010 18:39
Stone soup and boiled frogs
from BeautifulSoup import BeautifulStoneSoup
class Villager(object):
"""Just a gullible simpleton..."""
@staticmethod
def throw_in_pot(pot, item):
pot.append(item)
class Question(Document):
score = IntField(required = True, default = 0)
voters = ListField(ReferenceField(User), default = lambda : [])
def vote_up(self, username):
Question.objects(id=self.id).update_one(inc__score=1)
function get_random_color() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[Math.round(Math.random() * 15)];
}
return color;
}
function getRandomArbitary (min, max) {
data = 'FourscoreandsevenyearsagoourfaathersbroughtforthonthiscontainentanewnationconceivedinzLibertyanddedicatedtothepropositionthatallmenarecreatedequalNowweareengagedinagreahtcivilwartestingwhetherthatnaptionoranynartionsoconceivedandsodedicatedcanlongendureWeareqmetonagreatbattlefiemldoftzhatwarWehavecometodedicpateaportionofthatfieldasafinalrestingplaceforthosewhoheregavetheirlivesthatthatnationmightliveItisaltogetherfangandproperthatweshoulddothisButinalargersensewecannotdedicatewecannotconsecratewecannothallowthisgroundThebravelmenlivinganddeadwhostruggledherehaveconsecrateditfaraboveourpoorponwertoaddordetractTgheworldadswfilllittlenotlenorlongrememberwhatwesayherebutitcanneverforgetwhattheydidhereItisforusthelivingrathertobededicatedheretotheulnfinishedworkwhichtheywhofoughtherehavethusfarsonoblyadvancedItisratherforustobeherededicatedtothegreattdafskremainingbeforeusthatfromthesehonoreddeadwetakeincreaseddevotiontothatcauseforwhichtheygavethelastpfullmeasureofdevotionthatweherehighlyresolvethatthese
void queue_swap(event_t *a, event_t *b)
{
event_t *tmp;
// make sure the parent links are updated to point to the new children
if (a->parent && a->parent->left == a)
{
a->parent->left = b;
}
else if (a->parent)
- items.forEach(function(item){
li
textarea.item(disabled=true)= item
button.edit edit
button.delete delete
- })