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 / mix_out.py
Created June 27, 2014 13:47
alternating stderr with stdout with subprocess.Popen
# ideally we would have output like:
$ python process.py
this is an stderr line
this is an stdout line
this is an stderr line
this is an stdout line
@alfredodeza
alfredodeza / gist:88ea216f2cd57797b737
Last active August 29, 2015 14:02
Run a Vim command on a bunch of files
# For a bunch of Python files
vim -c "bufdo! set eventignore-=Syntax| %s/original/replacement/gce" *.py
# if you want to save as you go
vim -c "bufdo! set eventignore-=Syntax| %s/original/replacement/gce | update" *.py
# Breaking it down:
# bufdo! -> so that it doesn't complain about erroring
# set eventignore-=Syntax -> so that every buffer gets syntax highlighting
# /gce -> optional, global search in the line with confirmation and eating up the errors
@alfredodeza
alfredodeza / zpool_config
Created April 21, 2014 13:23
zpool get all zones
zpool get all zones
NAME PROPERTY VALUE SOURCE
zones size 2.72T -
zones capacity 42% -
zones altroot - default
zones health ONLINE -
zones guid 1181797254408314611 default
zones version - default
zones bootfs - default
zones delegation on default
@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):
@alfredodeza
alfredodeza / run.py
Last active September 5, 2017 22:14
Serve a WSGI application + static files with CherryPy
import os
import cherrypy
from cherrypy import wsgiserver
from my_wsgi_app import wsgi
PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), 'public'))
class Root(object):
@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 / histfile
Last active March 25, 2017 15:11
How I got netatalk 3.0.1 working in SmartOS
CFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib ./configure --with-bdb=/opt/local --with-init-style=solaris --without-pam --prefix=/opt/local --with-init-dir=/var/svc/manifest/network/ --with-ssl-dir=/opt/local --with-libgcrypt --prefix=/opt/local
LD_OPTIONS="-D libs,detail" CFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib make clean install
LD_OPTIONS="-D libs,detail" CC=gcc CFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib make clean install
ls /opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.0/
ln -s /opt/local/lib/libiconv.so /opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.0/
LD_OPTIONS="-D libs,detail" CC=gcc CFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib make clean install
ln -s /opt/local/lib/libwrap.so /opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.0/
LD_OPTIONS="-D libs,detail" CC=gcc CFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib make clean install
@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 / 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 / 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