Skip to content

Instantly share code, notes, and snippets.

View k0kubun's full-sized avatar

Takashi Kokubun k0kubun

View GitHub Profile
$ benchmark-driver benchmark.yml --rbenv '2.0.0::2.0.0-p648 --disable-gems;2.5.3::2.5.3 --disable-gems;2.6.0-preview3::trunk --disable-gems;2.6.0-preview3+JIT::trunk --disable-gems --jit' -v --repeat-count 24
2.0.0: ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-linux]
2.5.3: ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
2.6.0-preview3: ruby 2.6.0dev (2018-10-31 trunk 65474) [x86_64-linux]
2.6.0-preview3+JIT: ruby 2.6.0dev (2018-10-31 trunk 65474) +JIT [x86_64-linux]
Calculating -------------------------------------
2.0.0 2.5.3 2.6.0-preview3 2.6.0-preview3+JIT
Optcarrot Lan_Master.nes 34.548 48.314 54.535 85.690 fps
Comparison:
@k0kubun
k0kubun / benchmark_driver.optcarrot.log
Last active February 25, 2018 12:55
Optcarrot benchmark using benchmark_driver.gem: Intel 4.0GHz i7-4790K with 16GB memory under x86-64 Ubuntu 8 Cores
$ cat benchmark.yml
# Config for benchmark_driver.gem
type: command_stdout
name: optcarrot
command: bin/optcarrot --benchmark examples/Lan_Master.nes
metrics_type:
unit: fps
stdout_to_metrics: |
match = stdout.match(/^fps: (?<fps>\d+\.\d+)$/)
Float(match[:fps])
@k0kubun
k0kubun / bm_erb_render.rb
Created November 10, 2017 15:59
Intel 4.0GHz i7-4790K with 16GB memory under x86-64 Ubuntu 8 Cores
# based on ruby/benchmark/bm_erb_render.rb
require 'benchmark/ips'
require 'erb'
require 'erubi'
require 'erubis'
data = DATA.read
mod = Module.new
mod.instance_eval("def self.erb(title, content); #{ERB.new(data).src}; end", "(ERB)")
@k0kubun
k0kubun / trailing-whitespace
Created December 7, 2013 00:50
git pre-commit hook
#!/bin/sh
if git-rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
@k0kubun
k0kubun / kmb.rb
Created August 8, 2013 17:20
Twitterのアイコンをランダムでキルミーベイベー(http://killmebaby.tv/special_icon.html)にするやつ
# --- Usage ---
# ruby kmb.rb init
# ruby kmb.rb change
require 'twitter'
require 'nokogiri'
require 'open-uri'
require 'fileutils'
Twitter.configure do |config|
@k0kubun
k0kubun / list.rb
Created July 14, 2013 15:11
screen_nameいれてtwitterのリストに追加するやつ
require 'twitter'
Twitter.configure do |config|
config.consumer_key = ''
config.consumer_secret = ''
config.oauth_token = ''
config.oauth_token_secret = ''
end
print "Input list name: "
require 'RMagick'
bmp_file_name = ARGV[0]
image = Magick::Image.read(bmp_file_name).first
top_left_pixel = image.pixel_color(0, 0)
top_left_color = top_left_pixel.to_color(Magick::AllCompliance, false, 8, true)
png_file_name = bmp_file_name.gsub(/bmp$/, 'png')
`convert -transparent "#{top_left_color}" #{bmp_file_name} #{png_file_name}`
@k0kubun
k0kubun / fav-notifier.rb
Created March 13, 2013 04:20
fav-notifier beta
# -*- coding: utf-8 -*-
require 'user_stream'
require 'twitter'
require "net/http"
require "uri"
def notify(message)
uri = URI.parse("http://im.kayac.com/api/post/USERNAME")
Net::HTTP.start(uri.host, uri.port){|http|
request = Net::HTTP::Post.new(uri.path)
@k0kubun
k0kubun / auth.rb
Created March 12, 2013 23:57
twitter for iphone consumer authentication
require 'oauth'
require 'thor'
require 'thor/group'
class Auth < Thor::Group
include Thor::Actions
def get_pid
consumer = OAuth::Consumer.new(
'IQKbtAYlXLripLGPWd0HUA',
@k0kubun
k0kubun / kayac.rb
Created March 12, 2013 23:03
im.kayac.com
# -*- coding: utf-8 -*-
require "net/http"
require "uri"
uri = URI.parse("http://im.kayac.com/api/post/USERNAME")
Net::HTTP.start(uri.host, uri.port){|http|
request = Net::HTTP::Post.new(uri.path)
request.set_form_data({:message=>"MESSAGE"})
response = http.request(request)
}