Skip to content

Instantly share code, notes, and snippets.

cd /tmp
aria2c http://codespeak.net/lxml/lxml-2.2.4.tgz
tar -xzvf lxml-2.2.4.tgz
cd lxml-2.2.4
mkdir libs
cd libs/
aria2c ftp://xmlsoft.org/libxml2/libxml2-2.7.3.tar.gz
aria2c ftp://xmlsoft.org/libxml2/libxslt-1.1.24.tar.gz
cd ..
python setup.py build --static-deps --libxml2-version=2.7.3 --libxslt-version=1.1.24
" Allows you to do ":b ", type the beginning of some open buffer's name, and hit <Tab> to see/select possible matches
set wildcharm=<Tab> wildmenu wildmode=full
function! BufSel(pattern)
let bufcount = bufnr("$")
let currbufnr = 1
let nummatches = 0
let firstmatchingbufnr = 0
while currbufnr <= bufcount
if(bufexists(currbufnr))
"""
Tests the difference in speed in the following scenarios:
* Selecting all records from a SQLite database and doing processing using
regular Python functions (test_python)
* Calling a Python function in the SQL statement itself and returning all
results (test_sqlite)
"""
from hashlib import sha1
# ---- some file that is processed early in Django's execution (like a urls.py or __init__.py file)
from product.models import ProductManager
def deal_o_day(self):
"""Determines which product is the current Deal of the Day"""
return self.filter(stuff_in_stock__gt=0, foo=bar)
ProductManager.deal_o_day = deal_o_day
import os
from django.core.signals import post_delete
from articles.models import Attachment
def cleanup_filesystem(sender, instance):
"""Removes attached files from the filesystem"""
try:
os.unlink(instance.attachment.path)
import uuid
from django.db import models
from django.contrib.auth.models import User
from cumulus.storage import CloudFilesStorage
cloudfiles_storage = CloudFilesStorage()
# Create your models here.
class Upload(models.Model):
$ python test_enumerate.py
3 function calls in 8.030 CPU seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 8.030 8.030 <string>:1(<module>)
1 8.030 8.030 8.030 8.030 test_enumerate.py:5(test_enumerate)
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
@codekoala
codekoala / SerialServoControl.pde
Created September 22, 2011 02:09
Tells an Arduino to move some servos in order to center a webcam on someone's face.
/*******************************************************
* SerialServoControl Sketch
* Written by Ryan Owens for SparkFun Electronics
* 7/15/11
* Tweaked by Josh VanderLinden for himself
* 9/21/11
*
* This sketch listens to serial commands and uses the data
* to set the position of two servos.
*
try:
# for Python 2.x
from Queue import Queue
except ImportError:
# for Python 3.x
from queue import Queue
from threading import Thread, Event
import random
import sys
@codekoala
codekoala / gist:2352493
Created April 10, 2012 16:10
Simple interface for speedometer.py
#!/bin/sh
params=""
first=1
for int in "$@"; do
if [ $first -eq 1 ]; then
first=0
else
params="$params -c"
fi