Skip to content

Instantly share code, notes, and snippets.

@truemped
truemped / thumbnails.py
Created April 10, 2012 14:05
Thumbnail generation keeping the aspect ratio of the target width and height
# vim: set fileencoding: utf-8 :
#
import os
try:
from PIL import Image
except ImportError:
import Image
try:
@truemped
truemped / less2stylus.coffee
Created February 17, 2012 09:47 — forked from NHQ/less2stylus.coffee
Convert LESS to Stylus for Twitter Bootstrap
# Quick hack of regular expressions to convert twitter bootstrap from LESS to Stylus
less2stylus = (string) ->
string = string
.replace(/^(\ *)(.+)\ +\{\ *\n?\ */mg, "$1$2\n$1 ") # remove opening brackets
.replace(/^(\ *)([^\ ]+)\ +\{\ *\n?\ *?/mg, "$1$2\n$1 ") # remove opening brackets
.replace(/\ *\{\ *\n*/g, "\n") # remove opening brackets again (some random cases I'm too lazy to think through)
.replace(/\ *\}\ *\n*/g, "\n") # remove closing brackets
.replace(/\;\ *?$/gm, "") # remove semicolons
.replace(/@(\w+):(\ *)\ /g, "\$$1$2 = ") # replace @variable: with $variable =
.replace(/\@/g, "\$")
@truemped
truemped / gist:1717523
Created February 1, 2012 15:25 — forked from fennb/gist:1283573
nginx microcaching config example
# Set cache dir
proxy_cache_path /var/cache/nginx levels=1:2
keys_zone=microcache:5m max_size=1000m;
# Virtualhost/server configuration
server {
listen 80;
server_name yourhost.domain.com;
# Define cached location (may not be whole site)
@truemped
truemped / ubuntu puppet server passenger install.txt
Created September 30, 2011 04:30 — forked from andys/ubuntu puppet server passenger install.txt
Steps for installing puppet master in Ubuntu 10.04 with ruby 1.8 and passenger
Puppet Install steps for Ubuntu 10.04, ruby 1.8, and passenger
apt-get -y update
apt-get -y dist-upgrade
reboot
############################################
apt-get -y install build-essential
apt-get -y install bsubversion apache2 libcurl4-openssl-dev libssl-dev mysql-server
@truemped
truemped / sample.config
Created June 8, 2011 07:55 — forked from sidupadhyay/sample.config
Sample HA Proxy Config for Tornado/Socket.io Backends
global
maxconn 10000 # Total Max Connections. This is dependent on ulimit
nbproc 2
defaults
mode http
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
import trombi
from tornado.ioloop import IOLoop
ioloop = IOLoop.instance()
f = open('onemb.zero')
db = trombi.from_uri('http://localhost:5984/test')
def doc_created(doc):
@truemped
truemped / logsink.py
Created February 4, 2011 12:36
A sink for the pyzmq log handler
# Copyright (c) 2011 Daniel Truemper <truemped@googlemail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions: The above copyright notice and this
# permission notice shall be included in all copies or substantial portions of
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
@truemped
truemped / btree.py
Created October 31, 2010 12:10 — forked from teepark/btree.py
import bisect
import itertools
import operator
class _BNode(object):
__slots__ = ["tree", "contents", "children"]
def __init__(self, tree, contents=None, children=None):
self.tree = tree
@truemped
truemped / .bashrc
Created August 17, 2009 07:25 — forked from justintv/.bashrc
# If you work with git, you've probably had that nagging sensation of not knowing what branch you are on. Worry no longer!
export PS1="\\w:\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\$ "
# This will change your prompt to display not only your working directory but also your current git branch, if you have one. Pretty nifty!
# ~/code/web:beta_directory$ git checkout master
# Switched to branch "master"
# ~/code/web:master$ git checkout beta_directory
# Switched to branch "beta_directory"
  1. General Background and Overview