Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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
var grep = require('karma-webpack-grep')
var webpackConfig = require('./webpack.config')
module.exports = function (config) {
webpackConfig.plugins = (webpackConfig.plugins || []).concat(grep({
grep: config.grep,
basePath: '.',
testContext: './tests'
}))
'use strict'
let express = require('express')
let axios = require('axios')
let server
function once (cb) {
let app = express()
app.get('/foo', (req, res, next) => {
[Unit]
Description=Playe Controller
[Service]
ExecStart=/usr/bin/node /home/pi/play/play-controller/controller.js
Restart=always
RestartSec=5
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=play-controller
@KidkArolis
KidkArolis / actions.js
Created November 21, 2018 14:34
Fetch and take latest
import axios from 'axios'
import fetch from './fetch'
export default {
async fetchPage ({ dispatch }, { query, headers }, ref) {
// every time this action is dispatched, make the request using the fetch helper
// which ensures we cancel previous requests and only mutate state after the latest one
await fetch(ref, {
request: cancelToken => {
return Promise.all(