Skip to content

Instantly share code, notes, and snippets.

@thoas
thoas / multi_bench.py
Created September 21, 2012 08:32 — forked from oleiade/multi_bench.py
Benchmark single-process, threads, processes in python procedure
import time
import itertools
from fastset.bitvector import bitvector
from Queue import Queue
from threading import Thread
from multiprocessing import Process
@thoas
thoas / deps.pp
Created July 3, 2011 14:37 — forked from rcrowley/deps.pp
Deploying Django with Puppet
stage { "pre": before => Stage["main"] }
class python {
package {
"build-essential": ensure => latest;
"python": ensure => "2.6.6-2ubuntu1";
"python-dev": ensure => "2.6.6-2ubuntu1";
"python-setuptools": ensure => "latest";
}
exec { "easy_install pip":
path => "/usr/local/bin:/usr/bin:/bin",
@thoas
thoas / url_patterns.py
Created June 28, 2011 10:43 — forked from c4urself/url_patterns.py
URL Patterns with Optional Arguments
(r'^articles/(?P<year>\d{4}/?$, 'main.views.year'),
# When a use case comes up that a month needs to be involved as
# well, you add an argument in your regex:
(r'^articles/(?P<year>\d{4}/(?P<month>\d{2})/?$, 'main.views.year_month'),
# That works fine, unless of course you want to show something
# different for just the year, in which case the following case can be
# used, making separate views based on the arguments as djangoproject
import datetime
import subprocess
from django.conf import settings
from django.core.management.base import BaseCommand
from boto.s3.connection import S3Connection
from boto.s3.key import Key
class Command(BaseCommand):
@thoas
thoas / gist:588031
Created September 20, 2010 15:06 — forked from anonymous/gist:588026
#!/usr/bin/env python
# coding=utf-8
"""
Generate all the modules of the projects as SCORM2004r3 packages that match a
pattern.
This script work if your project as the following structure:
0123_project_root/ # 0123 = customer code
|-- .svn
|-- 0123_M01 # module 01
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="http://openlayers.org/dev/theme/default/style.css" type="text/css" />
<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAUXDSXET8IRGdgHP9FpGw5BT-fVzUWGS_eJ2ZLPBO_6yPqTi0vhQKAzahOrduDq0xQk09GR-UP3Jgcg'></script>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
<script src="http://www.google.com/jsapi?key=ABQIAAAAUXDSXET8IRGdgHP9FpGw5BT-fVzUWGS_eJ2ZLPBO_6yPqTi0vhQKAzahOrduDq0xQk09GR-UP3Jgcg"></script>
<script type="text/javascript">
google.load("jquery", '1.4');
google.load("maps", "2.x");
</script>
"""
Delete your old tweets (by old I mean all except latest 100)
without removing favorites of your own tweets and DM.
1/ Install python-twitter: http://code.google.com/p/python-twitter/ as ptwitter
2/ Patch it with http://code.google.com/p/python-twitter/issues/detail?id=60
3/ Populates USERNAME and PASSWORD
Note that you're limited to 150 calls to the API per hour and that you can't
retrieve more than the 3200 latest tweets, it means that even if you relaunch
/**
* Add this script to the end of your document that use <input autofocus type="text" />
* or <input type="text" placeholder="username" /> and it'll plug support for browser
* without these attributes
* Minified version at the bottom
*/
(function () {
function each(list, fn) {
var l = list.length;
@thoas
thoas / Extend.php
Created December 12, 2009 12:27 — forked from monzee/Extend.php
<?php
/**
* Calls the render() method of the Extend view helper if needed
*
* @author Mon Zafra <monzee at gmail>
* @copyright (c)2009 Mon Zafra
* @category Mz
* @package
* @license http://mz-project.googlecode.com/svn/trunk/LICENSE MIT License