Skip to content

Instantly share code, notes, and snippets.

View carlosvega20's full-sized avatar

Carlos Vega carlosvega20

  • San Francisco, CA
View GitHub Profile
@carlosvega20
carlosvega20 / .zshrc
Last active July 11, 2018 13:46
Zsh config
# Path to Oh-My-Zsh installation
export ZSH="/Users/carlosvega/.oh-my-zsh"
# Plugins
plugins=(git)
source $ZSH/oh-my-zsh.sh
PROMPT='$fg[yellow]$(echo "${PWD/$HOME/~}") $fg[cyan]$(git_prompt_info) $fg[magenta]$(node_version)
$reset_color$ '
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<input/>
<script id="jsbin-javascript">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>RXJS test</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/5.5.6/Rx.min.js"></script>
</head>
<body>
<input/>
<script id="jsbin-javascript">
@carlosvega20
carlosvega20 / Counter.js
Last active November 1, 2016 14:15 — forked from gaearon/Counter.js
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;
//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;
}
const add = (list, item) => {
return […list, item]
}
const remove = (list, index) => {
return [
…list.slice(0,index),
…list.slice(index+1)
]
}
@carlosvega20
carlosvega20 / slim-redux.js
Created December 11, 2015 06:17 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
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])) {
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)
@carlosvega20
carlosvega20 / Js Inheritance
Created December 4, 2015 06:10
prototype chain
//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
//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);
}
//////////////////////////////////////////////