Skip to content

Instantly share code, notes, and snippets.

View medikoo's full-sized avatar

Mariusz Nowak medikoo

View GitHub Profile
@medikoo
medikoo / async-to-promise.js
Created June 30, 2011 11:18
Treat low level async functions as promises
var slice = Function.prototype.bind.bind(Array.prototype.slice);
var p = function (fn, args) {
var d = defer();
fn.apply(this, slice(arguments, 1).concat(function (error, result) {
d.resolve((error == null) ? result : error);
}));
return d.promise;
};
@medikoo
medikoo / 450418.gecko-bug.html
Created February 18, 2011 14:30
Firefox (gecko) misaligns absolutely positioned elements, within fieldset that has left or top non zero padding and position set to other than static https://bugzilla.mozilla.org/show_bug.cgi?id=450418
<!DOCTYPE html>
<title>Gecko 450418 bug</title>
<style>
* { margin: 0; padding: 0; }
fieldset {
width: 200px; height: 200px; background: #ddd; border: 0;
position: relative; padding: 20px;
}
div {
width: 100px; height: 100px; background: red;
@medikoo
medikoo / Firefox quirk
Created March 2, 2010 13:53
Firefox quirk
/**
* First loop will run few hundred times slower
*/
var i, limit = 100000;
var time = +new Date;
for (i = 0; true; ++i) {
if (i > limit) {