Skip to content

Instantly share code, notes, and snippets.

@jmaupetit
jmaupetit / ghost_capture_pdf.py
Created December 5, 2012 17:57
Ghost.py capture to PDF
from ghost import Ghost
from PySide.QtGui import QApplication, QImage, QPainter, QPrinter
class MyGhost(Ghost):
def capture_pdf(self):
printer = QPrinter(QPrinter.HighResolution)
printer.setResolution(300)
printer.setOutputFileName("QtPrinter.pdf")
printer.setPaperSize(QPrinter.A4)
@timcowlishaw
timcowlishaw / container.py
Created July 31, 2012 08:43
Simple Dependency Injection in Python
class Container:
def __init__(self):
self.factories = {}
self.instances = {}
def add(self, feature, implementation):
if callable(implementation):
self.factories[feature] = implementation
else:
self.instances[feature] = implementation
@jboner
jboner / latency.txt
Last active September 23, 2024 03:34
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@jamiepittock
jamiepittock / gist:2708107
Created May 16, 2012 06:42
An old Jambor-ee article: A future recipe for ExpressionEngine?

Written by Simon Rudkin (@simonrudkin), this article was originally published on the now defunct, mythical EE fansite Jambor-ee (beautifully crafted by @jamiepittock for at least 3 weeks) back in January 2009.

I was reminded of it after reading the recent chatter on Twitter and various blogs about ExpressionEngine and themes so thought it was worth republishing.

A future recipe for ExpressionEngine?

January 28th 2009

I’ve just finished making a really tidy events calendar using ExpressionEngine. It keeps the events in one weblog, venues in another, uses custom fields to add a Google Maps link for each venue, and pulls it all together in a template group that splits events into upcoming and archived. Just the kind of project that EE handles with aplomb, and I’d love to share it with you but, erm… w

@klipstein
klipstein / b64field.py
Created November 22, 2010 12:25
Base64 file handling for django-tastypie
import base64
import os
from tastypie.fields import FileField
from django.core.files.uploadedfile import SimpleUploadedFile
class Base64FileField(FileField):
"""
A django-tastypie field for handling file-uploads through raw post data.
It uses base64 for en-/decoding the contents of the file.
Usage:
@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")