Skip to content

Instantly share code, notes, and snippets.

View ferreiro's full-sized avatar
👨‍🎤
Dancing in the rain

Jorge Ferreiro ferreiro

👨‍🎤
Dancing in the rain
View GitHub Profile
# MapReduce: gasto total realizado por las mujeres que han realizdo EXACTAMENTE
# 3 compras.
@get('/spending_female_3_orders_mr')
def spending_female_3_orders_mr():
mapper = Code("""
function countryMap()
{
if (this.gender == "Female") {
@ferreiro
ferreiro / BinomialCoefficient.js
Created August 29, 2015 11:32
Binomial coefficient in javascript
// Binomial coefficient
// Credits: github.com/jgferreiro
examples();
function examples() {
var a, b; // numerator and denominator of our coeffiecient
a = 2; b = 1;
console.log('Binomial for a = ' + a + " and b = "+ b + ' is ' + binomialCoefficient(a, b));
@ferreiro
ferreiro / poissonDistribution.js
Last active February 8, 2024 13:48
Poisson distribution formula in javascript
var k_total = 10; // number of times the event is repeated
var landa = 8; // Promedian number of error expected in a given time (Landa symbol)
var exponential = 2.718281828;
var total = 0;
var numerator, denominator;
// Sumatorio de k terminos usando la formula de poisson
function poisson(k, landa) {
@ferreiro
ferreiro / TextFrecuency
Last active August 29, 2015 14:27
Code for extracting all the words on a webpage and get the absolute frecuency of that elements
var words = (function(){
var sWords = document.body.innerText.toLowerCase().trim().replace(/[.,;?¿@]/g,' ').split(/[\s\/]+/g).sort();
var iWordsCount = sWords.length; // count w/ duplicates
// array of words to ignore
var ignore = ['and','the','to','a','of','for','as','i','with','it','is','on','that','this','can','in','be','has','if',
'de', 'del', 'y', 'en', 'que', 'para', 'tu', 'con', 'su', 'mas', 'o',
'el','te', 'ti', 'un', 'lo', 'los', 'la', 'las', 'una', 'más', 'sus', 'este', 'desde', 'tras',
@ferreiro
ferreiro / probabilityMedian.js
Last active August 29, 2015 14:27
Cheat mathematics: Simple programs to make my "Probabilty and staditics" problems for the university.
// Calculate the mean of a set.
var i;
var result = 0;
var data = [1, 2, 3, 4, 5, 6, 7, 8, 9]; // age.
var absFrec = [9, 8, 7, 6, 5, 4, 3, 2, 1]; // absolute frecuency.
var N = 0; // Total value of the set.
for (i = 0; i < data.length; i++) {
N += absFrec[i];