Skip to content

Instantly share code, notes, and snippets.

Drinking mate

Hernán Rodríguez Colmeiro peregrinogris

Drinking mate
View GitHub Profile
peregrinogris / private.xml
Last active Jul 25, 2016
The private.xml file I use for Karabiner, to swap around some weird placed keys when using a not en_US keyboard as en_US (Tested in Spanish and German layouts)
View private.xml
<?xml version="1.0"?>
<name>Spanish to English Papercuts</name>
<name>Swap '§' and '`'</name>
<autogen>__KeyToKey__ KeyCode::UK_SECTION, KeyCode::BACKQUOTE</autogen>
<autogen>__KeyToKey__ KeyCode::BACKQUOTE, KeyCode::UK_SECTION</autogen>
View .screenrc
term xterm-color
altscreen on
hardstatus on
hardstatus alwayslastline
startup_message off
termcapinfo xterm ti@:te@
hardstatus string "%{= kG}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a "
peregrinogris / GrayZone.css
Created Jul 1, 2013
My own take on GrayZone theme for LimeChat.
View GrayZone.css
html {
font: 13px/1.3em 'Lucida Grande' sans-serif;
background-color: #eee;
color: #333;
word-wrap: break-word;
margin: 0;
padding: 0;
body {
def countComb(coins, change, solutions, current):
ret = 0
if sum(current) < change:
for coin in coins:
newComb = [c for c in current]
ret += countComb(coins, change, solutions, newComb)
if sum(current) == change:
if current not in solutions:
peregrinogris / addScores.js
Created Jun 3, 2013
Klout Score Grouper. Requires `request` nodejs module, and you have to edit the file to add your Klout API key and the twitter handles you want to query Klout for scores.
View addScores.js
var request = require('request');
var api_key = "<KLOUT_API_KEY>";
var handles = ["user1", "user2"];
var twitter_url = "";
var klout_url = "";
var user, sum = 0, idx = 0;
function addUpUser(){
View .bash_profile
export CLICOLOR=1
# Modifies PS1 when called (to fix line-wrapping issues)
hg_branch() {
red=$(tput setaf 1)
reset=$(tput sgr0)
branch=`hg branch 2> /dev/null | awk '{print $1}'`
if [[ -n $branch ]]; then
PS1="$PS1 \[$red\](\[$reset\]$branch\[$red\])\[$reset\]"
peregrinogris / .gitconfig
Last active Jun 15, 2016
Git Config Files
View .gitconfig
st = status
ci = commit
co = checkout
di = diff -w
dic = diff -w --cached
ll = log --date local --no-merges --format='%C(yellow)%h%Creset %ad %Cgreen%aN%Creset %s'
forgot = commit --amend -C HEAD
branches = branch -av
fbranch = !git ll master..`git rev-parse --abbrev-ref HEAD`

Installing Scrapy

sudo apt-get install libxml2-dev libxslt-dev
pip install scrapy
pip install python-dateutil

Running Scrapy

When running scrapy, this bash script is handy:

View .bashrc
# screen
which screen > /dev/null
if [[ -n "$SSH_CONNECTION" && -z "$STY" && "$SCREEN" -eq "0" ]]; then
# Screen is not currently running, but we are in SSH, so start a session
exec screen -D -R
peregrinogris /
Created Mar 4, 2013
Split text into sentences and output that json.
from BeautifulSoup import BeautifulSoup
import json
import sys
if len(sys.argv) < 2:
print sys.argv[0] + ' <input file>'
in_file = sys.argv[1]
if len(sys.argv) < 3:
tag = 'div'