Skip to content

Instantly share code, notes, and snippets.

View ivancorrales's full-sized avatar
🐾
Doing what I love to do!

Iván Corrales Solera ivancorrales

🐾
Doing what I love to do!
View GitHub Profile
@ivancorrales
ivancorrales / Vagrantfile
Created June 18, 2015 07:09
Vagrantfile for running mongo mysql and postgresql with docker-compose
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024", "--cpus", "2"]
end
@ivancorrales
ivancorrales / setUp.go
Created June 18, 2015 09:40
Go script to create workspace structure
package main
import(
"fmt"
"os"
"runtime"
"path/filepath"
)
@ivancorrales
ivancorrales / curried-functions.js
Created October 25, 2015 19:55
Curried javascript functions example
#!/usr/bin/env node
function add(param1){
return function(param2){
return param1+param2;
}
}
function substract(param1){
@ivancorrales
ivancorrales / gist:d108cc0dccc1fad460ae
Created December 5, 2015 06:53
Avoiding using if-else statements
function _ifElseFn(condition, cb, cb2){
var result = {true:cb,false:cb2};
return result[condition]();
}
function sayYourCarIsOld(){
console.log('your car is old');
}
function sayYourCarIsNew(){
@ivancorrales
ivancorrales / first-steps-with-erlang.erl
Created January 29, 2016 06:29
Basic example of creating a record and iterating over a list of elements.
-module(poc).
-export([all/0,say_hello/1]).
-record(person,{name,genre,age}).
new_person(Name, Genre, Age) ->
#person{name=Name, genre=Genre, age=Age}.
isOlderThanAveragePeople(Age,AverageAge)->
Age>=AverageAge.
@ivancorrales
ivancorrales / shopping-cart.js
Last active March 7, 2016 19:03
Re-factor the code in a functional-programming way
var shoppingCartTotalPrice = (function(){
var items = [
{
name:'Domus IPA',
amount:3,
unitPrice:2.5,
},
{
name:'Cibeles',
@ivancorrales
ivancorrales / dates-001.js
Last active March 14, 2016 12:44
calculate days and months from a month and a number of days
var task = (function(){
var _days = [31,28,31,30,31,30,31,31,30,31,30,31];
function addDays(date,days){
date.setDate(date.getDate() + days);
return date;
}
function isLeapYear(year){
@ivancorrales
ivancorrales / app.py
Last active April 24, 2016 06:23
Basic falcon rest api
# app.py
__author__ = "Iván Corrales Solera <developer@wesovi.com>"
__written_date = "23/04/2016"
import falcon
class BookResource(object):
# app.py
__author__ = "Iván Corrales Solera <developer@wesovi.com>"
__written_date = "23/04/2016"
import falcon
from resources.books import BookResource
# app.py
__author__ = "Iván Corrales Solera <developer@wesovi.com>"
__written_date = "23/04/2016"
import falcon
from resources.books import BookResource