Skip to content

Instantly share code, notes, and snippets.

View prograhammer's full-sized avatar

David Graham prograhammer

View GitHub Profile
@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 / 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 / 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 / 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).

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) {
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `execAsap` is passed, trigger the function on the
// leading edge, instead of the trailing.
export function debounce (func, threshold, execAsap) {
var timeout
return function debounced () {
var obj = this
var args = arguments
@prograhammer
prograhammer / bash_profile.md
Created February 17, 2016 19:47 — forked from irazasyed/bash_profile.md
Terminal: Mac OS X Terminal Aliases & How-To - .bash_profile / .profile

Mac OS X Terminal Aliases & How-To

Collection of some of my fav terminal aliases that i use often & collected from the web. This file will be updated with more aliases as i find more. Feel free to comment and share your fav aliases you use :)

###Follow these simple steps to add the following aliases:###


  1. Within the Terminal, run:
@prograhammer
prograhammer / snowflake.php
Last active November 15, 2016 15:54
80-bit sequential unique identifier (as opposed to a 128-bit UUID)
<?php
/**
* Creates an 80-bit, binary(10) unique identifier.
*
* Smaller, so indexes fit better in memory/RAM and the hex representation
* is still relatively URL friendly. Sequential, so inserts/indexes faster.
* (see https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/)
*
* 4 bit worker id (supports 16 servers, from 0 to 15)
@prograhammer
prograhammer / vagrant_trouble.md
Last active August 29, 2015 14:22
Troubleshooting Vagrant Issues

#Trouble Shooting Vagrant Issues

####Vagrant stuck connection timeout retrying

This can happen if the guest machine is turned off improperly (or perhaps the host machine was rebooted without first doing a vagrant halt). When performing a vagrant up the machine is waiting on a response (probably "enter" key). You can update the vagrant file to have gui set to true but this will require a vagrant destroy. Instead, you can send an "enter" key to the machine. Open up a new terminal window and:

 // Get the list of running VMs
 $ vboxmanage list runningvms

// Will show something like this: