Skip to content

Instantly share code, notes, and snippets.

@KidkArolis
KidkArolis / shell.sh
Created October 10, 2015 20:50
karma start --grep examples
# build and run all tests
$ karma start
# build and run only those tests that are in this dir
$ karma start --grep app/modules/sidebar/tests
# build and run only this test file
$ karma start --grep app/modules/sidebar/tests/animation_test.js
@KidkArolis
KidkArolis / grep.js
Last active October 10, 2015 21:02
karma webpack --grep
module.exports = function (config) {
// karma parses cmd line args, therefore
// when executing `karma start --grep some/path`
// config will have `grep` set to 'some/path'
if (config.grep) {
var pattern = config.grep
// we then remove the .js suffix, this is useful
// because if you're typing `karma start --grep some/test_fi` and tab
// the terminal autocompletes to `karma start --grep some/test_file.js`
// however, we want to remove this to effectively make use of the
@KidkArolis
KidkArolis / karma.conf.js
Last active October 10, 2015 21:03
karma start --grep tests/someTest.js
var webpack = require('webpack')
var webpackConfig = require('./webpack.config')
module.exports = function (config) {
// prep your webpack config for karma
delete webpackConfig.entry
webpackConfig.devtool = 'cheap-inline-source-map'
// karma --grep
if (config.grep) {
@KidkArolis
KidkArolis / karma.conf.js
Last active October 10, 2015 21:00
An example of karma with karma-webpack
var webpackConfig = require('./webpack.config')
module.exports = function (config) {
// prep your webpack config for karma
delete webpackConfig.entry
webpackConfig.devtool = 'cheap-inline-source-map'
config.set({
// standard karma things
basePath: '.',
@KidkArolis
KidkArolis / gu.sh
Last active October 10, 2015 22:18
Update local repo after merging a PR
# add this to your ~/.bash_profile or similar
# say you're on a branch `my-feature` and
# you merge the PR for that branch on GitHub
# you can now execute `gu` to run the following
gu () {
branch=$(git symbolic-ref --short HEAD)
git checkout master
git pull
@KidkArolis
KidkArolis / middleearth.js
Created August 10, 2015 19:44
cherrytree example middleware
router.use(loadingAnimation)
router.use(loadHandlers(router))
router.use(computeAlreadyActive)
router.use(modelHook)
router.use(activateHook)
@KidkArolis
KidkArolis / cherrytree-app.js
Last active August 29, 2015 14:27
a quick intro to the cherrytree router
/**
* To run this example locally:
*
* $ git clone https://github.com/QubitProducts/cherrytree.git
* $ cd cherrytree/examples/hello-world-react
* $ npm install
* $ npm start
* $ open http://localhost:8000
*
*/
@KidkArolis
KidkArolis / cherrytree-express-render.js
Last active August 29, 2015 14:27
render a react app in express using cherrytree
/**
* A generic render helper for cherrytree + react + express.
*
* To run this example locally:
*
* $ git clone https://github.com/QubitProducts/cherrytree.git
* $ cd cherrytree/examples/server-side-react
* $ npm install
* $ npm start
* $ open http://localhost:8000
@KidkArolis
KidkArolis / index.js
Last active August 29, 2015 14:26
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var sinon = require("sinon")
console.log(sinon)
window.sinon = sinon
/*
sinon.stub(window.history, "pushState", function () {
console.log("PUSHING")
})
@KidkArolis
KidkArolis / timeout.js
Last active August 29, 2015 14:26
timeout.js
/**
* Usage:
*
* request("foo", timeout(function () {
* // get here after request completes, or 5 seconds,
* // whichever is first
* }, 5000));
*/
function timeout(done, duration) {
var alreadyCalled = false;