Skip to content

Instantly share code, notes, and snippets.

View cristobal's full-sized avatar
💭
¯\_(ツ)_/¯

Cristobal Dabed cristobal

💭
¯\_(ツ)_/¯
View GitHub Profile
@cristobal
cristobal / function.bind.js
Created August 25, 2014 14:46
JavaScript bind
// If you don't need new for bound functions do this
function bind(fn, c) {
if (Function.prototype.bind &&
fn.bind === Function.prototype.bind) {
return Function.prototype.bind.apply(fn,
Array.prototype.slice.call(arguments, 1));
}
var args = Array.prototype.slice.call(arguments, 2);
return function () {
@cristobal
cristobal / bashrc_ccze.sh
Created August 26, 2014 12:27
Colorize with CCZE
# CCZE Colourize Config for Centos
# http://lintut.com/colorize-log-files-on-linux-using-ccze-tool/
# http://www.tecmint.com/how-to-enable-epel-repository-for-rhel-centos-6-5/
CCZE=`which ccze`
if [ "$TERM" != dumb ] && [ -n "$CCZE" ]
then
function colourify { `$@` | $CCZE -A }
alias colourify=colourify
alias configure='colourify ./configure'
@cristobal
cristobal / brew_get_home_path_formula.sh
Last active August 29, 2015 14:07
Brew Get Home Path for a FORMULA
function brew_get_home_path_formula {
echo $(brew info ${1} | grep -E -o "/usr/local/Cellar/${1}/(\d+\.?)+")
}
## i.e. set GRADLE_HOME in .bashrc
export GRADLE_HOME=$(brew_get_home_path_formula gradle)/libexec
@cristobal
cristobal / notin.py
Created October 15, 2014 08:59
Diff lines from file a and b, all lines from b that are not in a will be displayed
#!/usr/bin/env python
import sys
def get_tokens(src):
file = open(src)
return [token.strip(' \t\n\r') for token in file.readlines()]
def diff_tokens(a, b):
return [x for x in a if x not in b]
@cristobal
cristobal / sort_asc.js
Last active August 29, 2015 14:16
Insertion Sort
function sort_asc(values) {
var n = values.length;
for (var i = 1; i < n; i++) {
var v = values[i];
var k = i - 1;
while (k >= 1 && v > values[k]) {
values[k + 1] = values[i];
k = k - 1;
}
@cristobal
cristobal / propel_session_config.php
Created April 20, 2015 12:20
Silex - Propel + Session in DB
<?php
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
use Propel\Runtime\Propel;
use Propel\Runtime\Connection\ConnectionWrapper;
use Propel\Runtime\Connection\PdoConnection;
use Propel\Silex\PropelServiceProvider;
//--------------------------------------
@cristobal
cristobal / machine-diskutil.sh
Last active November 2, 2024 08:05
Machine Diskutil to mount/unmont external volumes inside docker machines running on Virtualbox
#!/usr/bin/env sh
# @see http://stackoverflow.com/questions/30040708/how-to-mount-local-volumes-in-docker-machine
# @see https://github.com/boot2docker/boot2docker/blob/master/doc/FAQ.md
################################################################################
# Dependency Section #
# #
################################################################################
check_deps() {
## Make sure commands are available
@cristobal
cristobal / # mosml - 2016-03-19_16-50-37.txt
Created March 19, 2016 19:53
mosml on OS X 10.11.3 - Homebrew build logs
Homebrew build logs for mosml on OS X 10.11.3
Build date: 2016-03-19 16:50:37

Keybase proof

I hereby claim:

  • I am cristobal on github.
  • I am cristobal (https://keybase.io/cristobal) on keybase.
  • I have a public key ASAs5cvXRdcF-ajmMlIOsVqdbEkEVN0SUSEyZUPhWZ0OAgo

To claim this, I am signing this object:

@cristobal
cristobal / reduce-promises-over-x.js
Created September 1, 2016 11:42
Reduce a set of promises (S) over a a value x
const reducePromises = (S, x) =>
S.reduce((f, g) => f.then(g), Promise.resolve(x));