Skip to content

Instantly share code, notes, and snippets.

⚙️
Workin' on Chrome extensions!

Dave Stewart davestewart

⚙️
Workin' on Chrome extensions!
Block or report user

Report or block davestewart

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@davestewart
davestewart / helpers.js
Last active Nov 26, 2019
Vue "route helpers" example
View helpers.js
/**
* Helper function to reduce boilerplate in route creation
*
* @param {string} path The route's path
* @param {object} page A page component definition
* @param {Function} page A function that returns a page import
* @param {string} page A string path to a file in the view/pages folder
* @param {object} attrs Any additional attributes
*/
export function route (path, page, attrs = {}) {
View table-factory-hooks.js
cells (row, col, name) {
if (!this.hot) {
return null
}
const rowData = this.hot.getSourceDataAtRow(row)
if (rowData) {
if (rowData.state === NegotiationItemState.removed) {
return { readOnly: true }
}
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;
You can’t perform that action at this time.