Skip to content

Instantly share code, notes, and snippets.

View prograhammer's full-sized avatar

David Graham prograhammer

View GitHub Profile
selectItem (item) {
if (!this.multiple) {
this.inputValue = item
} else {
if (this.inputValue === null) {
this.inputValue = [item]
} else {
const i = this.inputValue.findIndex(i => this.getValue(i) === this.getValue(item))
if (i !== -1) {
@prograhammer
prograhammer / gh-pages-deploy.md
Created September 11, 2017 08:15 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@prograhammer
prograhammer / route-based-chunking.md
Created September 27, 2017 18:54 — forked from addyosmani/route-based-chunking.md
Route-based chunking

Route-based chunking

Many of us building single-page apps today use JavaScript module bundling tools that trend towards a monolithic "bundle.js" file including the full app and vendor code for multiple routes. This means if a user lands on any arbitrary route they need to wait for a large bundle of JS to be fetched, parsed and executed before the application is fully rendered and interactive.

screen shot 2016-09-28 at 4 45 52 pm

This is a little backwards, especially when apps are used under real-world network (3G) and device

@prograhammer
prograhammer / Vue Provide Inject reactive.vue
Last active June 27, 2020 09:39
Vue Provide Inject reactive
<template lang="pug">
li(@click='$store.commit("UPDATE_SIDE_NAV_ACTIVE_ITEM", $el)')
slot
</template>
<script>
export default {
data () {
return {
provideData: {
@prograhammer
prograhammer / es6-class.js
Last active August 14, 2018 05:21
ES6 Class
class Auto {
constructor(data) {
this.make = data.make;
this.model = data.model;
this.year = data.year;
this.price = data.price;
}
getDetails() {
return `${this.year} ${this.make} ${this.model}`;
@prograhammer
prograhammer / curl.md
Created February 28, 2018 06:19 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@prograhammer
prograhammer / index.html
Created July 18, 2018 19:20 — forked from jonnyreeves/index.html
JavaScript Class Structure using requireJS. The following code shows you how to create a Class definition in one JavaScript file and then import it for use in another; coming from an ActionScript 3 background this (and some of JavaScript specific traits)
<!DOCTYPE html>
<html>
<head>
<script data-main="usage" src="http://requirejs.org/docs/release/1.0.8/comments/require.js"></script>
</head>
<body>
<p>Check your JavaScript console for output!</p>
</body>
</head>
@prograhammer
prograhammer / regex.md
Last active July 21, 2018 21:57
Regex by example
@prograhammer
prograhammer / babel-polyfill.md
Last active August 16, 2018 05:19
Features Babel does and doesn't transpile

Features that need to be compiled

  • Arrow functions
  • Async functions
  • Async generator functions
  • Block scoping
  • Block scoped functions
  • Classes
  • Class properties
  • Computed property names
  • Constants