Skip to content

Instantly share code, notes, and snippets.

View thomasboyt's full-sized avatar

Thomas Boyt thomasboyt

View GitHub Profile
@thomasboyt
thomasboyt / 219.css
Created April 14, 2011 21:32
219.css Version 2
/* YOSPOS Style
Concept by Sweevo
CSS by Anal Volcano
Link flashing animation by roboshit
I totally forgot who did the images :(
*/
body {
@thomasboyt
thomasboyt / postimages.js
Created July 27, 2011 04:40
Something Awful [timg] script fix
// jQuery Max Size
// www.labs.skengdon.com/maxSize
;(function($){$.fn.maxSize=function(options){if(typeof options!=='object'){var options={width:options,height:options}};return this.each(function(){$img=$(this);var F;var FW=0;var FH=0;if(options.width){FW=$img.width()/options.width;F=1;};if(options.height){FH=$img.height()/options.height;F=0;};if(FW&&FH){F=FW/FH;};if((F>=1)&&(FW>=1)){$(this).width(options.width);};if((F<=1)&&(FH>=1)){$(this).height(options.height);};});};})(jQuery);
// fixed TIMG script for Something Awful forums
// depends on JQuery, so make sure it's loaded after jquery-min.js. Should work fine with the version on SA (1.4.2)
$("img.timg").one('load', function() {
var img = this;
@thomasboyt
thomasboyt / createreq.js
Created August 8, 2011 11:53
Request Manager Example
for (var i=0; i < 10; i++) {
reqManager.createReq({
url: "https://api.github.com/repos/jquery/jquery/pulls/" + i + "?callback=?",
type: "get",
dataType: "jsonp",
// callback for when this request has completed
onSuccess: savePullRequest
});
}
@thomasboyt
thomasboyt / models.py
Created October 20, 2011 21:40
Test Gist for Djangocasts
from datetime import datetime
from django.utils.translation import ugettext_lazy as _
from django.db import models
from django.contrib.auth.models import User
from django.template.defaultfilters import slugify
from django.template.loader import render_to_string
from django.conf import settings
from model_utils import Choices
@thomasboyt
thomasboyt / requirements.txt
Created October 22, 2011 21:03
Djangocasts VirtualEnv+PIP Tutorial
Django==1.3.1
Pinax
django-debug-toolbar==0.8.4
django-staticfiles==1.1.2
django_compressor==1.0.1
# [more Pinax-generated stuff]
-e git+http://github.com/pinax/pinax-theme-bootstrap.git#egg=pinax-theme-bootstrap
@thomasboyt
thomasboyt / gist:2582713
Created May 3, 2012 03:01
In-progress solution for Interview Street challenge: "Unfriendly Numbers"
import sys
def find_factors(n):
factors = [1, n]
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
factors.append(i)
factors.append(n / i)
if factors[-1] == factors[-2]:
@thomasboyt
thomasboyt / downloader.py
Created July 12, 2012 21:12
ShootMania Server Scripts
#!/usr/bin/python
import urllib2
import json
import shutil
import os
import argparse
import subprocess
parser = argparse.ArgumentParser(description="Download, rename, and move maps from Mania-Exchange.")
def ordered_to_dict(ordered_dict):
reg_dict = dict(ordered_dict)
for key, value in reg_dict.iteritems():
if isinstance(value, OrderedDict):
reg_dict[key] = ordered_to_dict(value)
return reg_dict
@thomasboyt
thomasboyt / pub.py
Created September 29, 2012 18:30
redis pub/sub example
import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
# [... flask routing code, sql queries, etc. ...]
r.publish("sms_replies", "%s %s %s" % (user.nick, user.last_sms_sender, text))
@thomasboyt
thomasboyt / index.html
Created October 2, 2012 02:27
SquiggleVision Graphing
<html>
<head>
<title>Squiggle Demo</title>
<script src="http://d3js.org/d3.v2.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js "></script>
<script src="squiggle.js"></script>
<style>
path {