This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def flash_error(message) | |
session[:error] = (session[:error] || []) + [message] | |
end | |
def flash_message(message) | |
session[:notice] = (session[:notice] || []) + [message] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"os" | |
"log" | |
"runtime/pprof" | |
"flag" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) | |
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> for n, c in enumerate("hello cyx"): | |
... print "%s %c" % (n, c) | |
... | |
0 h | |
1 e | |
2 l | |
3 l |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module CleanPasswordConfirmation | |
def clean_password_confirmation | |
password1 = cleaned_data[:password] | |
password2 = cleaned_data[:password_confirmation] | |
if password1 != password2 | |
fail_validation("Passwords don't match.") | |
else | |
password2 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Request < Rack::Request | |
def response | |
@response ||= respond | |
end | |
def respond(*args) | |
Rack::Response.new(*args) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... app code .... | |
require 'ruby-prof' | |
run(lambda do |env| | |
case env['PATH_INFO'] | |
when '/__START__' then | |
RubyProf.start | |
Rack::Response.new("Start profile").finish | |
when '/__STOP__' then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'fileutils' | |
require 'rubygems' | |
gem_dirs = [] | |
basedir = 'deps' | |
FileUtils.mkdir_p(basedir) | |
ARGV.each do |gemset| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task :compile_css do | |
system("sass --scss 'app/views/css/css.scss' 'public/css.css'") | |
puts "Generated public/css.css" | |
end | |
task :compile_js do | |
require './lib/javascripts' | |
js = JAVASCRIPTS.inject("") do |contents,file| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Matcher | |
def initialize(rules) | |
@rules = rules | |
end | |
def matches?(env) | |
captures = Captures.new([], {}, "") | |
@rules.all? do |rule| | |
rule.call(env, captures) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
validates = <<EOS | |
hola <h1>hola</h1> lalalal | |
asdasda <p>asdasda</p> adasda | |
<br> <span> asdasd</span> | |
EOS | |
# Falla porque no se cierra el h1 | |
fails = <<EOS | |
hola <h1>hola lalalal |