Skip to content

Instantly share code, notes, and snippets.

View k0kubun's full-sized avatar

Takashi Kokubun k0kubun

View GitHub Profile
@k0kubun
k0kubun / titech_portal_auto_login.user.js
Last active May 16, 2018 19:44 — forked from gifnksm/titech_portal_auto_login.user.js
東工大ポータルに自動ログインするFirefox用greasemonkeyスクリプトのE4X無効化対応版
// ==UserScript==
// @name Titech Portal Auto Login
// @namespace http://www.titech.ac.jp/
// @id titech-portal-auto-login@www.titech.ac.jp
// @description 東工大ポータルに自動的にログインします
// @author NAKASHIMA, Makoto <makoto.nksm@gmail.com>
// @include https://portal1.nap.gsic.titech.ac.jp/*
// @include https://portal.nap.gsic.titech.ac.jp/*
// @include http://portal.titech.ac.jp/*
// @jsversion 1.8
@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)
}
@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 / 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)
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 / 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: "
@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 / 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 / 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 / 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])