Skip to content

Instantly share code, notes, and snippets.

View phillipskevin's full-sized avatar

Kevin Phillips phillipskevin

View GitHub Profile
@phillipskevin
phillipskevin / unit-test-dependency-injection-using-stealjs.js
Created September 8, 2015 00:41
Example QUnit Test using StealJS for Dependency Injection
import QUnit from 'steal-qunit';
QUnit.module('Tournament Details ViewModel', {
beforeEach: function () {
localStorage.clear();
}
});
test('should load a tournament', (assert) => {
let done = assert.async(),
@phillipskevin
phillipskevin / _Forms with CanJS 2.3 Stache Syntax.md
Last active August 15, 2018 19:28
Forms with New Stache Syntax

Forms with CanJS 2.3 Stache Syntax

This gist shows examples of how to handle different types of form elements with the new stache binding syntax in CanJS 2.3.

<script src="../node_modules/steal/steal.js">
window.rerun = true;
function rerunIfSuccessful() {
var result = document.getElementById('qunit-testresult');
var failed = result.getElementsByClassName('failed');
if (!failed.length) {
setTimeout(rerunIfSuccessful, 4000);
} else if (failed[0].innerHTML === "0" && window.rerun) {
location.reload(true);
}
@phillipskevin
phillipskevin / npm-publish-dates.js
Created November 21, 2016 21:04
List when the dependencies of your project were published
const npm = require('npm');
const publishTimes = {};
function getInfo(name, version) {
return new Promise((resolve) => {
npm.info(name, (err, info) => {
const times = typeof info[version] === 'object' ? info[version].time : {};
resolve(`${name}@${version}|${times[version]}`);;
});
@phillipskevin
phillipskevin / index.js
Last active December 13, 2016 16:50
steal-tools-build-using-steal-clone
import clone from 'steal-clone';
return new Proxy(this, {
get: function(target, prop) {
var funcOrProp = target[prop];
if (typeof funcOrProp === 'function') {
return function() {
var result = funcOrProp.apply(target, arguments);
console.log(prop + '(' + [].join.call(arguments, ',') + ') -> ' + JSON.stringify(result));
return result;
}
@phillipskevin
phillipskevin / local-donejs-everything
Last active February 9, 2017 14:53
run donejs cli commands with local copies of everything and debugging all the things
npm uninstall -g donejs-cli
cd path/to/donejs-cli
npm link
cd path/to/generator-donejs
npm link
DEBUG=* node --inspect --debug-brk /path/to/bin/donejs add app
@phillipskevin
phillipskevin / _codemods
Last active October 26, 2017 14:59
codemods
This is a set of codemods
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Lazy Values</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>