Skip to content

Instantly share code, notes, and snippets.

View peregrinogris's full-sized avatar
🧉
Drinking mate

Hernán Rodríguez Colmeiro peregrinogris

🧉
Drinking mate
View GitHub Profile
@peregrinogris
peregrinogris / private.xml
Last active July 25, 2016 19:54
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)
<?xml version="1.0"?>
<root>
<item>
<name>Spanish to English Papercuts</name>
<item>
<name>Swap '§' and '`'</name>
<identifier>private.spanish_english_papercuts_backquote</identifier>
<autogen>__KeyToKey__ KeyCode::UK_SECTION, KeyCode::BACKQUOTE</autogen>
<autogen>__KeyToKey__ KeyCode::BACKQUOTE, KeyCode::UK_SECTION</autogen>
</item>
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
peregrinogris / GrayZone.css
Created July 1, 2013 14:09
My own take on GrayZone theme for LimeChat.
html {
font: 13px/1.3em 'Lucida Grande' sans-serif;
background-color: #eee;
color: #333;
word-wrap: break-word;
margin: 0;
padding: 0;
}
body {
@peregrinogris
peregrinogris / countComb.py
Last active December 18, 2015 11:39
count coins
def countComb(coins, change, solutions, current):
ret = 0
if sum(current) < change:
for coin in coins:
newComb = [c for c in current]
newComb.append(coin)
ret += countComb(coins, change, solutions, newComb)
if sum(current) == change:
current.sort()
if current not in solutions:
@peregrinogris
peregrinogris / addScores.js
Created June 3, 2013 21:40
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.
var request = require('request');
var api_key = "<KLOUT_API_KEY>";
var handles = ["user1", "user2"];
var twitter_url = "http://api.klout.com/v2/identity.json/twitter?screenName=";
var klout_url = "http://api.klout.com/v2/user.json/:klout_id/score?";
var user, sum = 0, idx = 0;
function addUpUser(){
@peregrinogris
peregrinogris / .bash_profile
Last active May 1, 2018 23:05
My .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\]"
fi
@peregrinogris
peregrinogris / .gitconfig
Last active June 15, 2016 14:29
Git Config Files
[alias]
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:

# screen
which screen > /dev/null
SCREEN=($?)
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
fi
@peregrinogris
peregrinogris / process.py
Created March 4, 2013 22:08
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>'
else:
in_file = sys.argv[1]
if len(sys.argv) < 3:
tag = 'div'