Skip to content

Instantly share code, notes, and snippets.

View fedeisas's full-sized avatar
🎯

Fede Isas fedeisas

🎯
  • Buenos Aires, Argentina
View GitHub Profile
% Fibonacci numbers
% The Fibonacci sequence is given by 0, 1, 1, 2, 3, 5, … where subsequent values are given by adding the two previous values in the sequence.
%
% Give a recursive definition of the function fib/1 computing the Fibonacci numbers, and give a step-by-step evaluation of fib(4).
%
% Usage:
% lists:map(fun(X) -> fibonacci:fib(X) end, lists:seq(0, 10)).
-module(fibonacci).
-export([fib/1]).
-module(maxThree).
-export([maxThree/3]).
maxThree(X, X, X) ->
X;
maxThree(X, X, Y) ->
case max(X, Y) of
X -> X;
Y -> Y
-module(howManyEqual).
-export([howManyEqual/3]).
rm_dup(List) ->
lists:foldl(
fun(Elem, Acc) ->
case lists:member(Elem, Acc) of
true ->
Acc;
false ->
@fedeisas
fedeisas / bubble_sort.py
Last active February 17, 2017 19:19
Python Bubblesort
import unittest
def bubblesort(input):
swapped = True
while swapped:
swapped = False
for i in xrange(0, len(input) - 1):
if input[i] > input[i + 1]:
swapped = True
@fedeisas
fedeisas / conway.php
Created December 12, 2016 00:11
Simple Conway's Game of Life
<?php
/**
* Conway's Game of Life
* @see https://en.wikipedia.org/wiki/Conway's_Game_of_Life
*/
define('SIZE', 36);
define('DISPLAY_ALIVE', '☼');
define('DISPLAY_DEAD', ' ');
define('DISPLAY_NEWLINE', PHP_EOL);
@fedeisas
fedeisas / fflush.php
Created March 22, 2016 15:33
SplFileObject::fflush
<?php
touch('/path/to/file.csv');
chmod('/path/to/file.csv', 0777);
$spl = new \SplFileObject('/path/to/file.csv');
foreach ([
[1, 2, 3],
[4, 5, 6],
] as $url) {
$spl->fputcsv($url);
}
@fedeisas
fedeisas / query.sql
Created October 27, 2015 21:18
Query para armar dataset Laboratorio de Implementación II
SELECT
cliente.cid AS cliente_cid,
cliente.monto_sucursal_1 AS cliente_monto_sucursal_1,
cliente.monto_sucursal_2 AS cliente_monto_sucursal_2,
cliente.monto_sucursal_3 AS cliente_monto_sucursal_3,
cliente.monto_sucursal_4 AS cliente_monto_sucursal_4,
cliente.promociones AS cliente_promociones,
cliente.dias_cliente AS cliente_dias_cliente,
cliente.sucursales AS cliente_sucursales,
cliente.promos_enviadas AS cliente_promos_enviadas,
norm_vec <- function(x) sqrt(sum(x^2))
x <- c(0.3, 0.4, 0.5, 0.6)
c12 <- c(0.1, 0.1, 0.1, 0.1)
c13 <- c(0.2, 0.2, 0.2, 0.2)
w10 <- 0.1
w12 <- 0.2
w13 <- 0.3
angular.module('api', [])
.factory('Photos', ['$http', function ($http) {
return {
items: [],
busy: true,
stadium_id: null,
max_id: null,
hasMore: true,
resetItems: function () {
this.items = [];
hash: {
options: {
mapping: 'public/assets.json',
flatten: false,
hashLength: 8,
hashFunction: function(source, encoding) {
return require('crypto').createHash('sha1').update(source, encoding).digest('hex');
}
},
js: {