Skip to content

Instantly share code, notes, and snippets.

View feross's full-sized avatar
🐢
For urgent issues, send me an email

Feross Aboukhadijeh feross

🐢
For urgent issues, send me an email
View GitHub Profile
$.when( $.getJSON('/some/data/'), $.get('template.tpl') ).then(function( data, tmpl ){
$( tmpl ) // create a jQuery object out of the template
.tmpl( data) // compile it
.appendTo( "#target" ); // insert it into the DOM
});
@feross
feross / gist:1936676
Created February 29, 2012 01:00
memoizer.js
var count = 0;
var memoizer = function(memo, formula) {
var recur = function(n) {
var result = memo[n];
if (typeof result !== "number") {
result = formula(n);
memo[n] = result;
}
return result;
@feross
feross / gist:1936829
Created February 29, 2012 01:32
typeracer.com cheat js
// Feross Aboukhadijeh - Apr 12 2010
//
// Script I hacked together to cheat on TypeRacer.com. You use it by waiting for the typing game
// to start. Once it starts, open up Firebug, paste in this code, and run it. Now, just press
// space to auto-type each word. I made the user push space, as opposed to advancing the words
// automatically because I believe the site looks for a keypress event before evaluating the contents
// of the input box. I could not figure out how to fake a user keypress event. Perhaps this is
// disallowed for browser security reasons?
//
// Next todo: Site detects the unbelievable WPM and asks you to do a captcha test.
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
@feross
feross / gist:4396663
Created December 28, 2012 10:23
Text shadow with conditional IE support for Stylus Looks terrible in IE, and may have bugs.
/*
* Text shadow with conditional IE support.
*
* Examples:
* text-shadow: none
* text-shadow: <color>? <offset-x> <offset-y> <blur-radius>?
* text-shadow: <offset-x> <offset-y> <blur-radius>? <color>?
*/
// TODO: Convert color to hex
text-shadow()
@feross
feross / Respect Rollcall.html
Last active March 9, 2022 04:37
A list of bloggers who I like, pasted from my old blog.
<!-- Respect Rollcall -->
<li><a href="http://www.alistapart.com/articles/">A List Apart &#8212; for website builders</a></li>
<li><a href="http://abstrusegoose.com/">Abstruse Goose &#8212; my favorite comic</a></li>
<li><a href="http://al3x.net/">Alex Payne &#8212; technology rambling</a></li>
<li><a href="http://dashes.com/anil/">Anil Dash &#8212; on culture, apple &amp; design</a></li>
<li><a href="http://weblogs.mozillazine.org/asa/">Asa Dotzler &#8212; on mozilla &amp; software</a></li>
<li><a href="http://www.azarask.in/blog/">Aza Raskin &#8211; on design &amp; firefox</a></li>
<li><a href="http://christophzillgens.com/en/">Christoph Zillgens &#8212; interface design</a></li>
<li><a href="http://cssremix.com/">CSS Remix &#8212; gorgeous designs</a></li>
<li><a href="http://css-tricks.com/">CSS Tricks</a></li>
@feross
feross / toAbsoluteURL.js
Last active December 16, 2015 23:29
Given a filename for a static resource, returns the resource's absolute URL. Supports file paths with or without origin/protocol.
/**
* Given a filename for a static resource, returns the resource's absolute
* URL. Supports file paths with or without origin/protocol.
*/
function toAbsoluteURL (url) {
// Handle absolute URLs (with protocol-relative prefix)
// Example: //domain.com/file.png
if (url.search(/^\/\//) != -1) {
return window.location.protocol + url
}
/**
* Make a JSONP request. Server must support JSONP with callback name specified as a GET
* parameter with the name `callback`. Callback function will be called when data arrives.
* If request times out, callback is called with an Error object.
* @param {string} uri
* @param {Object} params Object of url params. Gets transformed into ?key1=value1&key2=value2
* @param {function} cb
*/
exports.jsonp = function (uri, params, cb) {
cb = once(cb)
@feross
feross / WebTorrent Roadmap.md
Last active August 29, 2017 12:08
WebTorrent Roadmap

WebTorrent Roadmap

v1.0.0 Prove the vision

WebTorrent.tv. YouTube for public domain content

  • Make website
  • Find public domain content
  • Host content to ensure it’s always available
  • Need web seed support