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

xyzzy + global

http://xyzzy.g-artistic.net/2005/08/04/xyzzy-gnu-global-gtags/ NetInstallerからインスコ。 ちょっと幸せになった。

Kasperskyに移行

NAV→F-SecureときてKasperskyに移行。 検知率が高い割に、軽いのがよさげ。

getter書くのはもう飽きたー

http://storehouse.sakura.ne.jp/viewvc/viewvc.cgi/libarchive/?root=svn 地味に作成中。来年の1月中にはリリースできるといいなぁ… しかし、Rubyのライブラリを書いているとPerlのライブラリに充実ぶりがやたら目につく。*1 やっぱりPerlはすごいなー。 *…

DDDot

コレイイ!

強制的にコアダンプ

C

libarchiveにあった関数。強制的にコアダンプを起こしたいらしい… static void diediedie(void) { *(char *)0 = 1; /* Deliberately segfault and force a coredump. */ _exit(1); /* If that didn't work, just exit with an error. */ }

libarchive: アーカイブを作成する

C

archive_entry_copy_statをしないとアーカイブがうまく作成できず。 #include <stdio.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <io.h> #include <share.h> #include <archive.h> #include <archive_entry.h> int main() { struct archive *a; struct archive_entry *ae; int fd, len; char buff[BUFSIZ]; …</archive_entry.h></archive.h></share.h></io.h></sys/stat.h></sys/types.h></fcntl.h></stdio.h>

libarchiveを使う

C C++

http://people.freebsd.org/~kientzle/libarchive/ ふむふむ。 #include <iostream> #include <string> #include <archive.h> #include <archive_entry.h> using namespace std; namespace { void list(string filename) { archive *a = archive_read_new(); archive_read_support_compression_all(a); arch</archive_entry.h></archive.h></string></iostream>…

MSDN Search Plugin (VS2008, VC++)

MSDN Search Pluginを修正。 <SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/"> <os:ShortName>MSDN Search</os:ShortName> <os:Description>MSDN Search</os:Description> <os:InputEncoding>UTF-8</os:InputEncoding> <os:Image width="16" height="16">…</os:image></searchplugin>

年年歳歳…

Cygwinを使い始めてから10年*1ぐらい経っているなぁ…と、ふと思った。 ちょっと前まで本棚にあった角川文庫のロードス島戦記は初版が20年前だし… *1:gnu-win32 b19が98年だから、たぶんそのくらい

bindを実装してみる

C++

意外とわかりやすい…と思うんだけど。 #include <iostream> using namespace std; template <class R, class A> class Function { R (*f_)(A); A x_; public: Function(R (*f)(A), A x) : f_(f), x_(x) {} R operator() () { return f_(x_); } }; template <class R, class A> Function<R, A> bind(R (*f)(A), A x</r,></class></class></iostream>…

bind1st、bind2nd

C++

第一引数は「引数を2つとる関数オブジェクト」。 汎用的でないのはplus、minusとかのヘルパ関数だからかな。 #include <iostream> #include <functional> using namespace std; int count(int m, int n) { return m * 2 + n; } int main() { cout << bind1st(ptr_fun(count), 3)(5</functional></iostream>…

tr1:bindを使う

C++

VC9のtr1の実装具合ってどんなもんだろ。 #include <iostream> #include <functional> using namespace std; int count1(int n) { return ++n; } int count2(int &n) { return ++n; } int count3(int *n) { return ++(*n); } int main() { int n1 = 0, n2 = 0, n3 = 0; tr1::functi</functional></iostream>…

link: Q&A on our TR1 implementation

C++

http://d.hatena.ne.jp/ntnek/20080116/p1 めもめも。

梅本竜 『EVE burst error “THE PERFECT”』

http://www.amusement-center.com/project/mall/detail_book-game/eggmusic009/index.html 予約しないと。

戻り値・ポインタ

C++

関数の戻り値のstringをコピーで返すのは、C++だとふつーのこと? どうも、ポインタで渡すパターンは少ないように見える。スタンダードなん?

LNK1000

C++

Visual C++ プロジェクトを Microsoft Visual Studio 2008 で /INCREMENTAL ビルド オプションを使用して、リンクすると、次のエラー メッセージが表示される可能性があります。

boost::asio: echoサーバ

C++

う、動いてる… #include <iostream> #include <string> #define _WIN32_WINNT 0x0501 #include <boost/bind.hpp> #include <boost/asio.hpp> using namespace std; using boost::bind; using boost::asio::io_service; using boost::asio::ip::tcp; using boost::system::error_code; void echo(tcp::acceptor *</boost/asio.hpp></boost/bind.hpp></string></iostream>…

boost::bind萌え〜

C++

思わず顔がにやけてしまった。 #include <iostream> #include <string> #include <boost/bind.hpp> #include <boost/function.hpp> using namespace std; int add(int a, int b) { return a + b; } int main() { boost::function<int (int)> f = boost::bind(add, 5, _1); cout << f(1) << endl; cout << f(2) << endl; return </int></boost/function.hpp></boost/bind.hpp></string></iostream>…

boost:クロージャを作る

C++

萌え。 #include <iostream> #include <string> #include <boost/bind.hpp> #include <boost/function.hpp> #include <boost/shared_ptr.hpp> using namespace std; int count(boost::shared_ptr<int> n) { (*n)++; return *n; } int main() { boost::shared_ptr<int> n(new int(0)); boost::function<int (void)> f = boost::…</int></int></int></boost/shared_ptr.hpp></boost/function.hpp></boost/bind.hpp></string></iostream>

てきとーにスマートポインタを実装する

C++

shared_ptrの仕組みが気になったので、てきとーに実装してみる。 #include <iostream> using namespace std; template <typename T> class Ptr { T *p; int *cnt; public: Ptr(T *p) : p(p) { cnt = new int(1); cout << "count=" << *cnt << endl; } Ptr(const Ptr<T> &self) { p = s</t></typename></iostream>…

boost::asio

C++

boost::asioすごいなー。 #include <iostream> #include <string> #define _WIN32_WINNT 0x0501 #include <boost/asio.hpp> using namespace std; using namespace boost::asio; int main(int argc, char* argv[]) { ip::tcp::iostream s("www.boost.org", "http"); s << "GET / HTTP/1.1\r\n";</boost/asio.hpp></string></iostream>…

Boost C++ Librariesプログラミング

C++

Boost C++ Librariesプログラミング作者: 稲葉一浩出版社/メーカー: 秀和システム発売日: 2007/07メディア: 単行本購入: 4人 クリック: 235回この商品を含むブログ (34件) を見る日曜日に購入。小さな機能からちょこちょこ使ってみる…つもり。 しかし、便利…

EVP_BytesToKeyをRubyで実装する

訳あってEVP_BytesToKeyをRubyで実装したので、ログを残しておく。 require 'digest/md5' def bytes_to_key0(md_buf, salt, data, count) src = md_buf.empty? ? '' : md_buf src << data src << salt if salt dst = Digest::MD5.digest(src) (count - 1).ti…

opensslの暗号化を使う

ちょっとopensslの暗号化をさわる必要があったので、サンプルを書いてみた。 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <openssl/evp.h> #define KEYGEN_SALT NULL #define KEYGEN_COUNT 2048 static void print_hexstring(unsigned char *data, int datal) { int i; for (i </openssl/evp.h></string.h></stdlib.h></stdio.h>…

[PATCH] ActiveResource find(:all) method returns "NoMethodError: undefined method `collect!'...

http://dev.rubyonrails.org/ticket/8798 ActiveResourceを使ったら、いきなりバグにぶつかった。 Rails 2.2.2でも直っていないようだけど、あんまり使われていないのかなあ?

[PATCH] Add LibXML support to Active Resource

http://dev.rubyonrails.org/ticket/9017 速度面が少し気になったので、LibXMLを使うパッチを充ててみた。 n.times { Image.find(:all, :query => 'さくら 壁紙', :results => 10) } user system total real default (1 times): 0.125000 0.031000 0.156000 …

Rails 2.2、thin、Windows

Windowsにthinをインスコして、こないだのコードを動かしてみる。 #: # begin 01:50:31 #: # end 01:51:18 #: # begin 01:51:18 0 1 2 3 4 5 6 7 8 9 #: # end 01:51:18sleepでzooに制御が移ると思ったけど、そうならないなぁ。 Windowsのせいなのか、シング…

g++が使えない

g++が使えないんですよ。開発用サーバで。 gcc 4.1が必要らしい。 で、gccをupgradeしようとするとこの有様ですよ。 ~# apt-get upgrade gcc Reading Package Lists... Done Building Dependency Tree... Done The following packages have been kept back: …

link:HowTosWorkerThreads

http://wiki.rubyonrails.org/rails/pages/HowTosWorkerThreads あとで読みます。

Rails 2.2.2: ActiveRecordの並列性 - 2.0.1の場合

とりあえず、Rails 2.0.1でActiveRecordを並列に動かしてみる。 BarController $stdout.sync = true class BarController < ApplicationController def index 10.times do Thread.fork do touch end end render :text => 'OK' end private def touch begin 1…