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>
@peregrinogris
peregrinogris / max_search.py
Created June 27, 2016 17:49
Search for the maximum valid number in a range. Useful for scanning sequential ids and quickly (O(log(max_value))) find the maximum valid id.
class MaxSearch:
def __init__(self, max_value=2**16):
self.max_value = max_value
# Override this method with your validity check
def check_result(self, number):
pass
def scan(self, min_=0):
max_ = self.max_value
@peregrinogris
peregrinogris / keybase.md
Created June 23, 2016 03:16
Keybase proof

Keybase proof

I hereby claim:

  • I am peregrinogris on github.
  • I am peregrinogris (https://keybase.io/peregrinogris) on keybase.
  • I have a public key ASAZc3TC420CeX5vwpJmnILCDp64CP67AIxLC-P2NISSbgo

To claim this, I am signing this object:

@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`
@peregrinogris
peregrinogris / eslint.md
Created April 11, 2016 19:42
Configure eslint based on airbnb style guides for ES5/ES6/ES7

Install: $ npm install eslint babel-eslint eslint-config-airbnb

.eslintrc:

{
  "extends": "airbnb/base",
  "parser": "babel-eslint",
  "rules": {
 "max-len": [2, 80, 2, {
@peregrinogris
peregrinogris / pocket-links.js
Created March 20, 2016 15:57
Parse pocket links
<html>
<head>
<link rel="stylesheet" href="http://localhost:3000/build.css">
<!-- <script src="https://d2y1h8z11rh263.cloudfront.net/js/zepto.custom.js"></script> -->
</head>
<body>
<select id="timezone" name="timezone" class="select-control"><option value="America/Sao_Paulo">Brasilia</option></select>
<input type=reset>
<script type="text/javascript">
var select = document.createElement('select');
@peregrinogris
peregrinogris / .eslintignore
Last active February 24, 2016 19:10
Eslint error testcase
foo.js
@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(){