Skip to content

Instantly share code, notes, and snippets.

def buildConnectionString(params):
"""Build a connection string from a dictionary of parameters.
Returns string."""
return ";".join(["%s=%s" % (k, v) for k, v in params.items()])
<!DOCTYPE html>
<html>
<head>
<title>Dashboard</title>
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :all %>
<%= csrf_meta_tag %>
</head>
<body>
def buildConnectionString(params):
"""Build a connection string from a dictionary
Returns string.
"""
result = ["%s=%s" % (k, v) for k, v in params.items()]
return ";".join(result)
if __name__ == "__main__":
myParams = {"server":"mpilgrim", \
class SendMail < ActionMailer::Base
def contact(nome, fone, email, assunto, corpo)
recipients 'sac@ddd.com.br'
from "SITE:
subject assunto
sent_on Time.now
content_type "text/html"
# Retorna um par de lambdas que compartilham acesso para uma variável local.
def accessor_pair(initial_value=nil)
value = initial_value # variavel local compartilhada pelos lambdas retornados
getter = lambda { value } # valor mudado da variável local.
setter = lambda { |x| value = x } # retorna um par de lambdas para o caller.
return getter, setter
end
get_x, set_x = accessor_pair(0) # cria lambdas accessor para o valor inicial 0.
puts get_x[] # imprime 0. Observe colchetes, ao invés de call.
@norbajunior
norbajunior / rails_3_1_beta_1_changes.md
Created June 7, 2011 18:58 — forked from ryanb/rails_3_1_rc4_changes.md
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 Beta 1

  • The -j option of the application generator accepts an arbitrary string. If passed "foo", the gem "foo-rails" is added to the Gemfile, and the application JavaScript manifest requires "foo" and "foo_ujs". As of this writing "prototype-rails" and "jquery-rails" exist and provide those files via the asset pipeline. Default is "jquery". [fxn]

  • jQuery is no longer vendored, it is provided from now on by the jquery-rails gem. [fxn]

  • Prototype and Scriptaculous are no longer vendored, they are provided from now on by the prototype-rails gem. [fxn]

  • The scaffold controller will now produce SCSS file if Sass is available [Prem Sichanugrist]

@norbajunior
norbajunior / Gemfile
Created August 23, 2011 21:47
uninitialized constant Devise::IndifferentHash (NameError)
source 'http://rubygems.org'
gem 'rails', '3.1.0.rc6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
# ======= pass the paremeter :git with the repository's url that works. ====== #
@norbajunior
norbajunior / seeds.rb
Created August 30, 2011 13:25 — forked from dcrec1/seeds.rb
State of Brazil for Spree
states = <<STATES
28,AC,Acre
28,AL,Alagoas
28,AP,Amapá
28,AM,Amazonas
28,BA,Bahia
28,CE,Ceará
28,ES,Espírito Santo
28,GO,Goiás
28,MA,Maranhão
@norbajunior
norbajunior / roteiro-aula5.md
Created December 7, 2011 14:26 — forked from danielvlopes/roteiro-aula5.md
Roteiro aula 5 - Una Web 2