Skip to content

Instantly share code, notes, and snippets.

View Leechael's full-sized avatar
🐹
Working from home

Leechael Leechael

🐹
Working from home
View GitHub Profile
<?php
use Symfony\Component\HttpFoundation\File\UploadedFile;
class SmokeTestingController extends \BaseController
{
public function upload()
{
$iniMax = strtolower(ini_get('upload_max_filesize'));
#!/usr/bin/env python
# encoding: utf-8
class dict2obj(dict):
def __init__(self, d, default=None):
self.__d = d
self.__default = default
super(self.__class__, self).__init__(d)
def __getattr__(self, k):
#!/usr/bin/env python
# encoding: utf-8
def retriable(retry_counts=3, before_retry=None, final=None, noexc=False):
is_callable = lambda x: x is not None and hasattr(x, "__call__")
if not is_callable(before_retry):
before_retry = lambda err, c: c
if not is_callable(final):
final = lambda err, c: c
@Leechael
Leechael / benchmarks.py
Created July 26, 2013 09:34
Concurrency HTTP request benchmark
#!/usr/bin/env python
# encoding: utf-8
from contextlib import contextmanager
#
# Helpers
#
@Leechael
Leechael / example.py
Created June 9, 2013 08:28
Graceful shutdown handler for Tornado.
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import sys
import logging
logging.basicConfig(level=logging.DEBUG,
stream=sys.stdout)
@Leechael
Leechael / build_lightpng.sh
Created April 17, 2013 19:11
Small script that build lightpng on Mac OS X (with Homebrew installed).
#!/usr/bin/env bash
git clone -q git://github.com/shibukawa/lightpng.git
pushd lightpng
wget -nv "http://nchc.dl.sourceforge.net/project/boost/boost/1.53.0/boost_1_53_0.tar.bz2"
tar xjf boost_1_53_0.tar.bz2
git submodule update --init
which scons || sudo brew install scons
./build.sh
@Leechael
Leechael / proc.py
Last active December 10, 2015 11:29
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
from itertools import imap
from functools import partial
import types
"""
Usage:
@Leechael
Leechael / gist:4074485
Created November 14, 2012 20:17
vmlive and vmstart: my handy commands for VirtualBox Instance Management
alias vmlive="VBoxManage list runningvms"
function vmstart () {
if [ -e $1 ]; then
echo 'No VirualMachine specified. All available machines:'
VBoxManage list vms | cut -d'"' -f2 | sed -E 's/(.*)/> \1/'
return
fi
local _EXISTS=`VBoxManage list vms | grep $1 | wc -l | awk '{print $1}'`
if [ ! $_EXISTS -eq 1 ]; then
@Leechael
Leechael / pjson.py
Created November 10, 2012 07:21
Pretty print for JSON, in Python
#!/usr/bin/env python
# -*- coding: utf8 -*-
from simplejson import loads
from simplejson.decoder import JSONDecodeError
from betterprint import pprint
from os import path
if __name__ == '__main__':