Skip to content

Instantly share code, notes, and snippets.

View trodrigues's full-sized avatar
😸
:3

Tiago Rodrigues trodrigues

😸
:3
View GitHub Profile
@trodrigues
trodrigues / gist:4223742
Created December 6, 2012 11:08
testing AMD modules and mocking dependencies with buster.js and sinon
define(['dependency'], function(dependency){
buster.testCase('some test', {
setUp: function(done){
var self = this;
this.someStub = sinon.stub(dependency, 'method');
require(['moduleToTest'], function(ModuleToTest){
self.instance = new ModuleToTest();
});
function getProperty(){
for(var i in obj){
if(obj.hasOwnProperty(i)){
return i;
}
}
}
@trodrigues
trodrigues / gist:3952530
Created October 25, 2012 13:25
crazy var reference behavior on Android 2.3.6
function func(firstarg){
console.log(firstarg); // on Chrome it's defined, on Android 2.3.6 browser it's defined
var args = Array.prototype.splice.call(arguments, 0, arguments.length);
console.log(arguments[0]); // on Chrome it's undefined, on Android 2.3.6 browser it's undefined
console.log(firstarg); // on Chrome it's defined, on Android 2.3.6 browser it's *undefined*
}
func("hello");
@trodrigues
trodrigues / gist:3878515
Created October 12, 2012 10:05
hidden classes
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.addZ = function(val){
this.z = val;
};
var p1 = new Point(11, 22);
@trodrigues
trodrigues / build utils
Created September 21, 2012 09:28
bash functions
uglify(){
./node_modules/uglify-js/bin/uglifyjs $1 > $2
if [ $? != 0 ] ; then
exit 1
fi
}
build_js(){
./node_modules/requirejs/bin/r.js -o $1 $rjsopt
es=$?
@trodrigues
trodrigues / gist:3654769
Created September 6, 2012 10:55 — forked from jneves/gist:3654732
Greasemonkey script
// ==UserScript==
// @name Hootsuite promoted tweets never more
// @namespace http://localhost
// @description Remove hootsuite promoted tweets
// @include https://hootsuite.com/dashboard*
// @version 1
// ==/UserScript==
function addCss(cssString) {
var head = document.getElementsByTagName('head')[0];
@trodrigues
trodrigues / gist:2989617
Created June 25, 2012 16:32
flat hunting in london
Para quartos:
http://www.gumtree.com/
http://uk.easyroommate.com/
http://www.spareroom.co.uk/
Cuidado com os scams no gumtree, ha bastantes.
Para casas:
http://rightmove.co.uk
http://www.moveflat.com/
% curl https://registry.npmjs.org/promised-io/0.3.2
curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html
curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
@trodrigues
trodrigues / kill_test_servers.sh
Created May 7, 2012 20:33
kill script for phantom, buster, selenium
#!/bin/bash
# just call with ./kill_test_servers.sh buster-server|selenium|phantom
function get_buster_server_pid(){
echo `ps aux|grep buster-server|grep node|awk '{ print $2 }'`
}
function get_selenium_server_pid(){
echo `ps aux|grep selenium|grep java|awk '{ print $2 }'`
}
@trodrigues
trodrigues / gist:2489500
Created April 25, 2012 12:45
testing and mocking amd modules with sinon and buster.js
describe('when initializing a friends module', function(){
before(function(){
var self = this;
require('services/top10', function(top10Service) {
self.getFriendStub = sinon.stub(top10Service, 'getFriendTop10');
self.getTop10Stub = sinon.stub(top10Service, 'get');
});
this.view = new CreateLayoutView({
model: {