Skip to content

Instantly share code, notes, and snippets.

View davestewart's full-sized avatar
⚙️
Workin' on Chrome extensions!

Dave Stewart davestewart

⚙️
Workin' on Chrome extensions!
View GitHub Profile
@davestewart
davestewart / CarLoader.js
Created October 24, 2017 16:32
Example of a Vuex service
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 August 11, 2020 16:16
Vue JS local storage plugin. Hydrates modules from local storage on load, and saves state on each commit
@davestewart
davestewart / pythagorean-triples.js
Last active April 13, 2017 13:45
Function to calculate unique Pythagorean triples
// -----------------------------------------------------------------------------
// utils
function isPrime(value)
{
for(var i = 2; i < value; i++)
{
if(value % i === 0)
{
return false;
@davestewart
davestewart / rollup-jquery.js
Last active March 17, 2017 22:50
Basic rollup setup to watch and compile jQuery plugin source
/**
* 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 February 15, 2017 11:23
JavaScript decorator function
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
@davestewart
davestewart / broadcast-channel.md
Last active May 14, 2024 18:53
Example of using BroadcastChannel to communicate with pages in the same domain

screenshot

@davestewart
davestewart / MPlayerX Launcher.app
Created August 3, 2016 23:32
Droplet/App launcher script for MPlayerX (or any app if you change the app reference)
on run
do shell script "open -n /Applications/MPlayerX.app"
tell application "MPlayerX" to activate
end run
on open theFiles
repeat with theFile in theFiles
do shell script "open -na /Applications/MPlayerX.app " & quote & (POSIX path of theFile) & quote
end repeat
tell application "MPlayerX" to activate
@davestewart
davestewart / jquery.upgrade-columns.js
Created July 3, 2016 12:13
jQuery plugin to stylize table columns based on the table <col> tag styling
var $ = jQuery;
/**
* Upgrade Columns jQuery plugin
*
* Upgrades colgroup formatting to CSS styles
*/
$.fn.upgradeColumns = function()
{
// variables
@davestewart
davestewart / ratio.js
Created June 15, 2016 13:36
Utility component create a proportionally-sized element, into which other elements can be displayed
Vue.component('ratio', {
template:'<div class="ratio" :style="style"><slot></slot></div>',
props:
{
width:
{
default :512,
type :[String, Number],
@davestewart
davestewart / gulpfile.js
Last active October 7, 2018 10:03
Laravel Gulp setup - compiles scripts & styles (plus custom paths and live build option) with live-reload
// ---------------------------------------------------------------------------------
// libs
var gulp = require('gulp'),
// tools
sass = require('gulp-sass'),
uglify = require('gulp-uglify'),
sourcemaps = require('gulp-sourcemaps'),
livereload = require('gulp-livereload'),