This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#You need to enable i2c port | |
#sudo raspi-config | |
# Choose option: (8) Advanced Options | |
# A7 I2C and then enable yes. | |
#sudo reboot | |
#Update and install python rpi | |
sudo apt-get update | |
sudo apt-get dist-upgrade |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var x = [ {node: "ip2", app: "dbsyncer", containerId: "1234"}, | |
{node: "ip2", app: "logforwa", containerId: "3423"}, | |
{node: "ip4", app: "dbsyncer", containerId: "2213"}, | |
{node: "ip4", app: "logforwa", containerId: "3434"} ] | |
var newObj = {}; | |
x.forEach(function (item) { | |
newObj[item.node] = newObj[item.node] || []; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Simulation | |
var world = {gravity: 9.8, intervalTime: 100, verticalLimit: 600, dt: 0.1} | |
function simulation (obj) { | |
var t = 0, top = 0; | |
var interval = setInterval(function () { | |
if(top>world.verticalLimit) clearInterval(interval); | |
top += (world.gravity*obj.mass)*t; | |
obj.el.style.top = top+"px"; | |
t += world.dt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//StackOverflow: | |
//http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb | |
//Solution 1. | |
////////////////////////////////////////////// | |
function rgbToHex(r, g, b) { | |
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); | |
} | |
////////////////////////////////////////////// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Inheritance | |
var Mass = function () {this.material = "rock"; console.log("init Mass")}; | |
var Planet = function (name) {Mass.call(this); this.name = name || "Planet"; console.log("init "+this.name)}; | |
Planet.prototype = Object.create(Mass.prototype); | |
Planet.prototype.constructor = Planet; | |
var earth = new Planet("earth"); | |
// Second Way |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hablar sobre variables(fuerte tipado), | |
luego funciones (como se crean function, var function, arrow function), | |
luego scopes (var, const, let) | |
luego variables como templates | |
Classes, interfaces, herencia (polimorfismo, encapsulamient) | |
luego hablar sobre OOP con classes y extend | |
vs functional programing( fp are verbs, oop is nouns) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mapValues(obj, fn) { | |
return Object.keys(obj).reduce((result, key) => { | |
result[key] = fn(obj[key], key); | |
return result; | |
}, {}); | |
} | |
function pick(obj, fn) { | |
return Object.keys(obj).reduce((result, key) => { | |
if (fn(obj[key])) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const add = (list, item) => { | |
return […list, item] | |
} | |
const remove = (list, index) => { | |
return [ | |
…list.slice(0,index), | |
…list.slice(index+1) | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//based on https://github.com/krasimir/absurd/blob/master/lib/processors/html/helpers/TemplateEngine.js | |
//Basic | |
var TemplateEngine = function(tpl, data) { | |
var re = /<%(.+?)%>/g, match; | |
while(match = re.exec(tpl)) { | |
tpl = tpl.replace(match[0], data[match[1]]) | |
} | |
return tpl; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
const counter = (state = { value: 0 }, action) => { | |
switch (action.type) { | |
case 'INCREMENT': | |
return { value: state.value + 1 }; | |
case 'DECREMENT': | |
return { value: state.value - 1 }; | |
default: | |
return state; |
OlderNewer