Skip to content

Instantly share code, notes, and snippets.

View soundyogi's full-sized avatar
🦊

KaiserMerkle soundyogi

🦊
View GitHub Profile
@soundyogi
soundyogi / example.js
Created January 13, 2017 16:38 — forked from zachstronaut/example.js
Support for 1 - 4 Gamepad Controllers in Impact.js for Local Multiplayer Games
// bind keyboard and gamepad buttons
ig.input.bind( ig.KEY.X, 'shoot1');
ig.input.bind( ig.GAMEPAD1.FACE_1, 'shoot1');
ig.input.bind( ig.GAMEPAD2.FACE_1, 'shoot2');
ig.input.bind( ig.GAMEPAD3.FACE_1, 'shoot3');
ig.input.bind( ig.GAMEPAD4.FACE_1, 'shoot4');
@soundyogi
soundyogi / command.js
Created January 18, 2017 01:39 — forked from sword-jin/command.js
JavaScript Command Pattern -- es5
function Calculator () {
this._currentValue = 0;
this.commands = [];
}
Calculator.prototype = {
execute: function(command) {
this._currentValue = command.execute(this._currentValue);
this.commands.push(command);
},
@soundyogi
soundyogi / Gamepad.js
Created January 20, 2017 17:12 — forked from videlais/Gamepad.js
Complete Gamepad.js code
/**
* (Note: Depends on window.requestAnimationFrame for polling.)
*
* An experimental Gamepad object for detecting
* and parsing gamepad input.
*
* Current code borrows heavily from Marcin Wichary's work:
* http://www.html5rocks.com/en/tutorials/doodles/gamepad/
*
* Also uses deadzone values from
@soundyogi
soundyogi / reducers.js
Created January 23, 2017 20:37 — forked from gaearon/reducers.js
How I'd do code splitting in Redux (pseudo code, not tested!)
import { combineReducers } from 'redux';
import users from './reducers/users';
import posts from './reducers/posts';
export default function createReducer(asyncReducers) {
return combineReducers({
users,
posts,
...asyncReducers
});
@soundyogi
soundyogi / general-purpose-reducers.js
Created February 10, 2017 01:55 — forked from crisu83/general-purpose-reducers.js
General-purpose reducers for Redux.
/**
* This gist was inspired by the video course titled "Building React Applications with Idiomatic Redux"
* available on Egghead.io by the creator of Redux, Dan Abramov.
*
* The purpose of this gist is to demonstrate general purpose reducers that can be used via Redux's combineReducers
* to compose more complex reducers and therefore maximize code reuse.
*
* Feedback is more than welcome!
*
* @author Christoffer Niska <christofferniska@gmail.com>
@soundyogi
soundyogi / main.es6
Created April 1, 2017 22:20 — forked from mfellner/main.es6
Playing with RxJS Observables and ES6
const Rx = require('Rx');
require('babel/register');
const Observables = require('./observables.es6');
// Define a very simple, router-like object
class Router {
constructor() {
this.routes = {};
}
@soundyogi
soundyogi / stack_trace.py
Created April 2, 2017 20:33 — forked from socrateslee/stack_trace.py
A Stack Trace Decorator of Python Functions
import sys
import functools
'''
Usage:
consider following functions
import stack_trace
def foo():
pass
def bar():
import { matchPath } from 'react-router';
class MainRouter extends Component {
static displayName = 'MainRouter';
static propTypes = {
store: React.PropTypes.object,
component: React.PropTypes.oneOfType([
React.PropTypes.element,
React.PropTypes.func,
])
@soundyogi
soundyogi / Enhance.js
Created April 5, 2017 14:23 — forked from sebmarkbage/Enhance.js
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@soundyogi
soundyogi / stuns
Created April 6, 2017 03:44 — forked from yetithefoot/stuns
STUN+TURN servers list
{url:'stun:stun01.sipphone.com'},
{url:'stun:stun.ekiga.net'},
{url:'stun:stun.fwdnet.net'},
{url:'stun:stun.ideasip.com'},
{url:'stun:stun.iptel.org'},
{url:'stun:stun.rixtelecom.se'},
{url:'stun:stun.schlund.de'},
{url:'stun:stun.l.google.com:19302'},
{url:'stun:stun1.l.google.com:19302'},
{url:'stun:stun2.l.google.com:19302'},