Skip to content

Instantly share code, notes, and snippets.

View alfredodeza's full-sized avatar
:octocat:

Alfredo Deza alfredodeza

:octocat:
View GitHub Profile
@alfredodeza
alfredodeza / test_myclass.py
Created February 16, 2011 02:25
A proof of concept for better readability in tests
from testrunner import describe, it, before, after
import MyClass
with describe("My class can add"):
with before:
c = MyClass()
with after:
"clean up goes here"
@alfredodeza
alfredodeza / konira.bat
Created September 5, 2011 17:43
Trying to get a konira executable for MS win
@echo off
rem Windows Driver script for Konira
setlocal
rem Use a full path to Python (relative to this script) as the standard Python
rem install does not put python.exe on the PATH...
rem %~dp0 is the directory of this script
python "%~dp0konira" %*
@alfredodeza
alfredodeza / pecha_kucha.py
Created June 8, 2012 01:15
Pecha Kucha random image driver
# The web server:
import SimpleHTTPServer
import SocketServer
PORT = 8000
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
FOO = None
def set_or_return():
if FOO:
return FOO # local variable 'FOO' (defined in enclosing scope in line 1) referenced before assignment
try:
FOO = True
except:
FOO = False
return FOO
@alfredodeza
alfredodeza / gist:3264679
Created August 5, 2012 13:10
mosh working on OSX
# Getting mosh to work in OSX
# On the client /etc/ssh_config :
SendEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
SendEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
SendEnv LC_IDENTIFICATION LC_ALL LANGUAGE
# And on the server, in /etc/ssh/sshd_config :
@alfredodeza
alfredodeza / mvim_tabs.rst
Created December 3, 2012 19:53
Open tabs with mvim always

The mvim file is usually not writeable, change that:

sudo chmod u+w `which mvim`

Now open it for editing:

sudo vim `which mvim`

Add the following line to the top of the file, below the commented section:

@alfredodeza
alfredodeza / test_routes_dispatcher.py
Last active December 11, 2015 23:08
Trying to demonstrate a bug where the WSGI environ gets polluted with Routes + Cherrypy
import os
curdir = os.path.join(os.getcwd(), os.path.dirname(__file__))
import cherrypy
from cherrypy.test import helper
class RoutesDispatchTest(helper.CPWebCase):
@alfredodeza
alfredodeza / png_maker
Last active December 14, 2015 14:29
Create a set of PNG's to create a GIF
#!/bin/bash
set -e
app=$1
if [ $2 ]; then
window=$2
else
window=1
@alfredodeza
alfredodeza / prepare-commit-msg
Last active March 17, 2017 11:20
Pre-commit hook to prepend the branch name on every commit message
#!/bin/sh
# this file should be marked as executable and placed on .git/hooks/
BRANCH_NAME=$(git branch 2>/dev/null | grep -e ^* | tr -d ' *')
# FogBugz
if [[ $BRANCH_NAME =~ ^case ]]; then
CASE_NUMBER=$(echo $BRANCH_NAME 2>/dev/null | tr -d "case" | tr -d "-" | tr -d "_")
echo "[case $CASE_NUMBER] $(cat $1)" > $1
@alfredodeza
alfredodeza / pyversion.vim
Created June 6, 2013 13:01
Get the current Python version in Vim
function! PyVersion()
let out = system("python --version")
" Match on the first digit, fallback to 2 if nothing found
let major_version = get(matchlist(out, '\d'), 0, '2')
echo "This is Python version " . major_version
endfunction