Skip to content

Instantly share code, notes, and snippets.

View hernan's full-sized avatar

Hernan Fernandez hernan

  • Argentina
View GitHub Profile
@hernan
hernan / turbine.rb
Created November 21, 2012 18:55
middleware request observer
require 'active_support/core_ext/hash/conversions'
require 'action_dispatch/http/request'
require 'active_support/core_ext/hash/indifferent_access'
class Turbine
def initialize(app)
@app = app
end
@hernan
hernan / reqUrl.js
Created November 20, 2012 21:20 — forked from wilsonpage/reqUrl.js
A function I made that wraps the node http.request function to make it a little more friendly. In my case I am using it for API route testing.
// module dependencies
var http = require('http'),
url = require('url');
/**
* UrlReq - Wraps the http.request function making it nice for unit testing APIs.
*
* @param {string} reqUrl The required url in any form
* @param {object} options An options object (this is optional)
@hernan
hernan / app.rb
Created May 23, 2012 16:25 — forked from cpatni/app.rb
unique calculation using redis
require 'sinatra'
require 'redis'
require 'json'
require 'date'
class String
def &(str)
result = ''
result.force_encoding("BINARY")
@hernan
hernan / hack.sh
Created March 31, 2012 21:31 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@hernan
hernan / autocomplete.html
Created November 30, 2011 15:39
jquery autocomplete demo with custom render item implementation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Autocomplete - Custom data and display</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.6.2.js"></script>
<script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script>
@hernan
hernan / LICENSE.txt
Created November 2, 2011 13:01 — forked from jed/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@hernan
hernan / LICENSE.txt
Created November 2, 2011 13:01 — forked from jed/LICENSE.txt
linkify @mentions and #hashtags in a tweet
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@hernan
hernan / ba-backbone-module.js
Created October 10, 2011 19:13 — forked from cowboy/ba-backbone-module.js
Idea for a Backbone module system (allowing modules to be accessed across multiple files, possibly loaded out of order). Inspired by https://gist.github.com/1202511
/*!
* Backbone Module Manager - v0.1pre - 9/9/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
function ModuleManager(fn) {
@hernan
hernan / mini_shoulda.rb
Created October 3, 2011 21:50
keep the same shoulda syntax with minitest
#
# https://github.com/padrino/padrino-framework/blob/master/padrino-core/test/mini_shoulda.rb
#
gem 'minitest'
require 'minitest/spec'
require 'minitest/autorun'
require 'mocha' # Load mocha after minitest
begin
@hernan
hernan / code.rb
Created September 17, 2011 21:33 — forked from caius/code.rb
Useful Regular Expressions in Ruby's URI Library
require "uri"
(URI::REGEXP.constants - ["PATTERN"]).each do |rc|
puts "#{rc}: #{URI::REGEXP.const_get(rc)}"
end
URI::REGEXP::PATTERN.constants.each do |pc|
puts "#{pc}: #{URI::REGEXP::PATTERN.const_get(pc)}"
end