Skip to content

Instantly share code, notes, and snippets.

View kivanio's full-sized avatar
🏠
Working from home

Kivanio Barbosa kivanio

🏠
Working from home
View GitHub Profile
@njvitto
njvitto / deploy.rake
Created April 11, 2010 16:56 — forked from RSpace/deploy.rake
Rakefile to deploy and rollback to Heroku in two different environments (staging and production) for the same app
#Deploy and rollback on Heroku in staging and production
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
namespace :deploy do
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU'
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU'
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag]
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on]
@kivanio
kivanio / strategy_pattern_extend_self.rb
Created September 20, 2010 19:44
Strategy_pattern + extend self
# http://en.wikipedia.org/wiki/Strategy_pattern + extend self
module StrategyA
extend self
def execute
puts 'Doing the task the normal way'
end
end
@karmi
karmi / .gitignore
Created May 15, 2011 11:15
Import your Gmail messages into ElasticSearch and search them with a simple web application.
.DS_Store
*.log
Gemfile.lock
@lpar
lpar / timeout.rb
Created June 17, 2011 20:41
Run a shell command in a separate thread, terminate it after a time limit, return its output
# Runs a specified shell command in a separate thread.
# If it exceeds the given timeout in seconds, kills it.
# Returns any output produced by the command (stdout or stderr) as a String.
# Uses Kernel.select to wait up to the tick length (in seconds) between
# checks on the command's status
#
# If you've got a cleaner way of doing this, I'd be interested to see it.
# If you think you can do it with Ruby's Timeout module, think again.
def run_with_timeout(command, timeout, tick)
output = ''
@jcasimir
jcasimir / better_rails_through_better_ruby.markdown
Created September 13, 2011 18:32
Better Rails Through Better Ruby

The Problem is Your Ruby

(Intro)

Stop Trying

Stop trying to be an expert at Rails.

Is it Hard?

@nicalpi
nicalpi / helper.rb
Created September 29, 2011 16:07
Share with facebook url, with summary and title but no need of OG Data
def share_with_facebook_url(opts)
# Generates an url that will 'share with Facebook', and can includes title, url, summary, images without need of OG data.
#
# URL generate will be like
# http://www.facebook.com/sharer.php?s=100&p[title]=We also do cookies&p[url]=http://www.wealsodocookies.com&p[images][0]=http://www.wealsodocookies.com/images/logo.jpg&p[summary]=Super developer company
#
# For this you'll need to pass the options as
#
# { :url => "http://www.wealsodocookies.com",
@bbenezech
bbenezech / rails_admin_action_creator
Created January 16, 2012 14:35
Create a RailsAdmin custom action
say "Create stub for '#{action_name = name.sub('rails_admin_', '')}' in gem '#{name}'. This may take a while"
run "rm -rf script/ config/ lib/tasks/"
run "rm -rf app/assets app/controllers app/helpers app/mailers app/models"
run "mkdir -p app/views/rails_admin/main"
inside "app/views/rails_admin/main" do
create_file "#{action_name}.html.haml", <<-END
%h2 Custom action loaded and active
%pre @abstract_model.inspect
%pre @object.inspect
END
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@fnando
fnando / gist:2420869
Created April 19, 2012 13:10
My JavaScript Guidelines

Integers

1 + 1
2 * 2
5 / 3
5 % 3
5 ** 2