Skip to content

Instantly share code, notes, and snippets.

View 0xradical's full-sized avatar

Thiago Brandão 0xradical

View GitHub Profile
@0xradical
0xradical / ruby-1.9-tips.rb
Created October 17, 2011 00:46 — forked from igrigorik/ruby-1.9-tips.rb
Ruby 1.9 features, tips & tricks you may not know about...
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
@0xradical
0xradical / html5template.html
Created October 17, 2011 00:52 — forked from rwbaker/html5template.html
HTML5 Template
<!doctype html>
<!--[if lt IE 7]> <html class="ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="ie8 oldie" lang="en"> <![endif]-->
<!--[if IE 9]> <html class="ie9" lang="en"> <![endif]-->
<!--[if gt IE 9]><!-->
<html lang="en">
<!--<![endif]-->
<head>
<meta charset="utf-8">
@0xradical
0xradical / ruby_192_p190.rb
Created October 24, 2011 16:36
instalando ruby-1.9.2p190 com patch
brew install readline
brew install libiconv
brew link libiconv
curl https://raw.github.com/gist/1008945/4edd1e1dcc1f0db52d4816843a9d1e6b60661122/ruby-1.9.2p290.patch > /tmp/192.patch
rvm uninstall 1.9.2 && rvm cleanup all && rvm fetch 1.9.2
rvm install 1.9.2 --patch /tmp/192.patch --with-readline-dir=/usr/local/Cellar/readline/6.2.1 --with-iconv-dir=/usr/local/Cellar/libiconv/1.14
@0xradical
0xradical / performance_and_backport_gc.patch
Created January 27, 2012 15:21 — forked from funny-falcon/performance_and_backport_gc.patch
Union of backport GC and performance patches for ruby-1.9.3-p0
diff --git a/ChangeLog b/ChangeLog
index c4ea779..0a6bf73 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,188 @@
+Tue Jan 17 12:32:46 2012 Nobuyoshi Nakada <[email protected]>
+
+ * gc.c (aligned_malloc, aligned_free): covered missing defined
+ operators and fixes for cygwin.
+
@0xradical
0xradical / Gemfile
Created March 23, 2012 12:52
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
@0xradical
0xradical / ruby1.9.3-p194.txt
Created July 4, 2012 12:46
installing ruby-1.9.3-p195 with readline, openssl and proper flags
https://github.com/wayneeseguin/rvm/issues/1016
LDFLAGS=-L/usr/local/Cellar/readline/6.2.2/lib CFLAGS=-I/usr/local/Cellar/readline/6.2.2/include rvm install 1.9.3-p194 -j 3 --with-readline=--with-readline-dir=/usr/local/Cellar/readline/6.2.2 --with-openssl-dir=/usr/local/Cellar/openssl/1.0.1c/
@0xradical
0xradical / server from new install
Created October 5, 2012 16:29 — forked from rossnelson/server from new install
Leopard, Homebrew, Git, RVM, Ruby, MySQL and ImageMagick
# 2012-01-07
#
# Mac OS X 10.5.8
# Homebrew 0.9
# Xcode 3.1.4
# Git 1.7.10
# RVM 1.3.0
# Ruby 1.9.3
# MySQL 5.5.20
# ImageMagick 6.7.5-7
@0xradical
0xradical / foo_controller.rb
Created November 12, 2012 23:10 — forked from lloeki/foo_controller.rb
Streaming (CSV) data in Rails 3.2
class FooController
respond_to :csv
def index
@foos = Foo.scoped
if stale?(:last_modified => Foo.something)
respond_with @gta do |format|
format.csv { stream_csv @foo }
end
end
@0xradical
0xradical / controller_not_dry.rb
Created November 13, 2012 12:38 — forked from bsodmike/controller_not_dry.rb
Streaming CSV file to the Client with Rails 3.1
format.csv do
@scheduled_session = Session.find(params[:id])
@applicants = @scheduled_session.applicant_signups
filename = "#{@scheduled_session.title.parameterize.downcase}_applicant_list_#{Time.now.strftime('%d%m%Y')}.csv"
headers['Content-Disposition'] = 'attachment; filename="' + filename + '"'
titles = [
"Title", "First Name", "Last Name", "DOB Day", "DOB Month", "DOB Year", "Nationality", \
"Email", "Mobile Number", "Address Line 1", "Address Line 2", "Place of Work", \
"Discipline/Speciality", "Job Title", "Key Responsibilities", "Payment Ref."
]
@0xradical
0xradical / csv_streamer.rb
Created November 13, 2012 13:01
CSV streamer
# controller method
def csv_export
respond_to do |format|
format.csv {
@filename = "responses-#{Date.today.to_s(:db)}.csv"
self.response.headers["Content-Type"] ||= 'text/csv'
self.response.headers["Content-Disposition"] = "attachment; filename=#{@filename}"
self.response.headers['Last-Modified'] = Time.now.ctime.to_s