Skip to content

Instantly share code, notes, and snippets.

Avatar
🧉
Drinking mate

Hernán Rodríguez Colmeiro peregrinogris

🧉
Drinking mate
View GitHub Profile
@peregrinogris
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"?>
<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>
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
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 {
View countComb.py
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 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 = "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(){
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\]"
fi
@peregrinogris
peregrinogris / .gitconfig
Last active Jun 15, 2016
Git Config Files
View .gitconfig
[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`
View scrapy.md

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
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 Mar 4, 2013
Split text into sentences and output that json.
View process.py
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'