Skip to content

Instantly share code, notes, and snippets.

@jaw187
jaw187 / yerloop.js
Last active January 25, 2017 19:02
for( var current_index = 0; current_index < 10; current_index++ ){
var photo_path = PVL.Viewer.getPhotoPath( photos[ current_index ] );
var loadedIntoQueue = function (i) {
return function ( texture ){
console.log( 'texture loaded in queue', i, new Date() );
}
};
@jaw187
jaw187 / nodechallenge.js
Created January 18, 2016 15:16
Node Challenge, make this work by changing use
var Instance = function (options) {
this.options = options;
};
Instance.prototype.use = function (fn) {
var self = this;
process.nextTick(() => {
fn.call(self, self.options);
})
return this;
@jaw187
jaw187 / monkeypatch
Created May 14, 2015 16:15
A monkey patch which will override a method and throw an error after method is run a specific number of times
exports.forceWreckError = function (method, timer) {
var original = Wreck[method];
Wreck[method] = function () {
if (!timer) {
var callback = arguments[arguments.length - 1];
Wreck[method] = original;
return callback(new Error('foo'));
@jaw187
jaw187 / leakers
Created April 3, 2015 12:55
Async Leakageseses
var bad = function (options, callback) {
var a = options.a;
doSomethingAsync(function (err, res) {
callback(err, res);
});
};
@jaw187
jaw187 / eventloopexample
Created March 4, 2015 15:38
Example of how the event loop works
var test1 = function () {
var options = {
hostname: 'google.com',
port: 80,
path: '/'
};
http.get(options, function (res) {
// Load modules
// Declare internals
var internals = {};
module.exports.foo = internals.foo = function(args) {
// do awesome stuff
var CameraShare = function (cameraId, username, target) {
this.cameraId = cameraId;
this.fromName = username;
this.target = target;
this.branchUrl = function(cb) {
branchUrl = "http://www.google.com/"
cb(branchUrl);
function init() {
var pswp = new Pswp();
pswp.listen("gettingData", refreshSignedUrl(pswp));
};
function refreshSignedUrl(pswp) {
return function (index, item) {
var compose = function (f, g) {
var inner = function (x) {
return g(f(x));
};
};
@jaw187
jaw187 / gist:971f2a41474572405804
Created December 31, 2014 15:37
React update state
<div class="row">
<div class="col-md-3" id="playerContainer"></div>
<div class="col-md-6" id="playerDetailContainer"></div>
</div>
<script type="text/jsx">
var loadData = function (self) {
$.ajax({