Skip to content

Instantly share code, notes, and snippets.

View pedrombafonso's full-sized avatar
👨‍💻

Pedro Baptista Afonso pedrombafonso

👨‍💻
  • London, United Kingdom
View GitHub Profile
@pedrombafonso
pedrombafonso / .eslintrc
Created May 22, 2016 21:11 — forked from cletusw/.eslintrc
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names
@pedrombafonso
pedrombafonso / 0_reuse_code.js
Last active August 29, 2015 14:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@pedrombafonso
pedrombafonso / liveclicker.js
Created December 13, 2014 00:38
LiveClicker Video - Random code helpers for liveclicker
// checks play time
var checkTimeInterval = 500;
setInterval(function detectVideoPlay() {
try {
var player = $('embed', $el)[0];
if (player.getSettings().playTime > Number($el.data('duration'))) {
pause(element);
}
} catch(e) { }
}, checkTimeInterval);
@pedrombafonso
pedrombafonso / ge.tmux
Created April 22, 2014 15:42
tmux config for launching development tools
#!/bin/bash
shopt -s expand_aliases
source ~/.bash_profile;
PROJ_ROOT='~/dev/minuscode/dev/gitescrow/proj'
cd $PROJ_ROOT;
gco develop;
@pedrombafonso
pedrombafonso / statistics-distributions.js
Last active January 4, 2016 00:19 — forked from benrasmusen/statistics-distributions.js
Statistics distributions module for node.js
/*
* NAME
*
* statistics-distributions.js - JavaScript library for calculating
* critical values and upper probabilities of common statistical
* distributions
*
* SYNOPSIS
*
*
@pedrombafonso
pedrombafonso / quick_sort.js
Created May 29, 2013 09:01
Quick sort Sorts JSON complex type arrays by property
function partition ( list, prop, begin, end, pivot ) {
var piv = list[pivot];
swap (list, pivot, end-1 );
var store = begin;
var ix;
for ( ix = begin; ix < end - 1; ++ix ) {
if ( list[ix][prop] <= piv[prop] ) {
swap (list, store, ix );
++store;
}
@pedrombafonso
pedrombafonso / cleanObject.js
Last active December 16, 2015 12:28
Cleans JSON objects by removing undesired properties and promoting nested objects (set parent = child) recursively.
/*
@function cleanObject - Cleans javascript objects recursively (removes and promotes [parent = child] properties)
@param {Object} obj - Object to be clean
@param {Array} toRemove - array composed by the property names to be removed
@param {Array} toPromote - array composed by the property names to be promoted to the parent's value
*/
function cleanObject(dirtyObj, toRemove, toPromote) {
var obj = JSON.parse(JSON.stringify(dirtyObj));
var itemsObj;
var o;