Skip to content

Instantly share code, notes, and snippets.

View soundyogi's full-sized avatar
🦊

KaiserMerkle soundyogi

🦊
View GitHub Profile
@addyosmani
addyosmani / reverse.js
Created February 7, 2013 12:00
Reversing audio (old WebAudio sample)
var context = new AudioContext(),
request = new XMLHttpRequest(),
mp3File = 'yourFile.mp3';
request.open('GET', mp3File , true);
request.responseType = 'arraybuffer';
request.addEventListener('load', function(){
context.decodeAudioData(request.response, function(buffer){
@sword-jin
sword-jin / command.js
Created January 7, 2016 13:06
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);
},
@luqmaan
luqmaan / debugging reselect performance.md
Last active July 17, 2017 23:32
debug reselect performance

Debugging reselect performance

Some steps I'm taking to debug bad performance with reselect.

My performance problems are coming from the fact that I am not using reselect properly. I wrote a bunch of selectors that use props but don't do anything to make sure they can be shared across multiple components.

The fix for this is: https://github.com/reactjs/reselect/blob/fec65b63b9a2ffa570348271138d20cf831e0185/README.md#sharing-selectors-with-props-across-multiple-components.

But before rewriting tons of code, I'd like to see which selectors are recomputed the most.

@flarb
flarb / VRInputModule.cs
Created August 20, 2014 22:27
Lets you use a VR world space cursor with World Space Canvases in Unity3D 4.6. Add this to the EventSystem object. Put some box colliders on your buttons in the World Space Canvas. Then, do a trace to see if you're looking at a menu object--if the trace hits one of those buttons, pass it to SetTargetObject. See ralphbarbagallo.com for a longer e…
using UnityEngine;
using UnityEngine.EventSystems;
//by Ralph Barbagallo
//www.flarb.com
//www.ralphbarbagallo.com
//@flarb
public class VRInputModule : BaseInputModule {
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,
])
import 'rxjs';
import { Observable } from 'rxjs';
Observable.prototype.debug = function(_message) {
const message = `EpicDebug: ${_message}`;
return this.do(
function(next) {
if (__DEV__) {
@ayamflow
ayamflow / shadowMaterial.js
Created August 25, 2015 05:09
ShaderMaterial that only renders shadow
// Minimal version of MeshBasicMaterial
// But removed everything except shadow
// then only render the shadow
var shadowMaterial = {
transparent: true,
uniforms: THREE.UniformsUtils.merge([
THREE.UniformsLib['common'],
THREE.UniformsLib['shadowmap']
]),
// note: I'm using redux-actions in here, so the actions might look a bit different than you are used too
// note: This is not complete but the concepts are
// excerpt from app.js
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import fetch from 'isomorphic-fetch'
// note: you could totally leave out the fetch argument here if you set a default (as I do in my actions)
// I'm right now not absolutely sure how I will handle this in the future (the way it is now it is a bit redundant)
@xgalaxy
xgalaxy / gist:6743756
Last active April 24, 2019 08:40
Example of working with anonymous types in Unity3d
using System;
using System.Collections;
using UnityEngine;
public class Testing : MonoBehaviour
{
void Start()
{
// In C#, this is an 'Anonymous Type'
// A new System.Type is generated for it at compile type
@jaredpalmer
jaredpalmer / postinstall.js
Last active June 11, 2019 08:35
React Native Web x TypeScript
// ./postinstall.js
'use strict';
const fs = require('fs');
const RN_TSD = __dirname + '/node_modules/@types/react-native/index.d.ts';
const raw = fs.readFileSync(RN_TSD);
// Fix @types/node conflict
// @see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/15960