2010-01-01から1年間の記事一覧

mkmf、CFLAGS

存在しない関数があるのにWarningが出ないな…と思っていたら、extconf.rbで作ったMakefileのCFLAGSに-Wallがないだけだった。 デフォルトのCFLAGSがどっからきているのかたどってみたら、最終的にはRubyをビルドしたときのconfig.statusまで行きついた。 「-…

cflowを実行する

cflowを実行する関数 (defvar *cflow-option-complete-list* nil "Cflow option complete list.") (defvar *cflow-file-complete-list* nil "Cflow file complete list.") (defun cflow() (interactive) (let (current file func) (setq current (get-clipbo…

多重代入、暗黙の型変換

to_aryメソッドが定義されてれば、Arrayじゃなくても多重代入っぽいことが出来た。 class Foo def to_ary [100, 200] end end foo = Foo.new a, b = foo p a #=> 100 p b #=> 200 下の書き方はアレな感じだ。 c = foo p c #=>#<Foo:0xb7cb95a0> d, = foo p d # => 100</foo:0xb7cb95a0>

Kirisame

http://storehouse.sakura.ne.jp/viewvc/viewvc.cgi/kirisame/ext/?root=svn とりあえず動くは動いた。 require 'kirisame' client = Kirisame::Client.tcp('127.0.0.1', 3306, 'root', nil, 'mysql') rs = client.query('select * from user') if rs.done? …

Zip/Ruby、File、抽象化

open(path) do |f| Zip::Archive.open_buffer(f.read) 上のようなコードをWebで見かけて「なんでFileオブジェクトを受け取れないんだっけ?」としばし考え込む。 それで、Fileオブジェクトから実体(FILE構造体、またはファイルディスクリプタ)を取り出せな…

activerecord-alt-mongo-adapter 0.1.0

http://araltmongo.rubyforge.org/ とりあえずリリース。

libdrizzleで繋いで閉じるだけ

exampleを参考にしつつ。 #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <libdrizzle/drizzle_client.h> static void result_info(drizzle_result_st *result) { printf("Result: row_count=%" PRId64 "\n" " insert_id=%" PRId64 "\n" " warning_count=%u\n" " column_count=%u\n\n", drizzle_</libdrizzle/drizzle_client.h></unistd.h></stdlib.h></stdio.h>…

0.9

https://launchpad.net/libdrizzle/+milestone/0.9 リリース予定日は3/29のようだけど、まだリリースされてない。残念。 Windowsが正式にサポートされると良いなー。

ActiveMongo(作りかけ)

http://storehouse.sakura.ne.jp/viewvc/viewvc.cgi/activemongo/?root=svn そこそこできた。近々リリース予定。 require 'rubygems' require 'active_record' ActiveRecord::Base.establish_connection( :adapter => 'mongodb', :database => 'mydb' ) clas…

ActiveTokyoCabinet 0.2.1

http://activetokyocabi.rubyforge.org/ 会社の同僚がスキーマフリーの素晴らしさについて熱く語っていたので、ActiveTokyoCabinetでも実装してみた。 require 'active_record' require 'active_tokyocabinet/tdb' ActiveRecord::Base.logger = Logger.new($…

mongo_ext-0.19.1-x86-mswin32.gem

http://storehouse.sakura.ne.jp/viewvc/viewvc.cgi/mongo_ext-win32/?root=svn 細々と修正してVC9でビルド。mongo_extなくても動くみたいな感じだし、必要なかったかも。 defファイルがあるので、そのうちmswin32版が出るのかも。 WinSock2をリンクしてるけ…

最新のMySQLPlus

githubに2つリポジトリがあったり*1 *2、gemで検索するとバージョン0.1.1が2つあったり*3、RubyForgeにプロジェクトがあったりと、よく分からない状況のMySQLPlusだが、コードを読んだかぎりではgithubにあるoldmoe's mysqlplusが最新のようだ。 *1:http:/…

MySQLPlusのユースケース

MySQLPlusのユースケースについて、つらつらと考えてみた。 MySQLPlusはMySQLに非同期でクエリを投げられるドライバで、ちょっと見ただけだと「パフォーマンスが上がるかも」と思いそうだが、使いどころが難しい。 使いどころが難しい理由は ResultSetの取得…

ActiveTokyoCabinet 0.1.1

http://activetokyocabi.rubyforge.org/ActiveTokyoCabinet 0.1.1をリリースしました。 これは何? ActiveRecordのTokyo(Cabinet|Tyrant)のテーブルデータベースのアダプタです。 TokyoTyrantをActiveRecordのように使えるMiyazakiResistanceもあるんですが…

シンプル(=手抜き)なSLQ条件句パーサ

searchconditionparser.y class SearchConditionParser options no_result_var rule search_condition : boolean_primary { [val[0]] } | search_condition AND boolean_primary { (val[0] << val[2]).flatten } comparison_predicate : id COMP_OP value { …

TokyoCabinetのテーブルデータベースをSQL(もどき)で検索・更新できるようにする

http://storehouse.sakura.ne.jp/viewvc/viewvc.cgi/tcsql/?root=svn 文字列リテラルのエスケープとか、エラー処理は適当。 #!/usr/bin/ruby require 'rubygems' require 'tcsql' require 'pp' include TokyoCabinet def go(sql) puts <