Skip to content

Instantly share code, notes, and snippets.

View DimitarChristoff's full-sized avatar

Dimitar Christoff DimitarChristoff

View GitHub Profile
var pop = new new Class({
Implements: [Options, Events],
options: {
// onBlock: Function.from(),
// onClose: Function.from(),
// onOpen: Function.from(),
width: 1024,
height: 768,
@domenic
domenic / promises.md
Last active March 31, 2024 14:07
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@haf
haf / install-git.sh
Created August 22, 2012 14:38
Installing git and git-subtree from source in ubuntu as packages
# use with: curl -L https://raw.github.com/gist/3426227 | bash
# get git binary, then git with git
sudo apt-get install git -y
git clone https://github.com/git/git.git
# remove your binary/package
sudo apt-get remove git -y
sudo apt-get install make checkinstall libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev asciidoc -y
@nzakas
nzakas / noanon.md
Created June 8, 2012 21:19
Avoiding "new anonfn"

JSLint doesn't like using new function. This makes sense, because you're just creating a singleton, and so there's no point in using a constructor for that. If you have something like this:

var NowWithClosures = Backbone.Model.extend(new function(){
    var x = 1;
    this.initialize = function(){
        console.log('init');
    };
    this.AddOneToX = function(){
 x++;
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@DimitarChristoff
DimitarChristoff / Browser.features.base64.js
Created February 10, 2011 21:21
Feature detect base64 support for images in mootools
(function() {
Browser.Features.base64 = null;
var callback = function() {
Browser.Features.base64 = this.width == 1 && this.height == 1;
// alert(Browser.Features.base64); // true || false
};
var img = new Image(), img = document.id(img) || new Element("img");
img.onload = img.onerror = img.onabort = callback;
// 1x1 px gif to test with