Skip to content

Instantly share code, notes, and snippets.

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 / 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
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,
---
: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
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