Skip to content

Instantly share code, notes, and snippets.

View alfredodeza's full-sized avatar
:octocat:

Alfredo Deza alfredodeza

:octocat:
View GitHub Profile
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 / prepare-commit-msg
Last active October 19, 2015 20:06
prefix commit messages with branch names
#!/usr/bin/python
"""
This is a prepare-commit-msg hook that fill prefix commit messages with
[BRANCH]
Copy this file to $GITREPOSITORY/.git/hooks/prepare-commit-msg
and mark it executable.
Assumes your branch is based off of a tracker ID
"""
@alfredodeza
alfredodeza / unmask.js
Created December 1, 2015 13:31
Unmask **** passwords
var els = document.getElementsByTagName('input'); for(var x = 0; x < els.length; x++) { if(els[x].type.toLowerCase() == 'password' ) { var test = els[x].type = 'text'; } }
@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 / 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
@alfredodeza
alfredodeza / gist:5905095
Created July 1, 2013 22:13
Attempting to compile onto tasseo
/opt/heroku-buildpack-ruby/bin/compile .
-----> Using Ruby version: ruby-1.9.2
-----> Installing dependencies using
sh: -c: line 0: unexpected EOF while looking for matching ``'
sh: -c: line 1: syntax error: unexpected end of file
sh: -c: line 0: unexpected EOF while looking for matching ``'
sh: -c: line 1: syntax error: unexpected end of file
/opt/heroku-buildpack-ruby/lib/language_pack/ruby.rb:616:in `load_bundler_cache': private method `load' called for nil:NilClass (NoMethodError)
from /opt/heroku-buildpack-ruby/lib/language_pack/ruby.rb:430:in `block in build_bundler'
from /opt/heroku-buildpack-ruby/lib/language_pack/base.rb:91:in `log'
@alfredodeza
alfredodeza / gist:6319156
Created August 23, 2013 13:07
Supervisor in Ubuntu
First remove the apt-get supervisor version:
sudo apt-get remove supervisor
Kill the backend supervisor process:
sudo ps -ef | grep supervisor
Then get the newest version(apt-get version was 3.0a8):