Skip to content

Instantly share code, notes, and snippets.

View davemo's full-sized avatar
😀

David Mosher davemo

😀
View GitHub Profile
@searls
searls / layout.html.erb
Created August 27, 2014 18:50
Delay implementing a PDF rendering feature by beating Chrome into submission instead
<%= stylesheet_link_tag "application", :media => "screen,print" %>
@cowboy
cowboy / Gruntfile.js
Created January 9, 2013 22:09
grunt: lineman idea
module.exports = function(grunt) {
require('lineman').init(grunt);
grunt.initConfig({
// stuff
});
// Default task.
grunt.registerTask('default', ['run']);
};
@davemo
davemo / jquery.touch.js
Last active November 2, 2016 10:24 — forked from twalling/jquery.touch.js
Zeptos touch events, ported to work inside jQuery, including jQuery Mobiles scroll suppression.
;(function($){
var touch = {},
touchTimeout, tapTimeout, swipeTimeout,
longTapDelay = 750, longTapTimeout
function parentIfText(node) {
return 'tagName' in node ? node : node.parentNode
}
function swipeDirection(x1, x2, y1, y2) {
@jpillora
jpillora / di.coffee
Last active April 30, 2018 01:21
Micro JavaScript Dependancy Injection.Written in CoffeeScript / JS.This is *approximately* how AngularJS works.
# Micro JavaScript Dependancy Injection
define = (name, val) ->
#init modules map if missing
define.mods = define.mods or {}
#store 'name'
define.mods[name] = val
inject = (fn) ->
#regex match on function.toString()
@igrigorik
igrigorik / gist:3148848
Created July 20, 2012 05:24
Convert any YouTube video into an audio file you can listen to on the go...
# Convert any YouTube video into an audio file you can listen to on the go, using:
# http://rg3.github.com/youtube-dl/
{ ~ } > brew install ffmpeg
{ ~ } > wget https://raw.github.com/rg3/youtube-dl/2012.02.27/youtube-dl
{ ~ } > chmod u+x youtube-dl
# Pick which video format you want to download.. (use any YT video link)
{ ~ } > ./youtube-dl -s -F http://www.youtube.com/watch?v=vT1KmTQ-1Os
@madrobby
madrobby / i18n.coffee
Created November 14, 2011 15:45
Backbone i18n with CoffeeScript
# before this file is loaded, a locale should be set:
#
# In a browser environment, you can use:
# ```<script>__locale='en';</script>```
#
# In a server environment (specifically node.js):
# ```global.__locale = 'en';```
# normalize in-app locale string to "en" or "de-AT"
parts = @__locale.split('-')
@tbranyen
tbranyen / backbone.collectioncache.js
Created June 4, 2012 06:37
Backbone.Collection caching by URL
/*!
* backbone.collectioncache.js v0.0.2
* Copyright 2012, Tim Branyen (@tbranyen)
* backbone.collectioncache.js may be freely distributed under the MIT license.
*/
(function(window) {
"use strict";
// Dependencies
@cowboy
cowboy / delegate-refactor.js
Created April 1, 2011 11:26
jQuery: e.type + binding to multiple events at the same time FTW
// BEFORE
// http://jsfiddle.net/markcoleman/ffBcU/11/
var currentColor = "white";
var hold = false;
$(".canvas")
.delegate(".pixel", "mouseover", function() {
$(this).css("background-color", currentColor);
})
@searls
searls / git-unpull
Created August 29, 2013 11:15
a handy way to unpull a pull that bit off more than you could chew.
#!/bin/bash
git reset --hard HEAD@{1}
@fxsjy
fxsjy / gist:3291755
Last active January 9, 2021 16:12
Memcached in JavaScript based on Node.JS
//author: Sun, Junyi (weibo.com/treapdb)
//usage: node --nouse-idle-notification --expose-gc --max-old-space-size=8192 memcached.js
var config ={
port: 11211,
max_memory: 300 // default 100M bytes
}
var net = require('net');
var LRU = function (max) { // this LRU implementaion is based on https://github.com/chriso/lru