Skip to content

Instantly share code, notes, and snippets.

def flash_error(message)
session[:error] = (session[:error] || []) + [message]
end
def flash_message(message)
session[:notice] = (session[:notice] || []) + [message]
end
package main
import (
"fmt"
"net/http"
"os"
"log"
"runtime/pprof"
"flag"
)
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
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
class Request < Rack::Request
def response
@response ||= respond
end
def respond(*args)
Rack::Response.new(*args)
end
end
# ... 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
#!/usr/bin/env ruby
require 'fileutils'
require 'rubygems'
gem_dirs = []
basedir = 'deps'
FileUtils.mkdir_p(basedir)
ARGV.each do |gemset|
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|
class Matcher
def initialize(rules)
@rules = rules
end
def matches?(env)
captures = Captures.new([], {}, "")
@rules.all? do |rule|
rule.call(env, captures)
# -*- 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