Skip to content

Instantly share code, notes, and snippets.

View lerouxb's full-sized avatar

Le Roux Bodenstein lerouxb

View GitHub Profile
@lerouxb
lerouxb / gist:1175428
Created August 27, 2011 14:07
upgrouper theme test in jinjs
<!doctype html>
<html>
<head>
<title>{{account.twitter_screen_name}} | upgrouper</title>
<link rel="stylesheet" type="text/css" href="{{cssurl}}">
<script src="{{jsurl}}"></script>
</head>
<body>
<h1>@{{account.twitter_screen_name}}</h1>
@lerouxb
lerouxb / server.js
Created August 27, 2011 17:20 — forked from jeffrafter/server.js
Twitter OAuth with node-oauth for node.js+express
var express = require('express');
var sys = require('sys');
var oauth = require('oauth');
var app = express.createServer();
var _twitterConsumerKey = "YOURTWITTERCONSUMERKEY";
var _twitterConsumerSecret = "YOURTWITTERCONSUMERSECRET";
function consumer() {
@lerouxb
lerouxb / gist:1234843
Created September 22, 2011 14:02
Django Redis JSON Sessions
# originally from https://github.com/martinrusev/django-redis-sessions
# but use json, not pickle
import json
import pickle
import time
from redis import Redis
from django.utils.encoding import force_unicode
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
@lerouxb
lerouxb / weather.py
Created January 18, 2012 12:12
Get the current conditions for a city from Google's "hidden" weather API
#!/usr/bin/env python
def convert_mph(match):
try:
mph = int(match.group(0).split(' ')[0])
kph = mph*1.6
#return "%.1f kph" % (kph,)
return "%s kph" % (int(round(kph)),)
except:
return match.group(0)
@lerouxb
lerouxb / index.html
Created February 1, 2012 08:38 — forked from briehanlombaard/canvas_grid.html
Canvas grid generator thing
<!doctype html>
<head>
<title>Grid and baseline background image test</title>
<style type="text/css">
html, body {
height: 100%;
margin: 0;
padding: 0;
}
body {
@lerouxb
lerouxb / placehold.js.html
Created March 6, 2012 09:31
Dynamically create a canvas to be used as an image placeholder.
<!doctype html>
<html>
<head>
<title>placehold.js</title>
<script>
/*
Dynamically create a canvas to be used as an image placeholder.
If you really want an <img>, you can use:
var dataURL = canvas.toDataURL("image/png");
@lerouxb
lerouxb / gist:2108445
Created March 19, 2012 11:32
Star Control 2 Admission Policy
Person A: Can you imagine, Person B, what it must be like to argue for race based admissions policy?
Person A: To live in endless screaming pain for months on end? No you cannot.
Person B: hold, what you do is wrong!
Person A: You have not asked properly.
Person A: If you do not ask properly, we will not discuss this matter.
Person A: Instead, we use the race card.
Person A: oh wait
Person A: you DID ask properly
Person A: We will explain to you about the Nationalists and the British Colonialists
Person A: the PAC, our only friends... whom we exterminated
/*
Run this, connect to
http://localhost:3000/check/image?url=http://dl.dropbox.com/u/1167202/IMAG0193.jpg
That image is just under 2Mb. I tell the request to disconnect immediately (see
the maxSize = 0 hack inside identifyImageURL()) and all the data keeps arriving
bit by bit until the entire file is downloaded.
(This is perhaps more obvious on my slow South African line, but you can see
the byte totals coming in and it trying to call destroy again and again in the
var
express = require('express'),
gm = require('gm'),
http = require('http'),
request = require('request'),
urlmod = require('url'),
app = express.createServer();
app.use(express.logger('tiny'));
app.use(express.errorHandler({
var
express = require('express'),
gm = require('gm'),
http = require('http'),
request = require('request'),
urlmod = require('url'),
app = express.createServer();
app.use(express.logger('tiny'));
app.use(express.errorHandler({