Skip to content

Instantly share code, notes, and snippets.

View carlosrodriguez's full-sized avatar

Carlos Rodriguez carlosrodriguez

View GitHub Profile
require "rubygems"
require "test/unit"
gem "selenium-client", ">=1.2.16"
require "selenium/client"
require 'threadify'
class ExampleTest < Test::Unit::TestCase
#SELENIUM_BROWSERS=all
def browsers
// once the google maps is loaded, put a Raphael canvas on top of it
// be sure to apply margin:0 to the body in this case
var point = new GLatLng(46.065375, 5.448974);
var pixel = map.fromLatLngToContainerPixel(point);
var paper = Raphael(0, 0, 400, 300);
var circle = paper.circle(pixel.x, pixel.y, 10);
circle.attr("fill", "#f00");
circle.attr("stroke", "#fff");
@xonecas
xonecas / wget
Created January 22, 2011 21:17
simple wget for node.js
require('http');
function wget (host, path, https, callback) {
var port = (https)? 443: 80,
client = http.createClient(port, host, https),
request = client.request('get', path, { 'host': host }),
response_body = '';
request.end();
request.on('response', function (response) {
@nathany
nathany / git.rake
Created March 30, 2011 04:58
Generate a "Compare View" in markdown, complete with Gravatars and links to GitHub commits
require 'digest/md5'
namespace :git do
GITHUB_COMMIT_URL = "https://github.com/path/to/your/repo/commit/" # <= set me
# Before doing a deploy, I like to check GitHub's branch list
# but I wanted to be able to save it in a Lighthouse message
COMPARE_FOR = {
'production' => 'origin/production..origin/release',
@aslakhellesoy
aslakhellesoy / cukelite.js
Created April 19, 2011 23:15
A little example illustrating how to lex a Gherkin file with node.js
// First: npm install gherkin
// Usage: node cukelite.js path/to/some.feature
var fs = require('fs');
var Lexer = require('gherkin').Lexer('en');
var lexer = new Lexer({
comment: function(value, line) {
console.log(value);
},
tag: function(value, line) {
@hunterloftis
hunterloftis / gist:973973
Created May 16, 2011 05:25
Zepto + Mustache + KnockoutJS starting point
ko.mustacheTemplateEngine = function () {
this['getTemplateNode'] = function (template) {
var templateNode = document.getElementById(template);
if (templateNode == null)
throw new Error("Cannot find template with ID=" + template);
return templateNode;
}
this['renderTemplate'] = function (templateId, data, options) {
@founddrama
founddrama / gist:1013614
Created June 8, 2011 01:42
a jshint pre-commit hook for git
#!/bin/sh
# A pre-commit hook for git to lint JavaScript files with jshint
# @see https://github.com/jshint/jshint/
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
@cointilt
cointilt / gist:1331673
Created November 1, 2011 19:38
Javascript Mobile Sniffer
(function(a,b){if(/android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|
@nathansmith
nathansmith / file_input_example.css
Created December 9, 2011 14:56
Markup to Hide a File Input
.fake_file_input {
background: url(../images/fake_file_input.png) no-repeat;
cursor: pointer;
width: 150px;
height: 30px;
overflow: hidden;
position: relative;
display: inline-block;
*display: inline;
*zoom: 1;
@peol
peol / qunit.md
Created February 26, 2012 08:39
QUnit/SinonJS/Backbone.js

#Backbone.js Testing With QUnit & SinonJS

QUnit is a powerful JavaScript test suite written by Jörn Zaefferer and used by many large open-source projects (such as jQuery and Backbone.js) to test their code. It's both capable of testing standard JavaScript code in the browser as well as code on the server-side (where environments supported include Rhino, V8 and SpiderMonkey). This makes it a robust solution for a number of use-cases.

Quite a few Backbone.js contributors feel that QUnit is a better introductory framework for testing if you don't wish to start off with Jasmine and BDD right away. As we'll see later on in this chapter, QUnit can also be combined with third-party solutions such as SinonJS to produce an even more powerful testing solution supporting spies and mocks, which some say is preferable over Jasmine.

My personal recommendation is that it's worth comparing both frameworks and opting for the solution that you feel the most comfortable with.