Skip to content

Instantly share code, notes, and snippets.

class GatewayPagLw
VALID_PAG_TYPES = {:boleto => 'BOLETOLOCAWEB', :visa => nil, :redecard => nil}
VALID_ENVIRONMENT = {:producao => 'PRODUCAO', :teste => 'TESTE'}
def initialize(pag_type, environment, identification)
raise "Payment type #{pag_type} unknown" unless VALID_PAG_TYPES.include? pag_type
raise "Environment type #{environment} unknown" unless VALID_ENVIRONMENT.include? environment
@pag_type = pag_type
---
:bulk_threshold: 1000
:backtrace: false
:sources:
- http://gemcutter.org
- http://gems.rubyforge.org/
- http://gems.github.com/
gem: --no-ri --no-rdoc
:benchmark: false
:update_sources: true
require 'nokogiri'
doc = Nokogiri::XML(File.open('/home/felipe/banco_belasoft.xml', 'r'))
doc.search('ROOT//row').each do |c|
MyCustomerModel.create (
:old_code => c.search('field[@name="codigo"]').text,
:name => c.search('field[@name="nome"]').text,
:gender => c.search('field[@name="sexo"]').text,
:birth => c.search('field[@name="data_nascimento"]').text,
@warlley
warlley / gist:595843
Created September 24, 2010 18:54 — forked from durran/gist:315227
module MultiParameterAttributes
def filter_time(attributes, name)
attrs = attributes.collect do |key, value|
if key =~ /^#{Regexp.escape(name.to_s)}\((\d+)(\w)\)$/
[$1.to_i, value.send("to_#$2")]
end
end.compact.sort_by(&:first).map(&:last)
Time.zone.local(*attrs) unless attrs.empty?
end
warlley@fmdev-01:~$ ruby -rhttpclient -e 'c = HTTPClient.new;c.ssl_config.verify_callback = ->(ok, ctx){ p [ok, ctx.current_cert.subject];true }; c.get("https://graph.facebook.com/")'
[true, /C=US/O=Entrust.net/OU=www.entrust.net/CPS incorp. by ref. (limits liab.)/OU=(c) 1999 Entrust.net Limited/CN=Entrust.net Secure Server Certification Authority]
[true, /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance EV Root CA]
[true, /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance CA-3]
[true, /C=US/ST=California/L=Palo Alto/O=Facebook, Inc./CN=*.facebook.com]
warlley@fmdev-01:~$ ruby -rhttpclient -e 'c = HTTPClient.new; c.ssl_config.clear_cert_store; c.ssl_config.add_trust_ca("/home/warlley/restclient_with_cert/lib/cert"); c.ssl_config.verify_callback = ->(ok, ctx){ p [ok, ctx.current_cert.subject];true }; c.get("https://graph.facebook.com/")'
[false, /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance EV Root CA]
[false, /C=US/O=DigiCert Inc/OU=www.digicert.com/CN
@warlley
warlley / untitled.rb
Created May 16, 2011 14:24
Exemplo de busca e leitura de arquivos xml
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'find'
FIND_PATH = "/Users/warlley/Downloads/nfe"
Find.find(FIND_PATH) do |file_path|
if File.extname(file_path).downcase == '.xml'
nfe = Nokogiri::XML(File.open(file_path))
@warlley
warlley / gist:1234663
Created September 22, 2011 12:40
Rails Generators
config.generators do |g|
g.orm :mongoid
g.template_engine :erb
g.test_framework :rspec
end
xml.instruct! :xml, :version => "1.0"
xml.rss :version => "2.0" do
xml.channel do
xml.title "Titulo do blog"
xml.description "Este é um blog sobre..."
xml.link posts_url
for post in @posts
xml.item do
xml.title post.title
@warlley
warlley / gist:3788319
Created September 26, 2012 14:17
show branch on shell
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function proml {
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local YELLOW="\[\033[0;33m\]"
local LIGHT_GREEN="\[\033[1;32m\]"
local WHITE="\[\033[1;37m\]"
@warlley
warlley / .gitignore
Created January 3, 2013 10:50
.gitignore for delphi projects
*.dcu
*.ini
*.~*
*.bdsproj
*.cfg
*.dproj
*.dproj.local
*.bdsgroup
*.bdsgroup.local
*.bdsproj.local