Skip to content

Instantly share code, notes, and snippets.

@doug
doug / parallel_convert.sh
Created December 2, 2014 02:37
parallel image convert
ls -1 *.png | parallel --eta convert '{}' '{.}.jpg'
@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 / 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 / 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-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() {
#!/usr/bin/env zsh
#
# gulp-autocompletion-zsh
#
# Autocompletion for your gulp.js tasks
#
# Copyright(c) 2014 Doug Fritz <[email protected]>
# MIT Licensed
#
@doug
doug / dat-gui-demo.html
Created September 2, 2014 21:37
dat.gui proposal
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>dat-gui Demo</title>
<script src="../platform/platform.js"></script>
<link rel="import" href="dat-gui.html">
</head>
@doug
doug / for_convert.zsh
Created July 25, 2014 22:27
for loop zsh (convert a bunch of svgs to png)
for x (*.svg) convert $x ${x:r}.png
@doug
doug / app.yaml
Last active August 29, 2015 14:04
static serving app.yaml
# application: appid # new gcloud preview app deprecates the application tag
version: master
runtime: python27
api_version: 1
threadsafe: true
#default_expiration: "7d"
handlers:
- url: (.*)/
static_files: www\1/index.html
@doug
doug / download.js
Last active August 29, 2015 14:03
download all the images matching a regex on a page
function download(i) {
var link = document.createElement('a');
link.href = i.src;
link.download = '';
link.click();
}
Array.prototype.slice.call(document.querySelectorAll('img')).filter(
function(i){return !!i.src.match(/.*\.gif$/)}).forEach(download);