Skip to content

Instantly share code, notes, and snippets.

1) モデルだけのリポジトリ symlink
2) アプリ、モデルを分ける
3) APIで通信する(ActiveResourceで
4) サブアプリとして切り出す
5) Engine で切り出して、モデルは親のを使う
6) Microservices 化(API)
@inohiro
inohiro / gist:1102460
Created July 24, 2011 09:52
script that find recently chat topics, and p that name(But It's not work :(
require 'rubygems'
require 'skype'
Skype.init 'sample_application'
Skype.start_messageloop
chats = Skype::searchRecentChats
chats.each do |chat|
p chat.getName
end
Host ubuntu-master
HostName 192.168.0.226
User user
Host ubuntu01
HostName 192.168.10.1
User user
Host ubuntu02
HostName 192.168.10.2
package main
import (
"fmt"
"io"
"strings"
"image/png"
)
type Cset struct {
@inohiro
inohiro / gist:1395470
Created November 26, 2011 11:14
own configure and make in rvm dir.
inohiro@inohiro-ng-mac libmemcached-0.32$ ./configure --with-gcc=clang
configure: WARNING: unrecognized options: --with-gcc
checking build system type... i386-apple-darwin11.2.0
checking host system type... i386-apple-darwin11.2.0
checking target system type... i386-apple-darwin11.2.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... config/install-sh -c -d
checking for gawk... no
checking for mawk... no
@inohiro
inohiro / gem_install_memcached_on_lion_failed
Created November 26, 2011 10:59
gem install memcached on Lion is failed
inohiro@inohiro-ng-mac ~$ gem install memcached
Building native extensions. This could take a while...
ERROR: Error installing memcached:
ERROR: Failed to build gem native extension.
/Users/inohiro/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb
extconf.rb:7: Use RbConfig instead of obsolete and deprecated Config.
Touching aclocal.m4 in libmemcached.
touch -r libmemcached-0.32/m4/visibility.m4 libmemcached-0.32/configure.ac libmemcached-0.32/m4/pandora_have_sasl.m4 libmemcached-0.32/m4/aclocal.m4
Configuring libmemcached.
PATH = "/path/to/hoge"
Dir.glob( PATH + '*.rb' ) do |f|
puts f
# doesn't work correctly
exec( "rspec " + f ).to_s
# work correctly
result = system( 'rspec ' + f ).to_s
require 'highline'
def main
highline = HighLine.new
passwd = highline.ask( 'type your password: ' ) do |q|
q.echo = '*'
end
puts passwd
end
require 'json'
FILE = './2008_graph_mining.json'
# result of http://www.dblp.org/search/api/?q=ce:year:2008*%20graph*%20mining*&h=1000&c=4&f=0&format=json
def scrape
file = File.open( FILE )
doc = JSON.parse( file.read )
hits = doc["result"]["hits"]["hit"]
@inohiro
inohiro / gpa_cal.rb
Created May 27, 2012 13:29
atcoder3_A
length = gets.to_i
str = gets
result = 0.0
i = 0
str.each_byte do |s|
case s
when 65 # A
result = result + 4.0