Skip to content

Instantly share code, notes, and snippets.

View sergi's full-sized avatar
🎯
Focusing

Sergi Mansilla sergi

🎯
Focusing
View GitHub Profile
@sergi
sergi / gist:647065
Created October 26, 2010 15:06
YUI Module example
YUI.add("module1", function(Y) {
// Module code here
}, "0.0.1", { requires: ["module2"] });
@sergi
sergi / jasy_test.js
Created January 8, 2011 23:23
This test causes an (incorrect) syntax error
var Test = function(){}
Test.prototype = {
get foo() {
return 0;
},
set foo(val) {
return val;
},
}
@sergi
sergi / config.log
Created March 25, 2011 12:43
Homebrew couchdb installation failed
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by Apache CouchDB configure 1.0.2, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ ./configure --prefix=/usr/local/Cellar/couchdb/1.0.2 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc --with-erlang=/usr/local/lib/erlang/usr/include --with-js-include=/usr/local/include --with-js-lib=/usr/local/lib
## --------- ##
## Platform. ##
browser.loadJsSelector = function() {
return browser.addLocationStrategy("js", function(locator, inWindow, inDocument) {
var found;
try {
found = eval(locator);
} catch (e) {}
if (found)
return found;
else
var pasv, pasvReqs;
pasvReqs = function(next, stop) {
pasv = next;
};
pasvReqs(self.processPasv, function(err) { console.log(err) });
var processPasv = function(pasvData) {
console.log("PASVDATA", pasvData);
@sergi
sergi / test1.js
Created September 7, 2011 14:23
Test Async Queue + Streams
S = require("./support/jsftp/support/streamer/core");
function queue() {
var next;
var buffer = Array.prototype.slice.call(arguments)
function stream($, stop) { next = $; stream._update() }
stream._update = function _update() {
buffer.push.apply(buffer, arguments)
From ebb10691764938adec189da0e9f73e03a4291b2c Mon Sep 17 00:00:00 2001
From: Sergi Mansilla <[email protected]>
Date: Wed, 14 Sep 2011 14:35:50 +0200
Subject: [PATCH] Small optimizations
---
jsftp.js | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/jsftp.js b/jsftp.js
function HugeAnimal(name) {
Animal.apply(this, arguments)
}
HugeAnimal.prototype = new Animal
HugeAnimal.prototype.constructor = HugeAnimal
HugeAnimal.prototype.toString = function() {
return 'im ' + this.name + ' a ******* huge animal'
}
@sergi
sergi / reduce.js
Created April 4, 2012 14:49
JavaScript reduce implementation
var __reduce= function (func, list, initial) {
if (initial != null) {
var value = initial;
var idx = 0;
} else if (list) {
var value = list[0];
var idx = 1;
} else {
return null;
}
@sergi
sergi / javascript_background_thread.js
Created September 25, 2012 12:24 — forked from jameswomack/javascript_background_thread.js
Extend function prototype to run a function as a WebWorker
Function.prototype.runOnBackgroundThread = function (aCallback) {
var _blob = new Blob(['onmessage = '+this.toString()],{"type":"text/javascript"});
var _worker = new Worker((webkitURL.createObjectURL || URL.createObjectURL)(_blob));
_worker.onmessage = aCallback;
_worker.postMessage();
}
var _test = function () {
postMessage((1+1).toString());
}