Skip to content

Instantly share code, notes, and snippets.

View kevinchappell's full-sized avatar
🌠

Kevin Chappell kevinchappell

🌠
View GitHub Profile
/**
* Track class
*/
// configure the class for runtime loading
if (!window.fbControls) window.fbControls = []
window.fbControls.push(function(controlClass) {
/**
* Track class
*/
/**
* recursively flatten a nested array
* @param {Array} arr to be flattened
* @return {Array} flattened array
*/
const flattenArray = arr =>
arr.reduce(
(acc, val) => acc.concat(Array.isArray(val) ? flattenArray(val) : val),
[]
);
@kevinchappell
kevinchappell / throttle.js
Created September 28, 2018 21:17
Throttle class
/**
* Throttle class provides and easy way for binding
* and throttling events. Helpful for events like window
* scroll that are fired often.
*/
export class Throttle {
/**
* Add an event and register callbacks
* @param {String} event
* @param {Function} cb
@kevinchappell
kevinchappell / webpack.config.js
Created April 30, 2017 12:38
webpack.config.js
const pkg = require('./package.json');
const {resolve} = require('path');
const {BannerPlugin} = require('webpack');
const CompressionPlugin = require('compression-webpack-plugin');
const BabiliPlugin = require('babili-webpack-plugin');
const PRODUCTION = process.argv.includes('-p');
const bannerTemplate = [
`${pkg.name} - ${pkg.homepage}`,
@kevinchappell
kevinchappell / fizzBuzz.js
Created February 17, 2017 16:39
Configurable FizzBuzz
// Tired of seeing if else if else if else in fizzbuzz exercise I created
// this configurable FizzBuzz that uses only one if statement.
// https://jsfiddle.net/kevinchappell/44jrznbj/
/**
* Configurable fizzBuzz
* @param {Object} args
* @param {Number} until number of iterations
* @return {String} output
*/
@kevinchappell
kevinchappell / wp-push
Last active April 21, 2016 13:24
Push a WordPress site from vagrant to remote server
#!/bin/bash
# Author: Kevin Chappell http://kevin-chappell.com
# Description: Push a local vagrant dev site to production
# Version 0.1.2
echo -e '\e[32m
_ ______ ____ __
| | / / __ \ / __ \__ _______/ /_
| | /| / / /_/ / / /_/ / / / / ___/ __ \
| |/ |/ / ____/ / ____/ /_/ (__ ) / / /
@kevinchappell
kevinchappell / youtube-upload.sh
Last active April 9, 2016 16:54
Right-click upload to youtube
#!/bin/sh
# youtube-upload
# Dependencies: xclip and [youtube-upload](https://github.com/tokland/youtube-upload)
GREEN='\033[0;32m'
NC='\033[0m' # No Color
read -p 'Title (default filename): ' TITLE # defaults to filename
read -p 'Privacy (public | unlisted | private): ' PRIVACY # defaults to unlisted
@kevinchappell
kevinchappell / vid2gif.sh
Last active March 26, 2016 17:19
Convert any video to GIF
#!/bin/sh
# vid2gif - converts videos to gifs
# Usage: Add vid2gif.sh to your PATH then call like:
# $ vid2gif video.mp4 video.gif
#
# To add to context menu, create command that calls:
# $ vid2gif %F %d/%W.gif
# Get custom width and framerate from user input
@kevinchappell
kevinchappell / gulpfile.babel.js
Last active March 7, 2016 14:28
Font editing with Fontello and Gulp
'use strict';
import gulp from 'gulp';
import gulpPlugins from 'gulp-load-plugins';
import pkg from './package.json';
const files = pkg.config.files;
// Rather than manually defined each gulp plugin we need, gulpPlugins defines them for us.
var plugins = gulpPlugins(),
@kevinchappell
kevinchappell / Convert to Animated GIF
Last active December 26, 2015 23:40
Convert video to gif
[Desktop Entry]
Type=Action
TargetLocation=true
ToolbarLabel[en_US]=Convert to Animated GIF
ToolbarLabel[en]=Convert to Animated GIF
ToolbarLabel[C]=Convert to Animated GIF
Name[en_US]=Convert to Animated GIF
Name[en]=Convert to Animated GIF
Name[C]=Convert to Animated GIF
Profiles=profile-zero;