Skip to content

Instantly share code, notes, and snippets.

Matt Van Meter mavame

Block or report user

Report or block mavame

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
@mavame
mavame / index.js
Last active Dec 10, 2018
Write JSON file from csv using Node.js
View index.js
// given a csv file on the local filesystem, this program will JSON-serialize the contents in to a new file "output.json"
// First create a new directory and initialize a new node project:
// $ npm init -y && npm i -s csvtojson minimist
// Then run the program:
// $ node index.js -f path-to-csv.csv
const fs = require("fs");
const csv = require("csvtojson/v2");
const argv = require("minimist")(process.argv.slice(2));
@mavame
mavame / pizza.json
Created Oct 10, 2017
Sample pizza locations
View pizza.json
{
"businesses": [
{
"id": "minellis-pizza-columbus-2",
"name": "Minelli's Pizza",
"image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/RClRY8K40PbFvE-zg6CNJA/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/minellis-pizza-columbus-2?adjust_creative=MCLKONVnfSv060BOXT4UYQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=MCLKONVnfSv060BOXT4UYQ",
"review_count": 31,
"categories": [
@mavame
mavame / GoogleMapsApi.js
Last active Nov 17, 2019
A simple class for loading the Google Maps Javascript API in browser async using ES6 and Promise
View GoogleMapsApi.js
/**
* Use this class to ensure Google Maps API javascript is loaded before running any google map specific code.
*/
export class GoogleMapsApi {
/**
* Constructor set up config.
*/
constructor() {
// api key for google maps
View forEach.js
/**
* Maps a callback to an element in an array-like object
* Basically a copy of underscore's _.each
* source: http://underscorejs.org/docs/underscore.html#section-20
*/
export function forEach(obj, iteratee, context) {
let ctx = this;
const isObject = function(obj) {
@mavame
mavame / 00-old.js
Last active Sep 7, 2017
Lazy-loading (code splitting) ES6 using Webpack 3
View 00-old.js
import Flickity from 'flickity'; // flickity now appears in main bundle.
const slideshow = document.querySelector('.slideshow');
if (slideshow) {
new Flickity(...);
} else {
// well, slideshow doesn't exist but we're still loading Flickity on every page :-(
}
View 01-promise-wait-and-catch.js
/**
* Wait for a specified number of milliseconds. If a promise hasn't resolved, reject it.
* This is a necessary replacement in some cases since cancellable promises aren't a thing
* and is helpful if you want to wait _no longer than_ a specified amount of time.
* @param {int} time Amount of time to wait before resolving arbitrarily.
* @param {function} fn That returns a Promise. It will be run one tick before the timer starts.
* @return {Promise}
*/
export function waitAndCatch(time, fn) {
return new Promise((resolve, reject) => {
@mavame
mavame / breakpoint.scss
Last active May 2, 2019
Breakpoint SASS mixin
View breakpoint.scss
$breakpoints: (
xs: 24rem,
sm: 32rem,
md: 54rem,
lg: 64rem,
xl: 80rem
);
// mobile-first breakpoint mixin
@mixin breakpoint($breakpoint: md, $key: min, $orientation: false) {
@mavame
mavame / assign.js
Last active Aug 4, 2017
Assign function instead of MDN polyfill
View assign.js
/**
* Copy the values of all enumerable own properties from one or more objects to a target object.
* Portion taken from the Object.assign(target, ...sources) polyfill on MDN.
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill
* @param {object} target Target object
* @param {...object} sources Additional objects whose properties to copy into target
* @return {object} target
*/
export default function assign(target, ...sources) {
if (target == null) { // TypeError if undefined or null
View learning-vue.md

Learning Vue

Conditional Rendering

<div id="container" v-if="someJSexpression"></div>

If someJSExpression evaluates to true, the div will appear in the DOM. Otherwise, it's left out.

Data Binding

@mavame
mavame / Preferences.sublime-settings
Last active Mar 9, 2016
Sublime Text 3 User Settings
View Preferences.sublime-settings
{
"auto_complete": true,
"auto_indent": true,
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/Material Theme/schemes/Material-Theme-Darker-OceanicNext.tmTheme",
"default_encoding": "UTF-8",
"detect_indentation": true,
"draw_indent_guides": true,
"draw_white_space": true,
You can’t perform that action at this time.