123
 123

Sat 07 June, 2008

Click here to bookmark this link.Channel Image18:17 Easy Plugin: 让Plugin的安装更简单» LetRails
建新项目是个繁琐的过程,最主要的就是要查找一大堆常用插件的仓库地址,花了一下午时间做了个小插件:Easy Plugin,Easy Plugin的目的就是让这个过程变得简单点,这个gem提供了一个脚本,...
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:57 Rails框架:最重要的可视化图表Ruby语言库gchartrb» 天天红玉世界
免费无限存放图片在slide.com!
  • 说明
    • Ruby语言库gchartrb是一件穿着Ruby语言的外套,其核心是基于Google API Chart
    • bd7lx说:“不需要(自身)server端的图形处理库,计算(大权)交给强大的google(集群服务器)。给出(源自于数据库的)数据,返回漂亮的图形。”
    • 中文总是问题。上面的图形是通过Rails软件所生成的。

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

Fri 06 June, 2008

Click here to bookmark this link.Channel Image18:43 Twitter Updates for 2008-06-05» halostatue
quiet # @rstevens Dammit. It’s Steve Urkel. I wanted *Galactus*, or at least Darkseid. # MIME::Types is likely getting a new maintainer. This is good news, despite that I wish I had the time and energy to maintain it myself. # taking the dog out. then I’m either reading Hillegass or playing Mario Kart. # @jimweirich Cincinnati’s skyline is [...]
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 Image14:06 自制ftp server» 动态感觉 静观其变
不知道为什么总是会碰到一些问题?filezilla server安装在windows xp上有个问题,经常会第一次连接挂死。抽空换了它,最近看到一个python ftpd的库,很有意思,非常小,是异步方式的,我想对我来说足够了,我把它做成windows service,让它自动运行起来,不用管它了。

http://code.google.com/p/pyftpdlib/

文档都不错,还有例子,我就照搬了,然后把windows service的套上去:

import win32serviceutil
import win32service
import win32event

from pyftpdlib import ftpserver

FTP_USER = 'nps_card'
FTP_PASS = 'nps_card'
HOME_DIR='d:\nps_data\'

class MyFtpd(object):
    def __init__(self):
        self.ftpd = None

    def main(self):
        # Instantiate a dummy authorizer for managing 'virtual' users
        authorizer = ftpserver.DummyAuthorizer()

        # Define a new user having full r/w permissions and a read-only
        # anonymous user
        authorizer.add_user(FTP_USER, FTP_PASS, HOME_DIR, perm='elradfmw')
        authorizer.add_anonymous(HOME_DIR)

        # Instantiate FTP handler class
        ftp_handler = ftpserver.FTPHandler
        ftp_handler.authorizer = authorizer

        # Define a customized banner (string returned when client connects)
        ftp_handler.banner = "pyftpdlib %s based ftpd ready." %ftpserver.__ver__

        # Instantiate FTP server class and listen to 0.0.0.0:21
        address = ('', 21)
        self.ftpd = ftpserver.FTPServer(address, ftp_handler)

        # set a limit for connections
        self.ftpd.max_cons = 256
        self.ftpd.max_cons_per_ip = 5

    def start(self):
        # start ftp server
        self.ftpd.serve_forever()

    def stop(self):
        self.ftpd.close_all()

class MyService(win32serviceutil.ServiceFramework):
    """NT Service."""
    
    _svc_name_ = "PyFtpService"
    _svc_display_name_ = "Py Ftp Service"

    def __init__(self, args):
        win32serviceutil.ServiceFramework.__init__(self, args)
        # create an event that SvcDoRun can wait on and SvcStop
        # can set.
        self.stop_event = win32event.CreateEvent(None, 0, 0, None)
        self.myftpd = MyFtpd()

    def SvcDoRun(self):
        self.myftpd.main()
        self.myftpd.start()
        # now, block until our event is set...
        win32event.WaitForSingleObject(self.stop_event, win32event.INFINITE)
   
    def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
        self.myftpd.stop()
        win32event.SetEvent(self.stop_event)

if __name__ == '__main__':
    win32serviceutil.HandleCommandLine(MyService)


然后用另外一个ftp client的库,ftputil,

http://ftputil.sschwarzer.net/trac

随后,做好server,放到实际环境下实验,结果发现还是存在问题,估计就是外网和内网之间的互联互通上的防火墙的问题,也会造成没有响应,后来发现去掉service,server端看日志,发现server并没有退出,但是不响应,看看例子上的代码,有个地方我删除了,有可能就是nat的问题,加上:

ftp_handler.masquerade_address = '10.146.x.188'

passive_ports的范围,似乎nat也做了限制,我不规定范围了。

代码改好之后,好像还是有点问题,还是有点晕,谁了解这些,可以和我说说么?期待有人和我说说。。。
...
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:29 Enumerable#pick» Projectionist

Enumerable#pick

module Enumerable def pick(percentage) select do |element| percentage.chance.happens? end end def some pick 50.percent end def few pick 20.percent end def many pick 80.percent end end

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 Image12:07 YouTube adds annotations» James Britt - Code, Content, Caffiene

YouTube now allows you to add hotspots and notes to your videos.

I did a quick experiment with a Monkeybars screencast and the ability to add additional information is sweet. I can see this as particularly handy for instructional vids where you don’t want to belabor something in the main content, but still want to offer details or linkis to more information.

The video quality is still not quite all that spiffy, but readable. Overall, this is quite nice (but note some of the comments in the above link).


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 Image12:07 Tempe Nerds Lunch Follow-up» James Britt - Code, Content, Caffiene

Big thanks to Sean Tierney of JumpBox for organizing yesterday’s Tempe Nerds lunch.

Great turn-out. Check out some photos.

The next one is noon, June 19, at The Tavern on Mill (404 S. Mill, Tempe; map)


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 Image12:07 Some Git links for Wednesday's Refactor Phoenix» James Britt - Code, Content, Caffiene

I posted some links to the Refactor Phoenix sub-topic on Reddit:

http://reddit.com/r/refactorphoenix/

There are also some links on the Refactor home page.


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 Image12:07 Ruby-doc API pages updated» James Britt - Code, Content, Caffiene

Since Ruby 1.8.7 is out I went and updated the API docs on Ruby-doc.org .

It’s bothered me (and others) that running rdoc over the source using the default settings grabs yaml.rb and friends and ends up sticking additonal methods on core classes that would only be there were one to require yaml.

People have also asked me why so many files appear in both the core and stdlib sections. Ideally there would be just one place to look for docs, but for now rdoc gives cleaner results when files under lib/ and ext/ are processed apart from the core files.

So, for the 1.8.7 docs, I edited the .document files to restrict what appears in the core section. What’s missing from core should appear in stdlib.


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 Image12:07 New Monkeybars Tutorials» James Britt - Code, Content, Caffiene

Hot on the heels of the 0.6 Monkeybars releases comes spiffy new tutorials.

Here’s what’s rockin’:

  • Installing: Part 1 – Getting Monkeybars, creating a new project
  • Installing: Part 2 – The contents of a generated Monkeybars project
  • Installing: Part 3 – Using the Monkeybars generator
  • Configuring Netbeans
  • Overview of Monkeybars

Catch Monkey Fever and start building kick-ass cross-platform GUI applications in Ruby!


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 Image12:07 Monkeybars Kicks Ass at JavaOne» James Britt - Code, Content, Caffiene

There was a Script Bowl contest at JavaOne , pitting Groovy, JRuby, Jython and Scala against each other in a set of application challenges.

Long story short: JRuby ruled .

The client application entry was a Monkeybars Twitter app. It won, of course

Note: edited to correct for idiotic use of SunOne instead of JavaOne.


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 Image12:07 Happy Camper Studios in eWeek» James Britt - Code, Content, Caffiene

David was on a panel at the recent JavaOne, and eWeek has a few quotes from him in an interesting article on the continued rise of the Ruby language.


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 Image12:07 Handy git-daemon Ruby script» James Britt - Code, Content, Caffiene

Last night’s Refactor meeting was great. A big thanks to Austin for his detailed Git talk, and to David for demoing some git repo sharing.

Austin has posted his slides on his website:

http://uberhip.com/projects/presentations.html

And you can clone it from the repo with: git clone http://uberhip.com/git/gitintro.git

Earlier in the day David and I were poking around with git-daemon, getting the parameters Just So and experimenting with basic repo sharing. It crossed my mind that the process for selecting the git-daemon arguments and kicking off the process should be automated with a script; David, though, was way ahead of me and quickly had a working version running.

We now have a nice little Ruby script that makes sharing a git repo snake simple. David posted the code to the Refactor mailing list.

You just drop the script in your bin dir, and when you want to share a git repo you cd to the root of the working directory and run share_git_repo (or whatever you’ve named it).

It will figure out the correct base path and display the URL needed by the client.


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 Image12:07 Git to Refactor Phoenix next week» James Britt - Code, Content, Caffiene

The topic for the next Refactor Phoenix meeting, Wednesday May 28 is git.

Git is a distributed version control system (DVCS) with increasing popularity.

Along with Mercurial, Darcs, and Bazaar, DVCS’s are increasingly winning the hearts and minds of hackers everywhere. Austin Godber of JumpBox will give a presentation on the basics of git installation, local repository setup and basic usage. You’ll also learn how to publicly share, read only, a repo over HTTP to offer public, read-only access.

David and I will relate our experience with gitorious.org and its use for managing open-source projects.

Some worthwhile places to start learning about git and distributed version control systems:

Refactor Phoenix meets on the 4th Wednesday of each month, at Boulders on Broadway in Tempe. See the Web site for more details.


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 Image12:07 Desert Code Camp is here again» James Britt - Code, Content, Caffiene

May 31 is Desert Code Camp

It’s held at UAT in Tempe:

University of Advancing Technology
2625 W. Baseline Road
Tempe, Arizona 85283

Well worth checking out, though there seems to be a heavier slant towards Microsoft tech than in than past.

Also, a word on the Ruby presentations: David will not be available that day because of prior commitments; his Ruby talks might be canceled, though Logan will probably be covering at least one of them.

I will likely be attending, but prefer to play spectator this time.


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 Image12:07 Desert Code Camp Tomorrow» James Britt - Code, Content, Caffiene

Don’t forget: Desert Code Camp tomorrow, Saturday May 31.

Logan will be leading several Ruby talks, with topics covering basic Ruby, JRuby, and building kick-ass GUI apps with Monkeybars.

I’ll be there, too, lending a hand and grooving to the geek vibe.

If you’re in or around Phoenix, don’t miss this.


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 Image12:07 Dear Rubyists, When do you (not) use parentheses, and why (not)?» James Britt - Code, Content, Caffiene
Click here to bookmark this link.Channel Image12:07 David Koontz on Java CommunityOne Ruby Panel» James Britt - Code, Content, Caffiene

Happy Camper Studio’s own David Koontz will be part of an impressive Ruby panel at the upcoming Java CommunityOne

David will be joined by JRuby luminary Thomas Enebo (Sun Microsystems, Inc.), Rich Manalang (Oracle), Mark Driver (Gartner), and others.

All of us fellow Campers are damned proud of David’s pioneering work with Monkeybars, and if you’re at all interested in super-sweet cross-platform GUI application development you have to check it out.

David will be attending both CommunityOne and JavaOne, and if you’re also going be sure to catch the Ruby panel and then track him down to learn more about the future of Ruby desktop development


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 Image12:07 ... Tomorrow the World» James Britt - Code, Content, Caffiene
On this date in 1976, The Ramones released their self-titled debut album. 14 songs in less than 28 minutes. It contained the singles, “Blitzkrieg Bop” and “I Wanna Be Your Boyfriend”. The singles didn’t chart and the best the album could muster was a peak at the #111 spot on the U.S. albums chart. Nonetheless, legend was born. The legendary punk band from Queens, NY turned in their leather jackets for good in 1996.

From The Post Punk Progressive Pop Party

See also Bands That Changed Everything: The Ramones


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:43 Easy Charts in FXRuby with the Google Chart API» Lovable Lyle
InfoQ has just published an article written by Matthew Bass that introduces the Google Chart API and the gchartrb library, which you can use to programmatically generate URLs for use with Google Chart. It’s very easy to use this library to generate charts in your FXRuby applications. First, install the gchartrb gem: $ sudo gem install [...]
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:06 MagLev» Glenn Vanderburg: Blog
Chad Fowler nails it with his summary of MagLev.

Like Chad, I think MagLev’s initial performance numbers will hold up. It’s possible that as it matures it will get slower, but it could get a lot slower than it is now and still easily be the fastest Ruby VM around.

And I agree with Chad that it might even get faster. I’ve also spent some time investigating how to make Ruby run on a Smalltalk VM, and it’s a really close fit. During the presentation at RailsConf, either Avi or the Gemstone guys revealed that they had modified their Smalltalk VM by adding two new bytecodes aimed at Ruby. I’ll go so far as to speculate: it’s likely that those two bytecodes deal with variadic methods and creation/lookup of dynamic instance variables. It sounds as though the core Ruby language is nearly complete on top of that base, so it’s easy to imagine that the early, hurried implementation of those two new bytecodes could be optimized further. And some of the Ruby features that have hurt JRuby’s performance will be no problem on a Smalltalk VM—ObjectSpace, for example, can work using the same facilities that Smalltalk’s development tools use today.

The persistence story is amazing. Avi and the team at Gemstone plan to implement an interface that is similar to ActiveRecord, but cleaner, since the object/relational impedance mismatch no longer applies.

Finally, there’s the question of licensing. I’ll be shocked if MagLev is open-source, but I think there’s room for a proprietary Ruby implementation. The team has committed to complying with RubySpec, which means I’m not very worried about compatibility. Most Ruby projects won’t need MagLev, but the ones that do will gladly pay for a top-notch, supercharged implementation with great scalability and persistence stories.

I’m definitely looking forward to hearing more about MagLev over the next few months.


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 Image05:08 Class#initialize_with» Projectionist

Class#initialize_with

class Class def initialize_with(*params, &block) attr_reader *params define_method(:initialize) do |*args| params.zip(args).each do |param, arg| instance_variable_set("@#{param}", arg) end instance_eval(&block) if block_given? end end end class Account initialize_with :username, :password do p "Initializing..." # Initialization code end end Account.new 'joe', 'secret' "Initializing..." # => #<Account @password="secret", @username="joe">

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

Thu 05 June, 2008

Click here to bookmark this link.Channel Image21:58 You have to know how to acc...» Projectionist
You have to know how to accept rejection and reject acceptance.

Ray Bradbury


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:58 Herman Düne – I Wish ...» Projectionist

Herman Düne – I Wish That I Could See You Soon


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 Image14:39 Twitter Updates for 2008-06-04» halostatue
worn out # Is OSA really that bad for non-AppleScript languages? # @joeyGibson He is another Reagan in every way that matters except charisma. He’s as small-minded and mean-spirited, after all. # @ejacqui which keyboard shortcut is it? # @simplebits My wife enjoyed seeing them live in 77, 79, 80, and 82. She missed the 81 tour. She thinks [...]
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:59 Rails框架:Rails 2.1最重要的改进功能» 天天红玉世界
免费无限存放图片在slide.com!”>
  • Rails 2.1最重要的改进功能
    • 模型方法named_scope
    • 软件包gem的配置方法
    • 测试数据fixtures文件

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:55 寂静深夜改bug» 梦想风暴
bug这种东西,只要存在,早晚会暴露出来,即便是深藏25年。不过,我们了解到的bug大多不具备很深的资历。有些不幸的bug会被QA们扼杀在摇篮之中,稍微强壮一点的也许可以生存到系统发布之后。

拜IE6所赐,我们的系统刚刚上线,便有一个bug浮出水面。经过验证,这是IE6处理直接打开附件(如PDF、PPT等)的错误。不过,好在这是一个广泛遇到的问题,使得这个bug连午饭时间都没有坚持到,便被消灭了。

按照对客户的承诺,我和另外一个同事要在办公室支持到晚上10点。上午的时候,我们的QA和客户努力了三个小时,并没有发现其它问题,于是,我们想当然的认为我们可以按“点”下班。就在我们俩准备收拾东西回家睡觉之前,从睡梦中醒来的客户终于发现了bug。于是,我们只好在深夜来临之际,开始了bug征服之旅。

有bug不是什么坏事,发现总是比不发现好。

在客户和PM压力之下修改代码并不是什么愉快的经历,好在bug们都是一些友好的家伙,很容易就定位到。不过,因为客户在线,所以,必须强迫自己把事情做得尽可能按部就班:本机测试、提交到主干、提交到分支、部署到测试环境……

感谢之前大家辛勤努力编写的测试,让我们很容易就知道自己的修改在系统内会造成怎样的影响。通过所有测试的那一刻,心头如释重负。在这个原本很是紧张的时候,多了一份自信。我喜欢这种感觉,虽然忙碌,但依然从容,一切尽在掌握之中。

这个无眠的夜里,身边还有自己的Pair,有专程赶来帮助我们进行验证的项目组的老大哥,当然,还有一直都很辛苦的PM,一个敬业的团队。


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

Wed 04 June, 2008

Click here to bookmark this link.Channel Image13:12 Twitter Updates for 2008-06-03» halostatue
Jeebus, what a goal that was. Nicely done Pittsburgh. # This OT period is amazing, considering I don’t care about either team. # What a game. Well done Pittsburgh. # Less impressed today. # Powered by Twitter Tools.
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:51 网站推荐:使用行命令进行搜索» 天天红玉世界

Tue 03 June, 2008

Click here to bookmark this link.Channel Image22:08 等待发布» 梦想风暴
一起想一下,程序发布之前的情形。

印象中,这应该是一个手忙脚乱的阶段,一大群人奔前跑后,忙着处理各种各样的问题,尤其是bug。许多人回忆自己经历的时候,往往会很有成就感的说,在某某程序发布之前,忙了一整夜,终于在程序发布之后,回到家里,一觉睡了N个小时,俨然一副历经沧桑的样子。自己经过的,既有有过连续十几天工作十几个小时,为了赶上发布日的经历,也有连续几个熬到后半夜改bug的痛苦。虽然这些都是不错的日后谈资,但当时,那是透支的感觉。

现在,我在等待发布。

是的,等待!

Story的开发工作早就已经完成,bug修改也到了尾声。代码已经冻结,Mingle上可供开发的卡已无踪影,有一种闲暇无聊的感觉。

这已经不是第一次体验发布前的闲暇了。记忆中,最近做过的几个项目,到了最后的几天,都会出现无卡可做的情况。最极端的是有一次,在PM的陪伴之下,打了多半天的游戏。

对比之前的经历,这样的经历显得很特别。原本在我的印象中,越是临近发布,应该越是忙碌,而这种一下子闲下来的感觉,真的是让人有些不适应。

这个时候,PM就成了给大家找事的人。比如,他会组织大家进行一些讨论,看看之前那些做得好,做得不好,以便在后续的工作中进行改进。比如,他会把一些属于下一个阶段的任务拿过来,让大家分析一下,提前热热身,有些手快的家伙,甚至会顺便把一些任务做完。

这样难得的清闲,多半要归功于合理的计划和控制。其实,想想之前的经历,最终期限并不是合理规划出来的。事实上,大多数情况下,对于要做什么,以及这些工作的工作量究竟有多大,并没有很好的估计,所以,往往就是指定一个发布的日期,剩下的就是靠人了,其结果就是为了赶上发布日期,拼命的加班加点,那种透支需要很长一段时间才能恢复过来。

而现在做项目,所要做的一切都是经过大家一起估计出来,包括客户和开发团队,大家对于软件开发的实质认识得比较清楚,所以,不会做一些杀鸡取卵的事情,于是,所有的一切,都会按照预期一步步进行:开发团队也不会为了追赶进度,而损失了软件的内在质量;客户会重新认识他需求的价值所在,做好优先级排序,而不会不明就里的要求全部完成。这是一个合理的开发过程,一种软件开发应有的状态。

准备发布了!


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 Image18:10 Twitter Updates for 2008-06-02» halostatue
I really don’t like going to the dentist. But, needs must. Back to work now, though. # @robinbloor I don’t actually think that they (Twitter) got it wrong from the start. They got it out the door and it got attention. # @robinbloor Hitting that hurdle is a huge thing and a big success. Now the engineering [...]
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:59 Rails 2.1 时区简介» LetRails
今年的儿童节不止属于孩子们,它也属于所有Rails的开发者,因为DHH给大家送上了最好的儿童节礼物:Rails 2.1。因为最近正在做一个需要时区支持的项目,2.1的时区功能绝对是雪中送炭,下面让...
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 Image15:06 自动部署的小利器» 动态感觉 静观其变
开发用的机器做好程序后,要部署到服务端,一般手动的过程都是打包,上传,解包,重启服务等步骤,在ruby社区有个capistrano,就是自动部署用的,虽说可以独立使用,但是它的文档有一半的篇幅和ror有关,另外独立使用的文档偏少,而我现在也不怎么用ruby。所以就找了一下python社区中有无相关的工具。

还真有人作了一个包,我试了试,感觉还挺简单,也就是那几个动作,作一次就会。它的地址是:
http://www.nongnu.org/fab/index.html

我在archlinux下安装,碰到了一些问题,需要修改几个地方:
1)os.getlogin(),在gnome界面下使用,会报错,用pwd.getpwid(os.getuid())[0]来代替
2)fab的程序中,exit(1)之类的,要改成sys.exit(1)

保证程序不错后,还要保证paramiko这个包先安装,这个包是ssh用的,然后python setup.py install安装。

使用fabric,就是简单的写fabfile文件,文件就是py文件,内容就是几个简单的函数和变量:
1)变量
set(
  fab_hosts = ['172.16.7.13'],
  fab_user = 'hzg'
)
fab_hosts是远端服务器ip,fab_user是ssh的用户

2)函数
def deploy():
  "Build the project and deploy it to a specified environment."
  local("tar zcvf fx_analysis.tar.gz fx_analysis --exclude='*.XLS'")
  put("fx_analysis.tar.gz", "/home/hzg/work/fx_analysis.tar.gz")
  run("cd /home/hzg/work/; tar zxvf fx_analysis.tar.gz")

deploy函数,由fab来调用,其中它又调用了几个:
local()=>本地机器运行
put()=>上传文件到远端服务器
run()=>在远端服务器运行

还有一些:
send(), download, sudo()等之类,都很简单明了

3)使用方法
很简单,就一个fab,运行fab,自动会去找fabfile,deploy会显示出来。
要运行deploy的步骤,也很简单,fab deploy就可以了

(mypy)[hzg@myhost work]$ fab
   Fabric v. 0.0.5, Copyright (C) 2008 Christian Vest Hansen.
   Fabric comes with ABSOLUTELY NO WARRANTY; for details type `fab warranty'.
   This is free software, and you are welcome to redistribute it
   under certain conditions; type `fab license' for details.

No commands given.
Available commands are:
   deploy   : Build the project and deploy it to a specified environment.
   help     : Display Fabric usage help, or help for a given command.
   license  : Display the Fabric distribution license text.
   list     : Display a list of commands with descriptions.
   set      : Set a Fabric variable.
   shell    : Start an interactive shell connection to the specified hosts.
   warranty : Display warranty information for the Fabric software.
Done.

(mypy)[hzg@myhost work]$ fab deploy

这样就能自动远程部署了,当然可能功能上没有capistrano多,不过已经足够了。
...
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 Image12:37 Rails Conf 2008 Summary» { |one, step, back| }

Conference Summary Video

Wow, what a great conference! There was a lot of energy flowing at RailsConf this year. Overall I’d rate this year as head and shoulders above last year. I’m not going cover much here, but will direct you attention to a Rails Envy VideoCase that Greg Pollack put together. The video is a series of very short interviews with a number of presenters giving summaries of their own talks. The only downside with the video is that I wish it was available before the conference. I see there were a number of interesting talks that I missed.

Followup on the “Modelling Dialogue”

Joe O’Brien, Chris Nelson and myself did a dialogue style presentation on the difference between object modelling and data modelling. The most common question I got after the talk was requests for book titles to learn more about object oriented modelling. Here are the books that Joe, Chris and I have recommended:


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:14 Ruby语言:每周Ruby语言新闻综述» 天天红玉世界
Click here to bookmark this link.Channel Image03:21 RubyEnRails 2008» Riding Rails - home

RubyEnRails 2008 is a Dutch Rails conference happening on June 10th. They still have a few tickets left, so if you’re able to go, there’s still the option. Lots of good speakers there including Charlie from JRuby, Obie, and the Phusion Passenger guys. I’ll be doing a iChat Q&A session as well.


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:21 RailsConf in 36 minutes» Riding Rails - home

Gregg Pollack has made a great video with interviews of speakers and attendants at RailsConf as a way of giving people who weren’t there a taste of what it was like. The result is 36 minutes of video and really worth watching. Check it out.


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

Mon 02 June, 2008

Click here to bookmark this link.Channel Image14:48 Rails框架:Rails框架高级系列教程» 天天红玉世界
Click here to bookmark this link.Channel Image14:08 Twitter Updates for 2008-06-01» halostatue
Broke down and got the 1.8 50 mm lens. # @mWare heh. I’ll swing by there later this evening. # Powered by Twitter Tools.
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:08 Artichoke Music Rocks» { |one, step, back| }

The Musician’s Birds of a Feather gathering at RailsConf was great. We had a room full people, two guitars, a ukulele, a flute, several harmonicas and an improvised drum set. Unfortunately, one of the guitars was an electric travel guitar which had a dead battery, therefore no way to really hear it.

However, the other guitar was a nice Epiphone accoustic which was passed from player to player. It became the quickly became the basis for most of the music performed that night.

I want to thank Artichoke Community Music for supplying the guitar. Travelling with a guitar by plane is a big pain, so I arrived with nothing to bring to the music BOF. I called several local music stores looking for a guitar that I could rent for an evening. Artichoke music said they had a “not-for-profit” guitar that they would let me borrow for a day. Not many stores would do that for an out-of-town stranger.

So, if you’re in Portland looking for a good guitar store, check out the great people at Artichoke Community Music.


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

Sun 01 June, 2008

Click here to bookmark this link.Channel Image16:22 Twitter Updates for 2008-05-31» halostatue
played tennis, then came back and finished my Mario Kart game # @uliwitness Can’t run Myst V installer under rosetta? (I’m sure you’ve tried that already, though.) # @shayman Toronto bookstores suck, by and large. # @danielpunkass Not a bad first podcast. # getting ready for a CD launch party … it involves the Nozuka family. I don’t have [...]
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 Image12:07 Rails 2.1: Time zones, dirty, caching, gem dependencies, caching, etc» Riding Rails - home

Rails 2.1 is now available for general consumption with all the features and fixes we’ve been putting in over the last six months since 2.0. This has been a huge effort by a very wide range of contributors helping to make it happen.

Over the past six months, we’ve had 1,400 contributors creating patches and vetting them. This has resulted in 1,600+ patches. A truly staggering number. And lots of that has made it into this release.

New features
The new major features are:

Thanks to Ryan Daigle for the feature introductions and Ryan Bates for the Railscasts. It makes writing the release notes so much easier :).

As always, you can install with:

gem install rails

...or you can use the Git tag for 2.1.0.

Enjoy!


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 Image05:23 Kernel#maybe etc with Perce...» Projectionist

Kernel#maybe etc with Percentage::Chance

class Percentage def chance Chance.new(self) end class Chance attr_reader :odds, :happens alias :happens? :happens def initialize(percent) @odds = percent.amount @happens = @odds > Kernel.rand(100) end def of(&block) yield if happens? end end end module Kernel def maybe(percent = 50.percent, &block) if block_given? percent.chance.of &block else percent.chance.happens? end end def probably(&block) 80.percent.chance.of &block end def rarely(&block) 20.percent.chance.of &block end end

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

Sat 31 May, 2008

Click here to bookmark this link.Channel Image12:55 Twitter Updates for 2008-05-30» halostatue
I’m thinking a short little round of Mario Kart Wii and then bed. # MarioKart # @schwa You underestimate the power of the block-side. Join me and we can rule the galaxy… # Powered by Twitter Tools.
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Sources