Skip to content

Instantly share code, notes, and snippets.

View jhoguet's full-sized avatar

Jonathan Nelson jhoguet

  • South Dakota
View GitHub Profile
@jhoguet
jhoguet / sauce.js
Created June 21, 2015 15:28
How do I delete all the jobs in my sauce labs account?
var SauceLabs = require('saucelabs');
var myAccount = new SauceLabs({
username: "...",
password: "..."
});
myAccount.getJobs(function (err, jobs) {
jobs.forEach(function(job){
myAccount.send({
function createUl(ulSize, depth, maxDepth){
    var ul = document.createElement('ul');
    for (var i = 0; i < ulSize; i++){
        var li = document.createElement('li');
        ul.appendChild(li);
        li.textContent = 'Hi ' + depth + '.' + i;
        if (depth < maxDepth){
            li.appendChild(createUl(ulSize, depth + 1, maxDepth));    
 }
'a-big-bad-directive'.replace(/-(.)/g, function(a, b){
    return b.toUpperCase();
});
@jhoguet
jhoguet / debug.md
Created February 9, 2016 04:57
aurelia console debugger

Simply expose a global (eg in main.js)

window.au = el => {
    let aureliaNode  = el;
    // go up the structure until an element affected by aurelia is found
    while (aureliaNode !== null && aureliaNode !== undefined && aureliaNode.au === undefined) {
        aureliaNode = aureliaNode.parentNode;
    }
@jhoguet
jhoguet / debug.md
Created February 9, 2016 04:57
aurelia console debugger

Simply expose a global (eg in main.js)

window.au = el => {
    let aureliaNode  = el;
    // go up the structure until an element affected by aurelia is found
    while (aureliaNode !== null && aureliaNode !== undefined && aureliaNode.au === undefined) {
        aureliaNode = aureliaNode.parentNode;
    }
@jhoguet
jhoguet / rx js lift.js
Created March 1, 2016 02:47
demonstrating lift
import { Observable, Subscriber} from 'rxjs';
const _lift = Observable.prototype.lift;
function LogOperator(childOperator) {
this.childOperator = childOperator;
}
LogOperator.prototype.call = function (subscriber) {
return this.childOperator.call(new LogSubscriber(subscriber));
};
@jhoguet
jhoguet / testing only one file.js
Last active March 5, 2016 19:04
this ended up being too slow (given the overhead of spinning up mocha with babel). I could probably spin up mocha in memory (with babel) and re-run that way and be fast again... not really worth it til I have a lot more files so just using --watch for now
var gaze = require('gaze');
var Rx = require('rxjs');
var spawn = require('child_process').spawn;
// Watch all .js files/dirs in process.cwd()
gaze([
'./src/**/*.js',
'./src/*.js'
],
function(err, watcher) {
@jhoguet
jhoguet / jspm-thoughts.md
Last active May 22, 2016 16:45
Thoughts on JSPM

JSPM

JSPM is making some terrible choices IMO.

  1. Doesn't use npm the CLI, instead it uses NPM the http registry

    there is a very high chance that developers using JSPM also use NPM. Now their NPM packages might get installed in node_modules or jspm_packages even though they are the same package. They also need to understand how the jspm npm-registry works if anything goes wrong even though they already know how NPM works.

    there are good reasons they are doing this... but I am not convinced those reasons are worth it. In other words, I would rather see more complexity in JSPM to abstract this way, than more complexity on the consumer (as noted above).

  2. Uses both git the CLI and github's http api for the git registry

@jhoguet
jhoguet / aurelia-index.js
Created July 23, 2016 15:58
babel-aurelia-conflict
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
@jhoguet
jhoguet / learning-mobx.tests.js
Created December 13, 2016 04:35
in trying to wrap my head around mobx, I found it easiest to see how it handles a few scenarios
import { observable, observe, transaction, computed, reaction } from 'mobx';
import expect, { createSpy } from 'expect';
describe('learning mobx', () => {
it('some mobx basics', () => {
const computedSpy = createSpy();
const o1 = observable(1);
const o2 = observable(10)
const o3 = observable(() => {