Skip to content

Instantly share code, notes, and snippets.

View gabrielmansour's full-sized avatar

Gabriel Mansour gabrielmansour

View GitHub Profile
@natritmeyer
natritmeyer / unused.rb
Created April 5, 2011 20:00
Cucumber formatter for printing unused steps
# Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
#
# http://www.natontesting.com
#
# Save this in a file called 'unused.rb' in your 'features/support' directory. Then, to list
# all the unused steps in your project, run the following command:
#
# cucumber -d -f Cucumber::Formatter::Unused
#
# or...
jQuery.placeholder = function() {
$('[placeholder]').focus(function() {
var input = $(this);
if (input.hasClass('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
if (input.val() === '') {
// Released under MIT license: http://www.opensource.org/licenses/mit-license.php
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
@remy
remy / gist:350433
Created March 31, 2010 14:58
Storage polyfill
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
# Newbie Programmer
def factorial(x)
if x == 0
return 1
else
return x * factorial(x - 1)
end
end
puts factorial(6)
puts factorial(0)
@remy
remy / geolocation.js
Created January 29, 2010 00:22
Adds geolocation support via JavaScript and a service from maxmind.com to add the lat/long - perfect :)
if (!navigator.geolocation) {
navigator.geolocation = (function (window, document) {
function getCurrentPosition(callback) {
var geourl = 'http://www.google.com/jsapi?' + Math.random(),
iframe = document.createElement('iframe'),
doc, win;
iframe.style.display = 'none';
window.document.body.appendChild(iframe);
@cwsaylor
cwsaylor / gist:8511
Created September 3, 2008 00:53
hack sink ship
# Variation on Hashrocket's script for managing the git process
# as documented here: http://reinh.com/blog/2008/08/27/hack-and-and-ship.html
# Create shell scripts out of each of these, put them in your path (~/bin for example)
# chmod 755 them and use like this:
#
# This version of hack is totally different than Hackrockets. I feel that hack implies
# that you are getting started, not finishing up. sink is Hashrockets hack.
#
# $ hack branch_name
# Test and Implement until done