Skip to content

Instantly share code, notes, and snippets.

💭
Workin' on Chrome extensions!

Dave Stewart davestewart

View GitHub Profile
View workflowy x 2.js
javascript:
`
WorkFlowy x 2
=============
- A browser Bookmarklet to give you a dual panel WorkFlowy view
- Updates main page title with panel titles
- Saves panels between sessions
View collection.js
// collection.js
export function forEach (arr, callback) { ... }
export function map (arr, callback) { ... }
export function get (arr, id, key = 'id') { ... }
export function getIndex (arr, id, key = 'id') { ... }
export function add (arr, item, index = -1) { ... }
export function update (arr, id, values) { ... }
export function move (fromArr, id, toIndex, toArr = fromArr) { ... }
export function moveByIndex (fromArr, fromIndex, toIndex, toArr = fromArr) { ... }
export function remove (arr, id) { ... }
@davestewart
davestewart / ga.js
Created Jul 8, 2018
Google Analytics - single file include
View ga.js
(function track (id) {
// prepare data
window.dataLayer = window.dataLayer || []
function gtag () { dataLayer.push(arguments) }
gtag('js', new Date())
gtag('config', id)
// load analytics
var script = document.createElement('script')
@davestewart
davestewart / App.vue
Created Mar 19, 2018
Vue provide inject example for customisable icons
View App.vue
<template>
<ui-icon name="notes" />
<ui-icon name="book" />
<ui-icon name="map" />
</template>
@davestewart
davestewart / AddressForm.vue
Created Nov 13, 2017
Trifecta of Parent, Child and Layout components for reusable Form family
View AddressForm.vue
<template>
<ui-form name="address">
<div class="fields">
<ui-input
name="house_no"
label="House name / no"
:value.sync="values.house_no"
@davestewart
davestewart / CarLoader.js
Created Oct 24, 2017
Example of a Vuex service
View CarLoader.js
import Vue from 'vue'
import _ from 'lodash'
import { compare, stringify } from 'utils/query'
import store from 'app/store'
/**
* Car loader service
*
* Removes responsibility of loading cars from the results store
*
@davestewart
davestewart / 0. notes.md
Last active May 23, 2018
Vue JS local storage plugin. Hydrates modules from local storage on load, and saves state on each commit
View 0. notes.md
@davestewart
davestewart / pythagorean-triples.js
Last active Apr 13, 2017
Function to calculate unique Pythagorean triples
View pythagorean-triples.js
// -----------------------------------------------------------------------------
// utils
function isPrime(value)
{
for(var i = 2; i < value; i++)
{
if(value % i === 0)
{
return false;
@davestewart
davestewart / rollup-jquery.js
Last active Mar 17, 2017
Basic rollup setup to watch and compile jQuery plugin source
View rollup-jquery.js
/**
* Basic rollup setup for jQuery plugin development:
*
* - watch src folder
* - transpile ES6 to ES5
* - create development version (source maps)
* - create production version (minified)
*/
// dependencies
@davestewart
davestewart / console.txt
Last active Feb 15, 2017
JavaScript decorator function
View console.txt
Foo > 1
Bar > 1
Bar (doubled) > 2
Bar (doubled, default message) > New value is: 2
Bar (doubled, custom message) > New custom value is: 2
Bar (doubled, default message, uppercase) > NEW VALUE IS: 2
Bar (doubled, custom message, uppercase) > NEW CUSTOM VALUE IS: 2
You can’t perform that action at this time.