Skip to content

Instantly share code, notes, and snippets.

+----------------------+-------+-------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 544 | 412 | 21 | 65 | 3 | 4 |
| Helpers | 64 | 46 | 0 | 13 | 0 | 1 |
| Models | 761 | 566 | 20 | 91 | 4 | 4 |
| Libraries | 21 | 17 | 1 | 2 | 2 | 6 |
| Model specs | 391 | 305 | 0 | 0 | 0 | 0 |
| Mailer specs | 0 | 0 | 0 | 0 | 0 | 0 |
| Acceptance specs | 1043 | 767 | 2 | 16 | 8 | 45 |

puts Rack::Utils::HTTP_STATUS_CODES.sort.to_yaml

Summary, RFC

@raul
raul / rack_redirection.rb
Created February 7, 2011 23:59
rack redirection
next_url = 'http://google.com'
redirection = proc do |env|
[ 301, {'Content-Type' => 'text', 'Location' => next_url}, ["301 - redirected to #{next_url}"] ]
end
run redirection
#!/usr/bin/env ruby
#
# Joins paragraphs so that they span one long line.
# Quoted or indented text are left untouched.
# Useful for Gmail.
#
open('| pbcopy', 'w') do |pbcopy|
pbcopy.write(`pbpaste`.gsub(/([^>\n])\n(\w)/, '\\1 \\2'))
end
@raul
raul / configuration.rb
Created April 7, 2011 10:51
exercise from Charity Tutorial at Scottish Ruby Conf: configuration DSL
class AppServerConfiguration
attr_accessor :port, :admin_password
end
class Configuration
attr_accessor :tail_logs, :max_connections, :admin_password
def initialize(block)
block.call(self)
@raul
raul / redcarpet.rb
Created May 6, 2011 05:32
RedCarpet sample
# works with ruby1.9
require 'rubygems'
require 'redcarpet'
text = <<fenced
Now let's see some fancy CSS:
~~~.css
#foo{
border-top: #000; /* yeah, black */
@raul
raul / z-index.html
Created May 6, 2011 05:40
z-index demo
<!doctype html>
<html lang=en>
<head>
<title>z-index test</title>
<meta charset=utf-8>
<style type="text/css" media="screen">
* {
margin: 0;
padding: 0;
}
@raul
raul / js_test.html
Created May 9, 2011 21:55 — forked from javisantana/test.js
quick'n'dirty javascript testing framework
<!doctype html>
<html lang=en>
<head>
<title>quick'n'dirty js testing framework</title>
<meta charset=utf-8>
<style type="text/css" media="screen">
p { font: .8em courier; padding: .5em 1em; margin: 0;}
.pass { color: #4F8A10; background: #DFF2BF }
.fail { color: #D8000C; background: #FFBABA }
.error{ color: white; background: red }
@raul
raul / css3_bg_gradient.html
Created May 14, 2011 08:59
CSS3 gradient background in short page
<!doctype html>
<html lang=en>
<head>
<title>CSS3 gradient background in short page</title>
<meta charset=utf-8>
<style type="text/css" media="screen">
html{
height: 100%;
}
body{
@raul
raul / gist:1007292
Created June 3, 2011 22:31
Installing rails 3.1rc
> gem install rails --pre
/Users/raul/.rvm/rubies/ruby-1.9.2-p0/bin/gem:4: warning: Insecure world writable dir /usr/local in PATH, mode 040777
ERROR: While executing gem ... (NameError)
uninitialized constant Syck::Syck
> gem install rails -v ">=3.1.0rc"
/Users/raul/.rvm/rubies/ruby-1.9.2-p0/bin/gem:4: warning: Insecure world writable dir /usr/local in PATH, mode 040777
Building native extensions. This could take a while...
Successfully installed activesupport-3.1.0.rc1