Skip to content

Instantly share code, notes, and snippets.

View chl03ks's full-sized avatar
🍊
Working from home

Dan Garcia chl03ks

🍊
Working from home
View GitHub Profile
const players = (state = [{ id: 1, level: 10 }], action) => {
if (action.type === 'LEVEL_UP') {
return state.map(player => {
if(player.id !== action.id) return state;
return { ...player, level: player.level + 1 }
})
} else if (action.type === 'LEVEL_DOWN') {
return state.map(player => {
if(player.id !== action.id) return state;
return { ...player, level: player.level - 1 }
/* Action to be dispatched */
{
type: 'LEVEL_UP',
id: 1,
}
/* State Tree */
{
players: [{
id: 1,
level: 10
},{
id: 2,
level: 20
}]
}
@chl03ks
chl03ks / buildspec.yml
Created October 11, 2017 19:48 — forked from marcelog/buildspec.yml
Example for buildspec file for Amazon CodeBuild and Amazon CodePipeline to achieve Continuous Integration and Continuous Delivery for a ServerLess project
version: 0.1
phases:
install:
commands:
- printenv
- npm install
build:
commands:
- npm run build
@chl03ks
chl03ks / pull-request-template.md
Created September 26, 2017 21:45 — forked from Lordnibbler/pull-request-template.md
Sample Pull Request Template

Status

READY/IN DEVELOPMENT/HOLD

Migrations

YES | NO

Description

A few sentences describing the overall goals of the pull request's commits.

Related PRs

@chl03ks
chl03ks / .vimrc
Created August 31, 2017 16:54
.VIMRC
"Custom vimrc file based on vim-sublime
set shell=/bin/sh
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'tpope/vim-surround'
interface Callback { (data: any): void; }
declare class EventSource {
onmessage: Callback;
addEventListener(event: string, cb: Callback): void;
constructor(name: string);
}
@chl03ks
chl03ks / custom-eventemitter1.js
Created March 31, 2017 22:32 — forked from dominicbartl/custom-eventemitter1.js
2 ways to inherit from EventEmitter in Node.JS
var EventEmitter = require('events').EventEmitter;
module.exports = new EventEmitter();
exports.emitSomethingLater = function()
setTimeout(function() {
module.exports.emit('something');
}, 1000);
}
@chl03ks
chl03ks / database-module.js
Created February 8, 2017 18:34
Auto-migrate and Auto-update Promise Module loopback
const app = require('../server');
const log = require('debug')('boot:automigrate');
const path = require('path');
const env = process.env.NODE_ENV;
let datasources = require(path.resolve(__dirname, '../datasources.production.json'));
let models = path.resolve(__dirname, '../model-config.production.json')
@chl03ks
chl03ks / MySQL_macOS_Sierra.md
Created January 2, 2017 16:20 — forked from nrollr/MySQL_macOS_Sierra.md
Install MySQL on Sierra using Homebrew

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :