Skip to content

Instantly share code, notes, and snippets.

View dengjonathan's full-sized avatar

Jon Deng dengjonathan

View GitHub Profile
@dengjonathan
dengjonathan / curry.js
Created November 21, 2016 21:38
ramda curry
//Ramda
const R = require('ramda');
const giveProp = (propName, prop, obj) => Object.assign({}, obj, {[propName]: prop});
const givePropCurry = R.curry(giveProp);
const giveName = givePropCurry('name');
const giveJob = givePropCurry('job');
const giveHero = givePropCurry('hero');
const giveJobSmuggler = giveJob('smuggler')
@dengjonathan
dengjonathan / compose.js
Last active November 21, 2016 23:58
compose
const R = require('ramda');
const giveProp = (propName, prop, obj) => Object.assign({}, obj, {[propName]: prop});
const givePropCurry = R.curry(giveProp);
const giveName = givePropCurry('name');
const giveJob = givePropCurry('job');
const giveHero = givePropCurry('hero');
// Example 1: f(g(x))
@dengjonathan
dengjonathan / vanillaDom.html
Last active December 8, 2016 20:29
Vanilla DOM counter
<!DOCTYPE html>
<html>
<head>
<title>Vanilla JS MVC</title>
</head>
<body>
<div class="counter">
<button id="up">+</button>
<p id="count"></p>
<button id="down">-</button>
@dengjonathan
dengjonathan / vanillaMVC.html
Last active December 8, 2016 22:19
Vanilla MVC
<!DOCTYPE html>
<html>
<head>
<title>Backbone.js MVC</title>
</head>
<body>
<div id="app"></div>
<!-- App Dependencies -->
<script
src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>
@dengjonathan
dengjonathan / backbone.html
Last active December 8, 2016 22:21
Backbone Jquery MVC
<!DOCTYPE html>
<html>
<head>
<title>Backbone.js MVC</title>
</head>
<body>
<div id="app"></div>
<!-- App Dependencies -->
<script
src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>
@dengjonathan
dengjonathan / react.jsx
Last active December 8, 2016 22:56
React MVC
import React from 'react';
import ReactDOM from 'react-dom';
import {createStore} from 'redux';
import {connect, Provider} from 'react-redux';
/********************************REDUX*****************************************/
//default state
const INITIAL_STATE = {
value: 0
};
@dengjonathan
dengjonathan / react-redux.jsx
Created December 8, 2016 23:03
React Redux
import React from 'react';
import ReactDOM from 'react-dom';
import {createStore} from 'redux';
import {connect, Provider} from 'react-redux';
/********************************REDUX*****************************************/
//default state
const INITIAL_STATE = {
value: 0
};
@dengjonathan
dengjonathan / vanilladom.html
Last active December 9, 2016 03:18
Vanilla DOM
<!DOCTYPE html>
<html>
<head>
<title>Vanilla JS</title>
</head>
<body>
<div class="counter">
<button id="up">+</button>
<p id="count">0</p>
<button id="down">-</button>
@dengjonathan
dengjonathan / react.jsx
Created December 9, 2016 03:10
Counter React Example
// Counter.jsx
import React from 'react';
import ReactDOM from 'react-dom';
// PRESENTATIONAL COMPONENT: a simple stateless React View
const Button = ({onClick, label}) => (
<button onClick={onClick}>{label}</button>
);
// REACT COMPONENT: a stateful React View (stored in this.state)
<!DOCTYPE html>
<html>
<head>
<title>Vanilla JS MVC</title>
</head>
<body>
<div class="counter">
<button id="up">+</button>
<p id="count">0</p>
<button id="down">-</button>