Skip to content

Instantly share code, notes, and snippets.

View diath's full-sized avatar
💭
whoami | xargs pkill -9 -u

diath

💭
whoami | xargs pkill -9 -u
View GitHub Profile
@hest
hest / gist:8798884
Created February 4, 2014 06:08
Fast SQLAlchemy counting (avoid query.count() subquery)
def get_count(q):
count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar()
return count
q = session.query(TestModel).filter(...).order_by(...)
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ...
print q.count()
@muhuk
muhuk / ttf2love.py
Created September 30, 2014 13:36
Converts TTF fonts to a PNG file recognized by Love2D game engine.
#!/usr/bin/env python
import sys
from PIL import Image, ImageChops, ImageDraw, ImageFont
BACKGROUND_COLOR = (0, 0, 0, 0)
FONT_COLOR = (255, 255, 255, 255)
MARKER_COLOR = (255, 255, 0, 255)