Sat 14 July, 2007

#!/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. look up in del.icio.us.
add to furl
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. look up in del.icio.us.
add to furlFri 13 July, 2007

add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
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. look up in del.icio.us.
add to furlThu 12 July, 2007

add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
- Hans Roslings talks at TED
I really loved his poverty gap visualization - these are links to videos of his talks at TED
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
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. look up in del.icio.us.
add to furl
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. look up in del.icio.us.
add to furl
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. look up in del.icio.us.
add to furl
“ Food first, then morality. ”
Bertolt Brecht
add to del.icio.us. look up in del.icio.us.
add to furlWed 11 July, 2007

add to del.icio.us. look up in del.icio.us.
add to furl
“ The past is not dead. It’s not even past. ”
William Faulkner
add to del.icio.us. look up in del.icio.us.
add to furl
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. look up in del.icio.us.
add to furl

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. look up in del.icio.us.
add to furl
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. look up in del.icio.us.
add to furlTue 10 July, 2007

add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
“ Implicit is better than explicit, if you and computer feel same way. ”
Matz
add to del.icio.us. look up in del.icio.us.
add to furl
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. look up in del.icio.us.
add to furlMon 09 July, 2007

add to del.icio.us. look up in del.icio.us.
add to furl
- 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. look up in del.icio.us.
add to furl
Some well-done vids at Cannes Lions Live
(found via Reddit)
add to del.icio.us. look up in del.icio.us.
add to furl
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. look up in del.icio.us.
add to furl
I like a good amount of what Lennon did, but this quote from This idiocy is all John Lennon’s fault is dead on:
Lennon invented the pop star as conscientious rebel, a fog that has enveloped others in the years since. In fact, pop music, rock music, call it what you will, is essentially conservative. People conform to certain types, and one of those types is “the rebel”, who considers himself to be some sort of anti-establishment character because he wears a leather jacket, drops his Hs, and swears in interviews.
add to del.icio.us. look up in del.icio.us.
add to furl
Reading about the carbon footprint of those participating in the Live Earth concerts makes me think that it’s a bit like PETA holding a promotional barbecue.
add to del.icio.us. look up in del.icio.us.
add to furl
Tip Projectionist Archives
For Projectionist’s second birthday it got an Archives section at http://project.ioni.st/archives.
add to del.icio.us. look up in del.icio.us.
add to furlSun 08 July, 2007

在《管窥Ruby——方法定义》中,我们曾经讨论过在Java中实现方法定义时,因为Java语言的限制,我们不得不为方法加上了一个Wrapper,让它可以满足接口定义的需要。事实上,XRuby一直就是这么做的,通常Wrapper放在com.xruby.runtime.builtin这个包中,而诸如Array、Hash、String之类的具体实现放在com.xruby.runtime.value这个包中。初涉XRuby的人,常常会被这两个包搞得晕头转向。到底方法的具体实现应该放在哪里,大多是根据感觉来定义的。
在那篇blog中,我还讨论了JRuby的实现,不过,那里面的讨论并不是特别的完善。事实上,除了利用reflection,其中还有一种方式,通过代码生成动态产生这个Wrapper。我将这个实现借鉴到了XRuby中。通过采用这种生成Wrapper的方式,我们就可以在实际编写的代码中,忽略掉Wrapper部分的实现,而将原来令人混淆的builtin和value包统一起来。
下面是Array的clear方法原来的实现:
class Array_clear extends RubyNoArgMethod {
protected RubyValue run(RubyValue receiver, RubyBlock block) {
RubyArray value = (RubyArray) receiver;
return value.clear();
}
}
在这里,其实只要将receiver转型,然后调用它的方法就好。实际上,生成的代码只是做这样简单的工作就好,当然,根据具体的方法还会略有些差别。关于如何使用ASM进行代码生成,我在几篇blog中都进行了介绍,这里就不介绍生成代码的实现了。下面是在代码中如何使用这个方法。
MethodFactory factory = MethodFactory.createMethodFactory(RubyArray.class);
c.defineMethod("clear", factory.getMethod("clear", 0));
在这个方法的实现过程中,还有一些比较有趣的点。首先,并不是每次都需要调用getMethod都要动态生成一个类,因为一个类一旦已经加载,就没有必要再次进行加载,即便强行加载,class loader也是会抱怨的。所以,在创建类之前,我们需要尝试加载一下这个,如果加载成功,便省去了再次生成的麻烦。
再有,每次都去创建这个Wapper实际上也没有什么必要,一次生成之后,保存起来就可以了。如果我们把它放在class path中,那么我们尝试加载就会成功,所以,刚才提到的尝试加载还有这样一层含义。
作为builtin实现,我们还是希望这些生成类是可以放在我们最终发布的jar文件中,所以,我们通常的做法,是在打包之前,先用XRuby做一次最简单的执行,让所有的Wrapper生成出来,这样,打包的时候就可以将它们都加入其中。
具体的做法可以参考XRuby中MethodFactory和build.xml。
add to del.icio.us. look up in del.icio.us.
add to furl
… seine Abinoten ins Netz zu stellen: unter Umständen gewinnt man bei Weberberg.de einen vom vielen Preisen. :-)
Und dazu gabs noch einen Tweety-Gutschein über eine Pizza samt Getränk, einen Frisörgutschein von Figaro Claus und einen Essensgutschein im Poco Loco.
Abitur machen kann sich also durchaus lohnen. *g*
NP: Love—You Set The Scene
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
http://immike.net/blog/2007/07/06/interview-with-leah-culver-the-making-of-pownce/
...
add to del.icio.us. look up in del.icio.us.
add to furl
“ Mistakes are beautiful baby. ”
Ann’s piano player in Evening
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furlSat 07 July, 2007

add to del.icio.us. look up in del.icio.us.
add to furl
“ Like most Bobbindoctrin productions, this show is built for grown-ups. But unlike most Bobbindoctrin productions, the content in THE GIFT OF NIGHT will not traumatize children. ”
Disclaimer about The Gift of Night puppet show
add to del.icio.us. look up in del.icio.us.
add to furl

