Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env zsh
#
# gulp-autocompletion-zsh
#
# Autocompletion for your gulp.js tasks
#
# Copyright(c) 2014 Doug Fritz <doug@dougfritz.com>
# MIT Licensed
#
@doug
doug / gulp-concat.js
Last active August 29, 2015 14:06
gulp-concat.js
var through = require('through2')
var File = require('vinyl')
var concat = function(filename, opts) {
var dest = new File({path: filename, contents: through()})
var stream = through.obj(function(file, _, done) {
file.contents
.pipe(dest.contents, {end: false})
.on('end', function() {
@doug
doug / gulp-eachline.js
Last active August 29, 2015 14:06
gulp-eachline.js
var through = require('through2')
var eachline = function(transform, delim) {
delim = delim || '\n'
return through.obj(function(file, _, done) {
var extra = ''
file.contents = file.contents.pipe(
through(function(chunk, _, cb) {
var data = chunk.toString()
if (extra) { data = extra + data }
@doug
doug / gulp-prefix.js
Created September 12, 2014 21:15
gulp-prefix.js
var through = require('through2')
var prefix = function(data) {
return through.obj(function(file, _, done) {
var stream = through()
stream.push(data)
file.contents = file.contents.pipe(stream)
this.push(file)
done()
})
@doug
doug / yepnope.go
Last active August 29, 2015 14:08
yep nope http handler
package yepnope
import (
"net/http"
)
func YepNope(test func(r *http.Request) bool, yep http.Handler, nope http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
if test(r) {
yep.ServeHTTP(rw, r)
@doug
doug / parallel_convert.sh
Created December 2, 2014 02:37
parallel image convert
ls -1 *.png | parallel --eta convert '{}' '{.}.jpg'
@doug
doug / webcomponets.html
Created December 8, 2014 00:26
conditionally load webcomponents
<!-- Conditionally load WC polyfills -->
<script>
if ('registerElement' in document
&& 'createShadowRoot' in HTMLElement.prototype
&& 'import' in document.createElement('link')
&& 'content' in document.createElement('template')) {
// We're using a browser with native WC support!
} else {
document.write('<script src="/bower_components/webcomponentsjs/webcomponents.js"><\/script>');
}
@doug
doug / dropframes.sh
Created December 16, 2014 21:47
drop every other frame of a gif
# http://graphicdesign.stackexchange.com/questions/20908/how-to-remove-every-second-frame-from-an-animated-gif
gifsicle "$1" --unoptimize $(seq -f "#%g" 0 2 $numframes) -O2 -o "$2"
@doug
doug / random.js
Created October 16, 2015 00:38
Seeded random value
var seed = 1;
function random() {
var x = Math.sin(seed++) * 10000;
return x - Math.floor(x);
}
@doug
doug / article.md
Created August 22, 2016 06:32
dumb test

Hello

This is not an article.