Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Yuki Matsukura matsubo

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

Rails4をherokuで公開する方法

最終更新日:2013/2/23

概要

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

  • 0からのセットアップ
@matsubo
matsubo / activemerchant_proxy.rb
Created Mar 17, 2014
config/initializers/activemerchant_proxy.rb
View 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)
View stripe_js.html
<!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 Jun 21, 2014
meta programming
View meta.rb
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 Aug 29, 2015 — forked from leods92/group_date.rb
MySQL ONLY. Confirmed on Rails 4.0.x, MySQL 5.6.x
View group_date.rb
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 Jul 1, 2014
Deserializing session value in Rails
View deserialize.rb
$redis.keys.map {|key| p Marshal::load($redis.get(key)) }
View demo.diff
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.*",
View prototype.html
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>Sample Page</title>
<meta name="author" content="Yuki Matsukura">
</head>
<body>
<form>
View prototype.html
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>Sample Page</title>
<meta name="author" content="Yuki Matsukura">
</head>
<body>
<form>