Skip to content

Instantly share code, notes, and snippets.

View koshigoe's full-sized avatar

Masataka SUZUKI koshigoe

View GitHub Profile
#!/usr/bin/env ruby
$KCODE = 'utf8'
# 漢数字を数値に変換する
#
# * http://ja.wikipedia.org/wiki/%E6%BC%A2%E6%95%B0%E5%AD%97
# * http://www.akatsukinishisu.net/kanji/kansuji.html
module Kansuji
require 'set'
require 'rss'
# キーワード集合を作成
# キーワードの長さ配列を作成
dictionary = Set.new
size_list = []
# はてなキーワードの2カラム目を切り出して uniq したもの
# curl -s http://d.hatena.ne.jp/images/keyword/keywordlist_furigana.csv | lv -Ou -Ie | cut -f2 | sort -u > keywordlist.tsv
open('keywordlist.tsv') do |input|
@koshigoe
koshigoe / heroku_rails_template.rb
Created April 12, 2015 01:27
Rails Application Template for Heroku app
# $ rails new <application name> -T -d postgresql --skip-spring -m heroku_rails_template.rb
if yes? 'Deploy to herok?'
gem 'rails_12factor', group: :production
end
gem 'dotenv'
if yes? 'Use slim?'
gem 'slim-rails'
@koshigoe
koshigoe / gist:fdb25fdce655e3686d96
Created July 2, 2015 07:36
ファイルの文字コード変換のメモリ使用量を調べる、的な
require 'objspace'
require 'csv'
require 'nkf'
require 'tempfile'
def test_a
src_encoding = NKF.guess(File.read(ARGV[0], 1_048_576))
case src_encoding
when Encoding::US_ASCII, Encoding::UTF_8
'UTF-8'
@koshigoe
koshigoe / bench.rb
Created July 8, 2015 06:40
画像100%リサイズを mini_magick と convert で比較
require 'benchmark'
require 'mini_magick'
require 'open3'
n = 100
Benchmark.bm(22) do |x|
x.report("mini_magic") do
n.times do
blob = File.open('sample.jpg')
String.prototype.bytes = function() {
var count = 0;
for (var i = 0; i < this.length; i++) {
count += Math.ceil(encodeURIComponent(this.charAt(i)).length / 3)
}
return count;
};
# config/initializers/action_cache.rb
module ActionController::Caching::Actions::ClassMethods
# ex) continue filter chain
#
# caches_action :action_name, :continue => true
#
def caches_action(*actions)
return unless cache_configured?
diff --git a/lib/jpmobile.rb b/lib/jpmobile.rb
index af7ac4c..d18ca28 100644
--- a/lib/jpmobile.rb
+++ b/lib/jpmobile.rb
@@ -20,8 +20,32 @@ module Jpmobile
autoload :Livedoor, 'jpmobile/mobile/livedoor'
autoload :Goo, 'jpmobile/mobile/goo'
- def self.constants_with_discovery_order
- [ :Google, :Yahoo, :Livedoor, :Goo, :Docomo, :Au, :Softbank, :Vodafone, :Jphone, :Emobile, :Willcom, :Ddipocket ]
diff --git a/lib/jpmobile.rb b/lib/jpmobile.rb
index af7ac4c..d18ca28 100644
--- a/lib/jpmobile.rb
+++ b/lib/jpmobile.rb
@@ -20,8 +20,32 @@ module Jpmobile
autoload :Livedoor, 'jpmobile/mobile/livedoor'
autoload :Goo, 'jpmobile/mobile/goo'
- def self.constants_with_discovery_order
- [ :Google, :Yahoo, :Livedoor, :Goo, :Docomo, :Au, :Softbank, :Vodafone, :Jphone, :Emobile, :Willcom, :Ddipocket ]
Index: scripts/emoji_scrape.rb
===================================================================
--- scripts/emoji_scrape.rb (リビジョン 18881)
+++ scripts/emoji_scrape.rb (作業コピー)
@@ -77,17 +77,18 @@
end
def self.scrape_thirdforce
- base_uri = 'http://developers.softbankmobile.co.jp/dp/tool_dl/web/'
+ base_uri = 'http://creation.mb.softbank.jp/web/'