Skip to content

Instantly share code, notes, and snippets.

View myokoym's full-sized avatar
💭
hi

Masafumi Yokoyama myokoym

💭
hi
View GitHub Profile
@myokoym
myokoym / file0.txt
Last active December 3, 2015 14:34
GroongaのUTF-8なDBに対してShift_JIS(cmd.exe)で全文検索する3つの方法 ref: http://qiita.com/myokoym/items/c7ea4c83dad080d8ebbe
> groonga -n --encoding sjis test.db
#!/usr/bin/env ruby
require "readline"
require "tempfile"
if ARGV.size < 2
$stderr.puts("Usage: #{$0} GROONGA_EXE DB_PATH")
exit(1)
end
#!ruby
#encoding = ARGV.shift
#args = ARGV.dup
#args.map! do |arg|
# arg.encode(encoding)
#end
#system(*ARGV)
encoding = ARGV.shift
require "ruby-poker"
class Player
attr_reader :name, :cards
attr_accessor :hand
def initialize(name)
@name = name
@cards = []
@hand = nil
end
@myokoym
myokoym / ranransearch.rb
Created June 25, 2015 17:15
[WIP] A on-memory full-text search engine by pure Ruby.
#!/usr/bin/env ruby
class Database
attr_reader :files
def initialize
@ii = {}
@files = []
end
def add(path)
#!/usr/bin/env ruby
require "groonga"
db_path = ARGV[0] || File.expand_path("~/.feedcellar/db/feedcellar.db")
Groonga::Database.open(db_path) do |database|
feeds = Groonga["Feeds"]
selected_feeds = feeds.select do |feed|
feed.title =~ /Ruby/
diff --git config.ru config.ru
index 1cbc50c..ba8ecbd 100644
--- config.ru
+++ config.ru
@@ -21,6 +21,22 @@ lib_dir = File.join(base_dir, "lib")
$LOAD_PATH.unshift(lib_dir)
require "feedcellar/web/app"
+module Kaminari::Helpers
+ module SinatraHelpers
@myokoym
myokoym / capture.rb
Created May 5, 2015 10:05
Capture a terminal to FLV video using FFmpeg on Debian GNU/Linux.
#!/usr/bin/env ruby
output_path = "#{ARGV[0] || "out"}.flv"
info = `xwininfo -id $(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | grep -Eo "0x[0-9a-f]{2,}")`
x = info.scan(/Absolute upper-left X: *(\d+)/).first.last.to_i
y = info.scan(/Absolute upper-left Y: *(\d+)/).first.last.to_i
width = info.scan(/Width: *(\d+)/).first.last.to_i
height = info.scan(/Height: *(\d+)/).first.last.to_i
@myokoym
myokoym / file0.txt
Created February 15, 2015 10:39
test-unitで指定したテストだけ実行する方法 ref: http://qiita.com/myokoym/items/2c3559ec0e060b7ec943
$ ruby test_user.rb
Loaded suite test_user
Started
..
Finished in 0.000777458 seconds.
------
2 tests, 2 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
------
@myokoym
myokoym / dynamic.txt
Last active August 29, 2015 14:07
Groongaチュートリアル(コピペ用) http://groonga.org/ja/docs/tutorial/introduction.html
status
table_create --name Site --flags TABLE_HASH_KEY --key_type ShortText
select --table Site
column_create --table Site --name title --type ShortText
select --table Site