This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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), | |
[] | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Track class | |
*/ | |
// configure the class for runtime loading | |
if (!window.fbControls) window.fbControls = [] | |
window.fbControls.push(function(controlClass) { | |
/** | |
* Track class | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const labels = Array.from({ length: 1000000 }, (v, k) => ({isVerified: Math.random() >= 0.6})) | |
function getAcceptedPercent1(labels) { | |
let acceptedCount = 0 | |
const total = labels.length | |
for (let index = 0; index < total; index++) { | |
acceptedCount += labels[index].isVerified | |
} | |
return Math.round(acceptedCount / total * 100) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# safe? should return true or false if the absolute coordinate digit sum is a multiple of 3 | |
def safe?(x,y) | |
# [true, false].sample | |
# ([x, y].map(&:abs).to_s.chars.map(&:to_i).sum) % 3 == 0 | |
(x.abs + y.abs) % 3 == 0 | |
end | |
def fill_cell(x, y) | |
safe?(x,y) ? '■ ' : '□ ' | |
end |