Skip to content

Instantly share code, notes, and snippets.

View renanra's full-sized avatar

Renan de Azevedo renanra

  • Rio de Janeiro - Brazil
View GitHub Profile
@renanra
renanra / jquery.countable.js
Created July 16, 2012 20:33
jQuery Countable Plugin
;(function ( $, window, undefined ) {
var pluginName = 'countable',
document = window.document,
defaults = {
step: 1,
min: 1,
max: 0,
value: 1,
increase: ".increase",
decrease: ".decrease",
@renanra
renanra / gist:2703687
Created May 15, 2012 17:51
API test with CURL and jQuery
http://blogs.plexibus.com/2009/01/15/rest-esting-with-curl/
http://stackoverflow.com/questions/298745/how-do-i-send-a-cross-domain-post-request-via-javascript
POSTS CURL
curl -i -H "Accept: application/json" -X GET http://localhost:3000/posts.json
curl -i -H "Accept: application/json" -X GET http://localhost:3000/posts/2.json
curl -i -H "Accept: application/json" -X POST -d "post[title]=meu titulo&post[content]=meu conteudo" http://localhost:3000/posts.json
curl -i -H "Accept: application/json" -X PUT -d "post[title]=meu titulo2" http://localhost:3000/posts/1.json
curl -i -H "Accept: application/json" -X DELETE http://localhost:3000/posts/1.json
@renanra
renanra / random_date.rb
Created April 30, 2012 18:59
random_date ruby/rails
# USAGE:
# random_date() # => random date within 20 days past
# random_date(30) # => random date within 30 days past
# random_date(:unity => :second) => random date within 20 seconds past
# random_date(:future => true) => random date within 20 days future and past
# random_date(:past => false) => random date within 20 days future
# random_date(4.years, :unity => :second, :past => false) => random date withim 4 years future. Random year til second
# random_date(4, :unity => :years, :past => false) => random date withim 4 years future. Actual date with random year only
def random_date(*arguments)
options = {