Skip to content

Instantly share code, notes, and snippets.

View rcmachado's full-sized avatar

Rodrigo Machado rcmachado

View GitHub Profile
@rcmachado
rcmachado / git-commits-per-author
Created January 25, 2013 19:22
Custom git commands
git ls-files -z |
xargs -0 -n1 -E'\n' -J {} git blame --date short -wCMcp '{}' |
perl -pe 's/^.*?\((.*?) +\d{4}-\d{2}-\d{2} +\d+\).*/\1/' |
sort |
uniq -c |
sort -rn
@rcmachado
rcmachado / shutdown-test.conf
Created November 8, 2012 20:12
Upstart: execute task on shutd own (but before the kill signal)
description "Upstart task: execute this script on shutdown or reboot"
task
# this will execute this script before the upstart send the KILL signals
start on starting rc RUNLEVEL=[06]
exec mktemp --tmpdir=/home/ubuntu test.XXXXXX
@rcmachado
rcmachado / pdfsplitr.sh
Created April 24, 2012 21:39
Split (extract) pdf pages from larger document
#!/bin/bash
# Usage ./pdfsplitr.sh inputfile.pdf outputfile.pdf pagenumber
# Example: ./pdfsplitr.sh myfile.pdf myotherfile.pdf 2
# http://viktorpetersson.com/2010/10/22/how-to-split-a-pdf-files-on-mac-and-linuxunix/
GS=$(which gs)
# Make sure Ghostscript is installed
if [[ $GS = "" ]]
then
@rcmachado
rcmachado / .bash_profile
Created December 29, 2011 13:05
bash_profile
# Activate RVM
function rvm_activate {
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
}
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
@rcmachado
rcmachado / ssh-copy-id.sh
Created August 24, 2011 13:08
ssh-copy-id for Mac OS X and other *nix that don't ship with one
#!/bin/sh
#
# This is the same file as /usr/bin/ssh-copy-id on Ubuntu 10.04.2
#
# Shell script to install your public key on a remote machine
# Takes the remote machine name as an argument.
# Obviously, the remote machine must accept password authentication,
# or one of the other keys in your ssh-agent, for this to work.
ID_FILE="${HOME}/.ssh/id_rsa.pub"
@rcmachado
rcmachado / cisco-decrypt.c
Created May 27, 2011 18:02
Decoder for password encoding of Cisco VPN client
/* Decoder for password encoding of Cisco VPN client.
Copyright (C) 2005 Maurice Massar
Thanks to HAL-9000@evilscientists.de for decoding and posting the algorithm!
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@rcmachado
rcmachado / install_python.sh
Created December 21, 2010 20:24
A Little script that installs python 2.7.1 + setuptools + pip + virtualenv on CentOS
#!/bin/bash
PYTHON_URL=http://python.org/ftp/python/2.7.1/Python-2.7.1.tar.bz2
SETUPTOOLS_URL=http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg#md5=fe1f997bc722265116870bc7919059ea
INSTALL_PREFIX=/home/rcmachado/python
# Abort scripts if some of the comands returns != 0
set -o errexit
# Abort if a variable that isn't defined is used
set -o nounset
@rcmachado
rcmachado / send_sms_action.py
Created November 26, 2010 16:56
Custom action
from pyccuracy.actions import ActionBase
class SendSMSAction(ActionBase):
regex = r'^(And )?I send a SMS to [\"](?P<short_number>\d+)[\"] with [\"](?P<message>.+)[\"] as [\"](?P<msisdn>\d+)[\"]$'
def execute(self, context, short_number, message, msisdn):
url = "http://myserver/dispatcher.php?MESSAGE=" + message + "&SENDERID=" + msisdn + "&PHONEID=" + short_number
self.execute_action(u"I go to \"{0}\"".format(url), context)
@rcmachado
rcmachado / .screenrc
Created October 20, 2010 16:50
Screen configuration file
defutf8 on
msgwait 3
#sorendition 05 43
sorendition 00 02
hardstatus alwayslastline "%c | %Y-%m-%d | %w"
# barra verde e preto, com códigos de cores literais
#hardstatus alwayslastline "\033[m\033[42;30m%c\033[m \033[42;30m%Y%m%d\033[m \033[42;30m %w \033[m"
@rcmachado
rcmachado / install_phpunit.sh
Created September 20, 2010 13:29
Installs PHPUnit on a very old CentOS 5.3
#!/bin/bash
#
# Installs PHPUnit on a very old CentOS 5.3
#
pear upgrade --force http://pear.php.net/get/PEAR-1.8.1
pear channel-discover pear.phpunit.de
pear channel-discover pear.symfony-project.com
pear install phpunit/PHPUnit