Skip to content

Instantly share code, notes, and snippets.

@wayspurrchen
wayspurrchen / callbackWrapper.js
Last active Aug 29, 2015
Code snippet that can wrap any function and give it the ability to run a callback
View callbackWrapper.js
var callbackCurrier = function(obj, funcName) {
var originalFunction = obj[funcName];
var callbackFunc = function() {
var args = Array.prototype.slice.call(arguments, 0);
var callback = args.pop();
var returnValue = originalFunction.apply(obj, args);
if (callback) {
callback(returnValue);
}
};
@wayspurrchen
wayspurrchen / index.html
Created Aug 28, 2014
Quizzy sample code
View index.html
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="http://underscorejs.org/underscore-min.js"></script>
<script src="main.js"></script>
</head>
<body>
<div id="quiz-app"></div>
<script type="text/template" id="template-question">
View gist:ae7dbb4819c925a40f63
<!DOCTYPE html>
<html>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
</html>
<body>
<button id="scissors">scissors</button>
<button id="rock">rock</button>
<button id="paper">paper</button>
<h1 id="decision">OUTCOME GOES HERE</h1>
View index.html
<!DOCTYPE html>
<html>
<head>
<style>
.container-one {
min-height: 200px;
background-color: white;
}
.container-two {
min-height: 200px;
@wayspurrchen
wayspurrchen / controller.js
Created Oct 15, 2014
Johnny-Five Arduino UNO Pixel Iterator RGB LED Code
View controller.js
var five = require('johnny-five');
var keypress = require('keypress');
var gm = require('gm');
var board = new five.Board();
var fs = require('fs');
var PNG = require('pngjs').PNG;
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
View gist:240a2ca7eb95737a8ebc
http://mkopas.net/files/conversations/conversations.html
http://tarasue.makiyamazaki.com/
http://www.newgrounds.com/portal/view/591565
@wayspurrchen
wayspurrchen / gist:c688b2d9685418901791
Last active Aug 29, 2015
Grab and list all (unique) classes on page
View gist:c688b2d9685418901791
var cls = [];
Array.prototype.slice.call( document.querySelectorAll('*'), 0 ).forEach( function ( el ) {
cls = cls.concat( Array.prototype.slice.call( el.classList, 0 ) );
} );
cls = cls.reduce( function ( p, c ) {
if ( p.indexOf( c ) < 0 ) p.push( c );
return p;
}, [] );
console.log( cls );
View promiseretry.js
function retry ( promiseToRetry, maxRetries ) {
return new Promise( function ( resolve, reject ) {
promiseToRetry.then( function ( resolve ) {
resolve( result );
} ).catch( function ( e ) {
if ( maxRetries > 0 ) {
return retry( promiseToRetry, maxRetries - 1 );
} else {
reject( e )
}
@wayspurrchen
wayspurrchen / The Technical Interview Cheat Sheet.md
Last active Aug 29, 2015 — forked from TSiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.
View The Technical Interview Cheat Sheet.md

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@wayspurrchen
wayspurrchen / injector.js
Last active Jan 9, 2016
demo code showing how AngularJS 1.6 injectors (probably) magically inject services by name
View injector.js
/**
* This gist shows how you can inject other functions/variables
* into a function only by name. I imagine this is probably something
* like how AngularJS 1.6 does it, but Angular relies on an internal
* list of registered modules instead of just whatever's floating
* around the namespace, which is dangerous.
**/
// Things to inject
function LoggerOne () {