Skip to content

Instantly share code, notes, and snippets.

View hryk's full-sized avatar
🏠
Working from home

Hiroyuki Nakamura hryk

🏠
Working from home
View GitHub Profile
@hryk
hryk / setup.py
Created October 22, 2012 12:28
an example for using boost::unordered_map in Cython.
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [
Extension("test_um",
["test_um.pyx"],
include_dirs=["/usr/local/include/boost"],
library_dirs=["/usr/local/lib"],
language="c++")
@hryk
hryk / enc_1.9.rb
Created October 23, 2012 17:24
enc method in related.rb
def enc(s)
encoded = []
s.bytes {|i|
if i < 0x80
encoded << i.chr(Encoding::ASCII)
else
encoded << '%'+i.chr(Encoding::ASCII_8BIT).unpack('H2').join('')
end
}
encoded.join('')
@hryk
hryk / monitor_ds.py
Created November 28, 2012 13:03
任天堂製品がいるとGrowlで通知する。
#!/usr/bin/env python
import re
import string
import sets
import sys
import urllib2
import os.path
import subprocess
from gntp.notifier import mini
# tmux 1.3
set-window-option -g utf8 on
set-window-option -g mode-keys vi
#
set-option -g prefix C-q
set-option -g default-path /Users/hiroyuki/Develop/
set-option -g default-command "reattach-to-user-namespace -l zsh"
unbind-key C-b
bind-key C-q send-prefix
set-option -g detach-on-destroy
Testing Perl 5.014002, Method::Signatures 20120523, Moo 1.000006,
Object::InsideOut 3.97, Mouse 1.02, Moose 2.0604
Benchmark: timing 6000000 iterations of Method::Signatures, Moo, Moose, Mouse,
Object::InsideOut, manual, struct...
Method::Signatures: 31 wallclock secs (31.30 usr + 0.00 sys = 31.30 CPU) @191693.29/s (n=6000000)
Moo: 39 wallclock secs (39.50 usr + 0.00 sys = 39.50 CPU) @ 151898.73/s(n=6000000)
Moose: 12 wallclock secs (12.35 usr + 0.00 sys = 12.35 CPU) @ 485829.96/s(n=6000000)
Mouse: 2 wallclock secs ( 2.13 usr + 0.00 sys = 2.13 CPU) @ 2816901.41/s(n=6000000)
Object::InsideOut: 6 wallclock secs ( 6.11 usr + 0.00 sys = 6.11 CPU) @981996.73/s (n=6000000)
#!/usr/bin/env perl
use strict;
use warnings;
# ...........structure access..............
{
package Foo::Structure;
sub new { bless {} => shift }
@hryk
hryk / csshtmux.rb
Last active December 11, 2015 04:28
~/.csshclustersを読んでtmuxのwindowを開く。
#!/usr/bin/env ruby
require 'json'
def expand_clusters clusters
expanded = false
clusters.each do |label, hosts|
tmp_hosts = []
hosts.each do |host|
if clusters.key?(host)
tmp_hosts.concat(clusters[host])
@hryk
hryk / pomosound.rb
Last active December 11, 2015 22:49
20分~30分くらいの曲を探してきて適当に再生する。
#!/usr/bin/env ruby
require 'logger'
require 'rubygems'
require 'soundcloud'
require 'rainbow'
$: << "./soundcloud2000/lib"
require 'soundcloud2000'
def duration_to_s(mills)
@hryk
hryk / pomosound-macruby.rb
Last active December 11, 2015 23:08
20分~30分くらいの曲を探してきて適当に再生する。MacRubyで。
#!/usr/bin/env ruby
#encoding: utf-8
#
# TODO
# ----
#
# # Output inventories as HTML.
# ./pomosound.rb report > report.html
#
@hryk
hryk / terminate-and-relaunch-app.rb
Last active December 12, 2015 00:08
Terminate and re-launch an application with MacRuby.
#!/usr/bin/env ruby
#encoding: utf-8
framework 'Cocoa'
framework 'ApplicationServices'
framework 'AppKit'
# Get a list of applications currently running.
ws = NSWorkspace.sharedWorkspace