This file contains 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 delete_comment | |
message = Message.of(current_account.permalink).find(params[:message_id]) | |
comment = message.comments.criteria.where(:comment_id => params[:id]).first | |
current_account.facebook.api.delete(comment.comment_id) | |
comment.destroy | |
respond_to do |format| | |
format.json { render :json => message } | |
end | |
end |
This file contains 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
--------------- | |
Object1: !myObject1 { name: Jack, age: 26, address: Hong Kong } | |
Object2: !myObject2 { title: SAW, price: 65, location: [Hong Kong, Kowloon]} |
This file contains 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
DB_CONFIG = YAML.load_file(“#{RAILS_ROOT}/config/database.yml”)[RAILS_ENV] | |
p DB_CONFIG['host'] # 192.168.0.1 | |
p DB_CONFIG['username'] # project | |
p DB_CONFIG['password'] # xxxxxx |
This file contains 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
XML: | |
<watchlist> | |
<id type="integer">287</id> | |
<last-updated type="datetime">2007-10-22T13:05:27-04:00</last-updated> | |
<name>macromedia</name> | |
</watchlist> | |
<watchlist> | |
<id type="integer">288</id> | |
<last-updated type="datetime">2007-10-22T13:05:29-04:00</last-updated> |
This file contains 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
xml = File.read('timeline.xml') | |
puts Benchmark.measure { | |
doc, statuses = REXML::Document.new(xml), [] | |
doc.elements.each('statuses/status') do |s| | |
h = {:user => {}} | |
%w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| | |
h[a.intern] = s.elements[a].text | |
end | |
%w[id name screen_name location description profile_image_url url protected followers_count].each do |a| | |
h[:user][a.intern] = s.elements['user'].elements[a].text |
This file contains 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
development: | |
adapter: mysql2 | |
host: 192.168.00.01 | |
database: project | |
username: project | |
password: xxxxxx | |
# socket: /var/mysql/mysql.sock | |
pool: 5 | |
timeout: 5000 |
This file contains 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
development: | |
paypal: | |
login: | |
password: | |
signature: | |
cert_id : | |
paypal_standard: | |
email: | |
password: |
This file contains 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
#Encrypt the transaction information | |
cert_id =YAML.load(File.open("#{RAILS_ROOT}/config/paypal.yml"))[ENV["RAILS_ENV"]]['paypal']['cert_id'] | |
paypal_params = {:cert_id=>cert_id} | |
service.form_fields.collect do |field, value| | |
paypal_params.merge!({field=>value}) | |
end | |
result << hidden_field_tag(:cmd, "_s-xclick") | |
result << "\n" | |
result << hidden_field_tag(:encrypted, encrypt_for_paypal(paypal_params)) | |
# result << service.form_fields.collect do |field, value| |
This file contains 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
APP_CERT_PEM = File.read("#{Rails.root}/certs/app_cert.pem") | |
APP_KEY_PEM = File.read("#{Rails.root}/certs/app_key.pem") | |
def encrypt_for_paypal(values) | |
signed = OpenSSL::PKCS7::sign(OpenSSL::X509::Certificate.new(APP_CERT_PEM), | |
OpenSSL::PKey::RSA.new(APP_KEY_PEM, ''), values.map { |k, v| "#{k}=#{v}" }.join("\n"), [], OpenSSL::PKCS7::BINARY) | |
OpenSSL::PKCS7::encrypt([OpenSSL::X509::Certificate.new(PAYPAL_CERT_PEM)], signed.to_der, OpenSSL::Cipher::Cipher::new("DES3"), OpenSSL::PKCS7::BINARY).to_s.gsub("\n", "") | |
end |
This file contains 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
<% payment_service_for @order_id, @seller_account_email, | |
:amount => @total_price, | |
:currency => @currency, | |
:service => 'paypal', | |
:html => { :id => 'my-form' } do |service| %> | |
<% service.customer :first_name => @customer.first_name, | |
:last_name => @customer.last_name, | |
:phone => @customer.phone, | |
:email => @customer.email %> |