Skip to content

Instantly share code, notes, and snippets.

View revington's full-sized avatar
🎸
hey ho lets go!

Pedro Narciso García Revington revington

🎸
hey ho lets go!
View GitHub Profile
@revington
revington / .vimrc
Last active January 20, 2020 09:47
vimrc
syntax on
filetype plugin indent on
let g:ale_fixers = {'php': ['phpcs --standard=PSR2']}
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:erl_author="Pedro Narciso García Revington"
'use strict';
// simple feistel network
function feistel(input) {
var l1, l2, r1, r2, i = 0;
l1 = (input >> 16) & 65535;
r1 = input & 65535;
for (i = 0; i < 3; i++) {
l2 = r1;
r2 = l1 ^ ((((1366 * r1 + 150889) % 1114111) / 1114111.0) * 32767);
l1 = l2;
@revington
revington / package.json
Last active June 9, 2016 11:31
package.json with bundle task including aerospike
{
"scripts": {
"test": "istanbul cover node_modules/mocha/bin/_mocha -- --bail --check-leaks test",
"bundle": "rm -rf node_modules; git rm -rf --cached node_modules; npm install --production --ignore-scripts && git add -f node_modules && npm rebuild && (cd node_modules/aerospike/aerospike-client-c/; rm -r include lib lua package/usr package/aerospike-client-c-libuv-*) && git add -f node_modules/aerospike/aerospike-client-c"
}
}
@revington
revington / mysql-container
Created June 3, 2016 08:15
mysql docker container start and wait until ready
#!/bin/bash
MYSQL_ROOT_PASSWORD=root
function docker_container_ip {
docker inspect "$1" | jq -r '.[0] | .NetworkSettings | .IPAddress'
}
echo "Run mysql container"
mysql_id=$(docker run -d -e MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD mysql)
@revington
revington / System Design.md
Created April 18, 2016 07:31 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@revington
revington / app.js
Last active August 29, 2015 14:15
app bootstrap
"use strict";
var express = require('express'),
nano = require('nano'),
path = require('path'),
compression = require('compression'),
favicon = require('serve-favicon'),
logger = require('morgan'),
cookieParser = require('cookie-parser'),
session = require('express-session'),
bodyParser = require('body-parser'),
@revington
revington / setup_upnp.sh
Last active March 24, 2018 18:15
upnp set up script
#!/bin/bash
export IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
echo "setting up ip ${IP}"
check_service(){
echo `upnpc -l | grep $1'->' | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"`
}
register(){
local service_name=$1
@revington
revington / delete-test-db.sh
Created January 20, 2014 15:01
Delete all my test db from couch db
#!/bin/bash
while read -r line; do
curl -X DELETE http://localhost:5984/$line
done < <( curl http://localhost:5984/_all_dbs 2> /dev/null | node -e "
process.stdin.setEncoding('utf8');
process.stdin.resume();
var buf = '';
process.stdin.on('data', function(chunk){
buf += chunk;
@revington
revington / launch-grid.sh
Last active April 12, 2018 17:59
launch selenium grid + phantomjs
#!/usr/bin/env sh
trap 'killall' INT
killall() {
trap '' INT TERM # ignore INT and TERM while shutting down
echo "**** Shutting down... ****" # added double quotes
kill -TERM 0 # fixed order, send TERM not INT
wait
echo DONE
}
@revington
revington / ssh-tunnel-couchdb-aws
Created June 6, 2013 10:29
ssh tunnel to couchdb futon on aws
ssh -Ni ./my_key.pem -L 5984:127.0.0.1:5984 ec2-user@xxxxxxamazon-instance.compute.amazonaws.com