Skip to content

Instantly share code, notes, and snippets.

@kskb
kskb / croudwatch_sample.rb
Created March 23, 2015 06:11
AWS SDK for Ruby v2 Aws::CloudWatch::Client#get_metric_statistics sample
require 'aws-sdk-core'
require 'active_support'
require 'active_support/core_ext'
cw = Aws::CloudWatch::Client.new( region: 'us-east-1')
resp = cw.get_metric_statistics(
namespace: "AWS/Billing",
metric_name: "EstimatedCharges",
dimensions: [
{name: "Currency", value: "USD"}
@kskb
kskb / template.rb
Last active August 29, 2015 14:14
Rails4 Template
return unless yes?('Use Template?')
# clean file
run 'rm README.rdoc'
gem 'kaminari' # Pagenation
gem 'slim-rails'
gem 'simple_form'
gem 'puma'
gem 'rails-config'
@kskb
kskb / rails new
Last active December 10, 2015 06:08
rails new する時のオプションを毎回忘れるのでメモ
// $ rails new fuga --skip-bundle --skip-test-unit -d sqlite3
$ cd fuga
$ bundle install --path vendor/bundle --without production
@kskb
kskb / velify_receipt.rb
Last active December 23, 2015 03:59
In App Purchase テスト用スクリプト Receiptファイルは適宜どっかから持って来て receipt と言うファイル名で同一ディレクトリに置いて下さい
require 'rest_client'
require 'json'
params_json = "{ \"receipt-data\": \"#{open("./receipt").read}\" }"
apple_url = "https://buy.itunes.apple.com/verifyReceipt"
receipt_data = "#{open("./receipt").read}"
#p receipt_data
res = RestClient.post apple_url, {:'receipt-data' => receipt_data}.to_json
res = JSON.parse(res)
@kskb
kskb / gist:3437254
Created August 23, 2012 14:39
UNIX時間をNSDate型に変換する
[NSDate dateWithTimeIntervalSince1970:@"1342665568" doubleValue]];
@kskb
kskb / gist:3417061
Created August 21, 2012 16:29
UISegmentedControlのFontを変更する
// font is UIFont object
[segmentedCtrl setTitleTextAttributes:
[NSDictionary dictionaryWithObject:font forKey:UITextAttributeFont] forState:UIControlStateNormal];
@kskb
kskb / gist:3401893
Created August 20, 2012 07:36
NSUserDefaultsの永続化された内容を全消去
NSString *domainName = [[NSBundle mainBundle] bundleIdentifier];
[[NSUserDefaults standardUserDefaults] removePersistentDomainForName:domainName];