Skip to content

Instantly share code, notes, and snippets.

View avanslaars's full-sized avatar

Andy Van Slaars avanslaars

View GitHub Profile
@avanslaars
avanslaars / Unit Test Angular Run Block.js
Last active August 29, 2015 14:17
Simple example of unit testing run block in angular
(function () {
angular.module('MyApplication')
.run(appStartup)
appStartup.$inject = ['$cookieStore', 'AuthService']
function appStartup($cookieStore, AuthService)
{
var token = $cookieStore.get('auth-token')
if(token){
AuthService.LoadToken(token)
}
@avanslaars
avanslaars / 0_reuse_code.js
Last active August 29, 2015 14:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
npm i -S autoprefixer-core babel babel-loader css-loader json-loader postcss-loader react react-hot-loader style-loader stylus-loader url-loader webpack-dev-server yeticss
@avanslaars
avanslaars / .bash_profile
Created November 6, 2015 20:27
Bash functions for stepping forward and backward through git commits.
git_next() {
BRANCH=$1
git checkout `git log --reverse --ancestry-path HEAD..${BRANCH:="master"} | head -n 1 | cut -d \ -f 2`
}
git_prev(){
git checkout HEAD^
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine-html.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/boot.min.js"></script>
@avanslaars
avanslaars / morocycle_clear_field_issue.js
Last active April 16, 2016 13:49
Rendering issue when attempting to clear an input value after sampling the value. It works if something in the node relies on data from the source stream, but with static values, re-rendering of the input with an empty (or default) value doesn't happen. This code works because the mapped value is being applied to the input as a class, but this i…
// Run it here: http://www.webpackbin.com/Nk5AREvJb
import Motorcycle from '@motorcycle/core'
import {div, label, input, hr, h1, makeDOMDriver} from '@motorcycle/dom';
import most from 'most'
function main(sources) {
const input$ = sources.DOM.select('.field').events('input')
const click$ = sources.DOM.select('.btn').events('click')
@avanslaars
avanslaars / Motorcycle_Clear_Input_Snabbdom_Hook.js
Last active April 13, 2016 17:59
"Fix" For clearing an input field after submit using an update hook in Snabbdom
//Run it here: http://www.webpackbin.com/VJBxSuP1W
import Motorcycle from '@motorcycle/core'
import {div, label, input, hr, h1, makeDOMDriver} from '@motorcycle/dom';
import most from 'most'
function main(sources) {
const input$ = sources.DOM.select('.field').events('input')
const click$ = sources.DOM.select('.btn').events('click')
const sinks = {
@avanslaars
avanslaars / bash_profile
Created April 15, 2016 18:42
Force update of Chrome Canary
function ug() {
~/Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle/Contents/Resources/GoogleSoftwareUpdateAgent.app/Contents/MacOS/GoogleSoftwareUpdateAgent -runMode oneshot -userInitiated YES
}
@avanslaars
avanslaars / Motorcycle_Clear_Input_Function_of_State.js
Created April 15, 2016 18:47
Simple form that shows field value and clears field on button click. Tracks input to text and uses its value at the time of the button click and to update the state that the view is driven from.
//http://www.webpackbin.com/N1KplM91b
import Motorcycle from '@motorcycle/core'
import {div, label, input, hr, h1, makeDOMDriver} from '@motorcycle/dom';
import most from 'most'
function main(sources) {
const input$ = sources.DOM.select('.field').events('input')
const nameChange$ = input$
@avanslaars
avanslaars / motorcycle_webpackbin_boilerplate.js
Created April 16, 2016 13:30
Boilerplate code for Motorcycle on Webpackbin.com - This is a direct port of the CycleJS boilerplate to Motorcycle
//http://www.webpackbin.com/VkPA2Qj1Z
import Motorcycle from '@motorcycle/core';
import {div, label, input, hr, h1, makeDOMDriver} from '@motorcycle/dom';
function main(sources) {
const sinks = {
DOM: sources.DOM.select('.field').events('input')
.map(ev => ev.target.value)
.startWith('')
.map(name =>