Skip to content

Instantly share code, notes, and snippets.

View desandro's full-sized avatar

David DeSandro desandro

View GitHub Profile
@SlexAxton
SlexAxton / .zshrc
Last active April 25, 2023 03:57
My gif workflow
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
@tdreyno
tdreyno / gist:4947918
Created February 13, 2013 20:25
Cross-platform mouse/touch events
var evts = [],
touchEvt,
mouseEvt,
msEvent;
if (evt === 'up') {
touchEvt = 'touchend';
mouseEvt = 'mouseup';
msEvent = 'MSPointerUp';
} else if (evt === 'move') {
@malarkey
malarkey / Contract Killer 3.md
Last active April 16, 2024 21:44
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………

@jfsiii
jfsiii / node proxy
Created July 14, 2012 19:06
Requests come into publicPort and are sent to apiPort or handlebarPort
var http = require('http'),
httpProxy = require('http-proxy'),
publicPort = 8000,
handlebarPort = 8080,
apiPort = 8888
httpProxy.createServer(function (req, res, proxy) {
if (req.url.match(/\.json$/)) {
proxy.proxyRequest(req, res, {
@meddulla
meddulla / handlebars_equal_helper.js
Created May 1, 2012 21:23
Handlebars equal helper
Handlebars.registerHelper('eq', function(val, val2, block) {
if(val == val2){
return block(this);
}
});
//Usage in template
//{{#eq type "all" }}
//<button class="orderer" data-target="sortableAnswers_{{type}}">save order</button>
//{{/eq}}
@paulirish
paulirish / rAF.js
Last active March 22, 2024 00:00
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@drinks
drinks / awesome.js
Created August 19, 2011 17:30
Auto-Awesome in turntable.fm
var loveit = function(){
var e,el,interval=Math.random()*60000;
e = new jQuery.Event("click");
e.pageX=1;
e.pageY=1;
el = jQuery('.record_pile:last').nextAll('a').eq(2);
turntable.lastMotionTime=new Date().getTime();
el.hover().trigger(e);
setTimeout(loveit, interval);
};
@cowboy
cowboy / jquery.ba-deparam.js
Created June 14, 2011 20:39
jQuery Deparam -- WORK IN PROGRESS -- NOT DONE YET
// jQuery Deparam - v0.1.0 - 6/14/2011
// http://benalman.com/
// Copyright (c) 2011 Ben Alman; Licensed MIT, GPL
(function($) {
// Creating an internal undef value is safer than using undefined, in case it
// was ever overwritten.
var undef;
// A handy reference.
var decode = decodeURIComponent;
@BonsaiDen
BonsaiDen / bezierCurve.js
Created November 10, 2010 02:24
Bezier Curve in JS, includes arc-length parameterization stuff
function Bezier(a, b, c, d) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
this.len = 100;
this.arcLengths = new Array(this.len + 1);
this.arcLengths[0] = 0;
@jfsiii
jfsiii / image2canvas.js
Created October 16, 2010 22:06
previously canvasFromImage
var image2canvas = (function ( global, document, undefined )
{
// parseUri 1.2.2
// (c) Steven Levithan <stevenlevithan.com>
// MIT License
function parseUri (str)
{
var o = parseUri.options,
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
uri = {},