Instantly share code, notes, and snippets.

View rewind-buffer.js
'use strict';
class Frame {
constructor(samples){
// A single frame == 1 second of audio with a 44100 sample rate
this.prev = null;
this._next = null;
// this.samples = samples || new Float32Array(44100);
this.samples = samples || [];
this.callbacks = [];
View es6-spread-immutable-cheatsheet.md

update object

var state = {
    id: 1,
    points: 100,
    name: "Goran"
};

var newState = {
View with-reducer.js
import React, { Component } from 'react';
export const withReducer = (
stateName = 'internalState',
dispatchName = 'internalDispatch',
reducer = (state) => state,
View with-lifecycle.js
import React, { Component } from 'react';
export const withLifecycle = (hooks) => (BaseComponent) => {
return class WithLifecycle extends Component {
componentWillMount() {
hooks.willMount && hooks.willMount(this.props);
}
View utils.js
const compose = (...funcs) => (value) => funcs.reduce((v, fn) => fn(v), value);
const typeValueAction = (type) => (value) => ({ type, value });
View osx-for-hackers.sh
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
View pre-commit
#!/bin/bash
# find the changed files, get the name only and pipe result to a while loop
git diff --cached --name-only | while read FILE; do
# ff file matches extension pattern then
if [[ "$FILE" =~ ^.+(php|inc|module|install|test)$ ]]; then
# if file is actually and file that exists then
if [[ -f $FILE ]]; then
# php lint the file and
php -l "$FILE" 1> /dev/null
View directions-example
// from and to are objects that live somewhere else (for examples sake)
uiGmapGoogleMapApi.then(function(maps){
var directionsService = new maps.DirectionsService();
var request = {
origin: new maps.LatLng(
from.lat(),
from.lng()
),
View Windows 8 System PATH
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;