123
 123

Mon 16 July, 2007

Click here to bookmark this link.Channel Image02:34 Thatcher on Drums» Projectionist

Sun 15 July, 2007

Sat 14 July, 2007

Click here to bookmark this link.Channel Image21:47 How to Kill a Baby Lion» Lovable Lyle
This may just be the most precious discussion ever held on the ruby-talk mailing list. It started out innocently enough: Hey yall experienced coders and programmer dudes. I wanna make an MMORPG type game, but I have no programming experiance whatsoever. He was advised to check out some great introductory programming books, like Chris Pine’s Learn to [...]
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image17:50 SchützaBlog 2007» chris blogs

Biberach in Hochstimmung—es ist wieder Schützenfest!

Das neue Bierzelt wollte sich gleich mal beliebt machen und verteilte daher in Stadt größere Mengen an Gutscheinen für Halbe, deshalb war im Bierzelt gestern schon ordentlich was los. Schützen wirkt generationenübergreifend und es ist keine Besonderheit, wenn frische Abiturienten zusammen mit Ehefrauen von Bankvorstandsvorsitzenden auf Bänken und Tischen neben ehemaligen Schuldirektoren tanzen.

Im Bierzelt darf natürlich eins auf gar keinen Fall fehlen: der Böhmische Traum.

Geheimer Schützenhit ist bisher jedoch Gebroeders Ko – Boten Anna (Brutalst geekig übrigens, in der IRC Interpretation (en)).

Heute dürft ihr nicht die Schützenübergabe und den FaschingsJahrgängerumzug verpassen.

Rund um mich her ist alles Freude, und ich wunsch euch
Scheene Schütza!

NP: Funny van Dannen—Urbanhafen


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:00 权责发生制 与 收付实现制» Ruby Object Oriented
权责发生制原则要求,凡是当期已经实现的收入和已经发生或应当负担的费用,不论款项是否收付,都应当作为当期的收入和费用;凡是不属于当期的收入和费用,即使款项已在当期收付,也不应当作为当期的收入和费用。 收付实现制是与权责发生制相对应的一种确认基础,它是以收到或支付现金作为确认收入和费用的依据。目前,我国行政单位采用收付实现制,事业单位除经营业务采用权责发生制外,其他业务也采用收付实现制。 举个例子: 1月份预交全年房租120000元.   1、权责发生制按实际受益期分担费用   交纳时:借:待摊费用 120000 贷:银行存款 120000   各月摊销时:借:管理费用 1000 贷:待摊费用 1000     2、收付实现制在费用发生的当期计入费用   借:管理费用 120000 贷:银行存款 120000 权责发生制和收付实现制在处理收入和费用时的原则是不同的,所以同一会计事项按不同的会计处理基础进行处理,其结果可能是相同的,也可能是不同的.例如, 本期销售产品一批价值5 000元,货款已收存银行,这项经济业务不管采用应计基础或现金收付基础,5O00元货款均应作为本期收入,因为一方面它是本期获得的收入,应当作本期收入,另一方面现款也已收到,亦应当列作本期收入,这时就表现为两者的一致性.但在另外的情况下两者则是不一致的,例如,本期收到上月销售产品的货款存入银行,在这种情况下,如果采用现金收付基础,这笔货款应当作为本期的收入.因为现款是本期收到的,如果采用应计基础,则此项收入不能作为本期收入,因为它不是本期获得的. http://zhidao.baidu.com/question/2194746.html http://zhidao.baidu.com/question/3145917.html 权责发生制原则是指对于企业的一切收入或费用都是以权利已经形成,或义务(责任)已经发生为标准来确定其相应的归属期间并进行记帐。具体地说,凡是当期已经实现的收入,或已经发生应承担的费用,不论其款项是否实际收到或付出,均应列为当期的收入或费用处理;凡是不属于当期的收入或费用,即使在当期实际收到或付出现金,都不应列入本期的收入或费用账户。其核心是强调“应当”,因此,也称其为“应计制”或“应收应付制”
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image11:48 Yeah, it’s kind of th...» Projectionist
Yeah, it’s kind of the ‘Myst’ of websites. Real pretty to look at, but don’t try to move or anything.

Alan Francis on the new project.ioni.st archive feature


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image11:16 给lilina加上历史存档的功能» 404 梦想没找到
lilina是一个用php写的web新闻聚合器,他非常简单但是非常强大.不需要数据库支持,这个比较方便,但是可能也会带来速度上的问题,我有时候login都要很半天,也许不是读写文件的问题。 默认的lilina只有4个页面,index24,index48,index168还有index-1 index-1是所有的数据,时间长了或者数据多了,这个文件会很大,所以在想是不是给lilina加个存档功能? 简单的想法就是每个星期一个文件存档,所以只需要拷贝index168这个文件就行了。 打算将存单的文件都放在lilina的根目录下的weeks目录,所以 首先在index.php里面加一个链接到weeks/index.php,当然,目录可以自己换。 然后编译weeks/index.php源文件 <? // // author liubin // last modify: 2007.7.14 // http://liubin.nanshapo.com // error_reporting(0);   $fn1 = date("Y-W",time() - 7 * 86400); $fn1 = $fn1.".html"; if (!file_exists($fn1)) {     copy("../index168.html",$fn1); }   date_default_timezone_set('PRC'); header("Content-Type: text/html; charset=utf-8"); header("Pragma: no-cache");   //$dir    = $root; $dir    = "."; $files = scandir($dir); foreach ($files as $file) {     if(eregi("^[0-9]{4}-[0-9]{1,2}\.html$",$file)){         echo "<a href =\"/weeks/".$file."\">".$file."</a><br/>\n";     } }   ?> 每次这个页面被浏览的时候,都会判断指定格式的文件(yyyy-w.html)是不是存在, 如果上个星期(time() - 7 * 86400)的存档还没有,就将index168.html拷贝过来。 这个过程是当这个页面被浏览的时候才会执行,如果一个月都没人看这个网页,那么存档肯定是不会被保存的。 这个转存过程也可以放到根目录的index.php下,大概放在callback的rebuild部分处理,不过我还是放在了另外这个页面里, 把工作交给搜索引擎不知道会不会有什么问题。 这是历史记录的链接:http://ruby.nanshapo.com/weeks/
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image07:07 ubuntu 7.04的小插曲» 动态感觉 静观其变
昨晚有空在家,把ubuntu 7.04装上去看看,装好之后做软件更新的时候,发生了意外,总是报一堆的目录failed to write cache。我也没有引起特别的注意,还接着用,结果一用,发现启动任何程序都很慢,cpu占用很严重,这才意识到可能是前面那个错误造成,在网上发现是有这个bug,真是哭笑不得,只好照着作吧,这些命令就是简单地把这些目录的时间调成最新的,用的就是touch命令。摘录过来,以备查:

#!/bin/bash
#
# 修正 Ubuntu 7.04 fc-cache failed to write cache
#

sudo touch /usr/share/fonts
sudo touch /usr/share/fonts/X11
sudo touch /usr/share/fonts/X11/100dpi
sudo touch /usr/share/fonts/X11/75dpi
sudo touch /usr/share/fonts/X11/Type1
sudo touch /usr/share/fonts/X11/encodings
sudo touch /usr/share/fonts/X11/encodings/large
sudo touch /usr/share/fonts/X11/misc
sudo touch /usr/share/fonts/X11/util
sudo touch /usr/share/fonts/truetype
sudo touch /usr/share/fonts/truetype/arphic
sudo touch /usr/share/fonts/truetype/baekmuk
sudo touch /usr/share/fonts/truetype/freefont
sudo touch /usr/share/fonts/truetype/kochi
sudo touch /usr/share/fonts/truetype/openoffice
sudo touch /usr/share/fonts/truetype/thai
sudo touch /usr/share/fonts/truetype/ttf-arabeyes
sudo touch /usr/share/fonts/truetype/ttf-bengali-fonts
sudo touch /usr/share/fonts/truetype/ttf-bitstream-vera
sudo touch /usr/share/fonts/truetype/ttf-dejavu
sudo touch /usr/share/fonts/truetype/ttf-devanagari-fonts
sudo touch /usr/share/fonts/truetype/ttf-gentium
sudo touch /usr/share/fonts/truetype/ttf-gujarati-fonts
sudo touch /usr/share/fonts/truetype/ttf-kannada-fonts
sudo touch /usr/share/fonts/truetype/ttf-lao
sudo touch /usr/share/fonts/truetype/ttf-malayalam-fonts
sudo touch /usr/share/fonts/truetype/ttf-mgopen
sudo touch /usr/share/fonts/truetype/ttf-oriya-fonts
sudo touch /usr/share/fonts/truetype/ttf-punjabi-fonts
sudo touch /usr/share/fonts/truetype/ttf-tamil-fonts
sudo touch /usr/share/fonts/truetype/ttf-telugu-fonts
sudo touch /usr/share/fonts/type1
sudo touch /usr/share/fonts/type1/gsfonts
sudo touch /usr/share/X11/fonts
sudo touch /usr/share/X11/fonts/100dpi
sudo touch /usr/share/X11/fonts/75dpi
sudo touch /usr/share/X11/fonts/Type1
sudo touch /usr/share/X11/fonts/encodings
sudo touch /usr/share/X11/fonts/encodings/large
sudo touch /usr/share/X11/fonts/misc
sudo touch /usr/share/X11/fonts/util
sudo touch /usr/local/share/fonts
sudo touch /var/lib/defoma/fontconfig.d
sudo touch /var/lib/defoma/fontconfig.d/A
sudo touch /var/lib/defoma/fontconfig.d/B
sudo touch /var/lib/defoma/fontconfig.d/C
sudo touch /var/lib/defoma/fontconfig.d/D
sudo touch /var/lib/defoma/fontconfig.d/E
sudo touch /var/lib/defoma/fontconfig.d/F
sudo touch /var/lib/defoma/fontconfig.d/G
sudo touch /var/lib/defoma/fontconfig.d/H
sudo touch /var/lib/defoma/fontconfig.d/J
sudo touch /var/lib/defoma/fontconfig.d/K
sudo touch /var/lib/defoma/fontconfig.d/L
sudo touch /var/lib/defoma/fontconfig.d/M
sudo touch /var/lib/defoma/fontconfig.d/N
sudo touch /var/lib/defoma/fontconfig.d/O
sudo touch /var/lib/defoma/fontconfig.d/P
sudo touch /var/lib/defoma/fontconfig.d/R
sudo touch /var/lib/defoma/fontconfig.d/S
sudo touch /var/lib/defoma/fontconfig.d/T
sudo touch /var/lib/defoma/fontconfig.d/U
sudo touch /var/lib/defoma/fontconfig.d/V
sudo touch /var/lib/defoma/fontconfig.d/a
sudo touch /var/lib/defoma/fontconfig.d/j
sudo touch /var/lib/defoma/fontconfig.d/m
sudo touch /var/lib/defoma/fontconfig.d/u

然后运行


sudo fc-cache -f -v

出现succeed就可以了。

eiffelqiu还提示说有个桌面效果,我试了一下,我的机器用起来还行,有些动画的效果,和vista类似,看上去挺有趣的。
...
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image02:28 Copying and pasting in OS X...» Projectionist

Copying and pasting in OS X from Ruby

IO.popen('pbcopy', 'w+') do |clipboard| clipboard.write('Hello') end # ^V # => "Hello" IO.popen('pbpaste') do |clipboard| puts clipboard.read end # => "Hello"

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Fri 13 July, 2007

Click here to bookmark this link.Channel Image22:50 第5回 整理を拒否して能率を上げる (葉玉匡美の脱時空勉強術):NBonline(日経ビジネス オンライン)» Matzにっき
机は資料のキャッシュであると割り切って、 整理せずに積み上げる方式。すぐに見つからなければもう探さない。 単なる言い訳という気もしないでもないが、 とてつもなく散らかった机の持ち主としては非常に共感する。 ちなみに積み上がった机は限界が来た時点(大体年末の大掃除の時)で フラッシュし、きれいになる。が、机の面が見えるのはその後数週間だけだ。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image21:52 随机数是怎么产生的» 404 梦想没找到
最近在研究彩票,为什么人们那么在乎历史数据呢,虽然说简单的rand之类的函数不是很随机,但是彩票摇奖是像摇元宵那样从桶里摇出来的。 言归正传,买彩票还没中过什么奖呢。 刚才搜索了一下,原来是有一定的算法的,至于算法的理论基础,我就不知道了,也许是数学能证明的吧。 这里是一个类似glibc的实现的算法: http://www.mscs.dal.ca/~selinger/random/
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:23 [動画]RubyがLispから継承したもの、してないもの − @IT情報マネジメント» Matzにっき
平鍋さんとの対談シリーズ、第三回(全6回)。 今回はLispとRubyの関係。 「RubyとPythonはLispの別の側面を受け継いでいる」とかは 他人には話したことのないネタかもしれない。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:23 旭川に移動。» Matzにっき
島大の野田先生と、出雲空港から羽田経由で旭川へ。 北海道と聞いて寒いところじゃないかと思っていたんだけど、 気温は30℃近い。暑いじゃないか。 お昼は「いちくら」で鮭節塩ラーメンを。 最初の一口は物足りないかな、と思ったのだけど、 最後まで食べたら十分おいしかった。不思議な味。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:23 旭山動物園» Matzにっき
旭川SOHO協議会の会長さん、副会長さんにエスコートしていただいて、 いまや日本で一番人気の動物園である旭山動物園へ。 「なぜ旭川なのに旭山か」という素朴な質問に対しては、 「動物園が旭山という山にある」という答えが。なるほど。 昔から旭川の子供たちの遠足の地であった動物園は しかし90年代には不人気から閉園の危機にあったとか。 しかし、創意工夫でここまでもってきたとか。 今は人気のために施設が新設されたりしているが、 老朽化した施設の中で工夫をして人気を集めたという話の方が (プロジェクトXに感動しがちな)..
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:23 世界に広がるオブジェクト指向スクリプト言語〜Rubyについて開発者が語る» Matzにっき
というわけで、講演。 内容は先週の島大でのものと近いが、 先週の反省を踏まえてスライドの順序を並べ替えたり、 新しいものを書き足したりしている。 が、正直、もう少し若い人たちが多いと思っていたのだが、 予想以上にスーツ率が高くてどきどきしてしまった。 お役に立てたのかしら。 私の後は野田教授が島根での活動について 語ってくださった。さすが教育職だけあって、 なかなかプレゼンがうまい。RubyKaigiで(聞けなかったけど)好評だったのも わかるというものである。 その後、懇親会。さらに一部の人とはお酒の席に(私は飲ま..
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:23 インタビュー» Matzにっき
帰りは乗り継ぎが悪くて、 羽田で2時間ほど待つことになっていた、のだが、 「楽天技術研究所について取材したい」という話で、 このタイミングで、楽天の人と、日経の人とを羽田に呼びつけて(えらそー)、 取材を受ける。 ちゃんと「楽天の中の人」として仕事ができたかな。 まだまだ新米だけど
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:23 とりあえず暇だったし何となく始めたブログ - flymake でリアルタイム文法チェック» Matzにっき
Emacs 22に標準添付のflymakeを使うと (Rubyでも)リアルタイムに文法チェックができる、という話。 IDEでは時々見かけるこの機能が欲しいと言う人は それなりにいるようなので、そういう人は喜ぶんじゃないかな。 そういう人はそもそもEmacsを使わないという懸念はとりあえず置いといて。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:23 mixiが自社開発の検索エンジンに移行、ウェブ検索はYSTに:ニュース - CNET Japan» Matzにっき
やっとHyperEstrailerがmixi経営に活かされるということか。 っていうか、今まで使ってなかったの? それでも、 使われずに塩漬けになるプロジェクトも多い中、 ちゃんと使われるのは良いことだと思うけど。 っていうか、うちのRastが絶賛塩漬け中ってのは 大問題だと思う。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:23 cdiggins.com >> My Goal: Naive Programming» Matzにっき
アルゴリズムを直接書き下したようなプログラムを書くと、 「素朴」とか「工夫がない」とかけなされるけど、 考えてみりゃ思ったまま書いてちゃんと動く「素朴なプログラム」が一番じゃね? という話。 さらに言えば、ある言語特有のイディオム(特に性能に関するもの)は、 その言語の弱さの表明以外の何者ではないのでは、という懸念。 そう。人はもっと「実行可能擬似コード」の重要さについて 考えたほうがいい。あと、性能のためにはたくさん書く勤勉さは美徳ではないことも。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:23 Rhino on Rails» Matzにっき
Rhino on Railsについての、Steve Yegge本人による「釈明」。 端で揶揄されるほどRhino on Railsは馬鹿げた技術的選択ではないということ。 ま、そうだろうとも。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:23 Programming for the masses» Matzにっき
プログラミング人口は増えてるっていうけど、 増えたのは半分素人のようなのばっかりじゃないか、 フォーラムで「C#で配列はどうやって宣言するの」なんて 質問する連中がいくらいても役に立たない、という話。 まあねぇ、この業界、半分素人のような開発者は多いからねぇ。 アルゴリズムがなんだかわからない人とか。 Googleの使い方がわからない人とか。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:23 ITmedia エンタープライズ:ゼンド、PHP開発企業のための新パートナー制度を発表» Matzにっき
ゼンド・ジャパンは頑張っている(ように見える)。 オープンソースにどっぷりの身からは、こういうのがどこまで有効なのか 全然わからないんだけど、スーツな人にとってはこういうのが安心感を提供する、 のかもしれない。ま、それでスーツな人が大満足して オープンソースがうまく行くのであれば、それくらいのことはなんでもない気がする。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:23 CodeZine:Java開発者のためのRubyガイド(Word, 言語比較)» Matzにっき
私自身が「Java視点」というものをまったく持っていないので、 そういう意味では新鮮な記事であった。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image13:20 2ちゃんねる実況中継 あるベルギー人から見た日本» Matzにっき
確かに納得した。 334 :可愛い奥様:2007/06/26(火) 09:46:19 ID:raxdPvfD0 OLだった頃、会社で働いていた日本に超詳しいベルギー人が言ったことに納得してた。 日本文化は身内受けの凝り性文化だそう。 外国文化に負けまいとしているのではなく、 世に意図的にインパクトを与えようとしているのでもなく、 今ここにいる同じ価値観を共有する仲間からの喝采を浴びたいと考える。 その結果、同じものを志す者同士の「これすごいだろ、おもしろいだろ」合戦が始まり、 そこで生み出される物が自然と研ぎ澄まされていく。 でもその競争は、..
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image13:20 第一安息日» Matzにっき
もう7月だよ。時間がたつのが速すぎる気がする。 司会はビショップが引き受けてくださった。 私は日曜学校で教師、 「神権組織について」。 なんとなく蘊蓄っぽくなってしまった。 教会ではそういう知識偏重なやり方はやめようと思っているのに。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image09:03 新的一天又开始了» Ruby Object Oriented
今天早上想到的几个概念: 一.过滤器 [1,2,3].find [4,5,6].select [7,8,9].map 过滤器针对给定的集合,对集合的元素进行遍历,按照”约束条件”进行相应的处理. “约束条件”也就是过滤规则,该规则通俗的说法就是所谓的”筛选条件”. 例如:对于美国来说,恐怖分子是一个危险的元素,因此不能让恐怖分子混入美国的一些重要地区. 对于我们日常生活来说,针对人的集合,加一个”约束条件”来过滤,有时是非常必要的—-不是每个人都可以做任何事情(例如:你一般不会允许别人任意的冒犯你) 给定的集合,按照约束条件构造的集合是原来集合的子集,该集合的元素个数比原来的少,但是更加有序. 二.浏览器web应用UI(用户界面表示系统) javascript与UI相关问题 三.戏剧(略) 四.财务(相关业务知识) 略 需要做的事情还很多,前进…
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image07:51 IronRuby plans revealed on .NET Rocks» John Lam on Software
Richard and Carl interviewed me a few weeks ago on .NET Rocks! We had a fun discussion about a whole range of topics from my experience emigrating to the Republic of Microsoft to why Ruby the language is important. The...
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image03:20 Capturing Middle-Mouse Click in Safari» Joey Gibson's Blog

I have been a consistent user of the nightly builds of the WebKit project for some time now. For those of you who don't know, WebKit is essentially the work-in-progress that will be the next production version of Safari. I like the nightlies because they are extremely fast, and while they occasionally have problems, that's OK.

The point of that discussion was to say that I have stopped using Firefox on my Mac, because the nightly builds of WebKit are so much faster. But there's one problem. In Firefox I could click a tab with my middle-mouse button, and it would close. Safari doesn't have that feature, and that's the one feature from Firefox that I really miss.

So, I've been trying to solve this problem using SIMBL. What SIMBL does is let you write a standard Cocoa bundle and have it load into another program, like Safari. Once loaded, you can replace methods in the application with your own versions, in a way known as "method swizzling." I have successfully written a Cocoa bundle, made the approrpriate changes to make it loadable by SIMBL, and have loaded it into Safari/WebKit. I have logging statements at various points in the bundle, and I can see these on the system console, thus I know it's loading.

Once the bundle was loading, I needed to pick the objects and their methods that I thought would be most likely to let me do what I needed, and then swizzle in my changes. Using F-Script Anywhere I was able to identify a single tab as an instance of TabButton. Using class-dump I was able to generate header files for Safari that would let me see the methods on TabButton and it's parents. My first thought was to override mouseUp:. This works, and I can now trap mouse events when you click on any tab. According to the Apple docs, once I get a mouse event, I should be able to call [theEvent buttonNumber] to figure out which button was pressed. Well, maybe. No matter if I clicked with the left- or middle-mouse button, [theEvent buttonNumber] always returned 0. Further digging in the docs turned up an event called NSOtherMouseUp that is sent when a button "other" than left- or right-mouse is clicked. Supposedly, I should be able to override otherMouseUp: to get those events. I have successfully swizzled this method, but it never gets called. I know that TabButton had a version of this method, because when I swizzle, I can tell if there was already a method there, and there was. I'm just not sure why it isn't being called.

So what did I get working? Well, after working a long time trying to get the middle-mouse detection working, I decided to punt for the moment. I added some code to the mouseUp method to check the event for modifiers and if the user held down Command while clicking, then I will close the tab. This is close to what I want, but nearly as sexy as just middle-mouse clicking. In case you're interested, my TabButton.m looks like this:

	 1 #import "TabButton.h"
	 2 #import "WebKit/WebKit.h"
	 3 
	 4 @implementation TabButton (MCCSwizzle)
	 5 - (void)_mcc_mouseUp:(NSEvent *) theEvent
	 6 {
	 7   NSLog(@"_mcc_mouseDown");
	 8   int buttonNumber = [theEvent buttonNumber];
	 9 
	10   NSLog(@"buttonNumber: %d", buttonNumber);
	11   NSLog(@"type: %d", [theEvent type]);
	12   NSLog(@"modifierFlags: %d", [theEvent modifierFlags]);
	13 
	14   if ([theEvent modifierFlags] & NSCommandKeyMask) {
	15     NSLog(@"Cmd-Click!");
	16     [self closeTab: theEvent];
	17   } else {
	18     [self _safari_mouseUp: theEvent];
	19   }
	20 }
	21 @end
	
and then the swizzling looks like this:
	 1 #import <WebKit/WebKit.h>
	 2 #import "AppController.h"
	 3 #import "MiddleClickClose.h"
	 4 
	 5 typedef struct objc_method *Method;
	 6 
	 7 struct objc_method {
	 8   SEL method_name;
	 9   char *method_types;
	10   IMP method_imp;
	11 };
	12 
	13 BOOL MCCRenameSelector(Class _class, SEL _oldSelector, SEL _newSelector)
	14 {
	15   NSLog(@"OLD: %s", _oldSelector);
	16   NSLog(@"NEW: %s", _newSelector);
	17 
	18   Method method = nil;
	19 
	20   // Look for the methods
	21   method = (Method)class_getInstanceMethod(_class, _oldSelector);
	22   if (method == nil)
	23     return NO;
	24 
	25   // Point the method to a new function
	26   method->method_name = _newSelector;
	27   return YES;
	28 }
	29 
	30 @implementation MiddleClickClose
	31 + (void) load
	32 {
	33   int rc;
	34 
	35   rc = MCCRenameSelector([TabButton class], @selector(mouseUp:),
	36                                    @selector (_safari_mouseUp:));
	37   NSLog(@"RC: %d", rc);
	38 
	39   rc = MCCRenameSelector([TabButton class], @selector(_mcc_mouseUp:),
	40                                                  @selector(mouseUp:));
	41   NSLog(@"RC: %d", rc);
	42 
	43   rc = MCCRenameSelector([TabButton class], @selector(rightMouseUp:),
	44                                    @selector (_safari_rightMouseUp:));
	45   NSLog(@"RC: %d", rc);
	46 
	47   rc = MCCRenameSelector([TabButton class], @selector(_mcc_rightMouseUp:),
	48                                                  @selector(rightMouseUp:));
	49   NSLog(@"RC: %d", rc);
	50 
	51   NSLog(@"MiddleClickClose loaded");
	52 }
	53 
	54 + (MiddleClickClose*) sharedInstance
	55 {
	56   static MiddleClickClose* plugin = nil;
	57 
	58   if (plugin == nil)
	59   {
	60     plugin = [[MiddleClickClose alloc] init];
	61   }
	62 
	63   return plugin;
	64 }
	65 @end
	
Line 35 renames Safari's original mouseUp: method to _safari_mouseUp: and then line 39 renames my _mcc_mouseUp: method to mouseUp:. The otherMouseUp: method is handled on lines 43 and 47, but as I said otherMouseUp never gets called.

What's especially frustrating about this is that I know Safari knows how to bag a middle-click, because I frequently will middle-click on a link in a web page, and Safari will open that link in a new tab. So, why can't I get a middle-click in the TabButton instance? Does anyone have any ideas on this? I'd appreciate any pointers. I feel like I'm thiiiiiiiiiiis close to getting this working, but there's some small piece of info that is eluding me.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Thu 12 July, 2007

Click here to bookmark this link.Channel Image20:17 復活の予感……!» 青木日記
あー、適当なこと書いてたら調子よくなってきた。 明日には復活できるだろうか。 つーかさっさと寝ろという話だ。 はいそれじゃテンション高いまま寝ます。 (20:38)
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image20:17 うわー日記書くのめっちゃ久しぶりだ» 青木日記
風邪で完全にダウン。やすめないのがきつい。 …… 38 度台かあ。体感のわりに低いな。 まあ、おれは 39 度こえると吐くからそんなもんかもしれない。 (19:37)
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image20:17 Windows でパイプをつなぐ» 青木日記
Windows でパイプをつなぎたくなったとする。 それでいて system とかは使わず自力でつなぎたいとする。 なんでパイプをつなぎたいのかってのは人それぞれだが、 「パイプをつながないと死んじゃう病」になったとか、 cmd.exe にプチきれてシェルを書き始めたとか、理由はいろいろ考えられる。 そんなわけで Win32API を調べたりしたんだけど、 つなげるだけなら Ruby では IO.popen を使えばいいので IO.popen([こまんど, 引数]) と書いとけばいいわけである。 あ、第一引数に配列が渡せるのは 1.9 限定だな確か。 ただ、IO.popen で一段..
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image20:17 Windows でパイプをつなぐ (2)» 青木日記
あれ? なんで IO.popen(ls | grep build | false) ってちゃんと動くんだろ。 ……あああそうかこれ Mac OS X じゃん……。 だめだ本当に風邪はよくない。 もう寝ゆ。 (20:45)
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:57 3 ways to invoke a method in Ruby» Suave's Blog
string = “Hello” string.method(:length).call string.send(:length) string.length ...
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image13:38 Links for 2007-07-11 [del.icio.us]» John Lam on Software

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image13:17 设计非艺术» Ruby Object Oriented
设计非艺术 艺术是关于个人表达的。它关于生命,关于情感——艺术家的想法和主意。它不太关注第三者干什么,活动也不是必须的,仅是他们的鉴赏。艺术实践不需要这些。鉴赏是艺术家的必需品,同时他们也是孤独的。   设计,从另一方面来说,是关于使用的。设计师需要别人来使用(而不仅仅是鉴赏)他们的作品。设计不存在不让人们使用它的目的。设计辅助解决人类问题。我们能授予一个设计的最高荣誉不是它多漂亮,多艺术,而是它用途多广。   不像艺术,设计总是存在于情景中的。情景对一个设计至关重要:它要解决什么问题?为谁设计?在什么时期?这就是为何设计与技术如此紧密的缘故。因为技术变化太快,所以设计必须步随其后。十年前的设计在今天可能不值一提。充满精彩设计的历史没有必要继续存在。   伟大的艺术,从另一角度说,永远风行。就算今天我们可以复制一百万个大卫像,我们依然欣赏米开朗基罗的原作,因为它是一个人的辛劳和表达。艺术永远不会凋谢。伟大的设计则依赖于它产生的年代和要解决的问题。但艺术不这样,艺术是永恒的。 伟大的设计是无形的 伟大的设计一个有趣的属性是,它来源于认可。用得爽的时候我们忘了创造它时的种种艰辛。有时,就像普通的汤匙,显而易见,这东西太简单了,但我们会忽视了在历史的某一时期它并不这样。还有,就像汽车,这东西尽管很复杂但依然容易使用,但是我们却对于它背后数以万计的工时视而不见。这是一种羞耻……每一个伟大的设计都有丰富的历史。每一设计背后都是一个或一群设计师,他们想通过解决某些问题来让世界更美好。   烂的设计显然是因为它伤害了使用。它拙劣,困难和复杂。最为讽刺的是,这个世界上烂的设计比好的设计更容易碰着。它像恶徒一样在我们面前逞威风。因为有用,伟大的设计通常都是无形的。 http://realazy.org/blog/2007/03/07/five-principles-to-design-by/
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image11:17 Two Years of Rails Podcasting» Riding Rails - home

Two years ago today, Scott Barron published the first episode of the Ruby on Rails Podcast. —Geoffrey Grosenbach

Wow, has it been two years already? Geoffrey’s been a major positive force in the Rails community even longer then that, starting with the humble Pluralizer, which helped us all figure out what table names our ActiveRecord models were supposed to be using. For his next podcast, he’s turning the tables and letting himself be interviewed by Dan Benjamin. Be sure to send in some challenging questions (see Geoffrey’s blog post for details).

Congrats on the milestone, Geoffrey, Scott, and everyone else that’s been involved with the Rails Podcast!


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image11:17 Rising» James Britt - Code, Content, Caffiene

I’ve mentioned it to some people in the Phoenix tech crowd, but thought I should mention it here, too.

I’m quite pleased to say that I’ve joined Rising Tide Software.

If you’re curious, you can get an idea of the culture behind the company from David’s recent post.

We’re a wicked cool team of skilled, smart people, so keep an eye on future announcements.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image11:17 Desert CodeCamp 2007» James Britt - Code, Content, Caffiene

Planning is underway for Desert CodeCamp 2007. It will be held Saturday, September 15th, 2007, at the University of Advancing Technology in Tempe. Presentation proposals are being accepted now (see previous link).

I’d like to give talk, but I’m not sure what I want to talk about.

Here’s what’s running through my mind:

  • Trac: A Crash Course
  • Beyond Ruby: A Potentially Hasty Intro to Haskell, Erlang, and Io.
  • Nothing. Be a spectator and razz Josh and David

Comments and suggestions invited.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image07:08 Food first, then morality.» Projectionist

Wed 11 July, 2007

Click here to bookmark this link.Channel Image21:22 亚洲杯» 404 梦想没找到
哦,亚洲杯。 有人说日本平了是冷门,中国大胜也是冷门。 刚才伊朗是反败为胜的,有人说是为了攒rp,有人说是太热 现在韩国正在和沙特踢,沙特人都不白,换上黄衣服挺像巴西队的。 不知道欧洲人有没有熬夜看我们的亚洲杯?(转joke,妈的就知道你这么说) 不过李玮峰和政治依然的脑子被×踢了似的申请黄牌。 昨天丢了一把伞,今天换了一把伞,晚上买的鸡蛋不小心摔在了地上,只好炒着吃了,5个,太撑了。 今天在新系统上编译了一下程序,新的编译器提示了很多warning,发现几个比较搞笑的: 1. switch的default拼写错误,有的被写为defaut,有的被写为dafault,结果被编译器当成了label。 2. 一个函数,类似如下: while(1){ 一些判断,然后return } free(a); free(b); 所有的返回都是在while里处理的,后面的怎么释放? 3. 很多非void的函数都没有return。 不过还好,都是小问题,要是真的哪个api不被支持了可就惨了。谢谢你,hp。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image13:39 The past is not dead. It...» Projectionist
The past is not dead. It’s not even past.

William Faulkner


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image07:05 Phoenix Dev House» James Britt - Code, Content, Caffiene

Super happy Phoenix Dev House has arrived.

Sweet logo. ;)

Saturday August 4th, 2pm – 1am

21469 East Lords Way, Queen Creek AZ

Only an hour drive from my home.

Phoenix Dev House hopes to become the greater metro Phoenix premier hackathon event mimicking the now famous Bay Area SuperHappyDevHouse.

We’re about rapid development, ad-hoc collaboration, and cross pollination. Whether you’re a l33t hax0r, hardcore coder, or passionate designer, if you enjoy software and technology development, Phoenix Dev House is for you. Code in Ruby? PHP? Java? .NET? Perl? It doesn’t matter.

Phoenix Dev House is not a marketing event. It’s a non-exclusive event intended for passionate and creative technical people that want to have some fun, learn new things, and meet new people. In this way, we’re trying to resurrect the spirit of the Homebrew Computer Club. We also draw inspiration from the demoscene as one of the only intentional getting-things-done computer events in the world.

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image01:50 RailsForge?» Riding Rails - home

Jason Perry has started a survey at http://railsforge.com/, asking for community feedback on whether a Rails-specific forge-site would be useful or not. What are your thoughts? Head on over and let him know!


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image01:50 Haml 1.7» Riding Rails - home

The Haml team recently announced the release of Haml 1.7, which is an alternative markup system that you can use in Rails, instead of the default ERb-based markup. Version 1.7 is significantly faster than previous releases (and is almost as fast as Rails’ default system, now!). There are a few other new features, too: read all about it in the release notes. Great work!


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Tue 10 July, 2007

Click here to bookmark this link.Channel Image23:15 Gizmodo Reviews the iPhone» Lovable Lyle
From Brian Lam’s No BS iPhone Review, on Apple’s decision to partner with AT&T: Signing up for the iPhone is like being tossed into a menage a trois with Angelina and Rosie O’Donnell. You want the beauty, you have to sleep with the beast. His verdict on the iPhone, based on ten days of ownership, is that [...]
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:38 佣金和折扣» Ruby Object Oriented
在商品价格中,有时会包含佣金和折扣。 A.佣金   佣金(Commission)是指卖方或买方支付给中间商代理买卖或介绍交易的服务酬金。 我国的外贸专业公司,在代理国内企业进出口业务时,通常由双方签订协议规定代理佣金比率,而对外报价时,佣金率不明示在价格中,这种佣金称之为"暗佣"。如果在价格条款中,明确表示佣金多少,称为"明佣"。在我国对外贸易中,主要出现在我国出口企业向国外中间商的报价中。   包含佣金的合同价格,称为含佣价,通常以含佣价乘以佣金率,得出佣金额。其计算公式为:   佣金=含佣价X佣金率   佣金=含佣价-净价   整理后得含佣价和净价的关系:   含拥价=净价/1-拥金率   佣金通常以英文缩写字母C表示。比如每公吨1000美元 CFR西雅图包含佣金2%,可写成:每公吨1000美元CFRC2西雅图。其中的"C2"即表示佣金率为2% 。 卖方应在收妥货款后,再向中间商支付佣金。   B.折扣   折扣(Discount)是卖方在原价格的基础上给予买方的一定比例的价格减让。 使用折扣方式减让价格,而不直接降低报价,使卖方既保持了商品的价位,又明确表明了给予买方的某种优惠,是一种促销手段、如数量折扣、清仓折扣、新产品的促销折扣等。比如每件20美元CIF纽约减5%折扣。卖方在开具发票时,应标明折扣,并在总价中将折扣减去。 http://hi.baidu.com/wietrade/blog/item/eb0c3d227fbd3ba64723e870.html
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image11:25 写字楼出租率和平均单价» Ruby Object Oriented
写字楼出租率=已出租的写字楼/(已出租的写字楼+未出租的写字楼) 平均单价=出租的租金/已出租的写字楼数 http://zhidao.baidu.com/question/12012201.html
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image10:42 什么是营业收入» Ruby Object Oriented
基本公式(许多公式的前提) 利润=收入-支出 收入有很多:营业收入,营业外收入,其他业务收入,等等 支出有很多:营业费用,管理费用,财务费用,其他业务支出等等   营业收入是利润的主要成分 在会计中 一般把利润的形成写成以下形式 利润=主营业务收入-主营业务支出-营业费用+其他业务收入-其他业务支出+营业外收入-营业外支出-管理费用-财务费用 净利润的话还要减去税收   以上公式没有写制造费用,因为制造费用属于期间费用,在期末要分配到成本和费用中去 http://zhidao.baidu.com/question/15497190.html
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image10:17 入账和出帐» Ruby Object Oriented
入账:enter an item in an account 网友的一些看法: “入”是进入,录入的意思。“入帐”就是对会计事项在账上进行记载、记录,纳入帐上监督管理的意思。 就象你们家花钱要记帐的,今天买了一斤肉记在纸上,会计上叫入帐。 相关资料:收据可以作为入账凭证吗 那么什么叫出帐?
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image09:54 累计» Ruby Object Oriented
data=[   [1,10],   [2,15],   [3,17] ]   r=[] sum=0 data.each do |row|   sum+=row[1]   r<<[row[0],sum] end    p r 应用背景:http://zhidao.baidu.com/question/13025280.html?si=9
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image07:09 Implicit is better than exp...» Projectionist
Implicit is better than explicit, if you and computer feel same way.

Matz


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image06:35 Subversion Browser on Rails» Riding Rails - home

ActiveReload has just released Warehouse, a simple subversion browser written using Rails. It sports a beautiful UI and can handle the mundane task of user and permission management for you. It’s also being distributed in a unique fashion for most Rails applications. Instead of being hosted, it is sold and downloaded to be installed on your own server.

If you’re interested, check us out at the Warehouse site.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Mon 09 July, 2007

Click here to bookmark this link.Channel Image18:14 select和select_tag的不一致» Ruby Object Oriented
u.id是数字,params[:sale_id]是字符串,select能,但是select_tag需要手动转换保持一致,这样才能够默认选中. <% @sales = User.find(:al).map{|u| [u.name, u.id]} -%>         销售:<%= select_tag :sale_id, options_for_select(@sales, params[:sale_id].to_i) %> 使用select_tag默认选中的办法是 params[:sale_id].to_i,或者u.id.to_s,保持类型一致即可(都是字符串或者都是数字) select这个helper没有这个问题(即使u.id是数字,params[:sale_id]是字符串也能够正确选中). 造成这样的不一致的原因,可能是因为select_tag需要处理”多选”的缘故.
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:14 Links for 2007-07-08 [del.icio.us]» John Lam on Software
  • Madonna's got a blog?!
    I should have expected this, but I'm still blown away that she's got a blog. I found it when I was looking for some more info about Hey You.

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image08:00 Research on why and how adopts Rails» Riding Rails - home

Michel Barbosa has completed his bachelor thesis Delivery of the Key Adoption Factors and Key Characteristics of Companies Using Ruby on Rails. It presents research he has done and conclusions the why and who of switchers.

I’m happy to see that “Joy in Development” was a key adoption factor for 92% of the people interviewed.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Sources