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
| <?php | |
| function sendEmailViaWebService($email) { | |
| $soapClient = new soapclient("http://www.paulinia.sp.gov.br/email/sendmail.asmx?WSDL", "wsdl"); | |
| $request = "<Send xmlns='http://tempuri.org/'> | |
| <De>{$email['from']}</De> | |
| <Para>{$email['to']}</Para> | |
| <Assunto>{$email['subject']}</Assunto> | |
| <Mensagem>{$email['message']}</Mensagem> | |
| </Send>"; |
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
| 1.upto 500 do | |
| Class.new do | |
| 1.upto 1000 do |method_number| | |
| method_name = "method_#{method_number}" | |
| instance_eval "# Hi I am a comment for #{method_name}" | |
| attr_accessor method_name.to_sym | |
| end | |
| ["click", "mousedown", "mouseenter", "mouseleave", "mouseout", "mouseover", "mouseup"].each do |event| | |
| define_method event.to_sym do | |
| "Hi I am on #{event}" |
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
| # Ruby way fail | |
| # Implementation of a simple method to convert seconds to time format (03:44:23) | |
| require "benchmark" | |
| seconds = 45020 | |
| hours = seconds / 3600 | |
| minutes = seconds / 60 % 60 |
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
| Sass::Plugin.options[:template_location] = "#{Rails.root}/app/styles" => "#{Rails.root}/tmp/stylesheets" | |
| Rails.configuration.middleware.insert_after "Sass::Plugin::Rack", "Rack::Static", :urls => ["/stylesheets"], :root => "#{Rails.root}/tmp" |
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
| gem 'devise', '~> 1.1.2' | |
| gem 'cancan' | |
| generate 'devise:install' |
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
| apply 'http://gist.github.com/raw/562316/1c45aa71f17491c36d74123abf7886b9a08daddf/basic_stack.rb' | |
| apply 'http://gist.github.com/raw/562316/ed62987b05de614c9b37062f410a3a48e4e776f2/brazilian_app.rb' | |
| apply 'http://gist.github.com/raw/562316/56326e84aa23d9ac1cc227f8aa8ae178f2d4d6b5/cleanup.rb' | |
| apply 'http://gist.github.com/raw/562316/7406f13bf9d9b9d467f3d00a26b56a960685beeb/rspec.rb' | |
| apply 'http://gist.github.com/raw/562316/ad35700fa4f3cf9163b0149b19beeba0407ea325/cucumber.rb' | |
| apply 'http://gist.github.com/raw/562316/4cc84eb5ea709c2f0ea76783157548a660a374a2/w3.rb' |
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
| require "ostruct" | |
| module FormsHelper | |
| def search_form_for(object_name, options={}, &block) | |
| options[:html] = {:method => :get}.update(options[:html] || {}) | |
| object = OpenStruct.new(params[object_name]) | |
| form_for(object_name, object, options, &block) | |
| 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
| class CQM < ActiveRecord::Base | |
| self.abstract_class = true | |
| establish_connection( | |
| :adapter => "mysql2", | |
| :host => "localhost", | |
| :username => "root", | |
| :password => "root", | |
| :database => "cqm_development" | |
| ) |
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 Screenshoter | |
| include Java | |
| import java.io.File | |
| import java.awt.Robot | |
| import java.awt.Toolkit | |
| import java.awt.Rectangle | |
| import javax.imageio.ImageIO | |
| def self.shoot!(output = "screenshot.png") |
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 get(name, type = :string) | |
| parameter = name.is_a?(Array) ? self.key_chain(*name) : self[name] | |
| if !parameter.blank? | |
| case type | |
| when :string then parameter.to_s | |
| when :hash, :collection then parameter | |
| when :csv then parameter.split(',').map(&:strip) | |
| when :integer then Integer(parameter) | |
| when :float then Float(parameter) |