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 / main-tuples.rs
Last active July 19, 2018 19:54
Twelve Days of Christmas implementation in Rust.
fn main() {
let gifts = [
("First", "a Partridge in a Pear Tree"),
("Second", "Two Turtle Doves"),
("Third", "Three French Hens"),
("Fourth", "Four Calling Birds"),
("Fifth", "Five Gold Rings"),
("Sixth", "Six Geese a-Laying"),
("Seventh", "Seven Swans a-Swimming"),
("Eighth", "Eight Maids a-Milking"),
@peregrinogris
peregrinogris / README.md
Created April 8, 2018 15:49
Updating GNU screen on Raspbian

Updating GNU screen on Raspbian

I've been frustrated for a few years that GNU screen didn't have emoji support but I just rechecked the issue... And guess what? It's fixed as of version 4.6.0!! While this is great news, the last available version in raspbian is 4.1.0, meaning that yes, we have to compile.

Compiling

The steps are easy:

# name an email address in all old commits.
# WARNING: Will change all your commit SHA1s.
# Based off of the script from here:
# http://coffee.geek.nz/how-change-author-git.html
git filter-branch -f --commit-filter '
if [ "$GIT_COMMITTER_EMAIL" = "<INITIAL-EMAIL>" ];
then
GIT_AUTHOR_EMAIL="<FINAL-EMAIL>";
git commit-tree "$@";
else
'.source.js':
'i18n translation singular':
'prefix': 'i18'
'body': '{i18n.gettext(\'$1\')}$2'
'i18n translation plural':
'prefix': 'i18n'
'body': '{i18n.ngettext(\'$1\', \'$2\', ${3:idx})}$4'
'New test suite':
'prefix': 'newtest'
'body': """
@peregrinogris
peregrinogris / make-leanpub.py
Created August 18, 2016 14:04
Build a leanpub book source to epub, using pandoc
with open("Book.txt") as f:
print ('echo "Starting build of {book}.epub";'
"pandoc {files} " +
"--smart --table-of-contents --chapters -o {book}.epub;"
'echo " {book}.epub created."'
).format(book="Book", files=f.read().replace("\n", " "))
@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 / 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');