Skip to content

Instantly share code, notes, and snippets.

View matsubo's full-sized avatar

Yuki Matsukura matsubo

View GitHub Profile
@matsubo
matsubo / worldpay.rb
Last active August 29, 2015 13:56
Sample code for activemerchant's WorldpayGateway.
require 'active_merchant'
require 'pp'
currency = 'USD'
gateway = ActiveMerchant::Billing::WorldpayGateway.new(
:login => 'YOUR_MERCHANT_ID',
:password => 'YOUR_XML_PASSWORD',
:test => true,
)

Rails4をherokuで公開する方法

最終更新日:2013/2/23

概要

現在最新のRuby on Rails 4.0.3をherokuで公開するための設定を記載します。 大きく、2つの項目で構成されます。

  • 0からのセットアップ
@matsubo
matsubo / activemerchant_proxy.rb
Created March 17, 2014 11:08
config/initializers/activemerchant_proxy.rb
unless Settings.activemerchant.proxy.host.blank?
module ActiveMerchant
class Connection
alias_method :http_original, :http
private
def http
proxy = Settings.activemerchant.proxy
http = Net::HTTP.new(endpoint.host, endpoint.port, proxy.host, proxy.port)
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>Stripe JS Sample Page</title>
<meta name="author" content="Yuki Matsukura">
</head>
<body>
@matsubo
matsubo / meta.rb
Created June 21, 2014 03:38
meta programming
class << Time
alias_method :now_original, :now
def now
puts 'override'
end
end
puts Time.now
puts Time.now_original
@matsubo
matsubo / group_date.rb
Last active August 29, 2015 14:02 — forked from leods92/group_date.rb
MySQL ONLY. Confirmed on Rails 4.0.x, MySQL 5.6.x
module ActiveRecord
module Querying
delegate :group_date, :to => :scoped
end
module QueryMethods
def group_date(column_name = nil)
return self if column_name.blank?
# Rails uses a non standard time zone naming.
@matsubo
matsubo / deserialize.rb
Created July 1, 2014 06:08
Deserializing session value in Rails
$redis.keys.map {|key| p Marshal::load($redis.get(key)) }
diff --git a/composer.json b/composer.json
index 239a542..c697dad 100644
--- a/composer.json
+++ b/composer.json
@@ -1,5 +1,6 @@
{
"require": {
+ "php": ">=5.4.0",
"curl/curl": "dev-master",
"phpunit/phpunit": "4.1.*",
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>Sample Page</title>
<meta name="author" content="Yuki Matsukura">
</head>
<body>
<form>
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>Sample Page</title>
<meta name="author" content="Yuki Matsukura">
</head>
<body>
<form>