Skip to content

Instantly share code, notes, and snippets.

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 Jun 18, 2015
Vagrantfile for running mongo mysql and postgresql with docker-compose
View Vagrantfile
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 Jun 18, 2015
Go script to create workspace structure
View setUp.go
package main
import(
"fmt"
"os"
"runtime"
"path/filepath"
)
@ivancorrales
ivancorrales / curried-functions.js
Created Oct 25, 2015
Curried javascript functions example
View curried-functions.js
#!/usr/bin/env node
function add(param1){
return function(param2){
return param1+param2;
}
}
function substract(param1){
@ivancorrales
ivancorrales / gist:d108cc0dccc1fad460ae
Created Dec 5, 2015
Avoiding using if-else statements
View gist:d108cc0dccc1fad460ae
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 / shopping-cart.js
Last active Mar 7, 2016
Re-factor the code in a functional-programming way
View shopping-cart.js
var shoppingCartTotalPrice = (function(){
var items = [
{
name:'Domus IPA',
amount:3,
unitPrice:2.5,
},
{
name:'Cibeles',
@ivancorrales
ivancorrales / dates-001.js
Last active Mar 14, 2016
calculate days and months from a month and a number of days
View dates-001.js
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 Apr 24, 2016
Basic falcon rest api
View app.py
# app.py
__author__ = "Iván Corrales Solera <developer@wesovi.com>"
__written_date = "23/04/2016"
import falcon
class BookResource(object):
View app.py
# app.py
__author__ = "Iván Corrales Solera <developer@wesovi.com>"
__written_date = "23/04/2016"
import falcon
from resources.books import BookResource
View app.py
# app.py
__author__ = "Iván Corrales Solera <developer@wesovi.com>"
__written_date = "23/04/2016"
import falcon
from resources.books import BookResource
View model.py
class Book(object):
def __init__(self,title,author,id=None):
self.id = id
self.title=title
self.author=author