Skip to content

Instantly share code, notes, and snippets.

View tganzarolli's full-sized avatar

Thiago Ganzarolli tganzarolli

View GitHub Profile
module OAuth::RequestProxy::Net
module HTTP
class HTTPRequest < OAuth::RequestProxy::Base
def query_string
params = [ query_params, auth_header_params ]
params << post_params if
['POST', 'PUT'].include?(method.to_s.upcase) && form_url_encoded?
params.compact.join('&')
end
end
@tomas-stefano
tomas-stefano / before_changes.rb
Created October 21, 2010 19:18
before_changes
module BeforeChanges
def before_changes
before_change_object = self.clone
changes.each do |changed_field, change|
before_change_object.send("#{changed_field}=", change[0])
end
before_change_object
end
end
@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@mrrooijen
mrrooijen / deploy.rb
Created May 16, 2011 18:12
Unicorn + Bluepill + Capistrano with RVM
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
set :application, "my_app"
set :repository, "git@trunksapp.com:myuser/myapp.git"
set :branch, "production"
set :rvm_ruby_string, "1.9.2"
set :deploy_to, "/var/applications/"
set :user, "username"
@MaherSaif
MaherSaif / .gitignore
Created May 22, 2011 16:31 — forked from ledermann/.gitignore
rake deploy and rake cache_assets for Heroku (storing JS minimized and gzipped on Amazon S3)
# Add this
public/javascripts/all.js
@a-chernykh
a-chernykh / application_controller.rb
Created June 22, 2011 19:43
devise force https for sign in and sign up routes
class ApplicationController < ActionController::Base
before_filter :ensure_proper_protocol
protected
def ssl_allowed_action?
(params[:controller] == 'users/sessions' && ['new', 'create'].include?(params[:action])) ||
(params[:controller] == 'users/registrations' && ['new', 'create', 'edit', 'update'].include?(params[:action])) ||
(params[:controller] == 'users/omniauth_callbacks')
end
@thiagocaiubi
thiagocaiubi / gist:1134218
Created August 9, 2011 14:38
running mongo db as a daemon
# startup server
mongod --fork --rest --logpath=/usr/local/mongo/log/mongodb.log --logappend --dbpath=/usr/local/mongo/data/
# shutdown server
$ ./mongo
> use admin
> db.shutdownServer()
@rodbegbie
rodbegbie / facebook.py
Created September 3, 2011 00:15
Hacked version of "official" (but now unsupported) Facebook Python SDK to support OAuth 2.0
#!/usr/bin/env python
#
# Copyright 2010 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@avar
avar / 30-income-calculon.pl
Last active February 12, 2024 18:34
Calculate your income in The Netherlands with and without a 30% ruling.
# To check if this is up-to-date with the tax rates go to
# http://www.expatax.nl/tax-rates-2016.php and see if there's anything
# newer there.
#
# I make no guarantees that any of this is correct. I calculated this
# at the time and have been updating it when new tax rates come along
# because people keep finding this useful.
#
# There's also an interactive JS version of this created by
# @stevermeister at
@marcelcaraciolo
marcelcaraciolo / tf_idf_final.py
Created January 13, 2012 03:38
tf-idf example
#-*- coding: utf-8 -*-
import re
import nltk
from nltk.tokenize import RegexpTokenizer
from nltk import bigrams, trigrams
import math
stopwords = nltk.corpus.stopwords.words('portuguese')