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
Linode 512 vs DigitalOcean 512
------------------------------
DigitalOcean 512MB
========================================================================
BYTE UNIX Benchmarks (Version 5.1.3)
System: 1vq9: GNU/Linux
OS: GNU/Linux -- 3.5.0-17-generic -- #28-Ubuntu SMP Tue Oct 9 19:32:08 UTC
2012
@hryk
hryk / sample-swift.rb
Created March 18, 2013 14:25
list, get files from openstack swift with fog.
#!/usr/bin/env ruby
# encoding: utf-8
require 'rubygems'
require 'fog'
connection = Fog::Storage.new(
:provider => 'OpenStack',
:openstack_auth_url => ENV['OS_AUTH_URL'] + '/tokens',
:openstack_tenant => ENV['OS_TENANT_NAME'],
# Ubuntu upstart file at /etc/init/orientdb.conf
# description "Orientdb Server"
# author "Hiroyuki Nakamura"
start on runlevel [2345]
stop on runlevel [^2345]
# environment variables
env ENABLE_ORIENTDB="yes"
env JAVA_HOME="/usr/lib/jvm/java-1.6.0-openjdk-i386"
@hryk
hryk / Gemfile
Last active December 13, 2015 22:08
Examples for using blueprints on JRuby.
source "https://rubygems.org/"
gem "neo4j"
gem "pry"
gem "minitest"
gem "jbundler"
@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
@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 / 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 / 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])
#!/usr/bin/env perl
use strict;
use warnings;
# ...........structure access..............
{
package Foo::Structure;
sub new { bless {} => shift }
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)