\n", "created_at"=>2012-06-24 15:34:43 UTC, "_id"=>1}])
+MONGODB iceylog_development['categories'].find({:_id=>1}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>1}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['system.namespaces'].find({})
+MONGODB iceylog_development['$cmd'].find({:create=>"sites"}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({"count"=>"sites", "query"=>{"$or"=>[{:url=>"http://www.iceskysl.com"}]}, "fields"=>nil}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"sites"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['sites'].insert([{"name"=>"Iceskysl Blog", "url"=>"http://www.iceskysl.com", "favicon"=>"http://www.google.com/profiles/c/favicons?domain=www.iceskysl.com", "updated_at"=>2012-06-24 15:34:43 UTC, "created_at"=>2012-06-24 15:34:43 UTC, "_id"=>1}])
+MONGODB [WARNING] Please note that logging negatively impacts client-side performance. You should set your logging level no lower than :info in production.
+MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1)
+MONGODB iceylog_development['system.namespaces'].find({})
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({"count"=>"categories", "query"=>{:name=>"Ruby & Rails"}, "fields"=>nil}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"categories"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['categories'].insert([{"sort"=>0, "posts_count"=>0, "name"=>"Ruby & Rails", "updated_at"=>2012-06-24 15:35:07 UTC, "created_at"=>2012-06-24 15:35:07 UTC, "_id"=>2}])
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({"count"=>"categories", "query"=>{:name=>"Database"}, "fields"=>nil}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"categories"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['categories'].insert([{"sort"=>0, "posts_count"=>0, "name"=>"Database", "updated_at"=>2012-06-24 15:35:07 UTC, "created_at"=>2012-06-24 15:35:07 UTC, "_id"=>3}])
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['system.namespaces'].find({})
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["ruby"], "comments_count"=>0, "category_id"=>2, "title"=>"Check for nil and initialize on a single line", "body"=>"点评:关于ROR中的一中“遇nil赋值”的写法,这个很早的时候在书上看到的是||=操作符,也一直这么用,今天发现作者的另外这个写法也挺好的。\n\nSometimes, you want to initialize a variable to some value only if that variable is equal to nil. If you like to write your methods as short, clean and readable as possible, you can do that task in a single line instead of taking the traditionnal 3 lines approach. You have two options :\n\n1) You can use the if modifier 1. x = get_some_object if x.nil?Very easy to read. This is my favorite.\n\n2) Or you can use the ||= operator 1. x ||= get_some_object This one is even shorter. The ||= operator is a little bit less verbose and might confuse a ruby newcomer… but I’m not saying that it should be a reason for not using it. This is more a matter of personal taste than anything else.Both of these methods are better than this :\n\n1. #eeww… we don’t like this one.\n\n2. if(x.nil?)\n\n3. x = get_some_object 4. end", "created_at"=>2007-05-19 01:23:10 UTC, "updated_at"=>2012-06-24 15:35:07 UTC, "body_html"=>"
Sometimes, you want to initialize a variable to some value only if that variable is equal to nil. If you like to write your methods as short, clean and readable as possible, you can do that task in a single line instead of taking the traditionnal 3 lines approach. You have two options :
\n\n
1) You can use the if modifier 1. x = get_some_object if x.nil?Very easy to read. This is my favorite.
\n\n
2) Or you can use the ||= operator 1. x ||= get_some_object This one is even shorter. The ||= operator is a little bit less verbose and might confuse a ruby newcomer… but I’m not saying that it should be a reason for not using it. This is more a matter of personal taste than anything else.Both of these methods are better than this :
$ uname -a\r\nLinux oj-web03 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux
\r\n
[iceskysl@oj-web03 logs]$ cat /proc/version\r\nLinux version 2.4.21-27.ELsmp (bhcompile@bugs.build.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47)) #1 SMP Wed Dec 1 21:59:02 EST 20045、内存信息$ cat /proc/meminfo\r\n$ free -M6、CPU信息$cat /proc/cpuinfo7、硬盘信息\r\n$df\r\n\r\n
(1)用客户端连接到数据库,执行select * from v$instance查看version项 \n(2)select * from product_component_version \n(3)或查询V$VERSION查看组件级信息
\n\n
4、内核 \n$ uname -a \nLinux oj-web03 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux \n[iceskysl@oj-web03 logs]$ cat /proc/version \nLinux version 2.4.21-27.ELsmp (bhcompile@bugs.build.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47)) #1 SMP Wed Dec 1 21:59:02 EST 20045、内存信息$ cat /proc/meminfo \n$ free -M6、CPU信息$cat /proc/cpuinfo7、硬盘信息 \n$df
\n\n", "_id"=>4}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Security"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["ruby", "安全", "漏洞"], "comments_count"=>0, "category_id"=>8, "title"=>"Ruby暴出大量严重漏洞!", "body"=>"Drew Yao at Apple uncovered a handful of nasty security vulnerabilities affecting all current versions of Ruby. The details are still under wraps because an attacker can DoS you or possibly execute arbitrary code—holy crap! Better upgrade sooner than later.\n\nAccording to the official Ruby security advisory, the vulnerable Rubies are:\n\n* 1.8.4 and earlier\n* 1.8.5-p230 and earlier\n* 1.8.6-p229 and earlier\n* 1.8.7-p21 and earlier\n\nThose of us running Ruby 1.8.4 or earlier must upgrade to 1.8.5 or later for a fix. Those on 1.8.5-7 can grab the latest patchlevel release for a fix.\n\n(Please note: Ruby 1.8.7 breaks backward compatibility and is only compatible with Rails 2.1 and later, so don’t go overboard!)\n虽然暂时还没看到具体的细节公布出来,也没看到0day放出来,但是从其描述上不难看出,这些bug是ruby一致以来都有的,或许还有更多的bug,ruby走向成熟,离不开这样的检验。", "created_at"=>2008-06-25 06:05:42 UTC, "updated_at"=>2012-06-24 15:35:09 UTC, "body_html"=>"
Drew Yao at Apple uncovered a handful of nasty security vulnerabilities affecting all current versions of Ruby. The details are still under wraps because an attacker can DoS you or possibly execute arbitrary code—holy crap! Better upgrade sooner than later.
\n\n
According to the official Ruby security advisory, the vulnerable Rubies are:
\n\n
\n
1.8.4 and earlier
\n
1.8.5-p230 and earlier
\n
1.8.6-p229 and earlier
\n
1.8.7-p21 and earlier
\n
\n\n
Those of us running Ruby 1.8.4 or earlier must upgrade to 1.8.5 or later for a fix. Those on 1.8.5-7 can grab the latest patchlevel release for a fix.
\n\n
(Please note: Ruby 1.8.7 breaks backward compatibility and is only compatible with Rails 2.1 and later, so don’t go overboard!) \n虽然暂时还没看到具体的细节公布出来,也没看到0day放出来,但是从其描述上不难看出,这些bug是ruby一致以来都有的,或许还有更多的bug,ruby走向成熟,离不开这样的检验。
\n", "_id"=>6}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["rsync"], "comments_count"=>0, "category_id"=>9, "title"=>"同步利器rsync", "body"=>"rsync is a program that copies file from one location to another, with it you can make backups of your files, synchronize data on different locations and computers. It is commonly used by unix users to keep a safe backup of their files and is often recommended as the simplest solution for backups and safety copys.\r\n\r\n参考资料:\r\n\r\n1.rsync的安装和使用\r\n\r\n2. rsync", "created_at"=>2008-06-25 19:58:32 UTC, "updated_at"=>2012-06-24 15:35:09 UTC, "body_html"=>"
rsync is a program that copies file from one location to another, with it you can make backups of your files, synchronize data on different locations and computers. It is commonly used by unix users to keep a safe backup of their files and is often recommended as the simplest solution for backups and safety copys.
A gravatar, or globally recognized avatar, is quite simply an avatar image that follows you from weblog to weblog appearing beside your name when you comment on gravatar enabled sites. Avatars help identify your posts on web forums, so why not on weblogs?
\r\n看明白了么,就是一个你输入自己的Email,然后上传自己的图片标识,然后在其他支持 Gravatars的网站(blog居多)中发表评论的时候输入自己的Email地址,就可以在Gravatars上找到其对应的图片来显示了。\r\n\r\n这确实是个不错的Idea,相当简单,但是也做得有声有色的,有点意思。\r\n\r\n使用也很方便,其在“How the URL is constructed”上介绍了其URL的组成,中可以这么使用(来源Gravatars on Rails):\r\n\r\n\r\n\r\n1、首先在````application_helper.rb中增加一个helper方法```\r\n
这个世界有意思,多大的idea都可以做成网站,以前看过缩址的网站,现在有看到一个省份标识的网站, Gravatars,看他的介绍: \nA gravatar, or globally recognized avatar, is quite simply an avatar image that follows you from weblog to weblog appearing beside your name when you comment on gravatar enabled sites. Avatars help identify your posts on web forums, so why not on weblogs? \n看明白了么,就是一个你输入自己的Email,然后上传自己的图片标识,然后在其他支持 Gravatars的网站(blog居多)中发表评论的时候输入自己的Email地址,就可以在Gravatars上找到其对应的图片来显示了。
\n\n
这确实是个不错的Idea,相当简单,但是也做得有声有色的,有点意思。
\n\n
使用也很方便,其在“How the URL is constructed”上介绍了其URL的组成,中可以这么使用(来源Gravatars on Rails):
晓得TDD,BDD,RSpec这些东西很久了,也看了不少的资料和教程,但总感觉还在门外徘徊,始终不得其要,真是怪异。应该是没在实际项目中实践过的缘故吧。 \n本文记录一些RSpec和BDD(Behaviour Driven Development )的资料和文档,给我自己也给各位路过者提供一些资料,感兴趣的仔细看看吧。 \n \n http://rspec.info/ \n Telling a good story - Rspec stories from the trenches \n Slides from RailsConf \n rspec plain text stories + webrat = chunky bacon! \n http://chinaonrails.com/topic/view/220.html \n Story Driven Development with Rails - Part I: Up and Running \n \n另外,http://rspec.info/documentation/rails/上的资料非常棒。有路过的,玩BDD的朋友还望多多指教,领我进门,多谢!
\n", "_id"=>18}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"Html/css/js"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"Android & Java"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({"count"=>"categories", "query"=>{:name=>"Android & Java"}, "fields"=>nil}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"categories"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['categories'].insert([{"sort"=>0, "posts_count"=>0, "name"=>"Android & Java", "updated_at"=>2012-06-24 15:35:09 UTC, "created_at"=>2012-06-24 15:35:09 UTC, "_id"=>12}])
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Thin"], "comments_count"=>0, "category_id"=>6, "title"=>"Thin version 1.0.0 is out!", "body"=>"Thin version 1.0.0 (codename That's What She Said) is out!\r\n\r\nYes 1.0! That doesn't mean it's bug free or anything. But, it does\r\nmean that it's been running on a number of servers and no show stopper\r\nbugs have been found since a while.\r\n\r\nAlso see http://macournoyer.wordpress.com/2008/09/30/thin-10/\r\n\r\n== What's new?\r\n\r\n* Fixed vlad.rake to allow TCP or socket [hellekin]\r\n* Updated Mack adapter to handle both <0.8.0 and >0.8.0 [Mark Bates]\r\n* rails rack adapter uses File.readable_real? so it recognizes ACL\r\npermissions [Ricardo Chimal]\r\n* Log a warning if Rack application returns nil body [Michael S.\r\nKlishin]\r\n* Handle nil and Time header values correctly [#76 state:resolved]\r\n[tmm1]\r\n* Add Content-Length header to response automatically when possible\r\n[#74 state:resolved] [dkubb]\r\n* Runner now remembers -r, -D and -V parameters so that clustered\r\nservers inherit those and\r\nkeep your parameters.\r\n* Make Set-Cookie header, in Rails adapter, compatible with current\r\nRack spec [Pedro Belo]\r\n[#73, state:resolved]\r\n* Add --no-epoll option to disable epoll usage on Linux [#61\r\nstate:resolved]\r\n* Add --force (-f) option to force stopping of a daemonized server\r\n[#72 state:resolved]\r\n* Update halycon adapter loader [mtodd]\r\n\r\n== Get it!\r\n\r\nInstall Thin from RubyForge:\r\n\r\ngem install thin\r\n\r\nOr using my mirror:\r\n\r\ngem install thin --source http://code.macournoyer.com\r\n\r\n参考文档:\r\nhttp://groups.google.com/group/thin-ruby/browse_thread/thread/402d51a6d9f2651d", "created_at"=>2008-10-07 09:56:27 UTC, "updated_at"=>2012-06-24 15:35:09 UTC, "body_html"=>"
Thin version 1.0.0 (codename That's What She Said) is out!
\n\n
Yes 1.0! That doesn't mean it's bug free or anything. But, it does \nmean that it's been running on a number of servers and no show stopper \nbugs have been found since a while.
Search directory arguments recursively for files to convert.
\r\n\t
-d or --delete
\r\n\t
delete input files after successful conversion. May not be safe yet!!!
\r\n\t
-v or --verbose
\r\n\t
makes sneetchalizer more chatty.
\r\n\t
-s or --show-output
\r\n\t
shows output from conversion tool.
\r\n\t
-p or --pretend
\r\n\t
don't convert anything. sneetchalizer will go through the motions and print out the commands it would run. Useful for preview- ing a complex command line to ensure it does what you intend. You should interpret this option's output with a grain of salt. For example, if you include the '--sanitize' option, the files will not really be renamed when using --pretend, and as such the command's output will not reflect that the filenames would be changed during an actual run.
\r\n\t
-t or --terminate
\r\n\t
terminate sneetchalizer options. This is useful if you have to convert '--coolDir' or '-groovySong.mp3'. This is the only option whose order on the command line is significant.
\r\n\t
-D ARG or --out-directory=ARG
\r\n\t
write all outfiles to a directory argument. This is useful if you want to (re)encode files directly to a mounted portable device.
\r\n\t
--strict and --pedantic
\r\n\t
many errors that sneetchalizer may encounter are recoverable, such as specifying a directory as argument that contains no files to convert, or conversion failures in general. By default the script will print an error message and move on to the next file. If you use '--strict' then sneetchalizer will bail out at the first sign of trouble except for tag errors. With '--pedantic' the script will stop even on tag errors.
\r\n\t
--stasis
\r\n\t
Preserve timestamp (mtime) of original file.
\r\n\t
--threads [N]
\r\n\t
Experimental. Use threads to create concurrent jobs. This option takes an optional integer argument which represents the number of threads to launch. The default is two. Preliminary tests suggest there is little advantage (and even diminishing returns) when setting this number greater than the number of cores/CPUs you have. Due to the asychronous nature of threads the --verbose and --show-output flags will be silently disabled and most screen output is supressed.
\r\n\t
--sanitize
\r\n\t
Removes ,, ;, :, ', \", %, @, #, and ` from filenames and tags.
\r\n\t
-n [FORMAT] or --rename[=FORMAT]
\r\n\t
rename all outfiles (and temporary wavs) according to FORMAT. FORMAT is a string with special designators to be pulled from the file tags. The following options are available:
\r\n\t
\r\n\t
* %t Song title
\r\n\t
* %b Album title
\r\n\t
* %n Track number
\r\n\t
* %a Artist name
\r\n\t
* %y Year
\r\n\t
* %g Genre
\r\n\t
* %c Comment field
\r\n\t
\r\n\t
Directories may be created with this command, as in \"%b/%n - %t\". The default value of FORMAT is \"%n %t\".
\r\n\t
\r\n\t
Bitrate/Quality/Compression options:
\r\n\t
\r\n\t
-b or --bitrate
\r\n\t
mp3/ogg/m4a bitrate.
\r\n\t
-q or --quality
\r\n\t
mp3/ogg quality.
\r\n\t
\r\n\t
quality and bitrate are passed directly to lame or oggenc depending on mp3 or ogg output format respectively. Both tools can handle either a bitrate or quality argument, so it is important to understand what values are valid for the underlying tool in your specific use case. faac will accept a bitrate argument, but not a quality argument. These options will be silently ignored for any output formats other than mp3, ogg or m4a. Make sure you know what you are doing if you decide to use both in one run, and read each tools manpage for valid values. If these options are omitted the tools builtin defaults are used (-q3 for oggenc and -q5 for lame).
\r\n\t
\r\n\t
-c or --compression
\r\n\t
flac/mac compression level.
\r\n\t
\r\n\t
this option allows you to pass a compression argument to flac and mac. See 'flac --help' and/or 'mac --help' if you don't know what this means.
\r\n\t
\r\n\t
Format Options:
\r\n\t
\r\n\t
--out=format
\r\n\t
output format. Default is wav.
\r\n\t
--in=format[,format..]
\r\n\t
input format(s). Default is wav.
\r\n\t
\r\n\t
Valid output formats are: \"aac\", \"aif\", \"aifc\", \"aiff\", \"aiffc\", \"ape\", \"au\", \"cdr\", \"cdda\", \"copy\", \"flac\", \"m4a\", \"m4b\", \"mpc\", \"mp4\", \"mpp\", \"mp3\", \"mp2\", \"ofr\", \"ofs\", \"ogg\", \"snd\", \"spx\", \"tta\", \"wav\", \"wv\". Valid input formats are all of the above plus \"wma\". You can specify multiple input formats using a comma: 'mp3,m4a,wma'. Input format is only neccesary when passing directory arguments, as file arguments are handled by context (read: file extension). The \"copy\" output option copies files directly, bypassing decoding/encoding steps (useful in conjunction with --rename).
\r\n\t
\r\n\t
Tagging Options:
\r\n\t
\r\n\t
--tt or --title
\r\n\t
Set 'title' tag.
\r\n\t
--ta or --artist
\r\n\t
Set 'artist' tag.
\r\n\t
--tl or --album
\r\n\t
Set 'album' tag.
\r\n\t
--ty or --year
\r\n\t
Set 'year' tag.
\r\n\t
--tc or --comment
\r\n\t
Set 'comment' tag.
\r\n\t
--tg or --genre
\r\n\t
Set 'genre' tag.
\r\n\t
--tn or --trackn
\r\n\t
Set 'track number' tag.
\r\n\t
\r\n\t
The short and long versions are different in an important way: Using the long version will clobber any existing tags. The short version will only set the tag if the existing tag has no value. Note that these tags will be placed in _every_ outfile during the run.
\r\n\t
\r\n\t
Alternative Encoder/Decoder Options:
\r\n\t
\r\n\t
--gogo
\r\n\t
use gogo to encode mp3 files.
\r\n\t
--bladeenc
\r\n\t
use bladeenc to encode mp3 files.
\r\n\t
\r\n\t
The default is still 'lame'. If 'lame' is not found, the script will search for one of these two encoders regardless if these options are passed or not.
\r\n\t
\r\n\t
Special Options:
\r\n\t
\r\n\t
--in-optionhook=ARG
\r\n\t
add ARG to infile conversion command. Possibly dangerous!
\r\n\t
--out-optionhook=ARG
\r\n\t
add ARG to outfile conversion command. Possibly dangerous!
Using the same --in and --out format allows us to resample/encode the file at a different bitrate or quality. Note that this will overwrite the original file so only do this on a copy, or use '-D' to write files to another directory.
直接下载其gz包,sneetchalizer-0.9.0是现在的最新版本。下载解包后可以看到: \n \nManifest: \n \n README - You're reading it now. \n LICENSE - A copy of the GPL, under which sneetchalizer is released. \n CHANGES - sneetchalizer's cvs/svn commit log. \n sneetchalizer - The script itself. \n sneetchalizer.1 - The manpage for sneetchalizer. \n sneetchalizer.desktop - A KDE service menu for converting with Konqueror. \n install.rb - A quick and dirty script to install the sneetchalizer. \n \n \n如果有root权限,可以直接运行install.rb,其会将sneetchalizer拷贝到/usr/bin下,将sneetchalizer.1拷贝到/usr/share/man/man1下。
\n\n
2、参数解释
\n\n
不翻译了,都挺简单明了的,如下: \n \nXML/HTML代码 \n \n General options: \n \n -h or --help \n Print quick or full usage details respectively. \n -r or --recursive \n Search directory arguments recursively for files to convert. \n -d or --delete \n delete input files after successful conversion. May not be safe yet!!! \n -v or --verbose \n makes sneetchalizer more chatty. \n -s or --show-output \n shows output from conversion tool. \n -p or --pretend \n don't convert anything. sneetchalizer will go through the motions and print out the commands it would run. Useful for preview- ing a complex command line to ensure it does what you intend. You should interpret this option's output with a grain of salt. For example, if you include the '--sanitize' option, the files will not really be renamed when using --pretend, and as such the command's output will not reflect that the filenames would be changed during an actual run. \n -t or --terminate \n terminate sneetchalizer options. This is useful if you have to convert '--coolDir' or '-groovySong.mp3'. This is the only option whose order on the command line is significant. \n -D ARG or --out-directory=ARG \n write all outfiles to a directory argument. This is useful if you want to (re)encode files directly to a mounted portable device. \n --strict and --pedantic \n many errors that sneetchalizer may encounter are recoverable, such as specifying a directory as argument that contains no files to convert, or conversion failures in general. By default the script will print an error message and move on to the next file. If you use '--strict' then sneetchalizer will bail out at the first sign of trouble except for tag errors. With '--pedantic' the script will stop even on tag errors. \n --stasis \n Preserve timestamp (mtime) of original file. \n --threads [N] \n Experimental. Use threads to create concurrent jobs. This option takes an optional integer argument which represents the number of threads to launch. The default is two. Preliminary tests suggest there is little advantage (and even diminishing returns) when setting this number greater than the number of cores/CPUs you have. Due to the asychronous nature of threads the --verbose and --show-output flags will be silently disabled and most screen output is supressed. \n --sanitize \n Removes ,, ;, :, ', ", %, @, #, and ` from filenames and tags. \n -n [FORMAT] or --rename[=FORMAT] \n rename all outfiles (and temporary wavs) according to FORMAT. FORMAT is a string with special designators to be pulled from the file tags. The following options are available: \n \n * %t Song title \n * %b Album title \n * %n Track number \n * %a Artist name \n * %y Year \n * %g Genre \n * %c Comment field \n \n Directories may be created with this command, as in "%b/%n - %t". The default value of FORMAT is "%n %t". \n \n Bitrate/Quality/Compression options: \n \n -b or --bitrate \n mp3/ogg/m4a bitrate. \n -q or --quality \n mp3/ogg quality. \n \n quality and bitrate are passed directly to lame or oggenc depending on mp3 or ogg output format respectively. Both tools can handle either a bitrate or quality argument, so it is important to understand what values are valid for the underlying tool in your specific use case. faac will accept a bitrate argument, but not a quality argument. These options will be silently ignored for any output formats other than mp3, ogg or m4a. Make sure you know what you are doing if you decide to use both in one run, and read each tools manpage for valid values. If these options are omitted the tools builtin defaults are used (-q3 for oggenc and -q5 for lame). \n \n -c or --compression \n flac/mac compression level. \n \n this option allows you to pass a compression argument to flac and mac. See 'flac --help' and/or 'mac --help' if you don't know what this means. \n \n Format Options: \n \n --out=format \n output format. Default is wav. \n --in=format[,format..] \n input format(s). Default is wav. \n \n Valid output formats are: "aac", "aif", "aifc", "aiff", "aiffc", "ape", "au", "cdr", "cdda", "copy", "flac", "m4a", "m4b", "mpc", "mp4", "mpp", "mp3", "mp2", "ofr", "ofs", "ogg", "snd", "spx", "tta", "wav", "wv". Valid input formats are all of the above plus "wma". You can specify multiple input formats using a comma: 'mp3,m4a,wma'. Input format is only neccesary when passing directory arguments, as file arguments are handled by context (read: file extension). The "copy" output option copies files directly, bypassing decoding/encoding steps (useful in conjunction with --rename). \n \n Tagging Options: \n \n --tt or --title \n Set 'title' tag. \n --ta or --artist \n Set 'artist' tag. \n --tl or --album \n Set 'album' tag. \n --ty or --year \n Set 'year' tag. \n --tc or --comment \n Set 'comment' tag. \n --tg or --genre \n Set 'genre' tag. \n --tn or --trackn \n Set 'track number' tag. \n \n The short and long versions are different in an important way: Using the long version will clobber any existing tags. The short version will only set the tag if the existing tag has no value. Note that these tags will be placed in _every_ outfile during the run. \n \n Alternative Encoder/Decoder Options: \n \n --gogo \n use gogo to encode mp3 files. \n --bladeenc \n use bladeenc to encode mp3 files. \n \n The default is still 'lame'. If 'lame' is not found, the script will search for one of these two encoders regardless if these options are passed or not. \n \n Special Options: \n \n --in-optionhook=ARG \n add ARG to infile conversion command. Possibly dangerous! \n --out-optionhook=ARG \n add ARG to outfile conversion command. Possibly dangerous! \n \n \n另外,你可以运行sneetchalizer -h看到简要的使用说明,也可以使用sneetchalizer --help看到详细的使用信息。
\n\n
3、使用示例
\n\n
如下简要的写几个使用的示例: \n \n使用示例: \n \n $ sneetchalizer song.mp3 \n \n The most simple possible example, creates 'song.wav'. \n \n $ sneetchalizer --out=ogg --in=flac -q5 /some/music/dir \n \n This example converts every flac file in '/some/music/dir' to ogg format at quality 5. \n \n $ sneetchalizer -d --out=mp3 --in=ogg,m4a,wma -b 160 . \n \n Converts every ogg, m4a, and wma file in the current directory to a 160 kbps constant bitrate mp3 file. The original files are deleted. \n \n $ sneetchalizer --out=mp3 --out-optionhook="--preset extreme" /some/wavs \n \n Here we encode every wav in '/some/wavs' to mp3 format passing '--preset extreme' directly to lame. \n \n $ sneetchalizer --in=ogg --out=ogg --quality=1 norvegianWood.ogg /some/more/oggs \n \n Using the same --in and --out format allows us to resample/encode the file at a different bitrate or quality. Note that this will overwrite the original file so only do this on a copy, or use '-D' to write files to another directory. \n \n $ sneetchalizer --in=ogg --out=m4a -D /mnt/ipod/ /some/oggs \n \n Here we re-encode some ogg files to m4a format and write them to our mounted iPod. \n \n \n4、注意事项
\n\n
本脚本只是粘合剂,其他的tool还是需要另外安装的。
\n\n
其他信息请参考其主页说明,如果您有这个方面的问题或经验,欢迎和我讨论。
\n\n\n
\n", "_id"=>20}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["架构"], "comments_count"=>0, "category_id"=>9, "title"=>"网站架构文章列表(持续更新中)", "body"=>"互联网越来越开放,技术人员也越来越乐于分享,分析构架、演变和遇到的问题,虽然说没有真正经历过,很多体验可能会没那么深,但是有些东西提前了解会有诸多好处。在很多地方看到类似的构架分析、分享的文章,统一收集整理如下,遇到其他的,我会持续更新,如果经历允许,我还会写一些读后感或者点评;如果你看到其他的类似文章或者点评,欢迎留言让我知道。\n\n对dbanotes等表示感谢。\n\nWikiPedia 技术架构学习分享\nhttp://www.dbanotes.net/opensource/wikipedia_arch.html\n\nYouTube 的架构扩展\nhttp://www.dbanotes.net/opensource/youtube_web_arch.html\n\nLinkedIn 架构笔记\nhttp://www.dbanotes.net/arch/linkedin.html\n\nLinkedIn 架构与开发过程\nhttp://www.dbanotes.net/arch/linkedin_soa.html\n\nInternet Archive 的海量存储浅析\nhttp://www.dbanotes.net/database/internet_archive_storage.html\n\nTailrank 网站架构\nhttp://www.dbanotes.net/review/tailrank_arch.html\n\nTwitter 的架构扩展: 100 倍性能提升\nhttp://www.dbanotes.net/arch/twitter_arch.html\n\n财帮子(caibangzi.com)网站架构\nhttp://www.dbanotes.net/arch/caibangzi_web_arch.html\n\nYupoo! 的网站技术架构\nhttp://www.dbanotes.net/arch/yupoo_arch.html\n\n37Signals 架构\nhttp://www.dbanotes.net/arch/37signals_arch.html\n\nFlickr 的访问统计实现以及其他\nhttp://www.dbanotes.net/arch/flickr_stats_and_dathan.html\n\nPlentyOfFish 网站架构学习\nhttp://www.dbanotes.net/arch/plentyoffish_arch.html\n\nYahoo!社区架构\nhttp://www.dbanotes.net/arch/yahoo_arch.html\n\n有关 Alexa 与 AOL 部署集群文件系统\nhttp://www.dbanotes.net/arch/alexa_ibrix_san_file_system.html\n\neBay 的存储一瞥\nhttp://www.dbanotes.net/arch/ebay_storage.html\n\neBay 的数据量\nhttp://www.dbanotes.net/database/ebay_storage.html\n\neBay 的数据库分布扩展架构\nhttp://www.dbanotes.net/database/ebay_database_scale_out.html\n\neBay 的数据层扩展经验\nhttp://www.dbanotes.net/arch/ebay_db_scale_out.html\n\neBay 的应用服务器规模\nhttp://www.dbanotes.net/web/ebay_application_server.html\n\n性能扩展问题要趁早\nhttp://www.dbanotes.net/arch/scaling_an_early_stage_startup.html\n\nScaling an early stage startup\nhttp://www.scribd.com/doc/429986/Scaling-an-early-stage-startup\n\nFacebook 的 PHP 性能与扩展性\nhttp://www.dbanotes.net/arch/facebook_php.html\n\nSkype 用 PostgreSQL 支撑海量用户\nhttp://www.dbanotes.net/arch/skype_postgresql.html\n\n闲谈 Web 图片服务器\nhttp://www.dbanotes.net/web/web_image_server.html\n\n说说北京奥运购票系统瘫痪这事儿\nhttp://www.dbanotes.net/review/beijing_olympic_ticketes_system_crash.html\n\nArchitectures You’ve Always Wondered About\nhttp://qcon.infoq.com/london-2008/tracks/show_track.jsp?trackOID=82\n\neBay’s Architectural Principles\nhttp://www.eos1.dk/qcon-london-2008/slides/RandyShoup_eBaysArchitecturalPrinciples.pdf\n\nBuilding a large scale SaaS app\nhttp://www.eos1.dk/qcon-london-2008/slides/Dan_Hanley_Building_a_large_scale_SaaS_app.pdf\n\nScaling an early stage startup\nhttp://www.scribd.com/doc/429986/Scaling-an-early-stage-startup\n\n互联星空播客架构(原文在张宴blog上,但是后来文章撤下,很可惜.此为转载)\nhttp://www.flashmov.com/blog_1632.html\n\nQQ游戏百万人同时在线服务器架构实现\nhttp://www.libing.net.cn/read.php?41\n\n大型Web2.0站点构建技术初探\nhttp://blog.csdn.net/heiyeshuwu/archive/2007/11/18/1890793.aspx\n\nWeb站点数据库分布存储浅谈\nhttp://blog.csdn.net/heiyeshuwu/archive/2007/11/18/1891639.aspx\n\nQQ的架构讨论\nhttp://groups.google.com/group/dev4server/browse_thread/thread/0d72668d11c4886b/a6d202489cabf285#a6d202489cabf285\n\nNotes from Scaling MySQL - Up or Out\nhttp://venublog.com/2008/04/16/notes-from-scaling-mysql-up-or-out/\n\nYapache-Yahoo! Apache 的秘密\nhttp://www.dbanotes.net/web/yapache_yahoo_apache.html\n\nScalability Best Practices: Lessons from eBay\nhttp://www.infoq.com/articles/ebay-scalability-best-practices", "created_at"=>2008-10-09 06:51:05 UTC, "updated_at"=>2012-06-24 15:35:09 UTC, "body_html"=>"
Google的产品很多都深得我心,一直在使用,整理整合了一些Gmail的快捷方式,备忘。 \n \n \n \n快捷键 \n定义 \n作用 \n \n \nc \nCompose \n撰写新邮件。“Shift+C”打开新窗口撰写新邮件 \n \n \n<tab> then <Enter> \nSend message \n新邮件撰写完后,先<tab>后<Enter>可发送邮件。(在Windows中,使用IE和Firefox有效) \n \n \nk \nMove to newer conversation \n在收件箱中,向上移动光标,按<Enter>查看邮件;在查看邮件时,打开下一封新邮件 \n \n \nj \nMove to older conversation \n在收件箱中,向下移动光标,按<Enter>查看邮件;在查看邮件时,打开下一封旧邮件 \n \n \nn \nNext message \n查看邮件时,定位光标到 \n \n \np \nPrevious message \n移动光标到前一个消息。<Enter>展开或折叠消息。(只在“会话模式”(Conversation View)中有效) \n \n \no or <Enter> \nOpen \n打开会话。在“Conversation View”中,也可用于打开消息。 \n \n \nu \nReturn to conversation list \n刷新页面、返回收件箱或返回会话列表 \n \n \ny \nArchive* \nRemove from current view \n \n删除会话或消息。 \n在收件箱中,<Y>可“存档”选中的会话
\n\n
在“已加星标示”中,<Y>可取消选中会话的星号; \n 在查看有标签的邮件时,<Y>可取消标签。 \n 在“垃圾邮件”、“已发邮件”和“所有邮件”中,<Y>没有作用 \n \n \n \n \nx \nSelect conversation \n选中会话,配合其他快捷键可为会话存档、添加标签或从下拉菜单中选择其他命令 \n \n \ns \nStar a message or conversation \n为会话或消息加星标。 \n \n \n! \nReport spam \n将消息标记为垃圾邮件并从会话中删除 \n \n \nr \nReply \n回复邮件或会话。“shift+r”可在新窗口中回复消息(只在“会话模式”中有效) \n \n \na \nReply all \n回复所有收件人。“Shift+a”可打开新窗口中回复。(PConline注:如果邮件有抄送地址,<r>回复发件人,<a>则回复所有抄送地址) \n \n \nf \nForward \n转发消息。“Shift+f”可打开新窗口转发。(只在“查看消息模式”(“Conversation View”)中有效) \n \n \n<Esc> \nEscape from input field \nRemoves the cursor from your current input field.(PConline注:在中文版Gmail中暂未有效果) \n \n \ny then o \nArchive and next \n存档选中的会话并打开下一个 \n \n \ng then a \nGo to 'All Mail' \n转到“所有邮件” \n \n \ng then s \nGo to 'Starred' \n转到“已加星标” \n \n \ng then c \nGo to 'Contacts' \n转到“通讯录” \n \n \ng then d \nGo to 'Drafts' \n转到“草稿” \n \n \ng then i \nGo to 'Inbox' \n转到“收件箱” \n \n \n/ \nSearch \n将光标定位到搜索栏中的输入框中 \n \n \n \n
\n", "_id"=>22}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["analyzer"], "comments_count"=>0, "category_id"=>7, "title"=>"Request-log-analyzer: Rails&Merb的日志分析", "body"=>"生产环境下,需要对环境持续监控以尽快的发现问题,找到耗费资源较多的地方加以改进,比较常见的做法是使用moint或者God实时监控;另外,还可以定期分析日志找到特定的请求,虽然可以是shell来做这件事,但是何必再造轮子呢,因为我们已经有了Request log analyzer :\r\n``简介:This is a simple command line tool to analyze request log files of both Rails andMerb. Its purpose is to find what actions are best candidates for optimization.This tool will parse all requests in the logfile and aggregate theinformation. Once it is finished parsing the log file, it will show therequests that take op most server time. Different metrics are used (cumulativetime, average time, blockers, DB time, etc)\r\n\r\n安装:gem sources -a http://gems.github.comsudo gem install wvanbergen-request-log-analyzer\r\n\r\n使用:Usage: request-log-analyzer [FILE] [OPTION]Analyze the given log FILE with the given OPTIONExample: request-log-analyzer mongrel.log\r\n\r\n --fast, -t: Only use completed requests --guess-database-time, -g: Guesses the database duration of requests if they are not in the log --output, -o: Comma-separated list of reports to show --amount, -c: Displays the top <amount> elements in the reports --colorize, -z: Fancy bash coloring\r\n\r\n示例:Note that this example was shortened for your viewing pleasure.$ request-log-analyzer /var/log/my_app.log\r\n\r\nRequest log analyzer, by Willem van Bergen and Bart ten Brinke\r\n\r\nProcessing all log lines...========================================================================Successfully analyzed 58908 requests from log file\r\n\r\nTimestamp first request: 2008-07-13T06:25:58+00:00Timestamp last request: 2008-07-20T06:18:53+00:00Total time analyzed: 7 daysMethods: DELETE (1%), GET (50%), POST (22%), PUT (25%).\r\n\r\nTop 10 most requested actions========================================================================/overview/:date/ : 19359 requests/overview/day/:date/ : 6365 requests/overview/:date/set/ : 5589 requests/overview/ : 3985 requests/clients/:id/ : 1976 requests........\r\n\r\nTop 10 actions by time - cumulative========================================================================/overview/:date/ : 9044.582s [19359 requests]/overview/ : 8478.767s [3985 requests]/overview/:date/set/ : 3309.041s [5589 requests]/clients/:id/products/:id/ : 1479.911s [924 requests]/clients/:id/ : 750.080s [1976 requests]........\r\n\r\nTop 10 actions by time - per request mean========================================================================/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]/clients/:id/ : 0.380s [1976 requests]........\r\n\r\nTop 10 worst DB offenders - cumulative time========================================================================/overview/:date/ : 8773.993s [19359 requests]/overview/ : 8394.754s [3985 requests]/overview/:date/set/ : 3307.928s [5589 requests]/clients/:id/products/:id/ : 1425.220s [924 requests]/clients/:id/ : 535.229s [1976 requests]........\r\n\r\nTop 10 worst DB offenders - mean time========================================================================/overview/:id/:id/:id/print/ : 6.994s [448 requests]/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]........\r\n\r\nMongrel process blockers (> 1.0 seconds)========================================================================/overview/:date/ : 7494.233s [3144 requests]/overview/ : 8320.293s [1549 requests]/overview/:date/set/ : 1149.235s [803 requests]/overview/:id/:id/:id/print/new/ : 613.693s [341 requests]/clients/:id/products/:id/ : 1370.693s [313 requests]........\r\n\r\nRequests graph - per hour======================================================================== ........ 7:00 - 2731 : XXXXXXX 8:00 - 6139 : XXXXXXXXXXXXXXXX 9:00 - 7465 : XXXXXXXXXXXXXXXXXXXX 10:00 - 7118 : XXXXXXXXXXXXXXXXXXX 11:00 - 7409 : XXXXXXXXXXXXXXXXXXX 12:00 - 6450 : XXXXXXXXXXXXXXXXX 13:00 - 5377 : XXXXXXXXXXXXXX 14:00 - 6058 : XXXXXXXXXXXXXXXX 15:00 - 4156 : XXXXXXXXXXX 16:00 - 2767 : XXXXXXX 17:00 - 1598 : XXXX 18:00 - 792 : XX ........\r\n\r\nErrors========================================================================ArgumentError: [237 requests] -> invalid dateStaleObjectError: [28 requests] -> Attempted to update a stale objectRuntimeError: [3 requests] -> Cannot destroy rule before it was createdStatementError: [2 requests] -> Mysql::Error: Deadlock found when trying to get lock; try restarting transactionNoMethodError: [1 requests] -> undefined method `code' for nil:NilClass```", "created_at"=>2008-10-13 08:45:11 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
生产环境下,需要对环境持续监控以尽快的发现问题,找到耗费资源较多的地方加以改进,比较常见的做法是使用moint或者God实时监控;另外,还可以定期分析日志找到特定的请求,虽然可以是shell来做这件事,但是何必再造轮子呢,因为我们已经有了Request log analyzer : \n``简介:This is a simple command line tool to analyze request log files of both Rails andMerb. Its purpose is to find what actions are best candidates for optimization.This tool will parse all requests in the logfile and aggregate theinformation. Once it is finished parsing the log file, it will show therequests that take op most server time. Different metrics are used (cumulativetime, average time, blockers, DB time, etc)
\n\n
安装:gem sources -a http://gems.github.comsudo gem install wvanbergen-request-log-analyzer
\n\n
使用:Usage: request-log-analyzer [FILE] [OPTION]Analyze the given log FILE with the given OPTIONExample: request-log-analyzer mongrel.log
\n\n
--fast, -t: Only use completed requests --guess-database-time, -g: Guesses the database duration of requests if they are not in the log --output, -o: Comma-separated list of reports to show --amount, -c: Displays the top <amount> elements in the reports --colorize, -z: Fancy bash coloring
\n\n
示例:Note that this example was shortened for your viewing pleasure.$ request-log-analyzer /var/log/my_app.log
\n\n
Request log analyzer, by Willem van Bergen and Bart ten Brinke
\n\n
Processing all log lines...========================================================================Successfully analyzed 58908 requests from log file
\n\n
Timestamp first request: 2008-07-13T06:25:58+00:00Timestamp last request: 2008-07-20T06:18:53+00:00Total time analyzed: 7 daysMethods: DELETE (1%), GET (50%), POST (22%), PUT (25%).
\n\n
Top 10 most requested actions========================================================================/overview/:date/ : 19359 requests/overview/day/:date/ : 6365 requests/overview/:date/set/ : 5589 requests/overview/ : 3985 requests/clients/:id/ : 1976 requests........
\n\n
Top 10 actions by time - cumulative========================================================================/overview/:date/ : 9044.582s [19359 requests]/overview/ : 8478.767s [3985 requests]/overview/:date/set/ : 3309.041s [5589 requests]/clients/:id/products/:id/ : 1479.911s [924 requests]/clients/:id/ : 750.080s [1976 requests]........
\n\n
Top 10 actions by time - per request mean========================================================================/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]/clients/:id/ : 0.380s [1976 requests]........
Errors========================================================================ArgumentError: [237 requests] -> invalid dateStaleObjectError: [28 requests] -> Attempted to update a stale objectRuntimeError: [3 requests] -> Cannot destroy rule before it was createdStatementError: [2 requests] -> Mysql::Error: Deadlock found when trying to get lock; try restarting transactionNoMethodError: [1 requests] -> undefined method code' for nil:NilClass``
Nginx有个Log Rotation模块,nginx will re-open it's logs in response to the USR1 signal.参考如下脚本: \n`$ mv access.log access.log.0$ kill -USR1cat master.nginx.pid`$ sleep 1$ gzip access.log.0 # do something with access.log.0
\r\n``2、Hpricot```Pros: Cool name, created by _why, faster than REXML, also does HTML, creative APICons: Not as fast as libxml-ruby, more of an HTML parser linguistically (ie: uses innerHTML instead of text or content, etc.)```\r\n
\r\n
Ruby代码
\r\n\r\n\t
%w[benchmark pp rubygems].each { |x| require x }
\r\n\t
gem 'hpricot', '>= 0.6'
\r\n\t
require 'hpricot'
\r\n\t
\r\n\t
##################################
\r\n\t
# Parsing Delicious API Response #
\r\n\t
##################################
\r\n\t
xml = File.read('posts.xml')
\r\n\t
puts Benchmark.measure {
\r\n\t
doc, posts = Hpricot::XML(xml), []
\r\n\t
(doc/:post).eachdo |p|
\r\n\t
posts << p.attributes
\r\n\t
end
\r\n\t
# pp posts
\r\n\t
}
\r\n\t
\r\n\t
################################
\r\n\t
# Parsing Twitter API Response #
\r\n\t
################################
\r\n\t
xml = File.read('timeline.xml')
\r\n\t
puts Benchmark.measure {
\r\n\t
doc, statuses = Hpricot::XML(xml), []
\r\n\t
(doc/:status).eachdo |s|
\r\n\t
h = {:user => {}}
\r\n\t
%w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].eachdo |a|
\r\n\t
h[a.intern] = s.at(a).innerHTML
\r\n\t
end
\r\n\t
%w[id name screen_name location description profile_image_url url protected followers_count].eachdo |a|
\r\n\t
h[:user][a.intern] = s.at('user').at(a).innerHTML
\r\n\t
end
\r\n\t
statuses << h
\r\n\t
end
\r\n\t
# pp statuses
\r\n\t
}
\r\n\r\n
\r\n3、libxml-ruby \r\n\r\nPros: Blistering fast\r\nCons: Hpricot has cooler name, REXML and Hpricot both feel easier to use out of the box\r\n
Ruby可以很方便的解析XML格式的文档,目前用的比较多的lib主要有三个,分别是:REXML, Hpricot, libxml-ruby,如下选取两个XML文档,分别使用这三个lib解析,感受下各自的速度和易用性。 \n一、原料 \n \n posts.xml – Uses xml element for object (post) and xml attributes for object attributes \n timeline.xml – Uses xml element for object (status) and child xml elements for attributes \n \n二、解析过程 \n1、REXML
\n\n
Pros: In the standard library \nCons: Slow, I don’t like the name \n \nRuby代码 \n \n %w[benchmark pp rexml/document].each { |x| require x } \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n doc, posts = REXML::Document.new(xml), [] \n doc.elements.each('posts/post') do |p| \n posts << p.attributes \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n doc, statuses = REXML::Document.new(xml), [] \n doc.elements.each('statuses/status') do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.elements[a].text \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.elements['user'].elements[a].text \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n<code class="ruby"><strong>2、Hpricot</strong><strong>Pros:</strong> Cool name, created by _why, faster than <span class="caps">REXML</span>, also does <span class="caps">HTML</span>, creative <span class="caps">API</span><strong>Cons:</strong> Not as fast as libxml-ruby, more of an <span class="caps">HTML</span> parser linguistically (ie: uses innerHTML instead of text or content, etc.)`` \n \nRuby代码 \n \n %w[benchmark pp rubygems].each { |x| require x } \n gem 'hpricot', '>= 0.6' \n require 'hpricot' \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n doc, posts = Hpricot::XML(xml), [] \n (doc/:post).each do |p| \n posts << p.attributes \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n doc, statuses = Hpricot::XML(xml), [] \n (doc/:status).each do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.at(a).innerHTML \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.at('user').at(a).innerHTML \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n3、libxml-ruby
\n\n
Pros: Blistering fast \nCons: Hpricot has cooler name, REXML and Hpricot both feel easier to use out of the box \n \nRuby代码 \n \n %w[benchmark pp rubygems].each { |x| require x } \n gem 'libxml-ruby', '>= 0.8.3' \n require 'xml' \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n parser, parser.string = XML::Parser.new, xml \n doc, posts = parser.parse, [] \n doc.find('//posts/post').each do |p| \n posts << p.attributes.inject({}) { |h, a| h[a.name] = a.value; h } \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n parser, parser.string = XML::Parser.new, xml \n doc, statuses = parser.parse, [] \n doc.find('//statuses/status').each do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.find(a).first.content \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.find('user').first.find(a).first.content \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n<code class="ruby"><strong>三、结论</strong> \n<div class="codeText"> \n<div class="codeHead">结果如下:</div> \n<ol class="dp-xml" start="1"> \n <li class="alt"><span><span>=rexml </span></span></li> \n <li><span>delicious 0.020000 0.000000 0.020000 ( 0.021139) </span></li> \n <li class="alt"><span>twitter 0.940000 0.020000 0.960000 ( 0.988666) </span></li> \n <li><span> </span></li> \n <li class="alt"><span>=hpricot </span></li> \n <li><span>delicious 0.010000 0.000000 0.010000 ( 0.005548) </span></li> \n <li class="alt"><span>twitter 0.250000 0.010000 0.260000 ( 0.258320) </span></li> \n <li><span> </span></li> \n <li class="alt"><span>=libxml-ruby </span></li> \n <li><span>delicious 0.000000 0.000000 0.000000 ( 0.007829) </span></li> \n <li class="alt"><span>twitter 0.030000 0.010000 0.040000 ( 0.034040) </span></li> \n</ol> \n</div> \n``<code class="ruby">参考文档:http://railstips.org/2008/8/12/parsing-xml-with-ruby``
\n", "_id"=>26}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Tips"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["oauth"], "comments_count"=>0, "category_id"=>4, "title"=>"初识oauth: 为API访问授权提供一个开放的标准", "body"=>"最近在准备一些API设计开发工作,初步了解了下oauth,OAuth是由Blaine Cook、Chris Messina、Larry Halff 及David Recordon共同发起的,目的在于为API访问授权提供一个开放的标准。\r\noauth目前看来进展比较顺利,可以看到其有主流语言的lib(Java、C#、Objective-C、Perl、PHP及Ruby语言),目前支持oauth的API有twitter,douban等应用。\r\n\r\nOAuth is the great new standard allowing your users to use your application to talk to their accounts on other applications. I won’t go more into it here as it’s pretty well covered on the OAuth site.\r\n\r\nOAuth’s Goal\r\nWebsite X can access your protected data at API Y\r\n
\r\n\t
All without sharing your password off-site
\r\n\t
especially when there isn’t one like with OpenID
\r\n
\r\n其基本流程为:\r\n\r\n\t
Register your consumer application with the OAuth compliant service to receive your Consumer Credentials (This is only done once)
\r\n\t
You initiate the OAuth Token exchange process for a user by requesting a RequestToken from the Service
\r\n\t
You store the RequestToken in your database or in the users session object
\r\n\t
You redirect your user to the service providers authorize_url with the RequestToken’s key appended
\r\n\t
Your user is asked by the service provider to authorize your RequestToken
\r\n\t
Your user clicks yes and is redirected to your CallBack URL
OAuth is the great new standard allowing your users to use your application to talk to their accounts on other applications. I won’t go more into it here as it’s pretty well covered on the OAuth site. \n \nOAuth’s Goal \nWebsite X can access your protected data at API Y \n \n All without sharing your password off-site \n especially when there isn’t one like with OpenID \n \n其基本流程为: \n \n Register your consumer application with the OAuth compliant service to receive your Consumer Credentials (This is only done once) \n You initiate the OAuth Token exchange process for a user by requesting a RequestToken from the Service \n You store the RequestToken in your database or in the users session object \n You redirect your user to the service providers authorize_url with the RequestToken’s key appended \n Your user is asked by the service provider to authorize your RequestToken \n Your user clicks yes and is redirected to your CallBack URL \n Your callback action exchanges the RequestToken for an AccessToken \n Now you can access your users data by performing http requests signed by your consumer credentials and the AccessToken. \n ???? \n PROFIT!!! \n \n如果你想了解,请参考如下文档,如果你有经验,请分享,谢谢! \n \n参考文档: \n \n Developing OAuth clients in Ruby \n How to turn your rails site into an OAuth Provider \n OAuth不断获得动力 \n Rails plugin for OAuth \n OAuth implementation for Ruby \n 豆瓣 API 认证授权说明 \n The How of OAuth --这个PPT挺不错 \n
\n", "_id"=>34}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Ruby&Rails", "to_xml"], "comments_count"=>0, "category_id"=>11, "title"=>"Rails: Disabling XML character escaping for to_xml & xml builder", "body"=>"
In my case, I had to genarate the xml view for api render,but in rails, i got a &XXX format string for non englisg, it also appears to_xml will automatically escape any entities into their corresponding &XXX representation. There's a piece in the documentation that says "If $KCODE is set to u and encoding set to UTF8, then escaping will NOT be performed." \n \nUnfortunately, this doesn't appear to be the case. Even after following the docs and ensuring that default_charset is indeed UTF-8 (actually the default for Rails nowadays), we still get encoded characters in to_xml output. \n \nSince our client is UTF-8 aware, we need to pass thru the UTF-8 data intact. The only way we've found to do this is thru the following horrible monkey-patch:
\n
\n
Ruby代码
\n\n
module Builder
\n
class XmlBase
\n
def _escape(text)
\n
text
\n
end
\n
end
\n
end
\n\n
\n
\nWhat's the proper way to do this? \n \nPS: \nsomebody say that to "set $KCODE='UTF8' in config/environment.rb can solve this issue." but it's not for me. \n \nmore infos: \nhttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2c13ad7c0f8c0781
In my case, I had to genarate the xml view for api render,but in rails, i got a &XXX format string for non englisg, it also appears to_xml will automatically escape any entities into their corresponding &XXX representation. There's a piece in the documentation that says "If $KCODE is set to u and encoding set to UTF8, then escaping will NOT be performed." \n \nUnfortunately, this doesn't appear to be the case. Even after following the docs and ensuring that default_charset is indeed UTF-8 (actually the default for Rails nowadays), we still get encoded characters in to_xml output. \n \nSince our client is UTF-8 aware, we need to pass thru the UTF-8 data intact. The only way we've found to do this is thru the following horrible monkey-patch: \n \nRuby代码 \n \n module Builder \n class XmlBase \n def _escape(text) \n text \n end \n end \n end \n \n \n \nWhat's the proper way to do this? \n \nPS: \nsomebody say that to "set $KCODE='UTF8' in config/environment.rb can solve this issue." but it's not for me. \n \nmore infos: \nhttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2c13ad7c0f8c0781 \n
\n", "_id"=>35}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["random", "ruby"], "comments_count"=>0, "category_id"=>11, "title"=>"Generate a random string", "body"=>"Generates a random string of lowercase letters. Great for email verification codes or user password salt....\n
Some tips for mount&umount ,maybe give you some help..
\n
cdrom: \n# mount -t is09660 /dev/cdrom /mnt/cdrom \n# umount /mnt/cdrom \n \nfloppy: \n# mount /dev/fd0 /mnt/floppy \n#umount /mnt/floppy \n \nusb: \n1.use 'fdisk -l' to show the usb nums,something like '/dev/sda'; \n2.then use 'mkdir /mnt/usb' to create a dir for mount this usb; \n3.at last,use '# mount -t msdos /dev/sda1 /mnt/usb" to mount it. \n4.#umount /mnt/usb \n \nhda: \n1.use 'fdisk -l' to show the disk nums,like '/dev/hda1'; \n2.then use 'make /mnt/vfat' to create a mount point; \n3.at last,use '# mount -t vfat /dev/hda1 /mnt/vfat'to mount it.. \n4.#umount /mnt/vfat
Some tips for mount&umount ,maybe give you some help.. \ncdrom:
\n\n
mount -t is09660 /dev/cdrom /mnt/cdrom
\n\n
umount /mnt/cdrom
\n\n
floppy:
\n\n
mount /dev/fd0 /mnt/floppy
\n\n
umount /mnt/floppy
\n\n
usb: \n1.use 'fdisk -l' to show the usb nums,something like '/dev/sda'; \n2.then use 'mkdir /mnt/usb' to create a dir for mount this usb; \n3.at last,use '# mount -t msdos /dev/sda1 /mnt/usb" to mount it. \n4.#umount /mnt/usb \n \nhda: \n1.use 'fdisk -l' to show the disk nums,like '/dev/hda1'; \n2.then use 'make /mnt/vfat' to create a mount point; \n3.at last,use '# mount -t vfat /dev/hda1 /mnt/vfat'to mount it.. \n4.#umount /mnt/vfat \nand some usefull resource links and docs here: \nhttp://unix-cd.com/unixcd12/article_3967.html \nhttp://blog.oracle.com.cn/index.php/121320/viewspace-6733.html
In my case, I need do send big files to users, yes, you can do it with nginx,just like others static files,but i need some control for the request action,The delivery of a static file which depends on an application header is known as the X-Sendfile feature. \nLighttpd has this feature and there is a mod_xsendfile for Apache2. \nNginx also has this feature, but implemented a little bit differently. In Nginx this feature is called X-Accel-Redirect. \nThere are two main differences:
\n\n
The header must contain a URI
\n
The location should be defined as internal; to prevent the client going directly to the URI
\n\n
\n
\n
Ruby代码
\n\n
location /files {
\n
root /var/www;
\n
internal;
\n
}
\n\n
\n
\n
Ruby代码
\n\n
// Get requested file name
\n
path = @params["path"]
\n
\n
# ...
\n
# Perform any required security checks, validation
In my case, I need do send big files to users, yes, you can do it with nginx,just like others static files,but i need some control for the request action,The delivery of a static file which depends on an application header is known as the X-Sendfile feature. \nLighttpd has this feature and there is a mod_xsendfile for Apache2. \nNginx also has this feature, but implemented a little bit differently. In Nginx this feature is called X-Accel-Redirect. \nThere are two main differences: \n \n The header must contain a URI \n The location should be defined as internal; to prevent the client going directly to the URI \n \n \n \nRuby代码 \n \n location /files { \n root /var/www; \n internal; \n } \n \n \n \nRuby代码 \n \n // Get requested file name \n path = @params["path"] \n \n # ... \n # Perform any required security checks, validation \n # and/or stats accounting \n # ... \n \n # And redirect user to internal location \n response.headers['X-Accel-Redirect'] = "/files/" + path \n \n \n \nsome userfull link resource come here: \n \n http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/ \n http://wiki.codemongers.com/NginxXSendfile \n http://www.motionstandingstill.com/using-nginx-to-send-files-with-x-accel-redirect/2008-09-03/ \n \n
I store user sessions in memcache,and then i want do share theres sessions with sub domains,but i notice some strange things when i put session into memcached,there are: \n1. In my older website(rails 2.0),It genenrated sessions key for memcached as \#{namespace}-\#{RAILS_ENV}:"session:\#{id}"; \n2.In my newer website(reails 2.3),It generated seesions key for memcached just as "\#{namespace}:\#{id}"; \n \nso,i can not get the same seesion datas with diff session keys. i do have spend lots of time for sove this , i do have some userfull dis, \n \n1. In rails2.3 ,it's vendor memcache-client-1.5.0.5 in ruby\\lib\\ruby\\gems\\1.8\\gems\\activesupport-2.3.0\\lib\\active_support\\vendor; \n2. you can config namespace in you environment.rb file like " ActionController::Base.session_options[:namespace] = 'session'" \n3. In rails2.0,when you use memcached,you will use cached_fu and act_as_cache plugins,and you may have a config file in your config dir named memcached.yml, and in this file,you can config defaults,production,test and developer..with lots of filed,like namespace,servers etc.. \n4. you will notice it generate memcached key as mentioned above. \n \nI track it,and got this:
I store user sessions in memcache,and then i want do share theres sessions with sub domains,but i notice some strange things when i put session into memcached,there are: \n1. In my older website(rails 2.0),It genenrated sessions key for memcached as \#{namespace}-\#{RAILS_ENV}:"session:\#{id}"; \n2.In my newer website(reails 2.3),It generated seesions key for memcached just as "\#{namespace}:\#{id}"; \n \nso,i can not get the same seesion datas with diff session keys. i do have spend lots of time for sove this , i do have some userfull dis, \n \n1. In rails2.3 ,it's vendor memcache-client-1.5.0.5 in ruby\\lib\\ruby\\gems\\1.8\\gems\\activesupport-2.3.0\\lib\\active_support\\vendor; \n2. you can config namespace in you environment.rb file like " ActionController::Base.session_options[:namespace] = 'session'" \n3. In rails2.0,when you use memcached,you will use cached_fu and act_as_cache plugins,and you may have a config file in your config dir named memcached.yml, and in this file,you can config defaults,production,test and developer..with lots of filed,like namespace,servers etc.. \n4. you will notice it generate memcached key as mentioned above. \n \nI track it,and got this: \n \nRuby代码 \n \n def setup_memcache(config) \n config[:namespace] << "-\#{RAILS_ENV}" \n \n silence_warnings do \n Object.const_set :CACHE, memcache_klass.new(config) \n end \n \n CACHE.servers = Array(config.delete(:servers)) \n \n setup_session_store if config[:sessions] \n setup_fragment_store! if config[:fragments] \n setup_fast_hash! if config[:fast_hash] \n setup_fastest_hash! if config[:fastest_hash] \n \n CACHE \n end \n \n \nshit,it append RAILS_ENV to namespace with "-",that's it...I hate some hardcode config in plugin,blalal.... \nsome userfull link resources... \n \n http://errtheblog.com/posts/22-sessions-n-such \n http://www.raecoo.com/2008/10/25/rails-store-format-in-memcache/ \n http://www.scribd.com/doc/2203398/Scaling-Rails-with-memcached \n http://railscasts.com/episodes/115-caching-in-rails-2-1
In some case,you may want do get Uniquely Identifying for a 'real' android phone,and you can do it like this:
\n
In Android.Provider.Settings.System we have some interesting values that could be of use, one specifically is “Android_ID”. From the documentation it is the following;
\n
\n
String \tANDROID_ID \tThe Android ID (a unique 64-bit value) as a hex string. \t“android_id”
\nAlso, note that in an emulator this will return “null”, though a real device will return an actual value. The nice thing about this tid-bit of code is that you are not required any special permissions to call it, since it’s essentially a passive call to get information. No write access is (obviously) required.\n
Garry Tan, cofounder of Posterous, lists 12 lessons for scaling that apply to more than just Rails,and i mark some word below. \n \nUse cloud storage for static files. --S3,I do not care it 's fine in china. \nUse HTTP Cache Control to tell the browser what it can cache. --this is true,etag is great. \nUse Sphinx for text search. --sometimes,you do have others chose. \nUse InnoDB for more crash resistant and faster writes. --maybe it's right. \nDon't use textbook Rails ActiveRecord objects. Use New Relic to find exactly what is slow in your system. --yep \nUse memcache later so you find your database bottlenecks now. --this is very important. \nUse mongrel proctitle to find your slow queries. You are only as fast as your slowest queries. -maybe mongrel is not only chose,think about thin,ok? \nUse asynchronous job queuing to do work in parallel. --yes,but sometimes crontab is enough. \nUse monitoring so you'll know when your site went down and why. --that's it,just do it. \nLearn by reading the source code, fixing problems, and submitting them back to the community. --very userfull when you got some strange questions.. \nUse new plugins. Old plugins can't be trusted. --and check chang histroy carefully. \nUse new information. Old information can't be trusted. --and what's this? \n \ngo to http://axonflux.com/building-and-scaling-a-startup for more infos.
When it asks for driver location choose the unzipped folderand install the driver for it.
\n
You'll see sth like "HTC Dream Composite ADB Interface" on success
\n
(Re)Start Eclipse
\n
Your G1 should now be listed in the DDMS-Perspective under Devices
\n
Go to the AndroidManifest.xml of your App and modify it to containandroid:debuggable="true"in the <application ... >-Tag,look like this:<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
\n
Go Debug as usual. \n
\n\nps: I do not upload the zip file here,you can find it via the link above,but if you can not download it,you can mail me to fetch one.
I konw,you can dev app and test it on the simulator,but if you had a real driver,G1,you can do debug on it,very great,here is the tips for this: \n \n On your G1, go to Settings Applications Development [X] USB debugging \n Download this file: android_usb_windows.zip \n Unzip it to a folder \n Connect your G1 with your PC \n When it asks for driver location choose the unzipped folder and install the driver for it. \n You'll see sth like "HTC Dream Composite ADB Interface" on success \n (Re)Start Eclipse \n Your G1 should now be listed in the DDMS-Perspective under Devices \n Go to the AndroidManifest.xml of your App and modify it to contain android:debuggable="true" in the <application ... >-Tag ,look like this:<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> \n Go Debug as usual. \n \n \nps: I do not upload the zip file here,you can find it via the link above,but if you can not download it,you can mail me to fetch one. \nBtw: \nYou can now install (signed)APKs via USB: \nD:\\dev\\Android\\android-sdk-windows-1.0_r1\\tools>adb -d install D:\\Workspace\\keytools\\AndNav_signed.apk \n1305 KB/s (1975987 bytes in 1.478s) \npkg: /data/local/tmp/AndNav_signed.apk \nSuccess \n \n \nAnd uninstall them: \nD:\\dev\\Android\\android-sdk-windows-1.0_r1\\tools>adb uninstall org.andnav \nSuccess \n \n
In some case,you may want do get Uniquely Identifying for a 'real' android phone,such as IMEI code,SimOperator etc, and we all kown ,the IMEI like ID card,and you can use TelephonyManager to get it,some usefull codes like this :
Apr 1 01:47:49 garden kernel: Linux version 2.6.18-92.1.17.el5 (mockbuild@builder10.centos.org) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)) #1 SMP Tue Nov 4 13:43:30 EST 2008
\n
\n \nlooks like something wrong about "ip_conntrack",and i do some check like this: \n\n
Installing ri documentation for fastercsv-1.4.0...
\n
Installing RDoc documentation for fastercsv-1.4.0...
\n
iceskysl ~/webroot: cd ..
\n\n
\nand do not forget to add "require 'fastercsv'" in your class file.", "created_at"=>2009-04-22 17:12:15 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
some tips is here. \n \nRuby代码 \n \n def self.imp_init_owner_data \n fp = "\#{RAILS_ROOT}/datas/inumbers/ini_owner.csv" \n FasterCSV.open(fp, "w") do |csv| \n InumberCate.find_all_by_typee("owner").each do |owner| \n csv << [owner.name,owner.id] \n end \n end \n end \n \n \ninstall fastercsv gems like this.. \n \n \n \nRuby代码 \n \n iceskysl ~/webroot: gem install fastercsv \n Successfully installed fastercsv-1.4.0 \n 1 gem installed \n Installing ri documentation for fastercsv-1.4.0... \n Installing RDoc documentation for fastercsv-1.4.0... \n iceskysl ~/webroot: cd .. \n \n \nand do not forget to add "require 'fastercsv'" in your class file.
you can use apt-spy to update sources.list ,here is some step and tips. \n1.open /etc/apt/sources.list and add this \ndeb http://http.us.debian.org/debian/ stable main \n2.do "apt-get update" \n3.then "apt-get install apt-spy" \n4.then "apt-spy update" \n5.last,"apt-spy -d unstable -a asia -t 5" \n \nref: \nhttp://http.us.debian.org/debian/README.mirrors.txt
you can use apt-spy to update sources.list ,here is some step and tips. \n1.open /etc/apt/sources.list and add this \ndeb http://http.us.debian.org/debian/ stable main \n2.do "apt-get update" \n3.then "apt-get install apt-spy" \n4.then "apt-spy update" \n5.last,"apt-spy -d unstable -a asia -t 5" \n \nref: \nhttp://http.us.debian.org/debian/README.mirrors.txt
\n", "_id"=>50}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["iowait"], "comments_count"=>0, "category_id"=>11, "title"=>"How can I find out what is generating iowait on my server?", "body"=>"
A question I’m asked daily is “How can I find out what is generating iowait on my server?” Sure, you can dig through pages of lsof output, restart services, or run strace, but it can be a frustrating process. I saw a process on this blog post, and a guy changed the regexes to fit Red Hat and CentOS systems a bit better: \n
A question I’m asked daily is “How can I find out what is generating iowait on my server?” Sure, you can dig through pages of lsof output, restart services, or run strace, but it can be a frustrating process. I saw a process on this blog post, and a guy changed the regexes to fit Red Hat and CentOS systems a bit better: \n \nRuby代码 \n \n [root@5-3 ~]# /etc/init.d/syslog stop \n Shutting down kernel logger: [ OK ] \n Shutting down system logger: [ OK ] \n [root@5-3 ~]# echo 1 > /proc/sys/vm/block_dump \n [root@5-3 ~]# dmesg | egrep "READ|WRITE|dirtied" | egrep -o '([a-zA-Z]*)' | sort | uniq -c | sort -rn | head \n 202 kjournald \n 16 egrep \n 9 irqbalance \n 9 bash \n 2 java \n 1 sda \n 1 mailserver \n [root@5-3 ~]# echo 0 > /proc/sys/vm/block_dump \n [root@5-3 ~]# /etc/init.d/syslog start \n Starting system logger: [ OK ] \n Starting kernel logger: [ OK ] \n \n \nIn my specific situation, it looks like kjournald is the biggest abuser of my disk. \nDon’t forget to set things back to their normal state when you’re done! \n \nXML/HTML代码 \n \n # echo 0 > /proc/sys/vm/block_dump \n # /etc/init.d/syslog start \n \n \n \n \nref: \nhttp://rackerhacker.com/2008/03/11/hunting-down-elusive-sources-of-iowait/ \nhttp://blog.eikke.com/index.php/ikke/2007/03/22/who_s_abusing_my_sata_controller \nhttp://hi.baidu.com/dipsey/blog/item/900bbbaf3e46dcc97cd92aba.html \nhttp://www.ducea.com/2009/03/11/howto-install-iotop-on-debian-etch/ \n \nhttp://www.cppblog.com/go-benny/archive/2008/04/23/47908.html \n
--attach PID Quit god when the attached process dies
\n
--no-events Disable the event system
\n
--bleakhouse Enable bleakhouse profiling
\n
[iceskysl@ws_api]#
\n\n
\n1.DYNAMICALLY LOADING CONFIG FILES INTO AN ALREADY RUNNING GOD\n
\n
God allows you to load or reload configurations into an already running instance. There are a few things to consider when doing this:
\n
\n
Existng Watches with the samename```as the incoming Watches will be overidden by the new config.
\n
All paths must be either absolute or relative to the path from which god was started.
\n
\n
To load a config into a running god, issue the following command:
\n
$ sudo god load path/to/config.god # god load /data/www/api/config/config_thin_api.god```\n
Config files that are loaded dynamically can contain anything that a normal config file contains, however, global options such asGod.pid_file_directory```blocks will be ignored (and produce a warning in the logs).
\n
\n
2.show logs
\n
\n
\n
XML/HTML代码
\n\n
[iceskysl@ws_api]# god log thin-thin-7514
\n
I, [2009-04-28T08:24:16.705870 #23174] INFO -- : thin-thin-7514 moved 'up' to 'up'
\n
I, [2009-04-28T08:24:16.706346 #23174] INFO -- : thin-thin-7514 [trigger] process is not running (ProcessRunning)
\n
I, [2009-04-28T08:24:16.888477 #23174] INFO -- : thin-thin-7514 sent email to iceskysl@gmail.com (Email)
\n
I, [2009-04-28T08:24:16.888642 #23174] INFO -- : thin-thin-7514 move 'up' to 'start'
\n
I, [2009-04-28T08:24:16.888976 #23174] INFO -- : thin-thin-7514 before_start: no pid file to delete (CleanPidFile)
\n
I, [2009-04-28T08:24:16.889109 #23174] INFO -- : thin-thin-7514 start: thin start -C /data/www/web/current/config/thin.yml -o 7514
some days before,i posted a article 《God: 比Monit更好用的monitoring》,today,i will post more useful tips for God. \n \n \nRuby代码 \n \n [iceskysl@ws_api]# god --help \n Usage: \n Starting: \n god [-c <config file>] [-p <port> | -b] [-P <file>] [-l <file>] [-D] \n \n Querying: \n god <command> <argument> [-p <port>] \n god <command> [-p <port>] \n god -v \n god -V (must be run as root to be accurate on Linux) \n \n Commands: \n start <task or group name> start task or group \n restart <task or group name> restart task or group \n stop <task or group name> stop task or group \n monitor <task or group name> monitor task or group \n unmonitor <task or group name> unmonitor task or group \n remove <task or group name> remove task or group from god \n load <file> load a config into a running god \n log <task name> show realtime log for given task \n status show status of each task \n quit stop god \n terminate stop god and all tasks \n check run self diagnostic \n \n Options: \n -c, --config-file CONFIG Configuration file \n -p, --port PORT Communications port (default 17165) \n -b, --auto-bind Auto-bind to an unused port number \n -P, --pid FILE Where to write the PID file \n -l, --log FILE Where to write the log file \n -D, --no-daemonize Don't daemonize \n -v, --version Print the version number and exit \n -V Print extended version and build information \n --log-level LEVEL Log level [debug|info|warn|error|fatal] \n --no-syslog Disable output to syslog \n --attach PID Quit god when the attached process dies \n --no-events Disable the event system \n --bleakhouse Enable bleakhouse profiling \n [iceskysl@ws_api]# \n \n \n1.DYNAMICALLY LOADING CONFIG FILES INTO AN ALREADY RUNNING GOD \n \nGod allows you to load or reload configurations into an already running instance. There are a few things to consider when doing this: \n \n Existng Watches with the same name<span class="Apple-converted-space"> </span>as the incoming Watches will be overidden by the new config.</li> \n <li style="margin: 0px; font-size: 13px;">All paths must be either absolute or relative to the path from which god was started.</li> \n</ul> \n<p style="margin: 0px 0px 1em; font-size: 13px;">To load a config into a running god, issue the following command:</p> \n<pre style="border: 1px solid rgb(204, 204, 204); margin: 1em 0px; padding: 1em; font-size: 10px; line-height: 1.3; background-color: rgb(239, 239, 239);">$ sudo god load path/to/config.god<br /># god load /data/www/api/config/config_thin_api.god \nConfig files that are loaded dynamically can contain anything that a normal config file contains, however, global options such as God.pid_file_directory``` blocks will be ignored (and produce a warning in the logs). \n \n2.show logs \n \n \nXML/HTML代码 \n \n [iceskysl@ws_api]# god log thin-thin-7514 \n I, [2009-04-28T08:24:16.705870 #23174] INFO -- : thin-thin-7514 moved 'up' to 'up' \n I, [2009-04-28T08:24:16.706346 #23174] INFO -- : thin-thin-7514 [trigger] process is not running (ProcessRunning) \n I, [2009-04-28T08:24:16.888477 #23174] INFO -- : thin-thin-7514 sent email to iceskysl@gmail.com (Email) \n I, [2009-04-28T08:24:16.888642 #23174] INFO -- : thin-thin-7514 move 'up' to 'start' \n I, [2009-04-28T08:24:16.888976 #23174] INFO -- : thin-thin-7514 before_start: no pid file to delete (CleanPidFile) \n I, [2009-04-28T08:24:16.889109 #23174] INFO -- : thin-thin-7514 start: thin start -C /data/www/web/current/config/thin.yml -o 7514 \n \n \n \nresource links: \nhttp://god.rubyforge.org/ \n
If you have recently updated to Rails 2.2.2, you may encounter this error when you want to start your application: \n \n/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in \n`load_missing_constant': uninitialized constant Inflector (NameError) \n \nthe usage of Inflector class is changed a bit. You can see the difference when you compare the inflections.rb files. Path of the file is yourApp/config/initializers/inflections.rb \n \n
\n
inflections.rb (Rails 2.1.0)
\n\n
\n
\n
Inflector.inflections do |inflect|
\n
.
\n
.
\n
.
\n
end
\n\n
\n \n
\n
inflections.rb (Rails 2.2.2)
\n\n
ActiveSupport::Inflector.inflections do |inflect|
\n
.
\n
.
\n
.
\n
end
\n\n
\nthe situation changing Inflector to ActiveSupport::Inflector was enough to solve the problem.", "created_at"=>2009-05-05 13:37:01 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
If you have recently updated to Rails 2.2.2, you may encounter this error when you want to start your application: \n \n/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in \n`load_missing_constant': uninitialized constant Inflector (NameError) \n \nthe usage of Inflector class is changed a bit. You can see the difference when you compare the inflections.rb files. Path of the file is yourApp/config/initializers/inflections.rb \n \n \ninflections.rb (Rails 2.1.0) \n \n \n \n Inflector.inflections do |inflect| \n . \n . \n . \n end \n \n \n \n \ninflections.rb (Rails 2.2.2) \n \n ActiveSupport::Inflector.inflections do |inflect| \n . \n . \n . \n end \n \n \nthe situation changing Inflector to ActiveSupport::Inflector was enough to solve the problem.
when i start god.sh,then give some error msg like this:
\n
\n
\n
XML/HTML代码
\n\n
I [2009-05-16 21:25:41] INFO: Using pid file directory: /var/run/god
\n
/usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `initialize': Address family not supported by protocol - socket(2) (Errno::EAFNOSUPPORT)
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `open'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `open_server_inaddr_any'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:863:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:759:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in `each'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1340:in `initialize'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in `new'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in `start_service'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:78:in `start'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:43:in `initialize'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in `new'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in `start'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:633:in `at_exit'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:666
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/cli/run.rb:87
\n\n
\nok,then i find some userful messsage,like here:\n
Errno::EAFNOSUPPORT - the specifiedsockaddrisnot a valid address for the family of the callingsocket
\n
and here, i notice where is the problen,the god find hostname,name map it to ip address,then create some sockets on the ip,and the error point is here,so i nano my /etc/hosts file,and add map for hostname and 127.0.0.1,that's it! \n
when i start god.sh,then give some error msg like this: \n \n \nXML/HTML代码 \n \n I [2009-05-16 21:25:41] INFO: Using pid file directory: /var/run/god \n /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in initialize': Address family not supported by protocol - socket(2) (Errno::EAFNOSUPPORT) </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in open' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in open_server_inaddr_any' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:863:in open_server' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:759:in open_server' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in each' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in open_server' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1340:in initialize' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in new' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in start_service' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:78:in start' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:43:in initialize' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in new' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in start' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:633:in `at_exit' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:666 \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/cli/run.rb:87 \n \n \nok,then i find some userful messsage,like here: \nErrno::EAFNOSUPPORT - the specified sockaddr isnot a valid address for the family of the calling socket \nand here, i notice where is the problen,the god find hostname,name map it to ip address,then create some sockets on the ip,and the error point is here,so i nano my /etc/hosts file,and add map for hostname and 127.0.0.1,that's it!
\n", "_id"=>55}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["书"], "comments_count"=>0, "category_id"=>6, "title"=>"我写的书:《Google Android开发入门与实战》等即将上市.", "body"=>"这篇文章是非技术性的,所以使用中文写,免得写了大家看不懂,呵呵。\r\n\r\n写书不是第一次,出版却是第一本,至于原因,就不详述了,去年9月开始参与一些图书的翻译和撰写中,截至到目前,这段时间一共参与了三本书,按照参与的先后顺序,分别是《The Rails Way》,《Google API 编程.开发.实例》以及《Google Android开发入门与实战》。\r\n\r\n其中《The Rails Way》是做为译者参与,其他翻译者都是国内第一批Rails技术人员,分散在全国各地,还有一名译者在加拿大,我一共翻译了5章内容,分别是第2章“Working_with_Controllers”,第10章“ActionView”,第13章“Session__Session_Management”,第15章“XML_and_ActiveResource”和第16章“ActionMailer”,翻译很早前就结束了,目前好像还在审稿、校核工作,由YiTan在跟,至于何时出版,我还真不知道。\r\n\r\n《Google API 编程.开发.实例》我是从去年9月份介入,开始参与选题和策划,截至撰写相关内容,因为我自身是Google重度使用者,平时也比较多的使用和了解GoogleAPI,所以写起来得心应手,一共写了“Google Account Authentication”,“Google AJAX Language API”,“Google Chart API”,“Blogger Data API”,“Feedburner API”,“Google Code Search Data API”和“Google Book Search Book Viewability API”这些章节,前前后后也花了不少零碎的时间。其他作者大多都Google内部的同学,本书已经进入出版流程,由博文视点出版社策划出版,应该在6.5号Google开发者大会上可以看到,如下是本书第一版封面。\r\n\r\n\r\n\r\n本书特点:本书覆盖了Google绝大多数的API,其中针对每个API就其原理、用法做了详细说明,最后基本上都有实际的例子演示如何使用。\r\n\r\n《Google Android开发入门与实战》是08年11月份开始撰写的,和另外一个朋友一起,两个人陆续的差不多用了半年时间,在09年4月份差不多全部写完,后面主要是都在校核和审稿,由人民邮电出版社出版,5月底6月初即可上市,封面如下:\r\n\r\n\r\n\r\n \r\n
《Google API 编程.开发.实例》我是从去年9月份介入,开始参与选题和策划,截至撰写相关内容,因为我自身是Google重度使用者,平时也比较多的使用和了解GoogleAPI,所以写起来得心应手,一共写了“Google Account Authentication”,“Google AJAX Language API”,“Google Chart API”,“Blogger Data API”,“Feedburner API”,“Google Code Search Data API”和“Google Book Search Book Viewability API”这些章节,前前后后也花了不少零碎的时间。其他作者大多都Google内部的同学,本书已经进入出版流程,由博文视点出版社策划出版,应该在6.5号Google开发者大会上可以看到,如下是本书第一版封面。
and now,you can open a cmd shell,and input sqlite3 like this: \n
\n
C:\\Documents and Settings\\Administrator>sqlite3 \nSQLite version 3.5.9 \nEnter ".help" for instructions
\n
and some help infos is here:
\n
sqlite> .help \n.bail ON|OFF Stop after hitting an error. Default OFF \n.databases List names and files of attached databases \n.dump ?TABLE? ... Dump the database in an SQL text format \n.echo ON|OFF Turn command echo on or off \n.exit Exit this program \n.explain ON|OFF Turn output mode suitable for EXPLAIN on or off. \n.header(s) ON|OFF Turn display of headers on or off \n.help Show this message \n.import FILE TABLE Import data from FILE into TABLE \n.indices TABLE Show names of all indices on TABLE \n.load FILE ?ENTRY? Load an extension library \n.mode MODE ?TABLE? Set output mode where MODE is one of: \n csv Comma-separated values \n column Left-aligned columns. (See .width) \n html HTML <table> code \n insert SQL insert statements for TABLE \n line One value per line \n list Values delimited by .separator string \n tabs Tab-separated values \n tcl TCL list elements \n.nullvalue STRING Print STRING in place of NULL values \n.output FILENAME Send output to FILENAME \n.output stdout Send output to the screen \n.prompt MAIN CONTINUE Replace the standard prompts \n.quit Exit this program \n.read FILENAME Execute SQL in FILENAME \n.schema ?TABLE? Show the CREATE statements \n.separator STRING Change separator used by output mode and .import \n.show Show the current values for various settings \n.tables ?PATTERN? List names of tables matching a LIKE pattern \n.timeout MS Try opening locked tables for MS milliseconds \n.width NUM NUM ... Set column widths for "column" mode
Install SQLite3 for Windows by downloading the following 2 zip files and unzipping them into /WINDOWS/system32 \nhttp://www.sqlite.org/sqlite-3_6_14_1.zip \nhttp://www.sqlite.org/sqlitedll-3_6_14_1.zip \nIf those don't work try the official download site here \nand now,you can open a cmd shell,and input sqlite3 like this: \n \nC:\\Documents and Settings\\Administrator>sqlite3 \nSQLite version 3.5.9 \nEnter ".help" for instructions \nand some help infos is here: \nsqlite> .help \n.bail ON|OFF Stop after hitting an error. Default OFF \n.databases List names and files of attached databases \n.dump ?TABLE? ... Dump the database in an SQL text format \n.echo ON|OFF Turn command echo on or off \n.exit Exit this program \n.explain ON|OFF Turn output mode suitable for EXPLAIN on or off. \n.header(s) ON|OFF Turn display of headers on or off \n.help Show this message \n.import FILE TABLE Import data from FILE into TABLE \n.indices TABLE Show names of all indices on TABLE \n.load FILE ?ENTRY? Load an extension library \n.mode MODE ?TABLE? Set output mode where MODE is one of: \n csv Comma-separated values \n column Left-aligned columns. (See .width) \n html HTML <table> code \n insert SQL insert statements for TABLE \n line One value per line \n list Values delimited by .separator string \n tabs Tab-separated values \n tcl TCL list elements \n.nullvalue STRING Print STRING in place of NULL values \n.output FILENAME Send output to FILENAME \n.output stdout Send output to the screen \n.prompt MAIN CONTINUE Replace the standard prompts \n.quit Exit this program \n.read FILENAME Execute SQL in FILENAME \n.schema ?TABLE? Show the CREATE statements \n.separator STRING Change separator used by output mode and .import \n.show Show the current values for various settings \n.tables ?PATTERN? List names of tables matching a LIKE pattern \n.timeout MS Try opening locked tables for MS milliseconds \n.width NUM NUM ... Set column widths for "column" mode
add this line into /etc/lftp.conf \nset net:limit-rate 10240000,40960 \n \nthat's limit upload rate to 10M,and download to 40K \n \nsome useful resource:
\ncURL figures out which protocol to use from the URL you provide, and when \"http:\" is specified will, unless otherwise instructed (using -0), default to using HTTP 1.1. The first argument, -u, instructs cURL to use the next two parameters (separated by a colon) as the account name and password for basic authentication. The next argument, -d, specifies the data (maximum 140 characters) to be sent via a POST request.\n\nOf course what cURL expects is a response to the POST request so the result will be the requested page (update.xml) sent to stdout. This page will be encoded according to the file type used in the request, thus as we just requested update.xml we’ll get XML-formatted data. The alternatives are JSON (JavaScript Object Notation), RSS and Atom formats.\n\nfrom:\nhttp://www.networkworld.com/columnists/2008/052108-gearhead.html?page=2", "created_at"=>2009-09-27 18:26:17 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
curl -u email:passw -d status="text" http://twitter.com/statuses/update.xml \ncURL figures out which protocol to use from the URL you provide, and when "http:" is specified will, unless otherwise instructed (using -0), default to using HTTP 1.1. The first argument, -u, instructs cURL to use the next two parameters (separated by a colon) as the account name and password for basic authentication. The next argument, -d, specifies the data (maximum 140 characters) to be sent via a POST request.
\n\n
Of course what cURL expects is a response to the POST request so the result will be the requested page (update.xml) sent to stdout. This page will be encoded according to the file type used in the request, thus as we just requested update.xml we’ll get XML-formatted data. The alternatives are JSON (JavaScript Object Notation), RSS and Atom formats.
项目中使用nginx,上传一个大文件,出来错误提示,413 Request Entity Too Large! \n查了下资料,解决方法:打开nginx主配置文件nginx.conf,找到http{}段,添加
\n\n
client_max_body_size 20m;
\n\n
最好也调整下: \n keepalive_timeout 105; \n免得链接超时被关!
\n\n
该文件一般在/etc/nginx/nginx.conf
\n", "_id"=>65}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["rails", "rails-2.3.4"], "comments_count"=>0, "category_id"=>6, "title"=>"rails-2.3.4 发布了", "body"=>"Ruby on Rails 2.3.4, this release fixes bugs and introduces a few minor features. Due to the inclusion of two security fixes, all users of the 2.3 series are recommended to upgrade as soon as possible.\n\nC:\\Documents and Settings\\Administrator>gem install rails\nSuccessfully installed activesupport-2.3.4\nSuccessfully installed activerecord-2.3.4\nSuccessfully installed actionpack-2.3.4\nSuccessfully installed actionmailer-2.3.4\nSuccessfully installed activeresource-2.3.4\nSuccessfully installed rails-2.3.4\n6 gems installed\nInstalling ri documentation for activesupport-2.3.4...\nInstalling ri documentation for activerecord-2.3.4...\nInstalling ri documentation for actionpack-2.3.4...\nInstalling ri documentation for actionmailer-2.3.4...\nInstalling ri documentation for activeresource-2.3.4...\nInstalling RDoc documentation for activesupport-2.3.4...\nInstalling RDoc documentation for activerecord-2.3.4...\nInstalling RDoc documentation for actionpack-2.3.4...\nInstalling RDoc documentation for actionmailer-2.3.4...\nInstalling RDoc documentation for activeresource-2.3.4...\n\n详细信息:\n\nhttp://weblog.rubyonrails.org/2009/9/4/ruby-on-rails-2-3-4", "created_at"=>2009-10-14 07:47:04 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
Ruby on Rails 2.3.4, this release fixes bugs and introduces a few minor features. Due to the inclusion of two security fixes, all users of the 2.3 series are recommended to upgrade as soon as possible.
\n\n
C:\\Documents and Settings\\Administrator>gem install rails \nSuccessfully installed activesupport-2.3.4 \nSuccessfully installed activerecord-2.3.4 \nSuccessfully installed actionpack-2.3.4 \nSuccessfully installed actionmailer-2.3.4 \nSuccessfully installed activeresource-2.3.4 \nSuccessfully installed rails-2.3.4 \n6 gems installed \nInstalling ri documentation for activesupport-2.3.4... \nInstalling ri documentation for activerecord-2.3.4... \nInstalling ri documentation for actionpack-2.3.4... \nInstalling ri documentation for actionmailer-2.3.4... \nInstalling ri documentation for activeresource-2.3.4... \nInstalling RDoc documentation for activesupport-2.3.4... \nInstalling RDoc documentation for activerecord-2.3.4... \nInstalling RDoc documentation for actionpack-2.3.4... \nInstalling RDoc documentation for actionmailer-2.3.4... \nInstalling RDoc documentation for activeresource-2.3.4...
\n", "_id"=>67}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["package", "ubuntu", "uninstall"], "comments_count"=>0, "category_id"=>7, "title"=>"Uninstall / Delete / Remove Package", "body"=>"Just use the following syntax:\n\nsudo apt-get remove {package-name}\n\nFor example remove package called mplayer, enter:\n$ sudo apt-get remove mplayer\n\nRemove package called lighttpd along with all configuration files, enter:\n$ sudo apt-get --purge remove lighttpd\n\nTo list all installed package, enter:\\\ndpkg --list\ndpkg --list | less\ndpkg --list | grep -i 'http'", "created_at"=>2009-11-22 18:48:23 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
Just use the following syntax:
\n\n
sudo apt-get remove {package-name}
\n\n
For example remove package called mplayer, enter: \n$ sudo apt-get remove mplayer
\n\n
Remove package called lighttpd along with all configuration files, enter: \n$ sudo apt-get --purge remove lighttpd
\n\n
To list all installed package, enter:\\ \ndpkg --list \ndpkg --list | less \ndpkg --list | grep -i 'http'
\n", "_id"=>68}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["delegate", "ImageMagick"], "comments_count"=>0, "category_id"=>7, "title"=>"ImageMagick够折腾得,no decode delegate", "body"=>"估计RP出问题了,以前安装和今天在mac上安装都很顺利,但是在服务器上装得时候,出现一大堆得问题,极度诡异,最后查了N多资料,改了N多东西,也不晓得最后是哪个生效了,终于折腾好了.\n记录下我参考过得资料:\nhttp://www.imagemagick.org/script/command-line-processing.php\nhttp://wanguan2000.blog.ubuntu.org.cn/2009/01/04/ubuntu-下rmagick的安装/\nhttp://infrastacks.com/?p=57\nhttp://hi.baidu.com/yttxuehui/blog/item/9f1a21978d6fa96a55fb96d5.html\nhttp://www.blogjava.net/fl1429/archive/2009/06/17/282895.html\nhttp://hi.baidu.com/countryroadtao/blog/item/225c72dad2adc16cd0164e97.html\nhttp://www.cnscn.org/htm_data/602/0705/8717.html\nhttp://stackoverflow.com/questions/1483968/imagemagick-convert-error-wrong-jpeg-library-version-library-is-62-caller-expe\n我读最后一个问题印象深刻\n\"Looks like it is reading the wrong jpeg ibrary, but I have jpeg 7 installed. How do i tell ImageMagick to look up the right JPEG library version(I don't care 62 or 70 as long as it works).\"\nroot@li84-64:/data/soft/ImageMagick-6.5.7-9# convert -list format | grep JPEG\n see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS),\n and supplement 61 which adds JPEG-2000 encoding.\n JNG* PNG rw- JPEG Network Graphics\n JP2* JP2 rw- JPEG-2000 File Format Syntax\n JPC* JPC rw- JPEG-2000 Code Stream Syntax\n JPEG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n JPG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n JPX* JPX rw- JPEG-2000 File Format Syntax\n PGX* PGX r-- JPEG-2000 VM Format\n PJPEG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n\n看到其需要得JPEG得lib是70,但是我装得是\n\nroot@li84-64:/data/soft/ImageMagick-6.5.7-9# dpkg --list | grep \"magick\"\nrc imagemagick 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation programs\nii libmagick++10 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library\nii libmagick++9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library - develop\nii libmagick10 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library\nii libmagick9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library - development fil\nii libmagickcore1 7:6.4.5.4.dfsg1-1ubuntu3.1 low-level image manipulation library\nii libmagickwand1 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation library\nii librmagick-ruby 1.15.11-1ubuntu1 ImageMagick API for Ruby\nii librmagick-ruby1.8 1.15.11-1ubuntu1 ImageMagick API for Ruby", "created_at"=>2009-11-22 20:30:32 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
root@li84-64:/data/soft/ImageMagick-6.5.7-9# dpkg --list | grep "magick" \nrc imagemagick 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation programs \nii libmagick++10 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library \nii libmagick++9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library - develop \nii libmagick10 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library \nii libmagick9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library - development fil \nii libmagickcore1 7:6.4.5.4.dfsg1-1ubuntu3.1 low-level image manipulation library \nii libmagickwand1 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation library \nii librmagick-ruby 1.15.11-1ubuntu1 ImageMagick API for Ruby \nii librmagick-ruby1.8 1.15.11-1ubuntu1 ImageMagick API for Ruby
\n", "_id"=>69}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["find", "inject", "rails", "ruby", "select"], "comments_count"=>0, "category_id"=>5, "title"=>"用Ruby在已知数组中找到和目标最匹配得元素", "body"=>"有个需求,给定一个数组,然后给出一个变量,需要在这个数组中找到和这个变量得值最接近得那个元素,开始用find或者select都不是很合适,最后找到inject,很好得解决了这个需求,现在记录下:\n首先看下inject这个函数\n````\nenum.inject(initial) {| memo, obj | block } => obj\nenum.inject {| memo, obj | block } => obj\nCombines the elements of enum by applying the block to an accumulator value (memo) and each element in turn. At each step, memo is set to the value returned by the block. The first form lets you supply an initial value for memo. The second form uses the first element of the collection as a the initial value (and skips that element while iterating).\n\n # Sum some numbers\n (5..10).inject {|sum, n| sum + n } #=> 45\n # Multiply some numbers\n (5..10).inject(1) {|product, n| product * n } #=> 151200\n\n # find the longest word\n longest = %w{ cat sheep bear }.inject do |memo,word|\n memo.length > word.length ? memo : word\n end\n longest #=> \"sheep\"\n\n # find the length of the longest word\n longest = %w{ cat sheep bear }.inject(0) do |memo,word|\n memo >= word.length ? memo : word.length\n end\n longest #=> 5\n```\n\n然后根据我得需求,写出一个函数如下:\n````\n # find the min abs size\n def self.select_h(h)\n if ALL_FORMATS.include?(h)\n return h\n else\n ok_size = ALL_FORMATS.inject do |i,j|\n (i-h).abs < (j-h).abs ? i : j\n end\n return ok_size\n end\n end\n```\n首先看是否包含这个变量,如果又,直接返回,如果没有就inject来取一个最合适得。", "created_at"=>2009-11-24 08:06:13 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
有个需求,给定一个数组,然后给出一个变量,需要在这个数组中找到和这个变量得值最接近得那个元素,开始用find或者select都不是很合适,最后找到inject,很好得解决了这个需求,现在记录下: \n首先看下inject这个函数 \n```` \nenum.inject(initial) {| memo, obj | block } => obj \nenum.inject {| memo, obj | block } => obj \nCombines the elements of enum by applying the block to an accumulator value (memo) and each element in turn. At each step, memo is set to the value returned by the block. The first form lets you supply an initial value for memo. The second form uses the first element of the collection as a the initial value (and skips that element while iterating).
\n\n
# Sum some numbers \n (5..10).inject {|sum, n| sum + n } #=> 45 \n # Multiply some numbers \n (5..10).inject(1) {|product, n| product * n } #=> 151200
\n\n
# find the longest word \n longest = %w{ cat sheep bear }.inject do |memo,word| \n memo.length > word.length ? memo : word \n end \n longest #=> "sheep"
\n\n
# find the length of the longest word \n longest = %w{ cat sheep bear }.inject(0) do |memo,word| \n memo >= word.length ? memo : word.length \n end \n longest #=> 5 \n```
\n\n
然后根据我得需求,写出一个函数如下: \n` \n # find the min abs size \n def self.select_h(h) \n if ALL_FORMATS.include?(h) \n return h \n else \n ok_size = ALL_FORMATS.inject do |i,j| \n (i-h).abs < (j-h).abs ? i : j \n end \n return ok_size \n end \n end \n \n首先看是否包含这个变量,如果又,直接返回,如果没有就inject来取一个最合适得。
\n", "_id"=>72}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["GD", "php", "ubuntu"], "comments_count"=>0, "category_id"=>7, "title"=>"Install GD Support for PHP in Ubuntu", "body"=>"I am in the process of building my blog using wordpress ,then i install SI CAPTCHA Anti-Spam ,but it's say i didn’t have GD support for PHP5 installed on my server. so i need to do:\n\nOpen terminal and type in the following command:\n
\n\nThere you go, you now have GD Support for PHP5 in Ubuntu. Get your Drupal on!", "created_at"=>2010-01-13 02:25:36 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
I am in the process of building my blog using wordpress ,then i install SI CAPTCHA Anti-Spam ,but it's say i didn’t have GD support for PHP5 installed on my server. so i need to do:
\n\n
Open terminal and type in the following command: \n$ sudo apt-get install php5-gd
\n\n
Now restart Apache \n# sudo /etc/init.d/apache2 restart
\n\n
or restart spawn-fcgi \n/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9100 -u www-data -g www-data -f /usr/bin/php-cgi -C 10
\n\n
There you go, you now have GD Support for PHP5 in Ubuntu. Get your Drupal on!
\n", "_id"=>73}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["centOS", "Swap"], "comments_count"=>0, "category_id"=>7, "title"=>"Swap Space in centOS", "body"=>"Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.\n\nSwap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.\n\nSwap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.\n\nSo, if:\n\nM = Amount of RAM in GB, and S = Amount of swap in GB, then\n
If M < 2\n\tS = M *2\nElse\n\tS = M + 2
\nUsing this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.\n\nFor systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).\n\nsource:http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-swapspace.html", "created_at"=>2010-01-21 02:01:34 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.
\n\n
Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
\n\n
Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.
\n\n
So, if:
\n\n
M = Amount of RAM in GB, and S = Amount of swap in GB, then \nIf M < 2 \n S = M *2 \nElse \n S = M + 2 \nUsing this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.
\n\n
For systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).
\n", "_id"=>74}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["劫持", "电信"], "comments_count"=>0, "category_id"=>5, "title"=>"深圳电信耍流氓,劫持浏览器", "body"=>"今天无意发现在浏览器的左下角经常出现一个页面无法打开的提示,如下\nThe webpage at http://121.15.207.133:4022/logo.jpg?p=undefined|778|1276|24|800|1280might be temporarily down or it may have moved permanently to a new web address.\n\n看其样式是请求了一个121.15.207.133上的一个logo图片,然后传入了几个参数,但是这个图片的服务器貌似除了电问题,导致请求不到。\n无缘无故的,咋会去请求这个玩意呢,查了吓这个IP归属,属于:\n
\n", "_id"=>75}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["C", "ruby", "RubyInline"], "comments_count"=>0, "category_id"=>2, "title"=>"RubyInline, Making Making Things Faster Easier", "body"=>"发现一篇好文,讲的是如何使用RubyInline,在Ruby中直接嵌入C并运行,相比之前些lib,要方便的多,由于这个文章在墙外,就转了一份过来,可以翻墙的可以去看原文\nhttp://on-ruby.blogspot.com/2006/07/rubyinline-making-making-things-faster.html\n\nToday on ruby-talk, I caught a thread called \"For Performance, Write it in C\". I'd like to present a slight amendment to that thesis. Let me explain.\n\nIt all started with an email at work. Someone was passing around a bunch of prime number printers in various languages (C, Java, C#, Perl, and Python). They all used the same (ugly) algorithm, and were supposed to show just how 'performant the languages were. Since I'm the local Ruby evangelist, I was asked to write a Ruby version. Here's what I came up with (warning, ugly algorithm ahead):\n\n#!/usr/bin/ruby\n\nfor num in 1..10_000 do\nis_prime = 1\nfor x in 2..(num - 1) do\nif (num % x == 0)\nis_prime = x\nbreak\nend\nend\nif is_prime == 1\nputs \"\#{num} is a prime number\"\nelse\nputs \"\#{num} equals \#{is_prime} * \#{num/is_prime}\"\nend\nend\nHow fast is it? Well, time says:\n\n$ time ./primes.rb > /dev/null\n\nreal 0m2.905s\nuser 0m2.716s\nsys 0m0.004s\n$\n\nCertainly, nothing to write home about, but not too far from Perl or Python either.\nWanting to improve it, and not being able to touch the algorithm (we want to be comparing apples to quinces after all, not apples to oranges). I know my only hope is to find the bottleneck(s) and rewrite it (them?) in C. My first step is to grab Ruby's profiler and see what it says (oh, by the way, I reduced the value of num to 100 so that this would complete in my lifetime ... the profiler is slow).\n\n$ ruby -rprofile primes.rb > /dev/null\n% cumulative self self total\ntime seconds seconds calls ms/call ms/call name\n63.64 0.14 0.14 101 1.39 3.56 Range#each\n13.64 0.17 0.03 1133 0.03 0.03 Fixnum#%\n9.09 0.19 0.02 1233 0.02 0.02 Fixnum#==\n4.55 0.20 0.01 100 0.10 0.20 Kernel.puts\n4.55 0.21 0.01 200 0.05 0.05 IO#write\n4.55 0.22 0.01 248 0.04 0.04 Fixnum#to_s\n0.00 0.22 0.00 74 0.00 0.00 Fixnum#/\n0.00 0.22 0.00 100 0.00 0.00 Fixnum#-\n0.00 0.22 0.00 1 0.00 220.00 #toplevel\n$\n\nWhich tells me that most of my time is spent in each (well, it's actually spent in the block I sent to each. It's taking a whopping 1.39 msec per call, compared to .0X msec for everything else. What would happen if I rewrote just that block?\nEnter RubyInline (A great tool written by zenspider and Eric Hodel). I'm not a C wiz by any stretch of the imagination, but this stuff is pretty easy to bang out. My new code looks like this:\n\n#!/usr/bin/ruby\n\nrequire \"rubygems\"\nrequire \"inline\"\n\nclass Primes\ninline do |builder|\nbuilder.c '\nint prime(int num) {\nint x;\nfor (x = 2; x < (num - 1) ; x++) { if (num == 2) { return 1; } if (num % x == 0) { return x; } } return 1; }' end end p = Primes.new for num in 2..10_000 do is_prime = p.prime(num) if is_prime == 1 puts \"\#{num} is a prime number\" else puts \"\#{num} equals \#{is_prime} * \#{num/is_prime}\" end end Not too ugly. At least I can still see what's happening. The main loop being in Ruby helps a lot too (especially if this were a much bigger program). How much of a difference does it make? time says: $ time ./cprimes.rb > /dev/null\n\nreal 0m0.328s\nuser 0m0.288s\nsys 0m0.020s\n\nAn order of magnitude improvement. Not too shabby.\nWhat's the lesson here? Optimize what you need to (and only what you need to), profile find out what that is (it may be slow, but profiling is your friend), and use the right tools (rewriting a bit of code with RubyInline is way better than rewriting the whole app in C).", "created_at"=>2010-01-24 10:51:47 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
Today on ruby-talk, I caught a thread called "For Performance, Write it in C". I'd like to present a slight amendment to that thesis. Let me explain.
\n\n
It all started with an email at work. Someone was passing around a bunch of prime number printers in various languages (C, Java, C#, Perl, and Python). They all used the same (ugly) algorithm, and were supposed to show just how 'performant the languages were. Since I'm the local Ruby evangelist, I was asked to write a Ruby version. Here's what I came up with (warning, ugly algorithm ahead):
\n\n
!/usr/bin/ruby
\n\n
for num in 1..10_000 do \nis_prime = 1 \nfor x in 2..(num - 1) do \nif (num % x == 0) \nis_prime = x \nbreak \nend \nend \nif is_prime == 1 \nputs "\#{num} is a prime number" \nelse \nputs "\#{num} equals \#{is_prime} * \#{num/is_prime}" \nend \nend \nHow fast is it? Well, time says:
\n\n
$ time ./primes.rb > /dev/null
\n\n
real 0m2.905s \nuser 0m2.716s \nsys 0m0.004s \n$
\n\n
Certainly, nothing to write home about, but not too far from Perl or Python either. \nWanting to improve it, and not being able to touch the algorithm (we want to be comparing apples to quinces after all, not apples to oranges). I know my only hope is to find the bottleneck(s) and rewrite it (them?) in C. My first step is to grab Ruby's profiler and see what it says (oh, by the way, I reduced the value of num to 100 so that this would complete in my lifetime ... the profiler is slow).
Which tells me that most of my time is spent in each (well, it's actually spent in the block I sent to each. It's taking a whopping 1.39 msec per call, compared to .0X msec for everything else. What would happen if I rewrote just that block? \nEnter RubyInline (A great tool written by zenspider and Eric Hodel). I'm not a C wiz by any stretch of the imagination, but this stuff is pretty easy to bang out. My new code looks like this:
\n\n
!/usr/bin/ruby
\n\n
require "rubygems" \nrequire "inline"
\n\n
class Primes \ninline do |builder| \nbuilder.c ' \nint prime(int num) { \nint x; \nfor (x = 2; x < (num - 1) ; x++) { if (num == 2) { return 1; } if (num % x == 0) { return x; } } return 1; }' end end p = Primes.new for num in 2..10_000 do is_prime = p.prime(num) if is_prime == 1 puts "\#{num} is a prime number" else puts "\#{num} equals \#{is_prime} * \#{num/is_prime}" end end Not too ugly. At least I can still see what's happening. The main loop being in Ruby helps a lot too (especially if this were a much bigger program). How much of a difference does it make? time says: $ time ./cprimes.rb > /dev/null
\n\n
real 0m0.328s \nuser 0m0.288s \nsys 0m0.020s
\n\n
An order of magnitude improvement. Not too shabby. \nWhat's the lesson here? Optimize what you need to (and only what you need to), profile find out what that is (it may be slow, but profiling is your friend), and use the right tools (rewriting a bit of code with RubyInline is way better than rewriting the whole app in C).
\n# Example MySQL config file for large systems.\n#\n# This is for a large system with memory = 512M where the system runs mainly\n# MySQL.\n#\n# You can copy this file to\n# /etc/my.cnf to set global options,\n# mysql-data-dir/my.cnf to set server-specific options (in this\n# installation this directory is /var/lib/mysql) or\n# ~/.my.cnf to set user-specific options.\n#\n# In this file, you can use all long options that a program supports.\n# If you want to know which options a program supports, run the program\n# with the \"--help\" option.\n\n# The following options will be passed to all MySQL clients\n[client]\nport = 3306\nsocket = /var/lib/mysql/mysql.sock\n\n# Here follows entries for some specific programs\n\n# The MySQL server\n[mysqld]\ndatadir=/var/lib/mysql\nsocket=/var/lib/mysql/mysql.sock\nuser=mysql\nskip-locking\n\n# By default, the wait_timeout value is 28800. Unless you want MySQL to keep waiting for 28800 seconds (480 minutes or 8 hours),\n# please decrease its value according to your application needs.\nwait_timeout=60\n# Increase connect_timeout from 5 to 10\nconnect_timeout=10\n# Decrease interactive_timeout from 28800 to 100\ninteractive_timeout=120\n# Increase join_buffer_size from 131072 to 1M\njoin_buffer_size=1M\n# Increase query_cache_size from 0 to 128M\nquery_cache_size=32M\n# Increase query cache limit from 1048576 to 2M\nquery_cache_limit=2M\n# Increase max allowed packet size from 1M to 16M\nmax_allowed_packet=2M\n# Increase table cache cache from 256 to 1024\ntable_cache=1024\n# Increase sort buffer size from 1M\nsort_buffer_size=2M\n# Increase read buffer size from 1M\nread_buffer_size=2M\n# Increase read_rnd_buffer_size to 4M\nread_rnd_buffer_size=4M\n\n#Other settings\nsort_buffer_size=8M\nkey_buffer = 256M\nkey_buffer_size=64M\nmyisam_sort_buffer_size = 64M\nthread_cache_size = 8\n# Try number of CPU's*2 for thread_concurrency\nthread_concurrency = 2\n\n\n# Don't listen on a TCP/IP port at all. This can be a security enhancement,\n# if all processes that need to connect to mysqld run on the same host.\n# All interaction with mysqld must be made via Unix sockets or named pipes.\n# Note that using this option without enabling named pipes on Windows\n# (via the \"enable-named-pipe\" option) will render mysqld useless!\n#\n#skip-networking\n\n# Disable Federated by default\nskip-federated\n\nold_passwords=1\n\n#for slow queries\nlog-slow-queries = /var/log/mysql-slow.log\nlong_query_time = 3\n\n[mysqldump]\nquick\nmax_allowed_packet = 16M\n\n[mysql]\nno-auto-rehash\n# Remove the next comment character if you are not familiar with SQL\n#safe-updates\n\n[isamchk]\nkey_buffer = 128M\nsort_buffer_size = 128M\nread_buffer = 2M\nwrite_buffer = 2M\n\n[myisamchk]\nkey_buffer = 128M\nsort_buffer_size = 128M\nread_buffer = 2M\nwrite_buffer = 2M\n\n[mysqlhotcopy]\ninteractive-timeout\n\n[mysqld_safe]\nlog-error=/var/log/mysqld.log\npid-file=/var/run/mysqld/mysqld.pid\n
mysql> SHOW VARIABLES like \"%sort%\";\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| max_length_for_sort_data | 1024 |\n| max_sort_length | 1024 |\n| myisam_max_sort_file_size | 2146435072 |\n| myisam_sort_buffer_size | 67108864 |\n| sort_buffer_size | 8388608 |\n+---------------------------+------------+\n5 rows in set (0.00 sec)
\n\n不晓得是做啥用的,查了下资料:\n
http://forge.mysql.com/wiki/MySQL_Internals_Algorithms\n\nUsing the modified filesort algorithm, the tuples are longer than the pairs used in the original method, and fewer of them fit in the sort buffer (the size of which is given by sort_buffer_size). As a result, it is possible for the extra I/O to make the modified approach slower, not faster. To avoid a slowdown, the optimization is used only if the total size of the extra columns in the sort tuple does not exceed the value of the max_length_for_sort_data system variable. (A symptom of setting the value of this variable too high is that you should see high disk activity and low CPU activity.)
Using the modified filesort algorithm, the tuples are longer than the pairs used in the original method, and fewer of them fit in the sort buffer (the size of which is given by sort_buffer_size). As a result, it is possible for the extra I/O to make the modified approach slower, not faster. To avoid a slowdown, the optimization is used only if the total size of the extra columns in the sort tuple does not exceed the value of the max_length_for_sort_data system variable. (A symptom of setting the value of this variable too high is that you should see high disk activity and low CPU activity.)
\n", "_id"=>81}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "filesort"], "comments_count"=>0, "category_id"=>11, "title"=>"What does Using filesort mean in MySQL?", "body"=>"一直以来,只要我看到explain出来的结果有“Using filesort ”,我就要想方设法的优化和改善,因为我以前以为这个的意思就是使用文件系统来排序(那该多慢呀!),其实不是这样的。\n在mysqlperformanceblog上看到一篇文章《What does Using filesort mean in MySQL?》其中作者说自己每次面世的时候都会问“what does Using filesort mean in EXPLAIN,” 结果没有一个人回答的是对的,结果让其比较郁闷,就写了这个文章说明:\n
The usual answer is something like “rows are being placed into a temporary table which is too big to fit in memory, so it gets sorted on disk.” Unfortunately, this is not the same thing. First of all, this is Using temporary. Secondly, temporary tables may go to disk if they are too big, but EXPLAIN doesn’t show that. (If I interview you, I might ask you what “too big” means, or I might ask you the other reason temporary tables go to disk!)
The truth is, filesort is badly named. Anytime a sort can’t be performed from an index, it’s a filesort. It has nothing to do with files. Filesort should be called “sort.” It is quicksort at heart.
\n正解是,filesort这个名字有问题,容易给人误解,在mysql中,任何不能通过index进行的sort都称之为filesort,这里的filesort和文件没有任何关系,应该称之为“sort”而不是“filesort”,它的内部实现就是快速排序。\n\n参考资料:\nWhat does Using filesort mean in MySQL?\nhttp://www.mysqlperformanceblog.com/2009/03/05/what-does-using-filesort-mean-in-mysql/\n\nHow MySQL executes ORDER BY\nhttp://s.petrunia.net/blog/?p=24", "created_at"=>2010-02-03 03:51:36 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
一直以来,只要我看到explain出来的结果有“Using filesort ”,我就要想方设法的优化和改善,因为我以前以为这个的意思就是使用文件系统来排序(那该多慢呀!),其实不是这样的。 \n在mysqlperformanceblog上看到一篇文章《What does Using filesort mean in MySQL?》其中作者说自己每次面世的时候都会问“what does Using filesort mean in EXPLAIN,” 结果没有一个人回答的是对的,结果让其比较郁闷,就写了这个文章说明: \nThe usual answer is something like “rows are being placed into a temporary table which is too big to fit in memory, so it gets sorted on disk.” Unfortunately, this is not the same thing. First of all, this is Using temporary. Secondly, temporary tables may go to disk if they are too big, but EXPLAIN doesn’t show that. (If I interview you, I might ask you what “too big” means, or I might ask you the other reason temporary tables go to disk!) \n通常的解释是:选择出来的记录太多了,需要排序时内存中放不下了,所以会存储在磁盘中,并通过操作磁盘的文件的方式来排序。但是呢,这是不对的。
\n\n
The truth is, filesort is badly named. Anytime a sort can’t be performed from an index, it’s a filesort. It has nothing to do with files. Filesort should be called “sort.” It is quicksort at heart. \n正解是,filesort这个名字有问题,容易给人误解,在mysql中,任何不能通过index进行的sort都称之为filesort,这里的filesort和文件没有任何关系,应该称之为“sort”而不是“filesort”,它的内部实现就是快速排序。
\n", "_id"=>82}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "variables"], "comments_count"=>0, "category_id"=>11, "title"=>"Mysql动态修改参数", "body"=>"mysql数据库也像ORACLE数据库一样,可以动态的修改参数,可以修改会话级变量只对当前会话产生影响;也可以修改全局变量,对所有新连接的会话都产生影响。\n\n修改会话级变量\n用show variables 命令查看当前参数的值,like 'pattern'用于模式匹配,查找指定的参数\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n用set SESSION命令设置会话级变量的新值\n\nmysql> set SESSION sort_buffer_size=7000000;\nQuery OK, 0 rows affected (0.00 sec)\n\n--修改会话级变量对当前会话来说立刻生效\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 7000000 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\nmysql> exit\nBye\n退出重新连接后,此参数恢复原值\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 40 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n修改全局变量\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 40 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n用set GLOBAL 命令设置全局变量\n\nmysql> set GLOBAL sort_buffer_size = 7000000;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n当前此参数的值并不发生变化,先退出,然后重新连进去\nmysql> exit\nBye\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 41 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 7000000 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n新的参数值生效", "created_at"=>2010-02-03 04:00:12 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
--修改会话级变量对当前会话来说立刻生效 \nmysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 7000000 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
mysql> exit \nBye \n退出重新连接后,此参数恢复原值 \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 40 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
修改全局变量 \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 40 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
用set GLOBAL 命令设置全局变量
\n\n
mysql> set GLOBAL sort_buffer_size = 7000000; \nQuery OK, 0 rows affected (0.00 sec)
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec) \n当前此参数的值并不发生变化,先退出,然后重新连进去 \nmysql> exit \nBye \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 41 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 7000000 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec) \n新的参数值生效
\n", "_id"=>84}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Tips"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Textmate", "theme"], "comments_count"=>0, "category_id"=>4, "title"=>"Installing a New Textmate Theme", "body"=>"To install a new theme, select one of the .tmTheme links listed below, download it to your desktop and double-click on the file. This will place it in ~/Library/Application Support/TextMate/Themes, at which point the new theme will appear in the list found in Preferences → Fonts & Colors. This will also set it as the active theme. (Once the theme is installed, you may remove the .tmTheme from your desktop.)\n\nRails Envy TextMate Theme\n http://railsenvy.com/2008/9/18/rails-envy-textmate-theme\n\nUser Submitted Themes\n http://wiki.macromates.com/Themes/UserSubmittedThemes", "created_at"=>2010-02-04 18:24:02 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
To install a new theme, select one of the .tmTheme links listed below, download it to your desktop and double-click on the file. This will place it in ~/Library/Application Support/TextMate/Themes, at which point the new theme will appear in the list found in Preferences → Fonts & Colors. This will also set it as the active theme. (Once the theme is installed, you may remove the .tmTheme from your desktop.)
\n\nrestart teatmate and it's done!\n\nIn the TextMate preferences, advanced tab, shell variables, set the TM_GIT variable to point to your installation of git (ie /usr/local/bin/git)\nMany shortcuts are available from the Git-shortcut (Ctrl-Shift-G). Subversion commands are Command-Option-g. Less frequent commands are accessed via the menu.\nUpdate your bundle by running the “Update Git Bundle” command.", "created_at"=>2010-02-04 23:39:24 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
In the TextMate preferences, advanced tab, shell variables, set the TM_GIT variable to point to your installation of git (ie /usr/local/bin/git) \nMany shortcuts are available from the Git-shortcut (Ctrl-Shift-G). Subversion commands are Command-Option-g. Less frequent commands are accessed via the menu. \nUpdate your bundle by running the “Update Git Bundle” command.
SIMBL (SIMple Bundle Loader) - pronounced like \"symbol\" or \"cymbal\" - enables hacks and plugins. For instance, SIMBL enables PithHelmet to enhance Safari.
Install SIMBL and make sure you have latest SIMBL 0.9.x\nPlace Visor.bundle into ~/Library/Application Support/SIMBL/Plugins (create this directory if it does not exist)\nRelaunch Terminal.app - You should now see the Visor Status Menu Item\nConfigure your keyboard trigger by selecting the Visor Status Menu Item -> Visor Preferences ... and edit your keyboard hot-key\nYou can now trigger Visor with your hot-key from any application to get an instant terminal session.\n\nTo hide Visor, you can either:\nre-trigger with your key-combo\noptionally you can click off of the Visor window
如果你和我一样经常使用终端程序,这个小程序一定可以帮到你。他能将终端窗口变成类似雷神或CS那样的下拉窗口,非常酷。 \n可以从这里下载 http://visor.binaryage.com/ \n这个软件需要SIMBL ,如果你没有安装,要先安装这个。 \nhttp://www.culater.net/software/SIMBL/SIMBL.php \nSIMBL (SIMple Bundle Loader) - pronounced like "symbol" or "cymbal" - enables hacks and plugins. For instance, SIMBL enables PithHelmet to enhance Safari. \n之后将下载下来的文件解压,将解压后的文件拷贝至/Library/Application Support/SIMBL/Plugins,之后再重新启动你的终端你就可以看到效果了。 默认的快捷启动键是Ctrl+` \nvisor: http://visor.binaryage.com/
\n\n
Installation
\n\n
Install SIMBL and make sure you have latest SIMBL 0.9.x \nPlace Visor.bundle into ~/Library/Application Support/SIMBL/Plugins (create this directory if it does not exist) \nRelaunch Terminal.app - You should now see the Visor Status Menu Item \nConfigure your keyboard trigger by selecting the Visor Status Menu Item -> Visor Preferences ... and edit your keyboard hot-key \nYou can now trigger Visor with your hot-key from any application to get an instant terminal session.
\n\n
To hide Visor, you can either: \nre-trigger with your key-combo \noptionally you can click off of the Visor window
前段时间写了一篇《实例优化mysql配置文件my.cnf》,这几天看到效果非常明显,别的不说,单mysql cache_hits就很不错(之前竟然没注意到这个参数) \n# Increase query_cache_size from 0 to 128M \nquery_cache_size=128M
Rails 3 in Action by Yehuda Katz and Mike Gunderloy. Currently available is their Early Access Edition, which gives you access to chapters as they are written.
\n\t
Beginning Rails 3 by Jeffrey Allan Hardy , Cloves Carneiro Jr. & Rida Al Barazi
这次升级需要新装很多的gem,如下: \ngem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n \ngem install rails --pre \n期间遇到一个错误: \nDue to a rubygems bug, you must uninstall all older versions of bundler for 0.9 to work \n然后这边有N多关于Rails3的资料供参考:
\n\n
Rails 3 Tutorials & Blog Posts
\n\n
Edging your way towards Ruby 1.9.1 and Rails 3.0pre \n Unobtrusive JavaScript in Rails 3 by Zach Carter \n A Fresh Cup: Seed Data in Rails 3 tutorial – feature summary + code example by Mike Gunderloy. \n Rails3: Stepping off of the golden path slides by Matt Aimonetti \n Rails Magazine – RailsConf 2009 Edition page 5 has a section called The Unofficial Guide to What’s New in Rails 3 by Rupak Ganguly \n Jason Ting’s RailsConf 2009 Notes includes some basic notes about Rails 3 \n Noel Rappin: Railsconf 09 – After the RailsConfening article \n Yehuda Katz: Railsconf Wrapup blog – contains links to jQuery talk by Katz at RailsConf 09 \n How to Begin Playing With Rails 3 by Oscar Del Ben \n My Five Favorite Things About Rails 3 by Yehuda Katz \n Rails 3: The Great Decoupling by Yehuda Katz \n Rails Edge Architecture by Yehuda Katz \n How to Build Sinatra on Rails 3 by Yehuda Katz
\n\n
Rails 3 Presentations & Conference Talks
\n\n
Yehuda: What to Expect in Rails 3.0 webcast recording \n Scotland on Rails: Yehuda on Rails & Merb Merge video. For more Scotland on Rails videos, check out this Ruby Inside post. \n Yehuda Katz on Rails 3 and beyond interview by Mark Coleman \n RailsConf: Yehuda – The Russian Doll Pattern video \n RailsConf 09: DHH Keynote video – DHH previews unobtrusive javascript, default escaping & more.
\n\n
Rails 3 Books
\n\n
Rails 3 in Action by Yehuda Katz and Mike Gunderloy. Currently available is their Early Access Edition, which gives you access to chapters as they are written. \n Beginning Rails 3 by Jeffrey Allan Hardy , Cloves Carneiro Jr. & Rida Al Barazi
\n\n
Rails 3 Commentary
\n\n
Internet News: Rails 3 Gets Supersized With Merb \n eWeek: Rubyists Unite Ruby on Rails and Merb to Merge in Rails 3 \n CIO: Rails 3 to add security enhancement \n Yehuda Katz: Rails and Merb Merge \n RubyOnRails.org: Rails + Merb Merge Announcement
\n", "_id"=>89}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"02. 产品设计 | PM"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({"count"=>"categories", "query"=>{:name=>"02. 产品设计 | PM"}, "fields"=>nil}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"categories"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['categories'].insert([{"sort"=>0, "posts_count"=>0, "name"=>"02. 产品设计 | PM", "updated_at"=>2012-06-24 15:35:10 UTC, "created_at"=>2012-06-24 15:35:10 UTC, "_id"=>13}])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Axure", "Balsamiq Mockups", "原型设计"], "comments_count"=>0, "category_id"=>13, "title"=>"Balsamiq Mockups,理想的原型设计工具", "body"=>"由于经常要讨论产品,包括web和手机(\bAandroid,Iphone)的产品原型设计,尝试过很多的原型设计工具,例如Axure等,后来换了mac book,就一直找不到合适的原型设计工具,就一直在Google Doc中直接draw,其做了很多无用功。\n比较偶然的机会看到Balsamiq Mockups这个软件,和Pixelmator一样,是个人开发者(意大利人Peldi)开发的产品,其地址为http://www.balsamiq.com/ ,在其提供的demo页面上试了下http://www.balsamiq.com/demos/mockups/Mockups.html,效果很好,符合我的预期。\n虽然是由个人设计的,但功能却一点不弱于其他大牌的原型设计工具:\n操作方面,拖拽,控件分组,甚至元素之间的对齐都做得很贴心;\n预制了很多界面元素,从简单的输入框,下拉框,浏览器主要元素,到经常用得到的导航条,日历,表格,到复杂的Tag Cloud,Cover Flow, 地图,WYSWYG的格式工具栏等,有了这些不用从头画起,往往比用白板都快;\n界面元素的修改很简单,比如导航条的几个标签页的label,就是用逗号分隔的文字,下拉框的选项就是分行的文字;\n使用xml语言来记录和保存界面元素和布局,\n这使得每个设计都能被很好得放进SVN,Git,和CVS等工具中进行管理和跟踪;\n可以设计复杂的界面元素,保存后,以后可以重复使用(包括修改);\n可以将设计导出成PNG格式的图片;\n可以用命令行进行导出操作,这样就能让我写个脚本,从svn里checkout某个目录下的所有设计文件后,导出图片,打包后用邮件发到项目经理,工程师甚至客户那;\n跨平台,Balsamiq Mokups是用Flex和Air实现的,所以在Mac OS, Linux和Windows下都能使用;\n不仅仅有桌面版本,还有能集成在Confluence,JIRA,和XWiki中的版本,使得异地在线协作更方便有效。\n\n以下是关于Balsamiq Mockups的一些特点:\n易操作:从 Balsamiq Mockups 自带的元素里可以很方便地拖拽,效果图轻易形成;元素对齐很贴心;\n可偷懒:根据 Balsamiq Mockups 提供的 Wiki 风格的代码规则,画图时可以「偷懒」,输入文本符号则能生成图标。因此相比其它繁琐的软件操作,Balsamiq Mockups 也能更快地完成画图任务。\n控件足:Balsamiq Mockups 软件包括 50 多个控件, 70 多个图标。基本自带了所有常用的小控件,并在导航处进行分类;图标设计赏心悦目。要是 Balsamiq Mockups 允许用户导入自定义的控件就更好了,当然现有的也足够了 -\n新风格:让人眼前一亮的涂鸦风格,很能还原手绘效果;\n可中文:在菜单栏 View 里将 Use System Fonts 勾上,就能完美支持中文输入(注:非 Balsamiq Mockups 中文版);\n其它点:Balsamiq Mockups 使用 xml 记录,方便移植、二次利用;可导出为 png 格式图片。\n\n另外还有跨平台与多版本两个优点:\n跨平台:Balsamiq Mockups 基于 Air ,因此能同时在 Windows、Mac OS 及 Linux 下使用;\n多版本:包括桌面版本,以及集成于 Confluence、JIRA、XWiki、FogBugz 中的版本\n\n软件可以从其网站上下载,其中桌面版本售价是$79。但作者非常厚道,提供了几种免费使用的方式:http://www.balsamiq.com/products/mockups/desktop\n\nYou can download Mockups for Desktop for free. Some of the features of the app, like saving and loading multiple mockups or linking mockups together can only get unlocked using a license key.\n", "created_at"=>2010-02-21 18:39:26 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
You can download Mockups for Desktop for free. Some of the features of the app, like saving and loading multiple mockups or linking mockups together can only get unlocked using a license key.
\n", "_id"=>90}])
+MONGODB iceylog_development['categories'].find({:_id=>13}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>13}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "socket"], "comments_count"=>0, "category_id"=>3, "title"=>"Can’t connect to local MySQL server through socket 解决办法", "body"=>"Rails启动后报错,ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/temp/mysql.sock’ (2)\n\n1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.\n另外看看是不是权限问题.\n\n2、确定你的mysql.sock是不是在那个位置,\nmysql -u 你的mysql用户名 -p -S /var/lib/mysql/mysql.sock\n\n3、试试:service mysqld start\n\n4、如果是权限问题,则先改变权限 #chown -R mysql:mysql /var/lib/mysql\n\n[root@localhost ~]# /etc/init.d/mysqld start\n启动 MySQL: [ 确定 ]\n[root@localhost ~]# mysql -uroot -p", "created_at"=>2010-02-23 21:24:14 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
Rails启动后报错,ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/temp/mysql.sock’ (2)
\n\n
1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动. \n另外看看是不是权限问题.
\n", "_id"=>91}])
+MONGODB iceylog_development['categories'].find({:_id=>3}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>3}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Passenger", "REE"], "comments_count"=>0, "category_id"=>2, "title"=>"Download Ruby Enterprise Edition(REE)", "body"=>"前段时间用上了Passenger ,尔后就看到很多的人推荐使用Ruby Enterprise Edition(REE),今天得闲,试了一把。\nStep 1: Download\nSource code: version 1.8.7-2010.01\nStep 2: Install\nExtract it:\ntar xzvf ruby-enterprise-X.X.X.tar.gz\nRun the installer (completely safe, none of your system files will be touched!):\n./ruby-enterprise-X.X.X/installer\n
Welcome to the Ruby Enterprise Edition installer
\n
This installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.
\n
Don't worry, none of your system files will be touched if you don't want them
\n
to, so there is no risk that things will screw up.
\n
You can expect this from the installation process:
\n
1. Ruby Enterprise Edition will be compiled and optimized for speed for this
\n
system.
\n
2. Ruby on Rails will be installed for Ruby Enterprise Edition.
\n
3. You will learn how to tell Phusion Passenger to use Ruby Enterprise
\n
Edition instead of regular Ruby.
\n
Press Enter to continue, or Ctrl-C to abort.
\n
Welcome to the Ruby Enterprise Edition installerThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.Don't worry, none of your system files will be touched if you don't want themto, so there is no risk that things will screw up.\nYou can expect this from the installation process:\n1. Ruby Enterprise Edition will be compiled and optimized for speed for this system.\n\n2. Ruby on Rails will be installed for Ruby Enterprise Edition.\n\n3. You will learn how to tell Phusion Passenger to use Ruby Enterprise Edition instead of regular Ruby.\nPress Enter to continue, or Ctrl-C to abort.
\nStep 3: Make Phusion Passenger use Ruby Enterprise Edition instead of regular Ruby\nFollow the instructions that the Ruby Enterprise Edition installer gave you.", "created_at"=>2010-03-03 16:53:29 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
前段时间用上了Passenger ,尔后就看到很多的人推荐使用Ruby Enterprise Edition(REE),今天得闲,试了一把。 \nStep 1: Download \nSource code: version 1.8.7-2010.01 \nStep 2: Install \nExtract it: \ntar xzvf ruby-enterprise-X.X.X.tar.gz \nRun the installer (completely safe, none of your system files will be touched!): \n./ruby-enterprise-X.X.X/installer \nWelcome to the Ruby Enterprise Edition installer \nThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01. \nDon't worry, none of your system files will be touched if you don't want them \nto, so there is no risk that things will screw up. \nYou can expect this from the installation process: \n1. Ruby Enterprise Edition will be compiled and optimized for speed for this \nsystem. \n2. Ruby on Rails will be installed for Ruby Enterprise Edition. \n3. You will learn how to tell Phusion Passenger to use Ruby Enterprise \nEdition instead of regular Ruby. \nPress Enter to continue, or Ctrl-C to abort. \nWelcome to the Ruby Enterprise Edition installerThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.Don't worry, none of your system files will be touched if you don't want themto, so there is no risk that things will screw up. \nYou can expect this from the installation process: \n1. Ruby Enterprise Edition will be compiled and optimized for speed for this system.
\n\n\n
Ruby on Rails will be installed for Ruby Enterprise Edition.
\n
You will learn how to tell Phusion Passenger to use Ruby Enterprise Edition instead of regular Ruby. \nPress Enter to continue, or Ctrl-C to abort. \nStep 3: Make Phusion Passenger use Ruby Enterprise Edition instead of regular Ruby \nFollow the instructions that the Ruby Enterprise Edition installer gave you.
\n\n", "_id"=>92}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"02. 产品设计 | PM"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Border-radius", "css3"], "comments_count"=>0, "category_id"=>13, "title"=>"Border-radius: create rounded corners with CSS!", "body"=>"W3C has offered some new options for borders in CSS3, of which one is border-radius. Both Mozila/Firefox and Safari 3 have implemented this function, which allows you to create round corners on box-items. This is an example:\n\nMozilla/Firefox and Safari 3 users should see a nicely rounded box, with a nicely rounded border.\nThe code for this example above is actually quite simple:\n\nThese different corners can also each be handled on their own, Mozilla has other names for the feature than the spec says it should have though, as it has f.i. -moz-border-radius-topright as opposed to -webkit-border-top-right-radius:\n\nMozilla/Firefox and Safari 3 users should see a box with a rounded left upper corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded right upper corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded left lower corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded right lower corner.\nThese are handled by / should be handled by:\n\n````-moz-border-radius-topleft / -webkit-border-top-left-radius\n-moz-border-radius-topright / -webkit-border-top-right-radius\n-moz-border-radius-bottomleft / -webkit-border-bottom-left-radius\n-moz-border-radius-bottomright / -webkit-border-bottom-right-radius```", "created_at"=>2010-03-05 10:38:13 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
W3C has offered some new options for borders in CSS3, of which one is border-radius. Both Mozila/Firefox and Safari 3 have implemented this function, which allows you to create round corners on box-items. This is an example:
\n\n
Mozilla/Firefox and Safari 3 users should see a nicely rounded box, with a nicely rounded border. \nThe code for this example above is actually quite simple: \n \nThese different corners can also each be handled on their own, Mozilla has other names for the feature than the spec says it should have though, as it has f.i. -moz-border-radius-topright as opposed to -webkit-border-top-right-radius:
\n\n
Mozilla/Firefox and Safari 3 users should see a box with a rounded left upper corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded right upper corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded left lower corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded right lower corner. \nThese are handled by / should be handled by:
\n", "_id"=>95}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["action_mailer_optional_tls", "Gmail", "Redmine"], "comments_count"=>0, "category_id"=>2, "title"=>"Setup Redmine to send email using GMail", "body"=>"Redmine是用Rails写的一套很不错的项目管理系统,其提供了诸多很方便实用的功能,诸如里程碑管理,BUG跟踪,代码库变更管理等等。\n搭建以后在管理面板中测试邮件不通,主要原因是由于采用的Gmail的邮箱,于是找到一些解决方案,如下:\n1. Install the action_mailer_optional_tls plugin\nThe action_mailer_optional_tls_plugin adds a TLS option to Redmine's emailing library, ActionMailer. TLS is a version of SSL which is required by GMail in order to send email.\n\nTo install this plugin, use the script/plugin command in your Redmine directory:\n ./script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git\n\n2. Configure your email.yml\n# File: config/email.yml\nproduction:\n delivery_method: :smtp\n smtp_settings:\n tls: true\n address: \"smtp.gmail.com\"\n port: 587\n domain: \"www.YOURDOAMIN.com\" # 'your.domain.com' for GoogleApps\n authentication: :plain\n user_name: \"username@youdomain.com\"\n password: \"password\"\n\n3. Start up Redmine and test your Email\nNext it's time to start up Redmine and to send a test email. Make sure that you start Redmine in the same mode as you configured above (e.g. production). To send a test email:\nLogin as an administrator\nGo to the Administration panel\nGo into the Settings and select the \"Email notifications\" tab\nIn the bottom right, click the link to \"Send a test email\"", "created_at"=>2010-03-14 18:31:57 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
Redmine是用Rails写的一套很不错的项目管理系统,其提供了诸多很方便实用的功能,诸如里程碑管理,BUG跟踪,代码库变更管理等等。 \n搭建以后在管理面板中测试邮件不通,主要原因是由于采用的Gmail的邮箱,于是找到一些解决方案,如下: \n1. Install the action_mailer_optional_tls plugin \nThe action_mailer_optional_tls_plugin adds a TLS option to Redmine's emailing library, ActionMailer. TLS is a version of SSL which is required by GMail in order to send email.
\n\n
To install this plugin, use the script/plugin command in your Redmine directory: \n ./script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git
3. Start up Redmine and test your Email \nNext it's time to start up Redmine and to send a test email. Make sure that you start Redmine in the same mode as you configured above (e.g. production). To send a test email: \nLogin as an administrator \nGo to the Administration panel \nGo into the Settings and select the "Email notifications" tab \nIn the bottom right, click the link to "Send a test email"
\n", "_id"=>97}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["concat", "Database"], "comments_count"=>0, "category_id"=>3, "title"=>"MySQL CONCAT", "body"=>"MySQL CONCAT function is used to concatenate two strings to form a single string. Try out following example:\nmysql> SELECT CONCAT('FIRST ', 'SECOND');\n+----------------------------+\n| CONCAT('FIRST ', 'SECOND') |\n+----------------------------+\n| FIRST SECOND |\n+----------------------------+\n1 row in set (0.00 sec)\n\nie.\nmysql -u eoewallpapers -p123456123 wallpapers -e 'set names 'utf8'; select CONCAT(base_url,\"400\",title) from photos where state > 10 ' > photos_400.txt", "created_at"=>2010-03-19 20:34:34 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
MySQL CONCAT function is used to concatenate two strings to form a single string. Try out following example: \nmysql> SELECT CONCAT('FIRST ', 'SECOND'); \n+----------------------------+ \n| CONCAT('FIRST ', 'SECOND') | \n+----------------------------+ \n| FIRST SECOND | \n+----------------------------+ \n1 row in set (0.00 sec)
\n\n
ie. \nmysql -u eoewallpapers -p123456123 wallpapers -e 'set names 'utf8'; select CONCAT(base_url,"400",title) from photos where state > 10 ' > photos_400.txt
alias ls=”ls -G”是给”ls -G”起了一个别名,当执行ls时,就相当于执行了ls -G。
\n\n
CLICOLOR是用来设置是否进行颜色的显示。CLI是Command Line Interface的缩写。 \nLSCOLORS是用来设置当CLICOLOR被启用后,各种文件类型的颜色。LSCOLORS的值中每两个字母为一组,分别设置某个文件类型的文字颜色和背景颜色。LSCOLORS中一共11组颜色设置,按照先后顺序,分别对以下的文件类型进行设置:
\n\n
directory \nsymbolic link \nsocket \npipe \nexecutable \nblock special \ncharacter special \nexecutable with setuid bit set \nexecutable with setgid bit set \ndirectory writable to others, with sticky bit \ndirectory writable to others, without sticky bit \nLSCOLORS中,字母代表的颜色如下:
\n", "_id"=>103}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["10.6.3", "rails3", "railties"], "comments_count"=>0, "category_id"=>7, "title"=>"解决升级mac OS 10.6.3后rails3无法启动的问题", "body"=>"昨晚看hero的时候顺带update到mac OS 10.6.3,早上重启机器安装成功,发现rails3无法启动,报:\n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception)\nfrom /usr/bin/rails:19\n\n这个错误我之前安装rails3的时候遇到过,解决如下:\n1.先尝试下重新安装rails\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install rails --pre\nPassword:\nSuccessfully installed treetop-1.4.5\n1 gem installed\nInstalling ri documentation for treetop-1.4.5...\nInstalling RDoc documentation for treetop-1.4.5..\n发现多了个treetop的gem,查查是啥:\n
Treetop is a language for describing languages. Combining the elegance of Ruby with cutting-edge parsing expression grammars, it helps you analyze syntax with revolutionarily ease.
\n\n再次执行rails,发现\n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception)\n from /usr/bin/rails:19\n\n还是不行,那就是railties的问题了,重新装下\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install railties --pre\nSuccessfully installed railties-3.0.0.beta\n1 gem installed\nInstalling ri documentation for railties-3.0.0.beta...\nInstalling RDoc documentation for railties-3.0.0.beta...\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ rails -v\nRails 3.0.0.beta\n\nOK,可以了~", "created_at"=>2010-03-31 22:01:38 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
昨晚看hero的时候顺带update到mac OS 10.6.3,早上重启机器安装成功,发现rails3无法启动,报: \n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception) \nfrom /usr/bin/rails:19
\n\n
这个错误我之前安装rails3的时候遇到过,解决如下: \n1.先尝试下重新安装rails \nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install rails --pre \nPassword: \nSuccessfully installed treetop-1.4.5 \n1 gem installed \nInstalling ri documentation for treetop-1.4.5... \nInstalling RDoc documentation for treetop-1.4.5.. \n发现多了个treetop的gem,查查是啥: \nTreetop is a language for describing languages. Combining the elegance of Ruby with cutting-edge parsing expression grammars, it helps you analyze syntax with revolutionarily ease.
\n\n
再次执行rails,发现 \n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception) \n from /usr/bin/rails:19
做移动互联网的过程中,有这样一些词是必须知道的,如MO,MT,GSM,LINKID \n上行(MO)上行的意思就是短信发送到服务器端 MO又称 Mobile Original \n下行(MT)下行的意思就是短信从服务器端发回到手机上,MT又称Mobile Terminated \n简单的说,从手机发起一个的过程叫上行(MO),到手机结束的过程叫下行(MT),比如,平时给你的朋友发送一条短信,对你来说就是上行(MO),而对你的朋友来说,就是下行(MT)。在企业、行业应用中,从系统给手机发送信息的过程叫下行(MT),而手机发送信息给系统的过程叫上行(MO)。
\n", "_id"=>113}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["log", "rails3", "slice_before"], "comments_count"=>0, "category_id"=>2, "title"=>"Parse Rails 3 log file using Enumerable#slice_before", "body"=>"``def parse_rails_log_file(file)\n # Remove all empty lines\n lines = file.each_line.map(&:strip).reject(&:empty?)\n\n # Use +Enumerable#slice_before+ to slice log file into sections for each request\n lines.slice_before(/Started (GET|POST|PUT|DELETE)/).each_with_object({}) do |request_log, totals|\n # Only include successfully finished actions in report\n if duration = request_log.last[/Completed 200 OK in (?<duration>\\d+)ms/, :duration]\n action_name = request_log.first[/Started (GET|POST|PUT|DELETE) \"(?<action>.+?)\" for/, :action]\n totals[action_name] ||= 0\n totals[action_name] += duration.to_i\n end\n end\nend\n\nif __FILE__ == $PROGRAM_NAME\n require \"pp\"\n puts \"Parsing Rails 3 log file (extracting cumulative running time per request path):\"\n puts \"=================\"\n\n log_file = <<-LOG_FILE\n Started GET \"/index\" for 192.168.74.1 at 2010-03-09 11:37:40\n Processing by UpdatesController#index as HTML\n Update Load (0.5ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (16.7ms)\n Completed 200 OK in 71ms (Views: 44.3ms | ActiveRecord: 0.5ms)\n\n Started POST \"/updates\" for 192.168.74.1 at 2010-03-09 11:37:43\n Processing by UpdatesController#create as HTML\n Parameters: {\"commit\"=>\"Save changes\"}\n Update Load (0.4ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (1.3ms)\n Completed 200 OK in 60ms (Views: 32.1ms | ActiveRecord: 0.4ms)\n\n Started GET \"/updates\" for 192.168.74.1 at 2010-03-09 11:45:51\n Processing by UpdatesController#index as HTML\n\n TypeError (exception class/object expected):\n app/controllers/updates_controller.rb:3:in `raise'\n app/controllers/updates_controller.rb:3:in `index'\n\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.6ms)\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.9ms)\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb (23.9ms)\n\n Started GET \"/updates\" for 192.168.74.1 at 2010-03-09 11:45:58\n Processing by UpdatesController#index as HTML\n Update Load (0.3ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (1.1ms)\n Completed 200 OK in 100ms (Views: 29.3ms | ActiveRecord: 0.3ms)\n LOG_FILE\n\n pp parse_rails_log_file(log_file) # => {\"/index\"=>71, \"/updates\"=>160}\nend```", "created_at"=>2010-07-26 21:42:33 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
# Use +Enumerable#slice_before+ to slice log file into sections for each request \n lines.slice_before(/Started (GET|POST|PUT|DELETE)/).each_with_object({}) do |request_log, totals| \n # Only include successfully finished actions in report \n if duration = request_log.last[/Completed 200 OK in (?<duration>\\d+)ms/, :duration] \n action_name = request_log.first[/Started (GET|POST|PUT|DELETE) "(?<action>.+?)" for/, :action] \n totals[action_name] ||= 0 \n totals[action_name] += duration.to_i \n end \n end \nend
\n\n
if FILE == $PROGRAM_NAME \n require "pp" \n puts "Parsing Rails 3 log file (extracting cumulative running time per request path):" \n puts "================="
\n\n
log_file = <<-LOG_FILE \n Started GET "/index" for 192.168.74.1 at 2010-03-09 11:37:40 \n Processing by UpdatesController#index as HTML \n Update Load (0.5ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (16.7ms) \n Completed 200 OK in 71ms (Views: 44.3ms | ActiveRecord: 0.5ms)
\n\n
Started POST "/updates" for 192.168.74.1 at 2010-03-09 11:37:43 \n Processing by UpdatesController#create as HTML \n Parameters: {"commit"=>"Save changes"} \n Update Load (0.4ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (1.3ms) \n Completed 200 OK in 60ms (Views: 32.1ms | ActiveRecord: 0.4ms)
\n\n
Started GET "/updates" for 192.168.74.1 at 2010-03-09 11:45:51 \n Processing by UpdatesController#index as HTML
Started GET "/updates" for 192.168.74.1 at 2010-03-09 11:45:58 \n Processing by UpdatesController#index as HTML \n Update Load (0.3ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (1.1ms) \n Completed 200 OK in 100ms (Views: 29.3ms | ActiveRecord: 0.3ms) \n LOG_FILE
\n写完申明后,去看消息出处看到其竟然做了修改,我早料到其会做相关的行为,所有早些时候截了屏幕如下:\n\n\n\n而现在的文章被修改为:\n\n\n\n看我用鼠标标识的地方,对关键信息进行了修改,感兴趣的人可以去 http://mobile.venturebeat.com/2010/07/28/android-wallpaper-app-that-steals-your-data-was-downloaded-by-millions/ 查看原文,对于这种标题党用子虚乌有的事情炒作,等消息传播后再修改自己的内容算什么行为!而对国内部分媒体在传播时不但不对真实性进行验证,还添油加醋,歪曲意思的报道,我非常无奈(看到有人还说可以获取信用卡信息,还加密传输,我实在无语)。\n\n按照我个人的感觉,他们应该紧接着要开始拿这个事件来炒作自己的产品了,我个人懒得去关注,如果有人发现有人借此炒作自己的产品,请帮忙分析分析,看看到底是什么人用这样手法。\n\n再次update!!!\n\n通过email和mylookout的人取得联系,说明我取得诸如设备号,手机屏幕大小是为了更智能的给设备适配图片,而获取部分的sim卡号是后来用户反馈说自己换了手机还想使用之前的收藏记录才使用的,这些信息只在该应用中使用,并没提供给任何第三方!\n\n同时让其确认venturebeat上文章中说到的获取浏览器历史,短信息,密码等高敏感性信息是否是他们说的还是写文章的人自己写的(Lots of my users send me the email ask me why I collect their text message and voicemail passward, I just want to make sure whether you and your ceo said that I collected browsing history,text message ,voicemail passward during the meeting.)。\n\n其cto给我回复说他们没有说过我的应用获取过诸如text messages or browsing history这些信息( We never stated that the wallpaper applications gathered users text messages or browsing history.),是媒体在撰写和传播的时候错误报道了(A member of the press misreported our research and he has since corrected it. )。\n\n我非常无语~\n\n2010年8月4日第二次次update!\n\n多谢这些天很多朋友的关心,我很好,谢谢!这些天和google android组,lookout公司和venturebeat的作者,以及国内外很多媒体,博客们,记者们都有很多的接触。\n\n1. google就前段时间将应用暂停和我一起分析了这个应用,今天发来调查的结果:\n\nOur investigation has concluded that there's no obvious malicious code in your apps, though the implementation accesses data that it doesn't need to. We've restored your apps (and they'll be available on Market again once you publish them), and are looking forward to seeing them updated to use ANDROID_ID. We are likely to make a statement about this issue this week--I'll let you know.\n\n我早就说过,我配合调查,我把代码提供给他们,google也做出了公正的评判,另外也给我提了一些建议(ANDROID_ID)。\n\n2. 当时写这篇报道的venturebeat记者Dean Takahashi发来了mail,为自己犯的错误道歉,并道歉该事带来的恶劣影响,会再写一篇文章澄清这个事情以消除影响。\n\n3. 那个安全公司lookout的人写邮件来要于我一起“ We wanted to coordinate with you to prevent further misunderstandings. ”。\n\n4.好几个不认识的国外记者很负责任,发邮件和gt和我交流询问事情的真相,并帮我喊冤,谢谢这些有职业精神的记者们。\n\n这个事情到这差不多就结束了,其中看到很多假丑恶,也看到很多真善美!谢谢所有帮助过我的人(很多很多,就不一一列举)。", "created_at"=>2010-07-29 08:41:39 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
同时让其确认venturebeat上文章中说到的获取浏览器历史,短信息,密码等高敏感性信息是否是他们说的还是写文章的人自己写的(Lots of my users send me the email ask me why I collect their text message and voicemail passward, I just want to make sure whether you and your ceo said that I collected browsing history,text message ,voicemail passward during the meeting.)。
\n\n
其cto给我回复说他们没有说过我的应用获取过诸如text messages or browsing history这些信息( We never stated that the wallpaper applications gathered users text messages or browsing history.),是媒体在撰写和传播的时候错误报道了(A member of the press misreported our research and he has since corrected it. )。
Our investigation has concluded that there's no obvious malicious code in your apps, though the implementation accesses data that it doesn't need to. We've restored your apps (and they'll be available on Market again once you publish them), and are looking forward to seeing them updated to use ANDROID_ID. We are likely to make a statement about this issue this week--I'll let you know.
\n", "_id"=>115}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Munin", "netstat", "passive"], "comments_count"=>0, "category_id"=>7, "title"=>"Fix the passive netstat connections in Munin", "body"=>"\n\nIf your running Munin in WHM they you may have noticed the passive netstat connections have been rising steadily over the last couple of weeks. This isn't a problem with your server, its a Munin bug that can be easily fixed.\n\n\n\n\n\nApparently the problem stemms from Munin counting the passive connections rejected. You can fix this problem quite easily by following the instructions below\n\nEdit the following file:\n/usr/share/munin/plugins/netstat\n\nand change the line\n
If your running Munin in WHM they you may have noticed the passive netstat connections have been rising steadily over the last couple of weeks. This isn't a problem with your server, its a Munin bug that can be easily fixed.
\n\n\n\n
Apparently the problem stemms from Munin counting the passive connections rejected. You can fix this problem quite easily by following the instructions below
\n\n
Edit the following file: \n/usr/share/munin/plugins/netstat
\n", "_id"=>116}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Charts", "Highcharts", "rails"], "comments_count"=>0, "category_id"=>2, "title"=>"ChartsOnRails", "body"=>"这几天需要找到漂亮的Charts类库,找了几个,发现一个很不粗的,mark下待使用,介绍如下:\n\nHighcharts is a charting library written in pure JavaScript, offering an easy way of adding interactive charts to your web site or web application. Highcharts currently supports line, spline, area, areaspline, column, bar, pie and scatter chart types.\n\n有兴趣的可以参考如下连接去看看:\n\nhttp://highcharts.com/\n\nhttp://railscasts.com/episodes/223-charts\n\nhttp://www.spritle.com/blogs/?p=859", "created_at"=>2010-08-20 21:48:59 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
这几天需要找到漂亮的Charts类库,找了几个,发现一个很不粗的,mark下待使用,介绍如下:
\n\n
Highcharts is a charting library written in pure JavaScript, offering an easy way of adding interactive charts to your web site or web application. Highcharts currently supports line, spline, area, areaspline, column, bar, pie and scatter chart types.
Delete your debug certificate under ~/.android/debug.keystore (on Linux and Mac OS X); the directory is something like %USERHOME%/.androidon Windows.
\n\n
The Eclipse plugin should then generate a new certificate when you next try to build a debug package.
\n", "_id"=>122}])
+MONGODB iceylog_development['categories'].find({:_id=>12}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>12}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["brew"], "comments_count"=>0, "category_id"=>7, "title"=>"Installs Homebrew to /usr/local so you don't need sudo to `brew install`", "body"=>"$ curl https://raw.github.com/gist/323731/install_homebrew.rb -o /tmp/install_homebrew.rb\n % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n100 4569 100 4569 0 0 1605 0 0:00:02 0:00:02 --:--:-- 2346\n\n $ ruby /tmp/install_homebrew.rb\n==> This script will install:\n/usr/local/bin/brew\n/usr/local/Library/Formula/...\n/usr/local/Library/Homebrew/...\n==> The following directories will be made group writable:\n/usr/local/.\n/usr/local/bin\n==> The following directories will have their group set to admin:\n/usr/local/.\n/usr/local/bin\n\nPress enter to continue\n==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin\n==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin\n==> Downloading and Installing Homebrew...\nWarning: The following *evil* dylibs exist in /usr/local/lib\nThey may break builds or worse. You should consider deleting them:\n/usr/local/lib/libevent-1.4.2.1.3.dylib\n/usr/local/lib/libevent_core-1.4.2.1.3.dylib\n/usr/local/lib/libevent_extra-1.4.2.1.3.dylib\n/usr/local/lib/libkyotocabinet.4.8.0.dylib\n/usr/local/lib/libprotobuf-lite.6.dylib\n/usr/local/lib/libprotobuf.6.dylib\n/usr/local/lib/libprotoc.6.dylib\n==> Installation successful!\nNow type: brew help\n\n参考:https://gist.github.com/323731", "created_at"=>2011-09-03 08:29:42 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
$ curl https://raw.github.com/gist/323731/install_homebrew.rb -o /tmp/install_homebrew.rb \n % Total % Received % Xferd Average Speed Time Time Time Current \n Dload Upload Total Spent Left Speed \n100 4569 100 4569 0 0 1605 0 0:00:02 0:00:02 --:--:-- 2346
\n\n
$ ruby /tmp/install_homebrew.rb \n==> This script will install: \n/usr/local/bin/brew \n/usr/local/Library/Formula/... \n/usr/local/Library/Homebrew/... \n==> The following directories will be made group writable: \n/usr/local/. \n/usr/local/bin \n==> The following directories will have their group set to admin: \n/usr/local/. \n/usr/local/bin
\n\n
Press enter to continue \n==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin \n==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin \n==> Downloading and Installing Homebrew... \nWarning: The following evil dylibs exist in /usr/local/lib \nThey may break builds or worse. You should consider deleting them: \n/usr/local/lib/libevent-1.4.2.1.3.dylib \n/usr/local/lib/libevent_core-1.4.2.1.3.dylib \n/usr/local/lib/libevent_extra-1.4.2.1.3.dylib \n/usr/local/lib/libkyotocabinet.4.8.0.dylib \n/usr/local/lib/libprotobuf-lite.6.dylib \n/usr/local/lib/libprotobuf.6.dylib \n/usr/local/lib/libprotoc.6.dylib \n==> Installation successful! \nNow type: brew help
\n", "_id"=>123}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["perl", "Twig", "xml"], "comments_count"=>0, "category_id"=>7, "title"=>"install perl module for XML-Twig in RHEL-Red Hat/Fedora Linux?", "body"=>"This module provides a way to process XML documents. It is build on top of XML::Parser. XML::Twig offers a tree interface to the document, while allowing you to output the parts of it that have been completely processed. It allows minimal resource (CPU and memory) usage by building the tree only for the parts of the documents that need actual processing, through the use of the twig_roots and twig_print_outside_roots options.(as pointed by yum info)\r\n\r\nLet’s first search for the package\r\n$ yum search perl-XML-Twig\r\nperl-XML-Twig.noarch : A perl module for processing huge XML documents in tree\r\n\r\nNote that you must be the root/administrator to install the package. To install this package in Red Hat/Fedora Linux.\r\n$ yum install perl-XML-Twig.noarch\r\n\r\nYou can check the details of this package perl-XML-Twig\r\n$ yum info perl-XML-Twig.noarch\r\n\r\n或者:\r\nperl -MCPAN -e 'install XML::Twig'", "created_at"=>2011-12-10 10:53:02 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
This module provides a way to process XML documents. It is build on top of XML::Parser. XML::Twig offers a tree interface to the document, while allowing you to output the parts of it that have been completely processed. It allows minimal resource (CPU and memory) usage by building the tree only for the parts of the documents that need actual processing, through the use of the twig_roots and twig_print_outside_roots options.(as pointed by yum info)
\n\n
Let’s first search for the package \n$ yum search perl-XML-Twig \nperl-XML-Twig.noarch : A perl module for processing huge XML documents in tree
\n\n
Note that you must be the root/administrator to install the package. To install this package in Red Hat/Fedora Linux. \n$ yum install perl-XML-Twig.noarch
\n\n
You can check the details of this package perl-XML-Twig \n$ yum info perl-XML-Twig.noarch
USTATS module provides basic statistics for each backend in nginx upstreams:\r\n\r\nNumber of requests\r\nHttp 499/500/503 errors count\r\nTcp errors\r\nHttp read/write timeouts\r\nFail timeout\r\nMax fails count\r\nLast failed access time\r\nTotal fails count\r\nBlacklisted backend highlighting\r\nDown backends highlighting\r\nThe module allows you to sort values in some columns for each separate upstream. The data can be retrieved as JSON by appending \"?json\" to the end of location on which the module was set to work on (see configuration instructions below).
我们了解到socket模式的这个是backup,其他两个机器分别weight=3和weight=9,于是我们想监控下upstream每个后端具体处理了多少请求,有没有问题等,这个好像就不好监控了,nginx自带的status模块只能监控总的请求数,无法区分每个upstream的具体情况。 \n找到一个ustats(http://code.google.com/p/ustats/),其介绍是:NGINX basic upstream statistics module,具体的如下:<!--more--> \nUSTATS module provides basic statistics for each backend in nginx upstreams:
\n\n
Number of requests \nHttp 499/500/503 errors count \nTcp errors \nHttp read/write timeouts \nFail timeout \nMax fails count \nLast failed access time \nTotal fails count \nBlacklisted backend highlighting \nDown backends highlighting \nThe module allows you to sort values in some columns for each separate upstream. The data can be retrieved as JSON by appending "?json" to the end of location on which the module was set to work on (see configuration instructions below). \n看上去正是我需要的,有时间试试看~(为啥nginx不学haproxy官方自带一个详细statistics的页面呢~haproxy那个statistics很详细很好用~) \n详细使用指南:http://code.google.com/p/ustats/
\r\nThe reason is simple. I installed an extension called SEO Site Tools which installs an icon on the right of the address bar. When you click the button, on the window displayed there is the option “Show no follo” which is an option for displaying links that have the value nofollow for the attribute rel of an HTML element.\r\n\r\nThis attribute instructs some search engines that a hyperlink should not influence the link target’s ranking in the search engine’s index. (Source: wikipedia.org)\r\n
\r\n\r\n修复的方法很简单,去掉“Show no follo”的勾选就好了~\r\n", "created_at"=>2012-01-28 01:48:36 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
经过检查(Library/Application Support/Google/Chrome/Default/User StyleSheets/Custom.css),发现不是本地的css配置,最后找到是一个叫“SEO Site Tools”导致的,具体原因是: \n \nThe reason is simple. I installed an extension called SEO Site Tools which installs an icon on the right of the address bar. When you click the button, on the window displayed there is the option “Show no follo” which is an option for displaying links that have the value nofollow for the attribute rel of an HTML element.
\n\n
This attribute instructs some search engines that a hyperlink should not influence the link target’s ranking in the search engine’s index. (Source: wikipedia.org)
\n\n
修复的方法很简单,去掉“Show no follo”的勾选就好了~
\n", "_id"=>127}])
+MONGODB iceylog_development['categories'].find({:_id=>10}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>10}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Html/css/js"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["CoffeeScript", "Connect", "Express", "jade", "JavaScript", "Node.js", "npm"], "comments_count"=>0, "category_id"=>10, "title"=>"CoffeeScript解决JavaScript不美,Node.js潜力巨大", "body"=>"如果你对JavaScript感兴趣,但是不喜欢写一大堆一大堆的JavaScript代码,那真的不是你的错,因为很多人都说JavaScript不美,究其原因,可以归纳为:JavaScript的诞生是个悲剧. 它是函数式+动态语言的优秀内核, 却硬被绑上了C/Java的语法。\r\n\r\n如果你真的喜欢JavaScript,那么你可以尝试了解更多~比如CoffeeScript,再比如Node.js,再比如Connect,再比如Express,再再比如jade,再再再比如npm等等,于是我们从安装npm(a package manager for node)开始~\r\n\r\n#装npm\r\nice@mac:~ > curl http://npmjs.org/install.sh | sh\r\n % Total % Received % Xferd Average Speed Time Time Time Current\r\n Dload Upload Total Spent Left Speed\r\n100 7881 100 7881 0 0 3664 0 0:00:02 0:00:02 --:--:-- 8584\r\ntar=/usr/bin/tar\r\nversion:\r\nbsdtar 2.8.3 - libarchive 2.8.3\r\ninstall npm@1.1\r\nfetching: http://registry.npmjs.org/npm/-/npm-1.1.0-3.tgz\r\n0.6.2\r\n1.1.0-3\r\ncleanup prefix=/usr/local\r\n\r\nAll clean!\r\n/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js\r\nnpm@1.1.0-3 /usr/local/lib/node_modules/npm\r\nIt worked\r\n\r\n#看看怎么用\r\nice@mac:~ > npm help\r\n\r\nUsage: npm \r\n\r\nwhere is one of:\r\n adduser, apihelp, author, bin, bugs, c, cache, completion,\r\n config, deprecate, docs, edit, explore, faq, find, get,\r\n help, help-search, home, i, info, init, install, la, link,\r\n list, ll, ln, login, ls, outdated, owner, pack, prefix,\r\n prune, publish, r, rb, rebuild, remove, restart, rm, root,\r\n run-script, s, se, search, set, show, star, start, stop,\r\n submodule, tag, test, un, uninstall, unlink, unpublish,\r\n unstar, up, update, version, view, whoami\r\n\r\nnpm -h quick help on \r\nnpm -l display full usage info\r\nnpm faq commonly asked questions\r\nnpm help search for help on \r\nnpm help npm involved overview\r\n\r\nSpecify configs in the ini-formatted file:\r\n /Users/ice/.npmrc\r\nor on the command line via: npm --key value\r\nConfig info can be viewed via: npm help config\r\n\r\nnpm@1.1.0-3 /usr/local/lib/node_modules/npm\r\n\r\n#用npm装connect\r\nice@mac:~ > npm install connect\r\nnpm http GET https://registry.npmjs.org/connect\r\nnpm http 200 https://registry.npmjs.org/connect\r\nnpm http GET https://registry.npmjs.org/connect/-/connect-1.8.5.tgz\r\nnpm http 200 https://registry.npmjs.org/connect/-/connect-1.8.5.tgz\r\nnpm http GET https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/mime\r\nnpm http GET https://registry.npmjs.org/formidable\r\nnpm http 200 https://registry.npmjs.org/formidable\r\nnpm http 200 https://registry.npmjs.org/mime\r\nnpm http 200 https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/formidable/-/formidable-1.0.8.tgz\r\nnpm http GET https://registry.npmjs.org/mime/-/mime-1.2.4.tgz\r\nnpm http GET https://registry.npmjs.org/qs/-/qs-0.4.1.tgz\r\nnpm http 200 https://registry.npmjs.org/mime/-/mime-1.2.4.tgz\r\nnpm http 200 https://registry.npmjs.org/formidable/-/formidable-1.0.8.tgz\r\nnpm http 200 https://registry.npmjs.org/qs/-/qs-0.4.1.tgz\r\nconnect@1.8.5 ./node_modules/connect \r\n├── mime@1.2.4\r\n├── qs@0.4.1\r\n└── formidable@1.0.8\r\n\r\n#用npm装express\r\nice@mac:~ > npm install express\r\nnpm http GET https://registry.npmjs.org/express\r\nnpm http 200 https://registry.npmjs.org/express\r\nnpm http GET https://registry.npmjs.org/express/-/express-2.5.6.tgz\r\nnpm http 200 https://registry.npmjs.org/express/-/express-2.5.6.tgz\r\nnpm http GET https://registry.npmjs.org/mime\r\nnpm http GET https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/mkdirp/0.0.7\r\nnpm http 304 https://registry.npmjs.org/qs\r\nnpm http 304 https://registry.npmjs.org/mime\r\nnpm http 200 https://registry.npmjs.org/mkdirp/0.0.7\r\nnpm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.0.7.tgz\r\nnpm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.0.7.tgz\r\nexpress@2.5.6 ./node_modules/express \r\n├── mkdirp@0.0.7\r\n├── mime@1.2.4\r\n└── qs@0.4.1\r\n\r\n#用npm装jade\r\nice@mac:~ > npm install jade\r\nnpm http GET https://registry.npmjs.org/jade\r\nnpm http 200 https://registry.npmjs.org/jade\r\nnpm http GET https://registry.npmjs.org/jade/-/jade-0.20.0.tgz\r\nnpm http 200 https://registry.npmjs.org/jade/-/jade-0.20.0.tgz\r\nnpm http GET https://registry.npmjs.org/commander\r\nnpm http GET https://registry.npmjs.org/mkdirp\r\nnpm http 200 https://registry.npmjs.org/mkdirp\r\nnpm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz\r\nnpm http 200 https://registry.npmjs.org/commander\r\nnpm http GET https://registry.npmjs.org/commander/-/commander-0.2.1.tgz\r\nnpm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz\r\nnpm http 200 https://registry.npmjs.org/commander/-/commander-0.2.1.tgz\r\njade@0.20.0 ./node_modules/jade \r\n├── commander@0.2.1\r\n└── mkdirp@0.3.0\r\n\r\n好了,你入门了,更多资料,请自行查看如下链接的资料吧~\r\n\r\n相关资料\r\n\r\nCoffeeScript: CoffeeScript is a little language that compiles into JavaScript\r\nhttp://coffeescript.org/\r\n\r\n为什么CoffeeScript这么美?\r\nhttp://cnodejs.org/blog/?p=1584\r\n\r\nCoffeeScript: The beautiful way to write JavaScript\r\nhttp://amix.dk/blog/post/19612\r\n\r\n10个让朋友对你刮目相看的CoffeeScript单行代码绝技\r\nhttp://heikezhi.com/2011/06/08/10-coffeescript-one-liners-to-impress-your-friends/\r\n\r\nnpm: a package manager for node\r\nhttps://github.com/isaacs/npm\r\n\r\nExpress:http://expressjs.com/\r\nHigh performance, high class web development for Node.js\r\n\r\nConnect: Connect is a middleware layer for Node.js\r\nhttp://www.senchalabs.org/connect/\r\n\r\njade: http://jade-lang.com/\r\nNode Template Engine\r\n\r\ncoffee-box: Blog engine for fashionable developers. Built upon Node.js, Express, MongoDB and CoffeeScript.\r\nhttps://github.com/qiao/coffee-box", "created_at"=>2012-01-28 14:57:06 UTC, "updated_at"=>2012-06-24 15:35:10 UTC, "body_html"=>"
如果你真的喜欢JavaScript,那么你可以尝试了解更多~比如CoffeeScript,再比如Node.js,再比如Connect,再比如Express,再再比如jade,再再再比如npm等等,于是我们从安装npm(a package manager for node)开始~
\n\n
#装npm \nice@mac:~ > curl http://npmjs.org/install.sh | sh \n % Total % Received % Xferd Average Speed Time Time Time Current \n Dload Upload Total Spent Left Speed \n100 7881 100 7881 0 0 3664 0 0:00:02 0:00:02 --:--:-- 8584 \ntar=/usr/bin/tar \nversion: \nbsdtar 2.8.3 - libarchive 2.8.3 \ninstall npm@1.1 \nfetching: http://registry.npmjs.org/npm/-/npm-1.1.0-3.tgz \n0.6.2 \n1.1.0-3 \ncleanup prefix=/usr/local
\n\n
All clean! \n/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js \nnpm@1.1.0-3 /usr/local/lib/node_modules/npm \nIt worked \n<!--more-->
npm -h quick help on \nnpm -l display full usage info \nnpm faq commonly asked questions \nnpm help search for help on \nnpm help npm involved overview
\n\n
Specify configs in the ini-formatted file: \n /Users/ice/.npmrc \nor on the command line via: npm --key value \nConfig info can be viewed via: npm help config
首先安装Graphviz \n% brew install cairo pango graphviz # Homebrew on Mac OS X \n% sudo port install graphviz # Macports on Mac OS X \n% sudo aptitude install graphviz # Debian and Ubuntu
更多信息参考:http://rails-erd.rubyforge.org/ \n<!--more--> \n附:常见错误处理: \nCould not find gem 'choice (~> 0.1.4) ruby', which is required by gem 'rails-erd (>= 0) ruby', in any of the sources.
\n\n
原因是rails-erd依赖choice这个gem,装下 \nice@mac:/www/trunk > sudo gem install choice \nPassword: \nSuccessfully installed choice-0.1.4 \n1 gem installed \nInstalling ri documentation for choice-0.1.4... \nInstalling RDoc documentation for choice-0.1.4...
\n", "created_at"=>2012-06-24 15:43:35 UTC, "_id"=>1}])
+MONGODB iceylog_development['categories'].find({:_id=>1}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>1}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['system.namespaces'].find({})
+MONGODB iceylog_development['$cmd'].find({:create=>"sites"}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({"count"=>"sites", "query"=>{"$or"=>[{:url=>"http://www.iceskysl.com"}]}, "fields"=>nil}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"sites"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['sites'].insert([{"name"=>"Iceskysl Blog", "url"=>"http://www.iceskysl.com", "favicon"=>"http://www.google.com/profiles/c/favicons?domain=www.iceskysl.com", "updated_at"=>2012-06-24 15:43:35 UTC, "created_at"=>2012-06-24 15:43:35 UTC, "_id"=>1}])
+MONGODB [WARNING] Please note that logging negatively impacts client-side performance. You should set your logging level no lower than :info in production.
+MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1)
+MONGODB iceylog_development['system.namespaces'].find({})
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({"count"=>"categories", "query"=>{:name=>"Ruby & Rails"}, "fields"=>nil}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"categories"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['categories'].insert([{"sort"=>0, "posts_count"=>0, "name"=>"Ruby & Rails", "updated_at"=>2012-06-24 15:43:49 UTC, "created_at"=>2012-06-24 15:43:49 UTC, "_id"=>2}])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({"count"=>"categories", "query"=>{:name=>"Database"}, "fields"=>nil}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"categories"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['categories'].insert([{"sort"=>0, "posts_count"=>0, "name"=>"Database", "updated_at"=>2012-06-24 15:43:49 UTC, "created_at"=>2012-06-24 15:43:49 UTC, "_id"=>3}])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['system.namespaces'].find({})
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["ruby"], "comments_count"=>0, "category_id"=>2, "title"=>"Check for nil and initialize on a single line", "body"=>"点评:关于ROR中的一中“遇nil赋值”的写法,这个很早的时候在书上看到的是||=操作符,也一直这么用,今天发现作者的另外这个写法也挺好的。\n\nSometimes, you want to initialize a variable to some value only if that variable is equal to nil. If you like to write your methods as short, clean and readable as possible, you can do that task in a single line instead of taking the traditionnal 3 lines approach. You have two options :\n\n1) You can use the if modifier 1. x = get_some_object if x.nil?Very easy to read. This is my favorite.\n\n2) Or you can use the ||= operator 1. x ||= get_some_object This one is even shorter. The ||= operator is a little bit less verbose and might confuse a ruby newcomer… but I’m not saying that it should be a reason for not using it. This is more a matter of personal taste than anything else.Both of these methods are better than this :\n\n1. #eeww… we don’t like this one.\n\n2. if(x.nil?)\n\n3. x = get_some_object 4. end", "created_at"=>2007-05-19 01:23:10 UTC, "updated_at"=>2012-06-24 15:43:49 UTC, "body_html"=>"
Sometimes, you want to initialize a variable to some value only if that variable is equal to nil. If you like to write your methods as short, clean and readable as possible, you can do that task in a single line instead of taking the traditionnal 3 lines approach. You have two options :
\n\n
1) You can use the if modifier 1. x = get_some_object if x.nil?Very easy to read. This is my favorite.
\n\n
2) Or you can use the ||= operator 1. x ||= get_some_object This one is even shorter. The ||= operator is a little bit less verbose and might confuse a ruby newcomer… but I’m not saying that it should be a reason for not using it. This is more a matter of personal taste than anything else.Both of these methods are better than this :
$ uname -a\r\nLinux oj-web03 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux
\r\n
[iceskysl@oj-web03 logs]$ cat /proc/version\r\nLinux version 2.4.21-27.ELsmp (bhcompile@bugs.build.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47)) #1 SMP Wed Dec 1 21:59:02 EST 20045、内存信息$ cat /proc/meminfo\r\n$ free -M6、CPU信息$cat /proc/cpuinfo7、硬盘信息\r\n$df\r\n\r\n
(1)用客户端连接到数据库,执行select * from v$instance查看version项 \n(2)select * from product_component_version \n(3)或查询V$VERSION查看组件级信息
\n\n
4、内核 \n$ uname -a \nLinux oj-web03 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux \n[iceskysl@oj-web03 logs]$ cat /proc/version \nLinux version 2.4.21-27.ELsmp (bhcompile@bugs.build.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47)) #1 SMP Wed Dec 1 21:59:02 EST 20045、内存信息$ cat /proc/meminfo \n$ free -M6、CPU信息$cat /proc/cpuinfo7、硬盘信息 \n$df
\n\n", "_id"=>4}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Security"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["ruby", "安全", "漏洞"], "comments_count"=>0, "category_id"=>8, "title"=>"Ruby暴出大量严重漏洞!", "body"=>"Drew Yao at Apple uncovered a handful of nasty security vulnerabilities affecting all current versions of Ruby. The details are still under wraps because an attacker can DoS you or possibly execute arbitrary code—holy crap! Better upgrade sooner than later.\n\nAccording to the official Ruby security advisory, the vulnerable Rubies are:\n\n* 1.8.4 and earlier\n* 1.8.5-p230 and earlier\n* 1.8.6-p229 and earlier\n* 1.8.7-p21 and earlier\n\nThose of us running Ruby 1.8.4 or earlier must upgrade to 1.8.5 or later for a fix. Those on 1.8.5-7 can grab the latest patchlevel release for a fix.\n\n(Please note: Ruby 1.8.7 breaks backward compatibility and is only compatible with Rails 2.1 and later, so don’t go overboard!)\n虽然暂时还没看到具体的细节公布出来,也没看到0day放出来,但是从其描述上不难看出,这些bug是ruby一致以来都有的,或许还有更多的bug,ruby走向成熟,离不开这样的检验。", "created_at"=>2008-06-25 06:05:42 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
Drew Yao at Apple uncovered a handful of nasty security vulnerabilities affecting all current versions of Ruby. The details are still under wraps because an attacker can DoS you or possibly execute arbitrary code—holy crap! Better upgrade sooner than later.
\n\n
According to the official Ruby security advisory, the vulnerable Rubies are:
\n\n
\n
1.8.4 and earlier
\n
1.8.5-p230 and earlier
\n
1.8.6-p229 and earlier
\n
1.8.7-p21 and earlier
\n
\n\n
Those of us running Ruby 1.8.4 or earlier must upgrade to 1.8.5 or later for a fix. Those on 1.8.5-7 can grab the latest patchlevel release for a fix.
\n\n
(Please note: Ruby 1.8.7 breaks backward compatibility and is only compatible with Rails 2.1 and later, so don’t go overboard!) \n虽然暂时还没看到具体的细节公布出来,也没看到0day放出来,但是从其描述上不难看出,这些bug是ruby一致以来都有的,或许还有更多的bug,ruby走向成熟,离不开这样的检验。
\n", "_id"=>6}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["rsync"], "comments_count"=>0, "category_id"=>9, "title"=>"同步利器rsync", "body"=>"rsync is a program that copies file from one location to another, with it you can make backups of your files, synchronize data on different locations and computers. It is commonly used by unix users to keep a safe backup of their files and is often recommended as the simplest solution for backups and safety copys.\r\n\r\n参考资料:\r\n\r\n1.rsync的安装和使用\r\n\r\n2. rsync", "created_at"=>2008-06-25 19:58:32 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
rsync is a program that copies file from one location to another, with it you can make backups of your files, synchronize data on different locations and computers. It is commonly used by unix users to keep a safe backup of their files and is often recommended as the simplest solution for backups and safety copys.
A gravatar, or globally recognized avatar, is quite simply an avatar image that follows you from weblog to weblog appearing beside your name when you comment on gravatar enabled sites. Avatars help identify your posts on web forums, so why not on weblogs?
\r\n看明白了么,就是一个你输入自己的Email,然后上传自己的图片标识,然后在其他支持 Gravatars的网站(blog居多)中发表评论的时候输入自己的Email地址,就可以在Gravatars上找到其对应的图片来显示了。\r\n\r\n这确实是个不错的Idea,相当简单,但是也做得有声有色的,有点意思。\r\n\r\n使用也很方便,其在“How the URL is constructed”上介绍了其URL的组成,中可以这么使用(来源Gravatars on Rails):\r\n\r\n\r\n\r\n1、首先在````application_helper.rb中增加一个helper方法```\r\n
这个世界有意思,多大的idea都可以做成网站,以前看过缩址的网站,现在有看到一个省份标识的网站, Gravatars,看他的介绍: \nA gravatar, or globally recognized avatar, is quite simply an avatar image that follows you from weblog to weblog appearing beside your name when you comment on gravatar enabled sites. Avatars help identify your posts on web forums, so why not on weblogs? \n看明白了么,就是一个你输入自己的Email,然后上传自己的图片标识,然后在其他支持 Gravatars的网站(blog居多)中发表评论的时候输入自己的Email地址,就可以在Gravatars上找到其对应的图片来显示了。
\n\n
这确实是个不错的Idea,相当简单,但是也做得有声有色的,有点意思。
\n\n
使用也很方便,其在“How the URL is constructed”上介绍了其URL的组成,中可以这么使用(来源Gravatars on Rails):
晓得TDD,BDD,RSpec这些东西很久了,也看了不少的资料和教程,但总感觉还在门外徘徊,始终不得其要,真是怪异。应该是没在实际项目中实践过的缘故吧。 \n本文记录一些RSpec和BDD(Behaviour Driven Development )的资料和文档,给我自己也给各位路过者提供一些资料,感兴趣的仔细看看吧。 \n \n http://rspec.info/ \n Telling a good story - Rspec stories from the trenches \n Slides from RailsConf \n rspec plain text stories + webrat = chunky bacon! \n http://chinaonrails.com/topic/view/220.html \n Story Driven Development with Rails - Part I: Up and Running \n \n另外,http://rspec.info/documentation/rails/上的资料非常棒。有路过的,玩BDD的朋友还望多多指教,领我进门,多谢!
\n", "_id"=>18}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Html/css/js"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Android & Java"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({"count"=>"categories", "query"=>{:name=>"Android & Java"}, "fields"=>nil}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"categories"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['categories'].insert([{"sort"=>0, "posts_count"=>0, "name"=>"Android & Java", "updated_at"=>2012-06-24 15:43:51 UTC, "created_at"=>2012-06-24 15:43:51 UTC, "_id"=>12}])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Thin"], "comments_count"=>0, "category_id"=>6, "title"=>"Thin version 1.0.0 is out!", "body"=>"Thin version 1.0.0 (codename That's What She Said) is out!\r\n\r\nYes 1.0! That doesn't mean it's bug free or anything. But, it does\r\nmean that it's been running on a number of servers and no show stopper\r\nbugs have been found since a while.\r\n\r\nAlso see http://macournoyer.wordpress.com/2008/09/30/thin-10/\r\n\r\n== What's new?\r\n\r\n* Fixed vlad.rake to allow TCP or socket [hellekin]\r\n* Updated Mack adapter to handle both <0.8.0 and >0.8.0 [Mark Bates]\r\n* rails rack adapter uses File.readable_real? so it recognizes ACL\r\npermissions [Ricardo Chimal]\r\n* Log a warning if Rack application returns nil body [Michael S.\r\nKlishin]\r\n* Handle nil and Time header values correctly [#76 state:resolved]\r\n[tmm1]\r\n* Add Content-Length header to response automatically when possible\r\n[#74 state:resolved] [dkubb]\r\n* Runner now remembers -r, -D and -V parameters so that clustered\r\nservers inherit those and\r\nkeep your parameters.\r\n* Make Set-Cookie header, in Rails adapter, compatible with current\r\nRack spec [Pedro Belo]\r\n[#73, state:resolved]\r\n* Add --no-epoll option to disable epoll usage on Linux [#61\r\nstate:resolved]\r\n* Add --force (-f) option to force stopping of a daemonized server\r\n[#72 state:resolved]\r\n* Update halycon adapter loader [mtodd]\r\n\r\n== Get it!\r\n\r\nInstall Thin from RubyForge:\r\n\r\ngem install thin\r\n\r\nOr using my mirror:\r\n\r\ngem install thin --source http://code.macournoyer.com\r\n\r\n参考文档:\r\nhttp://groups.google.com/group/thin-ruby/browse_thread/thread/402d51a6d9f2651d", "created_at"=>2008-10-07 09:56:27 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
Thin version 1.0.0 (codename That's What She Said) is out!
\n\n
Yes 1.0! That doesn't mean it's bug free or anything. But, it does \nmean that it's been running on a number of servers and no show stopper \nbugs have been found since a while.
Search directory arguments recursively for files to convert.
\r\n\t
-d or --delete
\r\n\t
delete input files after successful conversion. May not be safe yet!!!
\r\n\t
-v or --verbose
\r\n\t
makes sneetchalizer more chatty.
\r\n\t
-s or --show-output
\r\n\t
shows output from conversion tool.
\r\n\t
-p or --pretend
\r\n\t
don't convert anything. sneetchalizer will go through the motions and print out the commands it would run. Useful for preview- ing a complex command line to ensure it does what you intend. You should interpret this option's output with a grain of salt. For example, if you include the '--sanitize' option, the files will not really be renamed when using --pretend, and as such the command's output will not reflect that the filenames would be changed during an actual run.
\r\n\t
-t or --terminate
\r\n\t
terminate sneetchalizer options. This is useful if you have to convert '--coolDir' or '-groovySong.mp3'. This is the only option whose order on the command line is significant.
\r\n\t
-D ARG or --out-directory=ARG
\r\n\t
write all outfiles to a directory argument. This is useful if you want to (re)encode files directly to a mounted portable device.
\r\n\t
--strict and --pedantic
\r\n\t
many errors that sneetchalizer may encounter are recoverable, such as specifying a directory as argument that contains no files to convert, or conversion failures in general. By default the script will print an error message and move on to the next file. If you use '--strict' then sneetchalizer will bail out at the first sign of trouble except for tag errors. With '--pedantic' the script will stop even on tag errors.
\r\n\t
--stasis
\r\n\t
Preserve timestamp (mtime) of original file.
\r\n\t
--threads [N]
\r\n\t
Experimental. Use threads to create concurrent jobs. This option takes an optional integer argument which represents the number of threads to launch. The default is two. Preliminary tests suggest there is little advantage (and even diminishing returns) when setting this number greater than the number of cores/CPUs you have. Due to the asychronous nature of threads the --verbose and --show-output flags will be silently disabled and most screen output is supressed.
\r\n\t
--sanitize
\r\n\t
Removes ,, ;, :, ', \", %, @, #, and ` from filenames and tags.
\r\n\t
-n [FORMAT] or --rename[=FORMAT]
\r\n\t
rename all outfiles (and temporary wavs) according to FORMAT. FORMAT is a string with special designators to be pulled from the file tags. The following options are available:
\r\n\t
\r\n\t
* %t Song title
\r\n\t
* %b Album title
\r\n\t
* %n Track number
\r\n\t
* %a Artist name
\r\n\t
* %y Year
\r\n\t
* %g Genre
\r\n\t
* %c Comment field
\r\n\t
\r\n\t
Directories may be created with this command, as in \"%b/%n - %t\". The default value of FORMAT is \"%n %t\".
\r\n\t
\r\n\t
Bitrate/Quality/Compression options:
\r\n\t
\r\n\t
-b or --bitrate
\r\n\t
mp3/ogg/m4a bitrate.
\r\n\t
-q or --quality
\r\n\t
mp3/ogg quality.
\r\n\t
\r\n\t
quality and bitrate are passed directly to lame or oggenc depending on mp3 or ogg output format respectively. Both tools can handle either a bitrate or quality argument, so it is important to understand what values are valid for the underlying tool in your specific use case. faac will accept a bitrate argument, but not a quality argument. These options will be silently ignored for any output formats other than mp3, ogg or m4a. Make sure you know what you are doing if you decide to use both in one run, and read each tools manpage for valid values. If these options are omitted the tools builtin defaults are used (-q3 for oggenc and -q5 for lame).
\r\n\t
\r\n\t
-c or --compression
\r\n\t
flac/mac compression level.
\r\n\t
\r\n\t
this option allows you to pass a compression argument to flac and mac. See 'flac --help' and/or 'mac --help' if you don't know what this means.
\r\n\t
\r\n\t
Format Options:
\r\n\t
\r\n\t
--out=format
\r\n\t
output format. Default is wav.
\r\n\t
--in=format[,format..]
\r\n\t
input format(s). Default is wav.
\r\n\t
\r\n\t
Valid output formats are: \"aac\", \"aif\", \"aifc\", \"aiff\", \"aiffc\", \"ape\", \"au\", \"cdr\", \"cdda\", \"copy\", \"flac\", \"m4a\", \"m4b\", \"mpc\", \"mp4\", \"mpp\", \"mp3\", \"mp2\", \"ofr\", \"ofs\", \"ogg\", \"snd\", \"spx\", \"tta\", \"wav\", \"wv\". Valid input formats are all of the above plus \"wma\". You can specify multiple input formats using a comma: 'mp3,m4a,wma'. Input format is only neccesary when passing directory arguments, as file arguments are handled by context (read: file extension). The \"copy\" output option copies files directly, bypassing decoding/encoding steps (useful in conjunction with --rename).
\r\n\t
\r\n\t
Tagging Options:
\r\n\t
\r\n\t
--tt or --title
\r\n\t
Set 'title' tag.
\r\n\t
--ta or --artist
\r\n\t
Set 'artist' tag.
\r\n\t
--tl or --album
\r\n\t
Set 'album' tag.
\r\n\t
--ty or --year
\r\n\t
Set 'year' tag.
\r\n\t
--tc or --comment
\r\n\t
Set 'comment' tag.
\r\n\t
--tg or --genre
\r\n\t
Set 'genre' tag.
\r\n\t
--tn or --trackn
\r\n\t
Set 'track number' tag.
\r\n\t
\r\n\t
The short and long versions are different in an important way: Using the long version will clobber any existing tags. The short version will only set the tag if the existing tag has no value. Note that these tags will be placed in _every_ outfile during the run.
\r\n\t
\r\n\t
Alternative Encoder/Decoder Options:
\r\n\t
\r\n\t
--gogo
\r\n\t
use gogo to encode mp3 files.
\r\n\t
--bladeenc
\r\n\t
use bladeenc to encode mp3 files.
\r\n\t
\r\n\t
The default is still 'lame'. If 'lame' is not found, the script will search for one of these two encoders regardless if these options are passed or not.
\r\n\t
\r\n\t
Special Options:
\r\n\t
\r\n\t
--in-optionhook=ARG
\r\n\t
add ARG to infile conversion command. Possibly dangerous!
\r\n\t
--out-optionhook=ARG
\r\n\t
add ARG to outfile conversion command. Possibly dangerous!
Using the same --in and --out format allows us to resample/encode the file at a different bitrate or quality. Note that this will overwrite the original file so only do this on a copy, or use '-D' to write files to another directory.
直接下载其gz包,sneetchalizer-0.9.0是现在的最新版本。下载解包后可以看到: \n \nManifest: \n \n README - You're reading it now. \n LICENSE - A copy of the GPL, under which sneetchalizer is released. \n CHANGES - sneetchalizer's cvs/svn commit log. \n sneetchalizer - The script itself. \n sneetchalizer.1 - The manpage for sneetchalizer. \n sneetchalizer.desktop - A KDE service menu for converting with Konqueror. \n install.rb - A quick and dirty script to install the sneetchalizer. \n \n \n如果有root权限,可以直接运行install.rb,其会将sneetchalizer拷贝到/usr/bin下,将sneetchalizer.1拷贝到/usr/share/man/man1下。
\n\n
2、参数解释
\n\n
不翻译了,都挺简单明了的,如下: \n \nXML/HTML代码 \n \n General options: \n \n -h or --help \n Print quick or full usage details respectively. \n -r or --recursive \n Search directory arguments recursively for files to convert. \n -d or --delete \n delete input files after successful conversion. May not be safe yet!!! \n -v or --verbose \n makes sneetchalizer more chatty. \n -s or --show-output \n shows output from conversion tool. \n -p or --pretend \n don't convert anything. sneetchalizer will go through the motions and print out the commands it would run. Useful for preview- ing a complex command line to ensure it does what you intend. You should interpret this option's output with a grain of salt. For example, if you include the '--sanitize' option, the files will not really be renamed when using --pretend, and as such the command's output will not reflect that the filenames would be changed during an actual run. \n -t or --terminate \n terminate sneetchalizer options. This is useful if you have to convert '--coolDir' or '-groovySong.mp3'. This is the only option whose order on the command line is significant. \n -D ARG or --out-directory=ARG \n write all outfiles to a directory argument. This is useful if you want to (re)encode files directly to a mounted portable device. \n --strict and --pedantic \n many errors that sneetchalizer may encounter are recoverable, such as specifying a directory as argument that contains no files to convert, or conversion failures in general. By default the script will print an error message and move on to the next file. If you use '--strict' then sneetchalizer will bail out at the first sign of trouble except for tag errors. With '--pedantic' the script will stop even on tag errors. \n --stasis \n Preserve timestamp (mtime) of original file. \n --threads [N] \n Experimental. Use threads to create concurrent jobs. This option takes an optional integer argument which represents the number of threads to launch. The default is two. Preliminary tests suggest there is little advantage (and even diminishing returns) when setting this number greater than the number of cores/CPUs you have. Due to the asychronous nature of threads the --verbose and --show-output flags will be silently disabled and most screen output is supressed. \n --sanitize \n Removes ,, ;, :, ', ", %, @, #, and ` from filenames and tags. \n -n [FORMAT] or --rename[=FORMAT] \n rename all outfiles (and temporary wavs) according to FORMAT. FORMAT is a string with special designators to be pulled from the file tags. The following options are available: \n \n * %t Song title \n * %b Album title \n * %n Track number \n * %a Artist name \n * %y Year \n * %g Genre \n * %c Comment field \n \n Directories may be created with this command, as in "%b/%n - %t". The default value of FORMAT is "%n %t". \n \n Bitrate/Quality/Compression options: \n \n -b or --bitrate \n mp3/ogg/m4a bitrate. \n -q or --quality \n mp3/ogg quality. \n \n quality and bitrate are passed directly to lame or oggenc depending on mp3 or ogg output format respectively. Both tools can handle either a bitrate or quality argument, so it is important to understand what values are valid for the underlying tool in your specific use case. faac will accept a bitrate argument, but not a quality argument. These options will be silently ignored for any output formats other than mp3, ogg or m4a. Make sure you know what you are doing if you decide to use both in one run, and read each tools manpage for valid values. If these options are omitted the tools builtin defaults are used (-q3 for oggenc and -q5 for lame). \n \n -c or --compression \n flac/mac compression level. \n \n this option allows you to pass a compression argument to flac and mac. See 'flac --help' and/or 'mac --help' if you don't know what this means. \n \n Format Options: \n \n --out=format \n output format. Default is wav. \n --in=format[,format..] \n input format(s). Default is wav. \n \n Valid output formats are: "aac", "aif", "aifc", "aiff", "aiffc", "ape", "au", "cdr", "cdda", "copy", "flac", "m4a", "m4b", "mpc", "mp4", "mpp", "mp3", "mp2", "ofr", "ofs", "ogg", "snd", "spx", "tta", "wav", "wv". Valid input formats are all of the above plus "wma". You can specify multiple input formats using a comma: 'mp3,m4a,wma'. Input format is only neccesary when passing directory arguments, as file arguments are handled by context (read: file extension). The "copy" output option copies files directly, bypassing decoding/encoding steps (useful in conjunction with --rename). \n \n Tagging Options: \n \n --tt or --title \n Set 'title' tag. \n --ta or --artist \n Set 'artist' tag. \n --tl or --album \n Set 'album' tag. \n --ty or --year \n Set 'year' tag. \n --tc or --comment \n Set 'comment' tag. \n --tg or --genre \n Set 'genre' tag. \n --tn or --trackn \n Set 'track number' tag. \n \n The short and long versions are different in an important way: Using the long version will clobber any existing tags. The short version will only set the tag if the existing tag has no value. Note that these tags will be placed in _every_ outfile during the run. \n \n Alternative Encoder/Decoder Options: \n \n --gogo \n use gogo to encode mp3 files. \n --bladeenc \n use bladeenc to encode mp3 files. \n \n The default is still 'lame'. If 'lame' is not found, the script will search for one of these two encoders regardless if these options are passed or not. \n \n Special Options: \n \n --in-optionhook=ARG \n add ARG to infile conversion command. Possibly dangerous! \n --out-optionhook=ARG \n add ARG to outfile conversion command. Possibly dangerous! \n \n \n另外,你可以运行sneetchalizer -h看到简要的使用说明,也可以使用sneetchalizer --help看到详细的使用信息。
\n\n
3、使用示例
\n\n
如下简要的写几个使用的示例: \n \n使用示例: \n \n $ sneetchalizer song.mp3 \n \n The most simple possible example, creates 'song.wav'. \n \n $ sneetchalizer --out=ogg --in=flac -q5 /some/music/dir \n \n This example converts every flac file in '/some/music/dir' to ogg format at quality 5. \n \n $ sneetchalizer -d --out=mp3 --in=ogg,m4a,wma -b 160 . \n \n Converts every ogg, m4a, and wma file in the current directory to a 160 kbps constant bitrate mp3 file. The original files are deleted. \n \n $ sneetchalizer --out=mp3 --out-optionhook="--preset extreme" /some/wavs \n \n Here we encode every wav in '/some/wavs' to mp3 format passing '--preset extreme' directly to lame. \n \n $ sneetchalizer --in=ogg --out=ogg --quality=1 norvegianWood.ogg /some/more/oggs \n \n Using the same --in and --out format allows us to resample/encode the file at a different bitrate or quality. Note that this will overwrite the original file so only do this on a copy, or use '-D' to write files to another directory. \n \n $ sneetchalizer --in=ogg --out=m4a -D /mnt/ipod/ /some/oggs \n \n Here we re-encode some ogg files to m4a format and write them to our mounted iPod. \n \n \n4、注意事项
\n\n
本脚本只是粘合剂,其他的tool还是需要另外安装的。
\n\n
其他信息请参考其主页说明,如果您有这个方面的问题或经验,欢迎和我讨论。
\n\n\n
\n", "_id"=>20}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["架构"], "comments_count"=>0, "category_id"=>9, "title"=>"网站架构文章列表(持续更新中)", "body"=>"互联网越来越开放,技术人员也越来越乐于分享,分析构架、演变和遇到的问题,虽然说没有真正经历过,很多体验可能会没那么深,但是有些东西提前了解会有诸多好处。在很多地方看到类似的构架分析、分享的文章,统一收集整理如下,遇到其他的,我会持续更新,如果经历允许,我还会写一些读后感或者点评;如果你看到其他的类似文章或者点评,欢迎留言让我知道。\n\n对dbanotes等表示感谢。\n\nWikiPedia 技术架构学习分享\nhttp://www.dbanotes.net/opensource/wikipedia_arch.html\n\nYouTube 的架构扩展\nhttp://www.dbanotes.net/opensource/youtube_web_arch.html\n\nLinkedIn 架构笔记\nhttp://www.dbanotes.net/arch/linkedin.html\n\nLinkedIn 架构与开发过程\nhttp://www.dbanotes.net/arch/linkedin_soa.html\n\nInternet Archive 的海量存储浅析\nhttp://www.dbanotes.net/database/internet_archive_storage.html\n\nTailrank 网站架构\nhttp://www.dbanotes.net/review/tailrank_arch.html\n\nTwitter 的架构扩展: 100 倍性能提升\nhttp://www.dbanotes.net/arch/twitter_arch.html\n\n财帮子(caibangzi.com)网站架构\nhttp://www.dbanotes.net/arch/caibangzi_web_arch.html\n\nYupoo! 的网站技术架构\nhttp://www.dbanotes.net/arch/yupoo_arch.html\n\n37Signals 架构\nhttp://www.dbanotes.net/arch/37signals_arch.html\n\nFlickr 的访问统计实现以及其他\nhttp://www.dbanotes.net/arch/flickr_stats_and_dathan.html\n\nPlentyOfFish 网站架构学习\nhttp://www.dbanotes.net/arch/plentyoffish_arch.html\n\nYahoo!社区架构\nhttp://www.dbanotes.net/arch/yahoo_arch.html\n\n有关 Alexa 与 AOL 部署集群文件系统\nhttp://www.dbanotes.net/arch/alexa_ibrix_san_file_system.html\n\neBay 的存储一瞥\nhttp://www.dbanotes.net/arch/ebay_storage.html\n\neBay 的数据量\nhttp://www.dbanotes.net/database/ebay_storage.html\n\neBay 的数据库分布扩展架构\nhttp://www.dbanotes.net/database/ebay_database_scale_out.html\n\neBay 的数据层扩展经验\nhttp://www.dbanotes.net/arch/ebay_db_scale_out.html\n\neBay 的应用服务器规模\nhttp://www.dbanotes.net/web/ebay_application_server.html\n\n性能扩展问题要趁早\nhttp://www.dbanotes.net/arch/scaling_an_early_stage_startup.html\n\nScaling an early stage startup\nhttp://www.scribd.com/doc/429986/Scaling-an-early-stage-startup\n\nFacebook 的 PHP 性能与扩展性\nhttp://www.dbanotes.net/arch/facebook_php.html\n\nSkype 用 PostgreSQL 支撑海量用户\nhttp://www.dbanotes.net/arch/skype_postgresql.html\n\n闲谈 Web 图片服务器\nhttp://www.dbanotes.net/web/web_image_server.html\n\n说说北京奥运购票系统瘫痪这事儿\nhttp://www.dbanotes.net/review/beijing_olympic_ticketes_system_crash.html\n\nArchitectures You’ve Always Wondered About\nhttp://qcon.infoq.com/london-2008/tracks/show_track.jsp?trackOID=82\n\neBay’s Architectural Principles\nhttp://www.eos1.dk/qcon-london-2008/slides/RandyShoup_eBaysArchitecturalPrinciples.pdf\n\nBuilding a large scale SaaS app\nhttp://www.eos1.dk/qcon-london-2008/slides/Dan_Hanley_Building_a_large_scale_SaaS_app.pdf\n\nScaling an early stage startup\nhttp://www.scribd.com/doc/429986/Scaling-an-early-stage-startup\n\n互联星空播客架构(原文在张宴blog上,但是后来文章撤下,很可惜.此为转载)\nhttp://www.flashmov.com/blog_1632.html\n\nQQ游戏百万人同时在线服务器架构实现\nhttp://www.libing.net.cn/read.php?41\n\n大型Web2.0站点构建技术初探\nhttp://blog.csdn.net/heiyeshuwu/archive/2007/11/18/1890793.aspx\n\nWeb站点数据库分布存储浅谈\nhttp://blog.csdn.net/heiyeshuwu/archive/2007/11/18/1891639.aspx\n\nQQ的架构讨论\nhttp://groups.google.com/group/dev4server/browse_thread/thread/0d72668d11c4886b/a6d202489cabf285#a6d202489cabf285\n\nNotes from Scaling MySQL - Up or Out\nhttp://venublog.com/2008/04/16/notes-from-scaling-mysql-up-or-out/\n\nYapache-Yahoo! Apache 的秘密\nhttp://www.dbanotes.net/web/yapache_yahoo_apache.html\n\nScalability Best Practices: Lessons from eBay\nhttp://www.infoq.com/articles/ebay-scalability-best-practices", "created_at"=>2008-10-09 06:51:05 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
Google的产品很多都深得我心,一直在使用,整理整合了一些Gmail的快捷方式,备忘。 \n \n \n \n快捷键 \n定义 \n作用 \n \n \nc \nCompose \n撰写新邮件。“Shift+C”打开新窗口撰写新邮件 \n \n \n<tab> then <Enter> \nSend message \n新邮件撰写完后,先<tab>后<Enter>可发送邮件。(在Windows中,使用IE和Firefox有效) \n \n \nk \nMove to newer conversation \n在收件箱中,向上移动光标,按<Enter>查看邮件;在查看邮件时,打开下一封新邮件 \n \n \nj \nMove to older conversation \n在收件箱中,向下移动光标,按<Enter>查看邮件;在查看邮件时,打开下一封旧邮件 \n \n \nn \nNext message \n查看邮件时,定位光标到 \n \n \np \nPrevious message \n移动光标到前一个消息。<Enter>展开或折叠消息。(只在“会话模式”(Conversation View)中有效) \n \n \no or <Enter> \nOpen \n打开会话。在“Conversation View”中,也可用于打开消息。 \n \n \nu \nReturn to conversation list \n刷新页面、返回收件箱或返回会话列表 \n \n \ny \nArchive* \nRemove from current view \n \n删除会话或消息。 \n在收件箱中,<Y>可“存档”选中的会话
\n\n
在“已加星标示”中,<Y>可取消选中会话的星号; \n 在查看有标签的邮件时,<Y>可取消标签。 \n 在“垃圾邮件”、“已发邮件”和“所有邮件”中,<Y>没有作用 \n \n \n \n \nx \nSelect conversation \n选中会话,配合其他快捷键可为会话存档、添加标签或从下拉菜单中选择其他命令 \n \n \ns \nStar a message or conversation \n为会话或消息加星标。 \n \n \n! \nReport spam \n将消息标记为垃圾邮件并从会话中删除 \n \n \nr \nReply \n回复邮件或会话。“shift+r”可在新窗口中回复消息(只在“会话模式”中有效) \n \n \na \nReply all \n回复所有收件人。“Shift+a”可打开新窗口中回复。(PConline注:如果邮件有抄送地址,<r>回复发件人,<a>则回复所有抄送地址) \n \n \nf \nForward \n转发消息。“Shift+f”可打开新窗口转发。(只在“查看消息模式”(“Conversation View”)中有效) \n \n \n<Esc> \nEscape from input field \nRemoves the cursor from your current input field.(PConline注:在中文版Gmail中暂未有效果) \n \n \ny then o \nArchive and next \n存档选中的会话并打开下一个 \n \n \ng then a \nGo to 'All Mail' \n转到“所有邮件” \n \n \ng then s \nGo to 'Starred' \n转到“已加星标” \n \n \ng then c \nGo to 'Contacts' \n转到“通讯录” \n \n \ng then d \nGo to 'Drafts' \n转到“草稿” \n \n \ng then i \nGo to 'Inbox' \n转到“收件箱” \n \n \n/ \nSearch \n将光标定位到搜索栏中的输入框中 \n \n \n \n
\n", "_id"=>22}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["analyzer"], "comments_count"=>0, "category_id"=>7, "title"=>"Request-log-analyzer: Rails&Merb的日志分析", "body"=>"生产环境下,需要对环境持续监控以尽快的发现问题,找到耗费资源较多的地方加以改进,比较常见的做法是使用moint或者God实时监控;另外,还可以定期分析日志找到特定的请求,虽然可以是shell来做这件事,但是何必再造轮子呢,因为我们已经有了Request log analyzer :\r\n``简介:This is a simple command line tool to analyze request log files of both Rails andMerb. Its purpose is to find what actions are best candidates for optimization.This tool will parse all requests in the logfile and aggregate theinformation. Once it is finished parsing the log file, it will show therequests that take op most server time. Different metrics are used (cumulativetime, average time, blockers, DB time, etc)\r\n\r\n安装:gem sources -a http://gems.github.comsudo gem install wvanbergen-request-log-analyzer\r\n\r\n使用:Usage: request-log-analyzer [FILE] [OPTION]Analyze the given log FILE with the given OPTIONExample: request-log-analyzer mongrel.log\r\n\r\n --fast, -t: Only use completed requests --guess-database-time, -g: Guesses the database duration of requests if they are not in the log --output, -o: Comma-separated list of reports to show --amount, -c: Displays the top <amount> elements in the reports --colorize, -z: Fancy bash coloring\r\n\r\n示例:Note that this example was shortened for your viewing pleasure.$ request-log-analyzer /var/log/my_app.log\r\n\r\nRequest log analyzer, by Willem van Bergen and Bart ten Brinke\r\n\r\nProcessing all log lines...========================================================================Successfully analyzed 58908 requests from log file\r\n\r\nTimestamp first request: 2008-07-13T06:25:58+00:00Timestamp last request: 2008-07-20T06:18:53+00:00Total time analyzed: 7 daysMethods: DELETE (1%), GET (50%), POST (22%), PUT (25%).\r\n\r\nTop 10 most requested actions========================================================================/overview/:date/ : 19359 requests/overview/day/:date/ : 6365 requests/overview/:date/set/ : 5589 requests/overview/ : 3985 requests/clients/:id/ : 1976 requests........\r\n\r\nTop 10 actions by time - cumulative========================================================================/overview/:date/ : 9044.582s [19359 requests]/overview/ : 8478.767s [3985 requests]/overview/:date/set/ : 3309.041s [5589 requests]/clients/:id/products/:id/ : 1479.911s [924 requests]/clients/:id/ : 750.080s [1976 requests]........\r\n\r\nTop 10 actions by time - per request mean========================================================================/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]/clients/:id/ : 0.380s [1976 requests]........\r\n\r\nTop 10 worst DB offenders - cumulative time========================================================================/overview/:date/ : 8773.993s [19359 requests]/overview/ : 8394.754s [3985 requests]/overview/:date/set/ : 3307.928s [5589 requests]/clients/:id/products/:id/ : 1425.220s [924 requests]/clients/:id/ : 535.229s [1976 requests]........\r\n\r\nTop 10 worst DB offenders - mean time========================================================================/overview/:id/:id/:id/print/ : 6.994s [448 requests]/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]........\r\n\r\nMongrel process blockers (> 1.0 seconds)========================================================================/overview/:date/ : 7494.233s [3144 requests]/overview/ : 8320.293s [1549 requests]/overview/:date/set/ : 1149.235s [803 requests]/overview/:id/:id/:id/print/new/ : 613.693s [341 requests]/clients/:id/products/:id/ : 1370.693s [313 requests]........\r\n\r\nRequests graph - per hour======================================================================== ........ 7:00 - 2731 : XXXXXXX 8:00 - 6139 : XXXXXXXXXXXXXXXX 9:00 - 7465 : XXXXXXXXXXXXXXXXXXXX 10:00 - 7118 : XXXXXXXXXXXXXXXXXXX 11:00 - 7409 : XXXXXXXXXXXXXXXXXXX 12:00 - 6450 : XXXXXXXXXXXXXXXXX 13:00 - 5377 : XXXXXXXXXXXXXX 14:00 - 6058 : XXXXXXXXXXXXXXXX 15:00 - 4156 : XXXXXXXXXXX 16:00 - 2767 : XXXXXXX 17:00 - 1598 : XXXX 18:00 - 792 : XX ........\r\n\r\nErrors========================================================================ArgumentError: [237 requests] -> invalid dateStaleObjectError: [28 requests] -> Attempted to update a stale objectRuntimeError: [3 requests] -> Cannot destroy rule before it was createdStatementError: [2 requests] -> Mysql::Error: Deadlock found when trying to get lock; try restarting transactionNoMethodError: [1 requests] -> undefined method `code' for nil:NilClass```", "created_at"=>2008-10-13 08:45:11 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
生产环境下,需要对环境持续监控以尽快的发现问题,找到耗费资源较多的地方加以改进,比较常见的做法是使用moint或者God实时监控;另外,还可以定期分析日志找到特定的请求,虽然可以是shell来做这件事,但是何必再造轮子呢,因为我们已经有了Request log analyzer : \n``简介:This is a simple command line tool to analyze request log files of both Rails andMerb. Its purpose is to find what actions are best candidates for optimization.This tool will parse all requests in the logfile and aggregate theinformation. Once it is finished parsing the log file, it will show therequests that take op most server time. Different metrics are used (cumulativetime, average time, blockers, DB time, etc)
\n\n
安装:gem sources -a http://gems.github.comsudo gem install wvanbergen-request-log-analyzer
\n\n
使用:Usage: request-log-analyzer [FILE] [OPTION]Analyze the given log FILE with the given OPTIONExample: request-log-analyzer mongrel.log
\n\n
--fast, -t: Only use completed requests --guess-database-time, -g: Guesses the database duration of requests if they are not in the log --output, -o: Comma-separated list of reports to show --amount, -c: Displays the top <amount> elements in the reports --colorize, -z: Fancy bash coloring
\n\n
示例:Note that this example was shortened for your viewing pleasure.$ request-log-analyzer /var/log/my_app.log
\n\n
Request log analyzer, by Willem van Bergen and Bart ten Brinke
\n\n
Processing all log lines...========================================================================Successfully analyzed 58908 requests from log file
\n\n
Timestamp first request: 2008-07-13T06:25:58+00:00Timestamp last request: 2008-07-20T06:18:53+00:00Total time analyzed: 7 daysMethods: DELETE (1%), GET (50%), POST (22%), PUT (25%).
\n\n
Top 10 most requested actions========================================================================/overview/:date/ : 19359 requests/overview/day/:date/ : 6365 requests/overview/:date/set/ : 5589 requests/overview/ : 3985 requests/clients/:id/ : 1976 requests........
\n\n
Top 10 actions by time - cumulative========================================================================/overview/:date/ : 9044.582s [19359 requests]/overview/ : 8478.767s [3985 requests]/overview/:date/set/ : 3309.041s [5589 requests]/clients/:id/products/:id/ : 1479.911s [924 requests]/clients/:id/ : 750.080s [1976 requests]........
\n\n
Top 10 actions by time - per request mean========================================================================/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]/clients/:id/ : 0.380s [1976 requests]........
Errors========================================================================ArgumentError: [237 requests] -> invalid dateStaleObjectError: [28 requests] -> Attempted to update a stale objectRuntimeError: [3 requests] -> Cannot destroy rule before it was createdStatementError: [2 requests] -> Mysql::Error: Deadlock found when trying to get lock; try restarting transactionNoMethodError: [1 requests] -> undefined method code' for nil:NilClass``
Nginx有个Log Rotation模块,nginx will re-open it's logs in response to the USR1 signal.参考如下脚本: \n`$ mv access.log access.log.0$ kill -USR1cat master.nginx.pid`$ sleep 1$ gzip access.log.0 # do something with access.log.0
\r\n``2、Hpricot```Pros: Cool name, created by _why, faster than REXML, also does HTML, creative APICons: Not as fast as libxml-ruby, more of an HTML parser linguistically (ie: uses innerHTML instead of text or content, etc.)```\r\n
\r\n
Ruby代码
\r\n\r\n\t
%w[benchmark pp rubygems].each { |x| require x }
\r\n\t
gem 'hpricot', '>= 0.6'
\r\n\t
require 'hpricot'
\r\n\t
\r\n\t
##################################
\r\n\t
# Parsing Delicious API Response #
\r\n\t
##################################
\r\n\t
xml = File.read('posts.xml')
\r\n\t
puts Benchmark.measure {
\r\n\t
doc, posts = Hpricot::XML(xml), []
\r\n\t
(doc/:post).eachdo |p|
\r\n\t
posts << p.attributes
\r\n\t
end
\r\n\t
# pp posts
\r\n\t
}
\r\n\t
\r\n\t
################################
\r\n\t
# Parsing Twitter API Response #
\r\n\t
################################
\r\n\t
xml = File.read('timeline.xml')
\r\n\t
puts Benchmark.measure {
\r\n\t
doc, statuses = Hpricot::XML(xml), []
\r\n\t
(doc/:status).eachdo |s|
\r\n\t
h = {:user => {}}
\r\n\t
%w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].eachdo |a|
\r\n\t
h[a.intern] = s.at(a).innerHTML
\r\n\t
end
\r\n\t
%w[id name screen_name location description profile_image_url url protected followers_count].eachdo |a|
\r\n\t
h[:user][a.intern] = s.at('user').at(a).innerHTML
\r\n\t
end
\r\n\t
statuses << h
\r\n\t
end
\r\n\t
# pp statuses
\r\n\t
}
\r\n\r\n
\r\n3、libxml-ruby \r\n\r\nPros: Blistering fast\r\nCons: Hpricot has cooler name, REXML and Hpricot both feel easier to use out of the box\r\n
Ruby可以很方便的解析XML格式的文档,目前用的比较多的lib主要有三个,分别是:REXML, Hpricot, libxml-ruby,如下选取两个XML文档,分别使用这三个lib解析,感受下各自的速度和易用性。 \n一、原料 \n \n posts.xml – Uses xml element for object (post) and xml attributes for object attributes \n timeline.xml – Uses xml element for object (status) and child xml elements for attributes \n \n二、解析过程 \n1、REXML
\n\n
Pros: In the standard library \nCons: Slow, I don’t like the name \n \nRuby代码 \n \n %w[benchmark pp rexml/document].each { |x| require x } \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n doc, posts = REXML::Document.new(xml), [] \n doc.elements.each('posts/post') do |p| \n posts << p.attributes \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n doc, statuses = REXML::Document.new(xml), [] \n doc.elements.each('statuses/status') do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.elements[a].text \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.elements['user'].elements[a].text \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n<code class="ruby"><strong>2、Hpricot</strong><strong>Pros:</strong> Cool name, created by _why, faster than <span class="caps">REXML</span>, also does <span class="caps">HTML</span>, creative <span class="caps">API</span><strong>Cons:</strong> Not as fast as libxml-ruby, more of an <span class="caps">HTML</span> parser linguistically (ie: uses innerHTML instead of text or content, etc.)`` \n \nRuby代码 \n \n %w[benchmark pp rubygems].each { |x| require x } \n gem 'hpricot', '>= 0.6' \n require 'hpricot' \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n doc, posts = Hpricot::XML(xml), [] \n (doc/:post).each do |p| \n posts << p.attributes \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n doc, statuses = Hpricot::XML(xml), [] \n (doc/:status).each do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.at(a).innerHTML \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.at('user').at(a).innerHTML \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n3、libxml-ruby
\n\n
Pros: Blistering fast \nCons: Hpricot has cooler name, REXML and Hpricot both feel easier to use out of the box \n \nRuby代码 \n \n %w[benchmark pp rubygems].each { |x| require x } \n gem 'libxml-ruby', '>= 0.8.3' \n require 'xml' \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n parser, parser.string = XML::Parser.new, xml \n doc, posts = parser.parse, [] \n doc.find('//posts/post').each do |p| \n posts << p.attributes.inject({}) { |h, a| h[a.name] = a.value; h } \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n parser, parser.string = XML::Parser.new, xml \n doc, statuses = parser.parse, [] \n doc.find('//statuses/status').each do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.find(a).first.content \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.find('user').first.find(a).first.content \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n<code class="ruby"><strong>三、结论</strong> \n<div class="codeText"> \n<div class="codeHead">结果如下:</div> \n<ol class="dp-xml" start="1"> \n <li class="alt"><span><span>=rexml </span></span></li> \n <li><span>delicious 0.020000 0.000000 0.020000 ( 0.021139) </span></li> \n <li class="alt"><span>twitter 0.940000 0.020000 0.960000 ( 0.988666) </span></li> \n <li><span> </span></li> \n <li class="alt"><span>=hpricot </span></li> \n <li><span>delicious 0.010000 0.000000 0.010000 ( 0.005548) </span></li> \n <li class="alt"><span>twitter 0.250000 0.010000 0.260000 ( 0.258320) </span></li> \n <li><span> </span></li> \n <li class="alt"><span>=libxml-ruby </span></li> \n <li><span>delicious 0.000000 0.000000 0.000000 ( 0.007829) </span></li> \n <li class="alt"><span>twitter 0.030000 0.010000 0.040000 ( 0.034040) </span></li> \n</ol> \n</div> \n``<code class="ruby">参考文档:http://railstips.org/2008/8/12/parsing-xml-with-ruby``
\n", "_id"=>26}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Tips"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["oauth"], "comments_count"=>0, "category_id"=>4, "title"=>"初识oauth: 为API访问授权提供一个开放的标准", "body"=>"最近在准备一些API设计开发工作,初步了解了下oauth,OAuth是由Blaine Cook、Chris Messina、Larry Halff 及David Recordon共同发起的,目的在于为API访问授权提供一个开放的标准。\r\noauth目前看来进展比较顺利,可以看到其有主流语言的lib(Java、C#、Objective-C、Perl、PHP及Ruby语言),目前支持oauth的API有twitter,douban等应用。\r\n\r\nOAuth is the great new standard allowing your users to use your application to talk to their accounts on other applications. I won’t go more into it here as it’s pretty well covered on the OAuth site.\r\n\r\nOAuth’s Goal\r\nWebsite X can access your protected data at API Y\r\n
\r\n\t
All without sharing your password off-site
\r\n\t
especially when there isn’t one like with OpenID
\r\n
\r\n其基本流程为:\r\n\r\n\t
Register your consumer application with the OAuth compliant service to receive your Consumer Credentials (This is only done once)
\r\n\t
You initiate the OAuth Token exchange process for a user by requesting a RequestToken from the Service
\r\n\t
You store the RequestToken in your database or in the users session object
\r\n\t
You redirect your user to the service providers authorize_url with the RequestToken’s key appended
\r\n\t
Your user is asked by the service provider to authorize your RequestToken
\r\n\t
Your user clicks yes and is redirected to your CallBack URL
OAuth is the great new standard allowing your users to use your application to talk to their accounts on other applications. I won’t go more into it here as it’s pretty well covered on the OAuth site. \n \nOAuth’s Goal \nWebsite X can access your protected data at API Y \n \n All without sharing your password off-site \n especially when there isn’t one like with OpenID \n \n其基本流程为: \n \n Register your consumer application with the OAuth compliant service to receive your Consumer Credentials (This is only done once) \n You initiate the OAuth Token exchange process for a user by requesting a RequestToken from the Service \n You store the RequestToken in your database or in the users session object \n You redirect your user to the service providers authorize_url with the RequestToken’s key appended \n Your user is asked by the service provider to authorize your RequestToken \n Your user clicks yes and is redirected to your CallBack URL \n Your callback action exchanges the RequestToken for an AccessToken \n Now you can access your users data by performing http requests signed by your consumer credentials and the AccessToken. \n ???? \n PROFIT!!! \n \n如果你想了解,请参考如下文档,如果你有经验,请分享,谢谢! \n \n参考文档: \n \n Developing OAuth clients in Ruby \n How to turn your rails site into an OAuth Provider \n OAuth不断获得动力 \n Rails plugin for OAuth \n OAuth implementation for Ruby \n 豆瓣 API 认证授权说明 \n The How of OAuth --这个PPT挺不错 \n
\n", "_id"=>34}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Ruby&Rails", "to_xml"], "comments_count"=>0, "category_id"=>11, "title"=>"Rails: Disabling XML character escaping for to_xml & xml builder", "body"=>"
In my case, I had to genarate the xml view for api render,but in rails, i got a &XXX format string for non englisg, it also appears to_xml will automatically escape any entities into their corresponding &XXX representation. There's a piece in the documentation that says "If $KCODE is set to u and encoding set to UTF8, then escaping will NOT be performed." \n \nUnfortunately, this doesn't appear to be the case. Even after following the docs and ensuring that default_charset is indeed UTF-8 (actually the default for Rails nowadays), we still get encoded characters in to_xml output. \n \nSince our client is UTF-8 aware, we need to pass thru the UTF-8 data intact. The only way we've found to do this is thru the following horrible monkey-patch:
\n
\n
Ruby代码
\n\n
module Builder
\n
class XmlBase
\n
def _escape(text)
\n
text
\n
end
\n
end
\n
end
\n\n
\n
\nWhat's the proper way to do this? \n \nPS: \nsomebody say that to "set $KCODE='UTF8' in config/environment.rb can solve this issue." but it's not for me. \n \nmore infos: \nhttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2c13ad7c0f8c0781
In my case, I had to genarate the xml view for api render,but in rails, i got a &XXX format string for non englisg, it also appears to_xml will automatically escape any entities into their corresponding &XXX representation. There's a piece in the documentation that says "If $KCODE is set to u and encoding set to UTF8, then escaping will NOT be performed." \n \nUnfortunately, this doesn't appear to be the case. Even after following the docs and ensuring that default_charset is indeed UTF-8 (actually the default for Rails nowadays), we still get encoded characters in to_xml output. \n \nSince our client is UTF-8 aware, we need to pass thru the UTF-8 data intact. The only way we've found to do this is thru the following horrible monkey-patch: \n \nRuby代码 \n \n module Builder \n class XmlBase \n def _escape(text) \n text \n end \n end \n end \n \n \n \nWhat's the proper way to do this? \n \nPS: \nsomebody say that to "set $KCODE='UTF8' in config/environment.rb can solve this issue." but it's not for me. \n \nmore infos: \nhttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2c13ad7c0f8c0781 \n
\n", "_id"=>35}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["random", "ruby"], "comments_count"=>0, "category_id"=>11, "title"=>"Generate a random string", "body"=>"Generates a random string of lowercase letters. Great for email verification codes or user password salt....\n
Some tips for mount&umount ,maybe give you some help..
\n
cdrom: \n# mount -t is09660 /dev/cdrom /mnt/cdrom \n# umount /mnt/cdrom \n \nfloppy: \n# mount /dev/fd0 /mnt/floppy \n#umount /mnt/floppy \n \nusb: \n1.use 'fdisk -l' to show the usb nums,something like '/dev/sda'; \n2.then use 'mkdir /mnt/usb' to create a dir for mount this usb; \n3.at last,use '# mount -t msdos /dev/sda1 /mnt/usb" to mount it. \n4.#umount /mnt/usb \n \nhda: \n1.use 'fdisk -l' to show the disk nums,like '/dev/hda1'; \n2.then use 'make /mnt/vfat' to create a mount point; \n3.at last,use '# mount -t vfat /dev/hda1 /mnt/vfat'to mount it.. \n4.#umount /mnt/vfat
Some tips for mount&umount ,maybe give you some help.. \ncdrom:
\n\n
mount -t is09660 /dev/cdrom /mnt/cdrom
\n\n
umount /mnt/cdrom
\n\n
floppy:
\n\n
mount /dev/fd0 /mnt/floppy
\n\n
umount /mnt/floppy
\n\n
usb: \n1.use 'fdisk -l' to show the usb nums,something like '/dev/sda'; \n2.then use 'mkdir /mnt/usb' to create a dir for mount this usb; \n3.at last,use '# mount -t msdos /dev/sda1 /mnt/usb" to mount it. \n4.#umount /mnt/usb \n \nhda: \n1.use 'fdisk -l' to show the disk nums,like '/dev/hda1'; \n2.then use 'make /mnt/vfat' to create a mount point; \n3.at last,use '# mount -t vfat /dev/hda1 /mnt/vfat'to mount it.. \n4.#umount /mnt/vfat \nand some usefull resource links and docs here: \nhttp://unix-cd.com/unixcd12/article_3967.html \nhttp://blog.oracle.com.cn/index.php/121320/viewspace-6733.html
In my case, I need do send big files to users, yes, you can do it with nginx,just like others static files,but i need some control for the request action,The delivery of a static file which depends on an application header is known as the X-Sendfile feature. \nLighttpd has this feature and there is a mod_xsendfile for Apache2. \nNginx also has this feature, but implemented a little bit differently. In Nginx this feature is called X-Accel-Redirect. \nThere are two main differences:
\n\n
The header must contain a URI
\n
The location should be defined as internal; to prevent the client going directly to the URI
\n\n
\n
\n
Ruby代码
\n\n
location /files {
\n
root /var/www;
\n
internal;
\n
}
\n\n
\n
\n
Ruby代码
\n\n
// Get requested file name
\n
path = @params["path"]
\n
\n
# ...
\n
# Perform any required security checks, validation
In my case, I need do send big files to users, yes, you can do it with nginx,just like others static files,but i need some control for the request action,The delivery of a static file which depends on an application header is known as the X-Sendfile feature. \nLighttpd has this feature and there is a mod_xsendfile for Apache2. \nNginx also has this feature, but implemented a little bit differently. In Nginx this feature is called X-Accel-Redirect. \nThere are two main differences: \n \n The header must contain a URI \n The location should be defined as internal; to prevent the client going directly to the URI \n \n \n \nRuby代码 \n \n location /files { \n root /var/www; \n internal; \n } \n \n \n \nRuby代码 \n \n // Get requested file name \n path = @params["path"] \n \n # ... \n # Perform any required security checks, validation \n # and/or stats accounting \n # ... \n \n # And redirect user to internal location \n response.headers['X-Accel-Redirect'] = "/files/" + path \n \n \n \nsome userfull link resource come here: \n \n http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/ \n http://wiki.codemongers.com/NginxXSendfile \n http://www.motionstandingstill.com/using-nginx-to-send-files-with-x-accel-redirect/2008-09-03/ \n \n
I store user sessions in memcache,and then i want do share theres sessions with sub domains,but i notice some strange things when i put session into memcached,there are: \n1. In my older website(rails 2.0),It genenrated sessions key for memcached as \#{namespace}-\#{RAILS_ENV}:"session:\#{id}"; \n2.In my newer website(reails 2.3),It generated seesions key for memcached just as "\#{namespace}:\#{id}"; \n \nso,i can not get the same seesion datas with diff session keys. i do have spend lots of time for sove this , i do have some userfull dis, \n \n1. In rails2.3 ,it's vendor memcache-client-1.5.0.5 in ruby\\lib\\ruby\\gems\\1.8\\gems\\activesupport-2.3.0\\lib\\active_support\\vendor; \n2. you can config namespace in you environment.rb file like " ActionController::Base.session_options[:namespace] = 'session'" \n3. In rails2.0,when you use memcached,you will use cached_fu and act_as_cache plugins,and you may have a config file in your config dir named memcached.yml, and in this file,you can config defaults,production,test and developer..with lots of filed,like namespace,servers etc.. \n4. you will notice it generate memcached key as mentioned above. \n \nI track it,and got this:
I store user sessions in memcache,and then i want do share theres sessions with sub domains,but i notice some strange things when i put session into memcached,there are: \n1. In my older website(rails 2.0),It genenrated sessions key for memcached as \#{namespace}-\#{RAILS_ENV}:"session:\#{id}"; \n2.In my newer website(reails 2.3),It generated seesions key for memcached just as "\#{namespace}:\#{id}"; \n \nso,i can not get the same seesion datas with diff session keys. i do have spend lots of time for sove this , i do have some userfull dis, \n \n1. In rails2.3 ,it's vendor memcache-client-1.5.0.5 in ruby\\lib\\ruby\\gems\\1.8\\gems\\activesupport-2.3.0\\lib\\active_support\\vendor; \n2. you can config namespace in you environment.rb file like " ActionController::Base.session_options[:namespace] = 'session'" \n3. In rails2.0,when you use memcached,you will use cached_fu and act_as_cache plugins,and you may have a config file in your config dir named memcached.yml, and in this file,you can config defaults,production,test and developer..with lots of filed,like namespace,servers etc.. \n4. you will notice it generate memcached key as mentioned above. \n \nI track it,and got this: \n \nRuby代码 \n \n def setup_memcache(config) \n config[:namespace] << "-\#{RAILS_ENV}" \n \n silence_warnings do \n Object.const_set :CACHE, memcache_klass.new(config) \n end \n \n CACHE.servers = Array(config.delete(:servers)) \n \n setup_session_store if config[:sessions] \n setup_fragment_store! if config[:fragments] \n setup_fast_hash! if config[:fast_hash] \n setup_fastest_hash! if config[:fastest_hash] \n \n CACHE \n end \n \n \nshit,it append RAILS_ENV to namespace with "-",that's it...I hate some hardcode config in plugin,blalal.... \nsome userfull link resources... \n \n http://errtheblog.com/posts/22-sessions-n-such \n http://www.raecoo.com/2008/10/25/rails-store-format-in-memcache/ \n http://www.scribd.com/doc/2203398/Scaling-Rails-with-memcached \n http://railscasts.com/episodes/115-caching-in-rails-2-1
In some case,you may want do get Uniquely Identifying for a 'real' android phone,and you can do it like this:
\n
In Android.Provider.Settings.System we have some interesting values that could be of use, one specifically is “Android_ID”. From the documentation it is the following;
\n
\n
String \tANDROID_ID \tThe Android ID (a unique 64-bit value) as a hex string. \t“android_id”
\nAlso, note that in an emulator this will return “null”, though a real device will return an actual value. The nice thing about this tid-bit of code is that you are not required any special permissions to call it, since it’s essentially a passive call to get information. No write access is (obviously) required.\n
Garry Tan, cofounder of Posterous, lists 12 lessons for scaling that apply to more than just Rails,and i mark some word below. \n \nUse cloud storage for static files. --S3,I do not care it 's fine in china. \nUse HTTP Cache Control to tell the browser what it can cache. --this is true,etag is great. \nUse Sphinx for text search. --sometimes,you do have others chose. \nUse InnoDB for more crash resistant and faster writes. --maybe it's right. \nDon't use textbook Rails ActiveRecord objects. Use New Relic to find exactly what is slow in your system. --yep \nUse memcache later so you find your database bottlenecks now. --this is very important. \nUse mongrel proctitle to find your slow queries. You are only as fast as your slowest queries. -maybe mongrel is not only chose,think about thin,ok? \nUse asynchronous job queuing to do work in parallel. --yes,but sometimes crontab is enough. \nUse monitoring so you'll know when your site went down and why. --that's it,just do it. \nLearn by reading the source code, fixing problems, and submitting them back to the community. --very userfull when you got some strange questions.. \nUse new plugins. Old plugins can't be trusted. --and check chang histroy carefully. \nUse new information. Old information can't be trusted. --and what's this? \n \ngo to http://axonflux.com/building-and-scaling-a-startup for more infos.
When it asks for driver location choose the unzipped folderand install the driver for it.
\n
You'll see sth like "HTC Dream Composite ADB Interface" on success
\n
(Re)Start Eclipse
\n
Your G1 should now be listed in the DDMS-Perspective under Devices
\n
Go to the AndroidManifest.xml of your App and modify it to containandroid:debuggable="true"in the <application ... >-Tag,look like this:<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
\n
Go Debug as usual. \n
\n\nps: I do not upload the zip file here,you can find it via the link above,but if you can not download it,you can mail me to fetch one.
I konw,you can dev app and test it on the simulator,but if you had a real driver,G1,you can do debug on it,very great,here is the tips for this: \n \n On your G1, go to Settings Applications Development [X] USB debugging \n Download this file: android_usb_windows.zip \n Unzip it to a folder \n Connect your G1 with your PC \n When it asks for driver location choose the unzipped folder and install the driver for it. \n You'll see sth like "HTC Dream Composite ADB Interface" on success \n (Re)Start Eclipse \n Your G1 should now be listed in the DDMS-Perspective under Devices \n Go to the AndroidManifest.xml of your App and modify it to contain android:debuggable="true" in the <application ... >-Tag ,look like this:<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> \n Go Debug as usual. \n \n \nps: I do not upload the zip file here,you can find it via the link above,but if you can not download it,you can mail me to fetch one. \nBtw: \nYou can now install (signed)APKs via USB: \nD:\\dev\\Android\\android-sdk-windows-1.0_r1\\tools>adb -d install D:\\Workspace\\keytools\\AndNav_signed.apk \n1305 KB/s (1975987 bytes in 1.478s) \npkg: /data/local/tmp/AndNav_signed.apk \nSuccess \n \n \nAnd uninstall them: \nD:\\dev\\Android\\android-sdk-windows-1.0_r1\\tools>adb uninstall org.andnav \nSuccess \n \n
In some case,you may want do get Uniquely Identifying for a 'real' android phone,such as IMEI code,SimOperator etc, and we all kown ,the IMEI like ID card,and you can use TelephonyManager to get it,some usefull codes like this :
Apr 1 01:47:49 garden kernel: Linux version 2.6.18-92.1.17.el5 (mockbuild@builder10.centos.org) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)) #1 SMP Tue Nov 4 13:43:30 EST 2008
\n
\n \nlooks like something wrong about "ip_conntrack",and i do some check like this: \n\n
Installing ri documentation for fastercsv-1.4.0...
\n
Installing RDoc documentation for fastercsv-1.4.0...
\n
iceskysl ~/webroot: cd ..
\n\n
\nand do not forget to add "require 'fastercsv'" in your class file.", "created_at"=>2009-04-22 17:12:15 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
some tips is here. \n \nRuby代码 \n \n def self.imp_init_owner_data \n fp = "\#{RAILS_ROOT}/datas/inumbers/ini_owner.csv" \n FasterCSV.open(fp, "w") do |csv| \n InumberCate.find_all_by_typee("owner").each do |owner| \n csv << [owner.name,owner.id] \n end \n end \n end \n \n \ninstall fastercsv gems like this.. \n \n \n \nRuby代码 \n \n iceskysl ~/webroot: gem install fastercsv \n Successfully installed fastercsv-1.4.0 \n 1 gem installed \n Installing ri documentation for fastercsv-1.4.0... \n Installing RDoc documentation for fastercsv-1.4.0... \n iceskysl ~/webroot: cd .. \n \n \nand do not forget to add "require 'fastercsv'" in your class file.
you can use apt-spy to update sources.list ,here is some step and tips. \n1.open /etc/apt/sources.list and add this \ndeb http://http.us.debian.org/debian/ stable main \n2.do "apt-get update" \n3.then "apt-get install apt-spy" \n4.then "apt-spy update" \n5.last,"apt-spy -d unstable -a asia -t 5" \n \nref: \nhttp://http.us.debian.org/debian/README.mirrors.txt
you can use apt-spy to update sources.list ,here is some step and tips. \n1.open /etc/apt/sources.list and add this \ndeb http://http.us.debian.org/debian/ stable main \n2.do "apt-get update" \n3.then "apt-get install apt-spy" \n4.then "apt-spy update" \n5.last,"apt-spy -d unstable -a asia -t 5" \n \nref: \nhttp://http.us.debian.org/debian/README.mirrors.txt
\n", "_id"=>50}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["iowait"], "comments_count"=>0, "category_id"=>11, "title"=>"How can I find out what is generating iowait on my server?", "body"=>"
A question I’m asked daily is “How can I find out what is generating iowait on my server?” Sure, you can dig through pages of lsof output, restart services, or run strace, but it can be a frustrating process. I saw a process on this blog post, and a guy changed the regexes to fit Red Hat and CentOS systems a bit better: \n
A question I’m asked daily is “How can I find out what is generating iowait on my server?” Sure, you can dig through pages of lsof output, restart services, or run strace, but it can be a frustrating process. I saw a process on this blog post, and a guy changed the regexes to fit Red Hat and CentOS systems a bit better: \n \nRuby代码 \n \n [root@5-3 ~]# /etc/init.d/syslog stop \n Shutting down kernel logger: [ OK ] \n Shutting down system logger: [ OK ] \n [root@5-3 ~]# echo 1 > /proc/sys/vm/block_dump \n [root@5-3 ~]# dmesg | egrep "READ|WRITE|dirtied" | egrep -o '([a-zA-Z]*)' | sort | uniq -c | sort -rn | head \n 202 kjournald \n 16 egrep \n 9 irqbalance \n 9 bash \n 2 java \n 1 sda \n 1 mailserver \n [root@5-3 ~]# echo 0 > /proc/sys/vm/block_dump \n [root@5-3 ~]# /etc/init.d/syslog start \n Starting system logger: [ OK ] \n Starting kernel logger: [ OK ] \n \n \nIn my specific situation, it looks like kjournald is the biggest abuser of my disk. \nDon’t forget to set things back to their normal state when you’re done! \n \nXML/HTML代码 \n \n # echo 0 > /proc/sys/vm/block_dump \n # /etc/init.d/syslog start \n \n \n \n \nref: \nhttp://rackerhacker.com/2008/03/11/hunting-down-elusive-sources-of-iowait/ \nhttp://blog.eikke.com/index.php/ikke/2007/03/22/who_s_abusing_my_sata_controller \nhttp://hi.baidu.com/dipsey/blog/item/900bbbaf3e46dcc97cd92aba.html \nhttp://www.ducea.com/2009/03/11/howto-install-iotop-on-debian-etch/ \n \nhttp://www.cppblog.com/go-benny/archive/2008/04/23/47908.html \n
--attach PID Quit god when the attached process dies
\n
--no-events Disable the event system
\n
--bleakhouse Enable bleakhouse profiling
\n
[iceskysl@ws_api]#
\n\n
\n1.DYNAMICALLY LOADING CONFIG FILES INTO AN ALREADY RUNNING GOD\n
\n
God allows you to load or reload configurations into an already running instance. There are a few things to consider when doing this:
\n
\n
Existng Watches with the samename```as the incoming Watches will be overidden by the new config.
\n
All paths must be either absolute or relative to the path from which god was started.
\n
\n
To load a config into a running god, issue the following command:
\n
$ sudo god load path/to/config.god # god load /data/www/api/config/config_thin_api.god```\n
Config files that are loaded dynamically can contain anything that a normal config file contains, however, global options such asGod.pid_file_directory```blocks will be ignored (and produce a warning in the logs).
\n
\n
2.show logs
\n
\n
\n
XML/HTML代码
\n\n
[iceskysl@ws_api]# god log thin-thin-7514
\n
I, [2009-04-28T08:24:16.705870 #23174] INFO -- : thin-thin-7514 moved 'up' to 'up'
\n
I, [2009-04-28T08:24:16.706346 #23174] INFO -- : thin-thin-7514 [trigger] process is not running (ProcessRunning)
\n
I, [2009-04-28T08:24:16.888477 #23174] INFO -- : thin-thin-7514 sent email to iceskysl@gmail.com (Email)
\n
I, [2009-04-28T08:24:16.888642 #23174] INFO -- : thin-thin-7514 move 'up' to 'start'
\n
I, [2009-04-28T08:24:16.888976 #23174] INFO -- : thin-thin-7514 before_start: no pid file to delete (CleanPidFile)
\n
I, [2009-04-28T08:24:16.889109 #23174] INFO -- : thin-thin-7514 start: thin start -C /data/www/web/current/config/thin.yml -o 7514
some days before,i posted a article 《God: 比Monit更好用的monitoring》,today,i will post more useful tips for God. \n \n \nRuby代码 \n \n [iceskysl@ws_api]# god --help \n Usage: \n Starting: \n god [-c <config file>] [-p <port> | -b] [-P <file>] [-l <file>] [-D] \n \n Querying: \n god <command> <argument> [-p <port>] \n god <command> [-p <port>] \n god -v \n god -V (must be run as root to be accurate on Linux) \n \n Commands: \n start <task or group name> start task or group \n restart <task or group name> restart task or group \n stop <task or group name> stop task or group \n monitor <task or group name> monitor task or group \n unmonitor <task or group name> unmonitor task or group \n remove <task or group name> remove task or group from god \n load <file> load a config into a running god \n log <task name> show realtime log for given task \n status show status of each task \n quit stop god \n terminate stop god and all tasks \n check run self diagnostic \n \n Options: \n -c, --config-file CONFIG Configuration file \n -p, --port PORT Communications port (default 17165) \n -b, --auto-bind Auto-bind to an unused port number \n -P, --pid FILE Where to write the PID file \n -l, --log FILE Where to write the log file \n -D, --no-daemonize Don't daemonize \n -v, --version Print the version number and exit \n -V Print extended version and build information \n --log-level LEVEL Log level [debug|info|warn|error|fatal] \n --no-syslog Disable output to syslog \n --attach PID Quit god when the attached process dies \n --no-events Disable the event system \n --bleakhouse Enable bleakhouse profiling \n [iceskysl@ws_api]# \n \n \n1.DYNAMICALLY LOADING CONFIG FILES INTO AN ALREADY RUNNING GOD \n \nGod allows you to load or reload configurations into an already running instance. There are a few things to consider when doing this: \n \n Existng Watches with the same name<span class="Apple-converted-space"> </span>as the incoming Watches will be overidden by the new config.</li> \n <li style="margin: 0px; font-size: 13px;">All paths must be either absolute or relative to the path from which god was started.</li> \n</ul> \n<p style="margin: 0px 0px 1em; font-size: 13px;">To load a config into a running god, issue the following command:</p> \n<pre style="border: 1px solid rgb(204, 204, 204); margin: 1em 0px; padding: 1em; font-size: 10px; line-height: 1.3; background-color: rgb(239, 239, 239);">$ sudo god load path/to/config.god<br /># god load /data/www/api/config/config_thin_api.god \nConfig files that are loaded dynamically can contain anything that a normal config file contains, however, global options such as God.pid_file_directory``` blocks will be ignored (and produce a warning in the logs). \n \n2.show logs \n \n \nXML/HTML代码 \n \n [iceskysl@ws_api]# god log thin-thin-7514 \n I, [2009-04-28T08:24:16.705870 #23174] INFO -- : thin-thin-7514 moved 'up' to 'up' \n I, [2009-04-28T08:24:16.706346 #23174] INFO -- : thin-thin-7514 [trigger] process is not running (ProcessRunning) \n I, [2009-04-28T08:24:16.888477 #23174] INFO -- : thin-thin-7514 sent email to iceskysl@gmail.com (Email) \n I, [2009-04-28T08:24:16.888642 #23174] INFO -- : thin-thin-7514 move 'up' to 'start' \n I, [2009-04-28T08:24:16.888976 #23174] INFO -- : thin-thin-7514 before_start: no pid file to delete (CleanPidFile) \n I, [2009-04-28T08:24:16.889109 #23174] INFO -- : thin-thin-7514 start: thin start -C /data/www/web/current/config/thin.yml -o 7514 \n \n \n \nresource links: \nhttp://god.rubyforge.org/ \n
If you have recently updated to Rails 2.2.2, you may encounter this error when you want to start your application: \n \n/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in \n`load_missing_constant': uninitialized constant Inflector (NameError) \n \nthe usage of Inflector class is changed a bit. You can see the difference when you compare the inflections.rb files. Path of the file is yourApp/config/initializers/inflections.rb \n \n
\n
inflections.rb (Rails 2.1.0)
\n\n
\n
\n
Inflector.inflections do |inflect|
\n
.
\n
.
\n
.
\n
end
\n\n
\n \n
\n
inflections.rb (Rails 2.2.2)
\n\n
ActiveSupport::Inflector.inflections do |inflect|
\n
.
\n
.
\n
.
\n
end
\n\n
\nthe situation changing Inflector to ActiveSupport::Inflector was enough to solve the problem.", "created_at"=>2009-05-05 13:37:01 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
If you have recently updated to Rails 2.2.2, you may encounter this error when you want to start your application: \n \n/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in \n`load_missing_constant': uninitialized constant Inflector (NameError) \n \nthe usage of Inflector class is changed a bit. You can see the difference when you compare the inflections.rb files. Path of the file is yourApp/config/initializers/inflections.rb \n \n \ninflections.rb (Rails 2.1.0) \n \n \n \n Inflector.inflections do |inflect| \n . \n . \n . \n end \n \n \n \n \ninflections.rb (Rails 2.2.2) \n \n ActiveSupport::Inflector.inflections do |inflect| \n . \n . \n . \n end \n \n \nthe situation changing Inflector to ActiveSupport::Inflector was enough to solve the problem.
\n", "_id"=>54}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["God", "ruby", "Ruby&Rails"], "comments_count"=>0, "category_id"=>11, "title"=>"Socket Errno::EAFNOSUPPORT with God in ruby", "body"=>"
when i start god.sh,then give some error msg like this:
\n
\n
\n
XML/HTML代码
\n\n
I [2009-05-16 21:25:41] INFO: Using pid file directory: /var/run/god
\n
/usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `initialize': Address family not supported by protocol - socket(2) (Errno::EAFNOSUPPORT)
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `open'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `open_server_inaddr_any'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:863:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:759:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in `each'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1340:in `initialize'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in `new'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in `start_service'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:78:in `start'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:43:in `initialize'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in `new'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in `start'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:633:in `at_exit'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:666
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/cli/run.rb:87
\n\n
\nok,then i find some userful messsage,like here:\n
Errno::EAFNOSUPPORT - the specifiedsockaddrisnot a valid address for the family of the callingsocket
\n
and here, i notice where is the problen,the god find hostname,name map it to ip address,then create some sockets on the ip,and the error point is here,so i nano my /etc/hosts file,and add map for hostname and 127.0.0.1,that's it! \n
when i start god.sh,then give some error msg like this: \n \n \nXML/HTML代码 \n \n I [2009-05-16 21:25:41] INFO: Using pid file directory: /var/run/god \n /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in initialize': Address family not supported by protocol - socket(2) (Errno::EAFNOSUPPORT) </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in open' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in open_server_inaddr_any' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:863:in open_server' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:759:in open_server' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in each' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in open_server' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1340:in initialize' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in new' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in start_service' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:78:in start' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:43:in initialize' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in new' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in start' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:633:in `at_exit' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:666 \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/cli/run.rb:87 \n \n \nok,then i find some userful messsage,like here: \nErrno::EAFNOSUPPORT - the specified sockaddr isnot a valid address for the family of the calling socket \nand here, i notice where is the problen,the god find hostname,name map it to ip address,then create some sockets on the ip,and the error point is here,so i nano my /etc/hosts file,and add map for hostname and 127.0.0.1,that's it!
\n", "_id"=>55}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["书"], "comments_count"=>0, "category_id"=>6, "title"=>"我写的书:《Google Android开发入门与实战》等即将上市.", "body"=>"这篇文章是非技术性的,所以使用中文写,免得写了大家看不懂,呵呵。\r\n\r\n写书不是第一次,出版却是第一本,至于原因,就不详述了,去年9月开始参与一些图书的翻译和撰写中,截至到目前,这段时间一共参与了三本书,按照参与的先后顺序,分别是《The Rails Way》,《Google API 编程.开发.实例》以及《Google Android开发入门与实战》。\r\n\r\n其中《The Rails Way》是做为译者参与,其他翻译者都是国内第一批Rails技术人员,分散在全国各地,还有一名译者在加拿大,我一共翻译了5章内容,分别是第2章“Working_with_Controllers”,第10章“ActionView”,第13章“Session__Session_Management”,第15章“XML_and_ActiveResource”和第16章“ActionMailer”,翻译很早前就结束了,目前好像还在审稿、校核工作,由YiTan在跟,至于何时出版,我还真不知道。\r\n\r\n《Google API 编程.开发.实例》我是从去年9月份介入,开始参与选题和策划,截至撰写相关内容,因为我自身是Google重度使用者,平时也比较多的使用和了解GoogleAPI,所以写起来得心应手,一共写了“Google Account Authentication”,“Google AJAX Language API”,“Google Chart API”,“Blogger Data API”,“Feedburner API”,“Google Code Search Data API”和“Google Book Search Book Viewability API”这些章节,前前后后也花了不少零碎的时间。其他作者大多都Google内部的同学,本书已经进入出版流程,由博文视点出版社策划出版,应该在6.5号Google开发者大会上可以看到,如下是本书第一版封面。\r\n\r\n\r\n\r\n本书特点:本书覆盖了Google绝大多数的API,其中针对每个API就其原理、用法做了详细说明,最后基本上都有实际的例子演示如何使用。\r\n\r\n《Google Android开发入门与实战》是08年11月份开始撰写的,和另外一个朋友一起,两个人陆续的差不多用了半年时间,在09年4月份差不多全部写完,后面主要是都在校核和审稿,由人民邮电出版社出版,5月底6月初即可上市,封面如下:\r\n\r\n\r\n\r\n \r\n
《Google API 编程.开发.实例》我是从去年9月份介入,开始参与选题和策划,截至撰写相关内容,因为我自身是Google重度使用者,平时也比较多的使用和了解GoogleAPI,所以写起来得心应手,一共写了“Google Account Authentication”,“Google AJAX Language API”,“Google Chart API”,“Blogger Data API”,“Feedburner API”,“Google Code Search Data API”和“Google Book Search Book Viewability API”这些章节,前前后后也花了不少零碎的时间。其他作者大多都Google内部的同学,本书已经进入出版流程,由博文视点出版社策划出版,应该在6.5号Google开发者大会上可以看到,如下是本书第一版封面。
and now,you can open a cmd shell,and input sqlite3 like this: \n
\n
C:\\Documents and Settings\\Administrator>sqlite3 \nSQLite version 3.5.9 \nEnter ".help" for instructions
\n
and some help infos is here:
\n
sqlite> .help \n.bail ON|OFF Stop after hitting an error. Default OFF \n.databases List names and files of attached databases \n.dump ?TABLE? ... Dump the database in an SQL text format \n.echo ON|OFF Turn command echo on or off \n.exit Exit this program \n.explain ON|OFF Turn output mode suitable for EXPLAIN on or off. \n.header(s) ON|OFF Turn display of headers on or off \n.help Show this message \n.import FILE TABLE Import data from FILE into TABLE \n.indices TABLE Show names of all indices on TABLE \n.load FILE ?ENTRY? Load an extension library \n.mode MODE ?TABLE? Set output mode where MODE is one of: \n csv Comma-separated values \n column Left-aligned columns. (See .width) \n html HTML <table> code \n insert SQL insert statements for TABLE \n line One value per line \n list Values delimited by .separator string \n tabs Tab-separated values \n tcl TCL list elements \n.nullvalue STRING Print STRING in place of NULL values \n.output FILENAME Send output to FILENAME \n.output stdout Send output to the screen \n.prompt MAIN CONTINUE Replace the standard prompts \n.quit Exit this program \n.read FILENAME Execute SQL in FILENAME \n.schema ?TABLE? Show the CREATE statements \n.separator STRING Change separator used by output mode and .import \n.show Show the current values for various settings \n.tables ?PATTERN? List names of tables matching a LIKE pattern \n.timeout MS Try opening locked tables for MS milliseconds \n.width NUM NUM ... Set column widths for "column" mode
Install SQLite3 for Windows by downloading the following 2 zip files and unzipping them into /WINDOWS/system32 \nhttp://www.sqlite.org/sqlite-3_6_14_1.zip \nhttp://www.sqlite.org/sqlitedll-3_6_14_1.zip \nIf those don't work try the official download site here \nand now,you can open a cmd shell,and input sqlite3 like this: \n \nC:\\Documents and Settings\\Administrator>sqlite3 \nSQLite version 3.5.9 \nEnter ".help" for instructions \nand some help infos is here: \nsqlite> .help \n.bail ON|OFF Stop after hitting an error. Default OFF \n.databases List names and files of attached databases \n.dump ?TABLE? ... Dump the database in an SQL text format \n.echo ON|OFF Turn command echo on or off \n.exit Exit this program \n.explain ON|OFF Turn output mode suitable for EXPLAIN on or off. \n.header(s) ON|OFF Turn display of headers on or off \n.help Show this message \n.import FILE TABLE Import data from FILE into TABLE \n.indices TABLE Show names of all indices on TABLE \n.load FILE ?ENTRY? Load an extension library \n.mode MODE ?TABLE? Set output mode where MODE is one of: \n csv Comma-separated values \n column Left-aligned columns. (See .width) \n html HTML <table> code \n insert SQL insert statements for TABLE \n line One value per line \n list Values delimited by .separator string \n tabs Tab-separated values \n tcl TCL list elements \n.nullvalue STRING Print STRING in place of NULL values \n.output FILENAME Send output to FILENAME \n.output stdout Send output to the screen \n.prompt MAIN CONTINUE Replace the standard prompts \n.quit Exit this program \n.read FILENAME Execute SQL in FILENAME \n.schema ?TABLE? Show the CREATE statements \n.separator STRING Change separator used by output mode and .import \n.show Show the current values for various settings \n.tables ?PATTERN? List names of tables matching a LIKE pattern \n.timeout MS Try opening locked tables for MS milliseconds \n.width NUM NUM ... Set column widths for "column" mode
add this line into /etc/lftp.conf \nset net:limit-rate 10240000,40960 \n \nthat's limit upload rate to 10M,and download to 40K \n \nsome useful resource:
\ncURL figures out which protocol to use from the URL you provide, and when \"http:\" is specified will, unless otherwise instructed (using -0), default to using HTTP 1.1. The first argument, -u, instructs cURL to use the next two parameters (separated by a colon) as the account name and password for basic authentication. The next argument, -d, specifies the data (maximum 140 characters) to be sent via a POST request.\n\nOf course what cURL expects is a response to the POST request so the result will be the requested page (update.xml) sent to stdout. This page will be encoded according to the file type used in the request, thus as we just requested update.xml we’ll get XML-formatted data. The alternatives are JSON (JavaScript Object Notation), RSS and Atom formats.\n\nfrom:\nhttp://www.networkworld.com/columnists/2008/052108-gearhead.html?page=2", "created_at"=>2009-09-27 18:26:17 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
curl -u email:passw -d status="text" http://twitter.com/statuses/update.xml \ncURL figures out which protocol to use from the URL you provide, and when "http:" is specified will, unless otherwise instructed (using -0), default to using HTTP 1.1. The first argument, -u, instructs cURL to use the next two parameters (separated by a colon) as the account name and password for basic authentication. The next argument, -d, specifies the data (maximum 140 characters) to be sent via a POST request.
\n\n
Of course what cURL expects is a response to the POST request so the result will be the requested page (update.xml) sent to stdout. This page will be encoded according to the file type used in the request, thus as we just requested update.xml we’ll get XML-formatted data. The alternatives are JSON (JavaScript Object Notation), RSS and Atom formats.
项目中使用nginx,上传一个大文件,出来错误提示,413 Request Entity Too Large! \n查了下资料,解决方法:打开nginx主配置文件nginx.conf,找到http{}段,添加
\n\n
client_max_body_size 20m;
\n\n
最好也调整下: \n keepalive_timeout 105; \n免得链接超时被关!
\n\n
该文件一般在/etc/nginx/nginx.conf
\n", "_id"=>65}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["rails", "rails-2.3.4"], "comments_count"=>0, "category_id"=>6, "title"=>"rails-2.3.4 发布了", "body"=>"Ruby on Rails 2.3.4, this release fixes bugs and introduces a few minor features. Due to the inclusion of two security fixes, all users of the 2.3 series are recommended to upgrade as soon as possible.\n\nC:\\Documents and Settings\\Administrator>gem install rails\nSuccessfully installed activesupport-2.3.4\nSuccessfully installed activerecord-2.3.4\nSuccessfully installed actionpack-2.3.4\nSuccessfully installed actionmailer-2.3.4\nSuccessfully installed activeresource-2.3.4\nSuccessfully installed rails-2.3.4\n6 gems installed\nInstalling ri documentation for activesupport-2.3.4...\nInstalling ri documentation for activerecord-2.3.4...\nInstalling ri documentation for actionpack-2.3.4...\nInstalling ri documentation for actionmailer-2.3.4...\nInstalling ri documentation for activeresource-2.3.4...\nInstalling RDoc documentation for activesupport-2.3.4...\nInstalling RDoc documentation for activerecord-2.3.4...\nInstalling RDoc documentation for actionpack-2.3.4...\nInstalling RDoc documentation for actionmailer-2.3.4...\nInstalling RDoc documentation for activeresource-2.3.4...\n\n详细信息:\n\nhttp://weblog.rubyonrails.org/2009/9/4/ruby-on-rails-2-3-4", "created_at"=>2009-10-14 07:47:04 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
Ruby on Rails 2.3.4, this release fixes bugs and introduces a few minor features. Due to the inclusion of two security fixes, all users of the 2.3 series are recommended to upgrade as soon as possible.
\n\n
C:\\Documents and Settings\\Administrator>gem install rails \nSuccessfully installed activesupport-2.3.4 \nSuccessfully installed activerecord-2.3.4 \nSuccessfully installed actionpack-2.3.4 \nSuccessfully installed actionmailer-2.3.4 \nSuccessfully installed activeresource-2.3.4 \nSuccessfully installed rails-2.3.4 \n6 gems installed \nInstalling ri documentation for activesupport-2.3.4... \nInstalling ri documentation for activerecord-2.3.4... \nInstalling ri documentation for actionpack-2.3.4... \nInstalling ri documentation for actionmailer-2.3.4... \nInstalling ri documentation for activeresource-2.3.4... \nInstalling RDoc documentation for activesupport-2.3.4... \nInstalling RDoc documentation for activerecord-2.3.4... \nInstalling RDoc documentation for actionpack-2.3.4... \nInstalling RDoc documentation for actionmailer-2.3.4... \nInstalling RDoc documentation for activeresource-2.3.4...
\n", "_id"=>67}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["package", "ubuntu", "uninstall"], "comments_count"=>0, "category_id"=>7, "title"=>"Uninstall / Delete / Remove Package", "body"=>"Just use the following syntax:\n\nsudo apt-get remove {package-name}\n\nFor example remove package called mplayer, enter:\n$ sudo apt-get remove mplayer\n\nRemove package called lighttpd along with all configuration files, enter:\n$ sudo apt-get --purge remove lighttpd\n\nTo list all installed package, enter:\\\ndpkg --list\ndpkg --list | less\ndpkg --list | grep -i 'http'", "created_at"=>2009-11-22 18:48:23 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
Just use the following syntax:
\n\n
sudo apt-get remove {package-name}
\n\n
For example remove package called mplayer, enter: \n$ sudo apt-get remove mplayer
\n\n
Remove package called lighttpd along with all configuration files, enter: \n$ sudo apt-get --purge remove lighttpd
\n\n
To list all installed package, enter:\\ \ndpkg --list \ndpkg --list | less \ndpkg --list | grep -i 'http'
\n", "_id"=>68}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["delegate", "ImageMagick"], "comments_count"=>0, "category_id"=>7, "title"=>"ImageMagick够折腾得,no decode delegate", "body"=>"估计RP出问题了,以前安装和今天在mac上安装都很顺利,但是在服务器上装得时候,出现一大堆得问题,极度诡异,最后查了N多资料,改了N多东西,也不晓得最后是哪个生效了,终于折腾好了.\n记录下我参考过得资料:\nhttp://www.imagemagick.org/script/command-line-processing.php\nhttp://wanguan2000.blog.ubuntu.org.cn/2009/01/04/ubuntu-下rmagick的安装/\nhttp://infrastacks.com/?p=57\nhttp://hi.baidu.com/yttxuehui/blog/item/9f1a21978d6fa96a55fb96d5.html\nhttp://www.blogjava.net/fl1429/archive/2009/06/17/282895.html\nhttp://hi.baidu.com/countryroadtao/blog/item/225c72dad2adc16cd0164e97.html\nhttp://www.cnscn.org/htm_data/602/0705/8717.html\nhttp://stackoverflow.com/questions/1483968/imagemagick-convert-error-wrong-jpeg-library-version-library-is-62-caller-expe\n我读最后一个问题印象深刻\n\"Looks like it is reading the wrong jpeg ibrary, but I have jpeg 7 installed. How do i tell ImageMagick to look up the right JPEG library version(I don't care 62 or 70 as long as it works).\"\nroot@li84-64:/data/soft/ImageMagick-6.5.7-9# convert -list format | grep JPEG\n see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS),\n and supplement 61 which adds JPEG-2000 encoding.\n JNG* PNG rw- JPEG Network Graphics\n JP2* JP2 rw- JPEG-2000 File Format Syntax\n JPC* JPC rw- JPEG-2000 Code Stream Syntax\n JPEG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n JPG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n JPX* JPX rw- JPEG-2000 File Format Syntax\n PGX* PGX r-- JPEG-2000 VM Format\n PJPEG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n\n看到其需要得JPEG得lib是70,但是我装得是\n\nroot@li84-64:/data/soft/ImageMagick-6.5.7-9# dpkg --list | grep \"magick\"\nrc imagemagick 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation programs\nii libmagick++10 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library\nii libmagick++9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library - develop\nii libmagick10 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library\nii libmagick9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library - development fil\nii libmagickcore1 7:6.4.5.4.dfsg1-1ubuntu3.1 low-level image manipulation library\nii libmagickwand1 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation library\nii librmagick-ruby 1.15.11-1ubuntu1 ImageMagick API for Ruby\nii librmagick-ruby1.8 1.15.11-1ubuntu1 ImageMagick API for Ruby", "created_at"=>2009-11-22 20:30:32 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
root@li84-64:/data/soft/ImageMagick-6.5.7-9# dpkg --list | grep "magick" \nrc imagemagick 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation programs \nii libmagick++10 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library \nii libmagick++9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library - develop \nii libmagick10 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library \nii libmagick9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library - development fil \nii libmagickcore1 7:6.4.5.4.dfsg1-1ubuntu3.1 low-level image manipulation library \nii libmagickwand1 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation library \nii librmagick-ruby 1.15.11-1ubuntu1 ImageMagick API for Ruby \nii librmagick-ruby1.8 1.15.11-1ubuntu1 ImageMagick API for Ruby
\n", "_id"=>69}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["find", "inject", "rails", "ruby", "select"], "comments_count"=>0, "category_id"=>5, "title"=>"用Ruby在已知数组中找到和目标最匹配得元素", "body"=>"有个需求,给定一个数组,然后给出一个变量,需要在这个数组中找到和这个变量得值最接近得那个元素,开始用find或者select都不是很合适,最后找到inject,很好得解决了这个需求,现在记录下:\n首先看下inject这个函数\n````\nenum.inject(initial) {| memo, obj | block } => obj\nenum.inject {| memo, obj | block } => obj\nCombines the elements of enum by applying the block to an accumulator value (memo) and each element in turn. At each step, memo is set to the value returned by the block. The first form lets you supply an initial value for memo. The second form uses the first element of the collection as a the initial value (and skips that element while iterating).\n\n # Sum some numbers\n (5..10).inject {|sum, n| sum + n } #=> 45\n # Multiply some numbers\n (5..10).inject(1) {|product, n| product * n } #=> 151200\n\n # find the longest word\n longest = %w{ cat sheep bear }.inject do |memo,word|\n memo.length > word.length ? memo : word\n end\n longest #=> \"sheep\"\n\n # find the length of the longest word\n longest = %w{ cat sheep bear }.inject(0) do |memo,word|\n memo >= word.length ? memo : word.length\n end\n longest #=> 5\n```\n\n然后根据我得需求,写出一个函数如下:\n````\n # find the min abs size\n def self.select_h(h)\n if ALL_FORMATS.include?(h)\n return h\n else\n ok_size = ALL_FORMATS.inject do |i,j|\n (i-h).abs < (j-h).abs ? i : j\n end\n return ok_size\n end\n end\n```\n首先看是否包含这个变量,如果又,直接返回,如果没有就inject来取一个最合适得。", "created_at"=>2009-11-24 08:06:13 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
有个需求,给定一个数组,然后给出一个变量,需要在这个数组中找到和这个变量得值最接近得那个元素,开始用find或者select都不是很合适,最后找到inject,很好得解决了这个需求,现在记录下: \n首先看下inject这个函数 \n```` \nenum.inject(initial) {| memo, obj | block } => obj \nenum.inject {| memo, obj | block } => obj \nCombines the elements of enum by applying the block to an accumulator value (memo) and each element in turn. At each step, memo is set to the value returned by the block. The first form lets you supply an initial value for memo. The second form uses the first element of the collection as a the initial value (and skips that element while iterating).
\n\n
# Sum some numbers \n (5..10).inject {|sum, n| sum + n } #=> 45 \n # Multiply some numbers \n (5..10).inject(1) {|product, n| product * n } #=> 151200
\n\n
# find the longest word \n longest = %w{ cat sheep bear }.inject do |memo,word| \n memo.length > word.length ? memo : word \n end \n longest #=> "sheep"
\n\n
# find the length of the longest word \n longest = %w{ cat sheep bear }.inject(0) do |memo,word| \n memo >= word.length ? memo : word.length \n end \n longest #=> 5 \n```
\n\n
然后根据我得需求,写出一个函数如下: \n` \n # find the min abs size \n def self.select_h(h) \n if ALL_FORMATS.include?(h) \n return h \n else \n ok_size = ALL_FORMATS.inject do |i,j| \n (i-h).abs < (j-h).abs ? i : j \n end \n return ok_size \n end \n end \n \n首先看是否包含这个变量,如果又,直接返回,如果没有就inject来取一个最合适得。
\n", "_id"=>72}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["GD", "php", "ubuntu"], "comments_count"=>0, "category_id"=>7, "title"=>"Install GD Support for PHP in Ubuntu", "body"=>"I am in the process of building my blog using wordpress ,then i install SI CAPTCHA Anti-Spam ,but it's say i didn’t have GD support for PHP5 installed on my server. so i need to do:\n\nOpen terminal and type in the following command:\n
\n\nThere you go, you now have GD Support for PHP5 in Ubuntu. Get your Drupal on!", "created_at"=>2010-01-13 02:25:36 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
I am in the process of building my blog using wordpress ,then i install SI CAPTCHA Anti-Spam ,but it's say i didn’t have GD support for PHP5 installed on my server. so i need to do:
\n\n
Open terminal and type in the following command: \n$ sudo apt-get install php5-gd
\n\n
Now restart Apache \n# sudo /etc/init.d/apache2 restart
\n\n
or restart spawn-fcgi \n/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9100 -u www-data -g www-data -f /usr/bin/php-cgi -C 10
\n\n
There you go, you now have GD Support for PHP5 in Ubuntu. Get your Drupal on!
\n", "_id"=>73}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["centOS", "Swap"], "comments_count"=>0, "category_id"=>7, "title"=>"Swap Space in centOS", "body"=>"Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.\n\nSwap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.\n\nSwap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.\n\nSo, if:\n\nM = Amount of RAM in GB, and S = Amount of swap in GB, then\n
If M < 2\n\tS = M *2\nElse\n\tS = M + 2
\nUsing this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.\n\nFor systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).\n\nsource:http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-swapspace.html", "created_at"=>2010-01-21 02:01:34 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.
\n\n
Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
\n\n
Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.
\n\n
So, if:
\n\n
M = Amount of RAM in GB, and S = Amount of swap in GB, then \nIf M < 2 \n S = M *2 \nElse \n S = M + 2 \nUsing this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.
\n\n
For systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).
\n", "_id"=>74}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["劫持", "电信"], "comments_count"=>0, "category_id"=>5, "title"=>"深圳电信耍流氓,劫持浏览器", "body"=>"今天无意发现在浏览器的左下角经常出现一个页面无法打开的提示,如下\nThe webpage at http://121.15.207.133:4022/logo.jpg?p=undefined|778|1276|24|800|1280might be temporarily down or it may have moved permanently to a new web address.\n\n看其样式是请求了一个121.15.207.133上的一个logo图片,然后传入了几个参数,但是这个图片的服务器貌似除了电问题,导致请求不到。\n无缘无故的,咋会去请求这个玩意呢,查了吓这个IP归属,属于:\n
\n", "_id"=>75}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["C", "ruby", "RubyInline"], "comments_count"=>0, "category_id"=>2, "title"=>"RubyInline, Making Making Things Faster Easier", "body"=>"发现一篇好文,讲的是如何使用RubyInline,在Ruby中直接嵌入C并运行,相比之前些lib,要方便的多,由于这个文章在墙外,就转了一份过来,可以翻墙的可以去看原文\nhttp://on-ruby.blogspot.com/2006/07/rubyinline-making-making-things-faster.html\n\nToday on ruby-talk, I caught a thread called \"For Performance, Write it in C\". I'd like to present a slight amendment to that thesis. Let me explain.\n\nIt all started with an email at work. Someone was passing around a bunch of prime number printers in various languages (C, Java, C#, Perl, and Python). They all used the same (ugly) algorithm, and were supposed to show just how 'performant the languages were. Since I'm the local Ruby evangelist, I was asked to write a Ruby version. Here's what I came up with (warning, ugly algorithm ahead):\n\n#!/usr/bin/ruby\n\nfor num in 1..10_000 do\nis_prime = 1\nfor x in 2..(num - 1) do\nif (num % x == 0)\nis_prime = x\nbreak\nend\nend\nif is_prime == 1\nputs \"\#{num} is a prime number\"\nelse\nputs \"\#{num} equals \#{is_prime} * \#{num/is_prime}\"\nend\nend\nHow fast is it? Well, time says:\n\n$ time ./primes.rb > /dev/null\n\nreal 0m2.905s\nuser 0m2.716s\nsys 0m0.004s\n$\n\nCertainly, nothing to write home about, but not too far from Perl or Python either.\nWanting to improve it, and not being able to touch the algorithm (we want to be comparing apples to quinces after all, not apples to oranges). I know my only hope is to find the bottleneck(s) and rewrite it (them?) in C. My first step is to grab Ruby's profiler and see what it says (oh, by the way, I reduced the value of num to 100 so that this would complete in my lifetime ... the profiler is slow).\n\n$ ruby -rprofile primes.rb > /dev/null\n% cumulative self self total\ntime seconds seconds calls ms/call ms/call name\n63.64 0.14 0.14 101 1.39 3.56 Range#each\n13.64 0.17 0.03 1133 0.03 0.03 Fixnum#%\n9.09 0.19 0.02 1233 0.02 0.02 Fixnum#==\n4.55 0.20 0.01 100 0.10 0.20 Kernel.puts\n4.55 0.21 0.01 200 0.05 0.05 IO#write\n4.55 0.22 0.01 248 0.04 0.04 Fixnum#to_s\n0.00 0.22 0.00 74 0.00 0.00 Fixnum#/\n0.00 0.22 0.00 100 0.00 0.00 Fixnum#-\n0.00 0.22 0.00 1 0.00 220.00 #toplevel\n$\n\nWhich tells me that most of my time is spent in each (well, it's actually spent in the block I sent to each. It's taking a whopping 1.39 msec per call, compared to .0X msec for everything else. What would happen if I rewrote just that block?\nEnter RubyInline (A great tool written by zenspider and Eric Hodel). I'm not a C wiz by any stretch of the imagination, but this stuff is pretty easy to bang out. My new code looks like this:\n\n#!/usr/bin/ruby\n\nrequire \"rubygems\"\nrequire \"inline\"\n\nclass Primes\ninline do |builder|\nbuilder.c '\nint prime(int num) {\nint x;\nfor (x = 2; x < (num - 1) ; x++) { if (num == 2) { return 1; } if (num % x == 0) { return x; } } return 1; }' end end p = Primes.new for num in 2..10_000 do is_prime = p.prime(num) if is_prime == 1 puts \"\#{num} is a prime number\" else puts \"\#{num} equals \#{is_prime} * \#{num/is_prime}\" end end Not too ugly. At least I can still see what's happening. The main loop being in Ruby helps a lot too (especially if this were a much bigger program). How much of a difference does it make? time says: $ time ./cprimes.rb > /dev/null\n\nreal 0m0.328s\nuser 0m0.288s\nsys 0m0.020s\n\nAn order of magnitude improvement. Not too shabby.\nWhat's the lesson here? Optimize what you need to (and only what you need to), profile find out what that is (it may be slow, but profiling is your friend), and use the right tools (rewriting a bit of code with RubyInline is way better than rewriting the whole app in C).", "created_at"=>2010-01-24 10:51:47 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
Today on ruby-talk, I caught a thread called "For Performance, Write it in C". I'd like to present a slight amendment to that thesis. Let me explain.
\n\n
It all started with an email at work. Someone was passing around a bunch of prime number printers in various languages (C, Java, C#, Perl, and Python). They all used the same (ugly) algorithm, and were supposed to show just how 'performant the languages were. Since I'm the local Ruby evangelist, I was asked to write a Ruby version. Here's what I came up with (warning, ugly algorithm ahead):
\n\n
!/usr/bin/ruby
\n\n
for num in 1..10_000 do \nis_prime = 1 \nfor x in 2..(num - 1) do \nif (num % x == 0) \nis_prime = x \nbreak \nend \nend \nif is_prime == 1 \nputs "\#{num} is a prime number" \nelse \nputs "\#{num} equals \#{is_prime} * \#{num/is_prime}" \nend \nend \nHow fast is it? Well, time says:
\n\n
$ time ./primes.rb > /dev/null
\n\n
real 0m2.905s \nuser 0m2.716s \nsys 0m0.004s \n$
\n\n
Certainly, nothing to write home about, but not too far from Perl or Python either. \nWanting to improve it, and not being able to touch the algorithm (we want to be comparing apples to quinces after all, not apples to oranges). I know my only hope is to find the bottleneck(s) and rewrite it (them?) in C. My first step is to grab Ruby's profiler and see what it says (oh, by the way, I reduced the value of num to 100 so that this would complete in my lifetime ... the profiler is slow).
Which tells me that most of my time is spent in each (well, it's actually spent in the block I sent to each. It's taking a whopping 1.39 msec per call, compared to .0X msec for everything else. What would happen if I rewrote just that block? \nEnter RubyInline (A great tool written by zenspider and Eric Hodel). I'm not a C wiz by any stretch of the imagination, but this stuff is pretty easy to bang out. My new code looks like this:
\n\n
!/usr/bin/ruby
\n\n
require "rubygems" \nrequire "inline"
\n\n
class Primes \ninline do |builder| \nbuilder.c ' \nint prime(int num) { \nint x; \nfor (x = 2; x < (num - 1) ; x++) { if (num == 2) { return 1; } if (num % x == 0) { return x; } } return 1; }' end end p = Primes.new for num in 2..10_000 do is_prime = p.prime(num) if is_prime == 1 puts "\#{num} is a prime number" else puts "\#{num} equals \#{is_prime} * \#{num/is_prime}" end end Not too ugly. At least I can still see what's happening. The main loop being in Ruby helps a lot too (especially if this were a much bigger program). How much of a difference does it make? time says: $ time ./cprimes.rb > /dev/null
\n\n
real 0m0.328s \nuser 0m0.288s \nsys 0m0.020s
\n\n
An order of magnitude improvement. Not too shabby. \nWhat's the lesson here? Optimize what you need to (and only what you need to), profile find out what that is (it may be slow, but profiling is your friend), and use the right tools (rewriting a bit of code with RubyInline is way better than rewriting the whole app in C).
\n# Example MySQL config file for large systems.\n#\n# This is for a large system with memory = 512M where the system runs mainly\n# MySQL.\n#\n# You can copy this file to\n# /etc/my.cnf to set global options,\n# mysql-data-dir/my.cnf to set server-specific options (in this\n# installation this directory is /var/lib/mysql) or\n# ~/.my.cnf to set user-specific options.\n#\n# In this file, you can use all long options that a program supports.\n# If you want to know which options a program supports, run the program\n# with the \"--help\" option.\n\n# The following options will be passed to all MySQL clients\n[client]\nport = 3306\nsocket = /var/lib/mysql/mysql.sock\n\n# Here follows entries for some specific programs\n\n# The MySQL server\n[mysqld]\ndatadir=/var/lib/mysql\nsocket=/var/lib/mysql/mysql.sock\nuser=mysql\nskip-locking\n\n# By default, the wait_timeout value is 28800. Unless you want MySQL to keep waiting for 28800 seconds (480 minutes or 8 hours),\n# please decrease its value according to your application needs.\nwait_timeout=60\n# Increase connect_timeout from 5 to 10\nconnect_timeout=10\n# Decrease interactive_timeout from 28800 to 100\ninteractive_timeout=120\n# Increase join_buffer_size from 131072 to 1M\njoin_buffer_size=1M\n# Increase query_cache_size from 0 to 128M\nquery_cache_size=32M\n# Increase query cache limit from 1048576 to 2M\nquery_cache_limit=2M\n# Increase max allowed packet size from 1M to 16M\nmax_allowed_packet=2M\n# Increase table cache cache from 256 to 1024\ntable_cache=1024\n# Increase sort buffer size from 1M\nsort_buffer_size=2M\n# Increase read buffer size from 1M\nread_buffer_size=2M\n# Increase read_rnd_buffer_size to 4M\nread_rnd_buffer_size=4M\n\n#Other settings\nsort_buffer_size=8M\nkey_buffer = 256M\nkey_buffer_size=64M\nmyisam_sort_buffer_size = 64M\nthread_cache_size = 8\n# Try number of CPU's*2 for thread_concurrency\nthread_concurrency = 2\n\n\n# Don't listen on a TCP/IP port at all. This can be a security enhancement,\n# if all processes that need to connect to mysqld run on the same host.\n# All interaction with mysqld must be made via Unix sockets or named pipes.\n# Note that using this option without enabling named pipes on Windows\n# (via the \"enable-named-pipe\" option) will render mysqld useless!\n#\n#skip-networking\n\n# Disable Federated by default\nskip-federated\n\nold_passwords=1\n\n#for slow queries\nlog-slow-queries = /var/log/mysql-slow.log\nlong_query_time = 3\n\n[mysqldump]\nquick\nmax_allowed_packet = 16M\n\n[mysql]\nno-auto-rehash\n# Remove the next comment character if you are not familiar with SQL\n#safe-updates\n\n[isamchk]\nkey_buffer = 128M\nsort_buffer_size = 128M\nread_buffer = 2M\nwrite_buffer = 2M\n\n[myisamchk]\nkey_buffer = 128M\nsort_buffer_size = 128M\nread_buffer = 2M\nwrite_buffer = 2M\n\n[mysqlhotcopy]\ninteractive-timeout\n\n[mysqld_safe]\nlog-error=/var/log/mysqld.log\npid-file=/var/run/mysqld/mysqld.pid\n
mysql> SHOW VARIABLES like \"%sort%\";\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| max_length_for_sort_data | 1024 |\n| max_sort_length | 1024 |\n| myisam_max_sort_file_size | 2146435072 |\n| myisam_sort_buffer_size | 67108864 |\n| sort_buffer_size | 8388608 |\n+---------------------------+------------+\n5 rows in set (0.00 sec)
\n\n不晓得是做啥用的,查了下资料:\n
http://forge.mysql.com/wiki/MySQL_Internals_Algorithms\n\nUsing the modified filesort algorithm, the tuples are longer than the pairs used in the original method, and fewer of them fit in the sort buffer (the size of which is given by sort_buffer_size). As a result, it is possible for the extra I/O to make the modified approach slower, not faster. To avoid a slowdown, the optimization is used only if the total size of the extra columns in the sort tuple does not exceed the value of the max_length_for_sort_data system variable. (A symptom of setting the value of this variable too high is that you should see high disk activity and low CPU activity.)
Using the modified filesort algorithm, the tuples are longer than the pairs used in the original method, and fewer of them fit in the sort buffer (the size of which is given by sort_buffer_size). As a result, it is possible for the extra I/O to make the modified approach slower, not faster. To avoid a slowdown, the optimization is used only if the total size of the extra columns in the sort tuple does not exceed the value of the max_length_for_sort_data system variable. (A symptom of setting the value of this variable too high is that you should see high disk activity and low CPU activity.)
\n", "_id"=>81}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "filesort"], "comments_count"=>0, "category_id"=>11, "title"=>"What does Using filesort mean in MySQL?", "body"=>"一直以来,只要我看到explain出来的结果有“Using filesort ”,我就要想方设法的优化和改善,因为我以前以为这个的意思就是使用文件系统来排序(那该多慢呀!),其实不是这样的。\n在mysqlperformanceblog上看到一篇文章《What does Using filesort mean in MySQL?》其中作者说自己每次面世的时候都会问“what does Using filesort mean in EXPLAIN,” 结果没有一个人回答的是对的,结果让其比较郁闷,就写了这个文章说明:\n
The usual answer is something like “rows are being placed into a temporary table which is too big to fit in memory, so it gets sorted on disk.” Unfortunately, this is not the same thing. First of all, this is Using temporary. Secondly, temporary tables may go to disk if they are too big, but EXPLAIN doesn’t show that. (If I interview you, I might ask you what “too big” means, or I might ask you the other reason temporary tables go to disk!)
The truth is, filesort is badly named. Anytime a sort can’t be performed from an index, it’s a filesort. It has nothing to do with files. Filesort should be called “sort.” It is quicksort at heart.
\n正解是,filesort这个名字有问题,容易给人误解,在mysql中,任何不能通过index进行的sort都称之为filesort,这里的filesort和文件没有任何关系,应该称之为“sort”而不是“filesort”,它的内部实现就是快速排序。\n\n参考资料:\nWhat does Using filesort mean in MySQL?\nhttp://www.mysqlperformanceblog.com/2009/03/05/what-does-using-filesort-mean-in-mysql/\n\nHow MySQL executes ORDER BY\nhttp://s.petrunia.net/blog/?p=24", "created_at"=>2010-02-03 03:51:36 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
一直以来,只要我看到explain出来的结果有“Using filesort ”,我就要想方设法的优化和改善,因为我以前以为这个的意思就是使用文件系统来排序(那该多慢呀!),其实不是这样的。 \n在mysqlperformanceblog上看到一篇文章《What does Using filesort mean in MySQL?》其中作者说自己每次面世的时候都会问“what does Using filesort mean in EXPLAIN,” 结果没有一个人回答的是对的,结果让其比较郁闷,就写了这个文章说明: \nThe usual answer is something like “rows are being placed into a temporary table which is too big to fit in memory, so it gets sorted on disk.” Unfortunately, this is not the same thing. First of all, this is Using temporary. Secondly, temporary tables may go to disk if they are too big, but EXPLAIN doesn’t show that. (If I interview you, I might ask you what “too big” means, or I might ask you the other reason temporary tables go to disk!) \n通常的解释是:选择出来的记录太多了,需要排序时内存中放不下了,所以会存储在磁盘中,并通过操作磁盘的文件的方式来排序。但是呢,这是不对的。
\n\n
The truth is, filesort is badly named. Anytime a sort can’t be performed from an index, it’s a filesort. It has nothing to do with files. Filesort should be called “sort.” It is quicksort at heart. \n正解是,filesort这个名字有问题,容易给人误解,在mysql中,任何不能通过index进行的sort都称之为filesort,这里的filesort和文件没有任何关系,应该称之为“sort”而不是“filesort”,它的内部实现就是快速排序。
\n", "_id"=>82}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "variables"], "comments_count"=>0, "category_id"=>11, "title"=>"Mysql动态修改参数", "body"=>"mysql数据库也像ORACLE数据库一样,可以动态的修改参数,可以修改会话级变量只对当前会话产生影响;也可以修改全局变量,对所有新连接的会话都产生影响。\n\n修改会话级变量\n用show variables 命令查看当前参数的值,like 'pattern'用于模式匹配,查找指定的参数\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n用set SESSION命令设置会话级变量的新值\n\nmysql> set SESSION sort_buffer_size=7000000;\nQuery OK, 0 rows affected (0.00 sec)\n\n--修改会话级变量对当前会话来说立刻生效\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 7000000 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\nmysql> exit\nBye\n退出重新连接后,此参数恢复原值\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 40 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n修改全局变量\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 40 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n用set GLOBAL 命令设置全局变量\n\nmysql> set GLOBAL sort_buffer_size = 7000000;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n当前此参数的值并不发生变化,先退出,然后重新连进去\nmysql> exit\nBye\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 41 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 7000000 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n新的参数值生效", "created_at"=>2010-02-03 04:00:12 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
--修改会话级变量对当前会话来说立刻生效 \nmysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 7000000 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
mysql> exit \nBye \n退出重新连接后,此参数恢复原值 \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 40 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
修改全局变量 \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 40 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
用set GLOBAL 命令设置全局变量
\n\n
mysql> set GLOBAL sort_buffer_size = 7000000; \nQuery OK, 0 rows affected (0.00 sec)
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec) \n当前此参数的值并不发生变化,先退出,然后重新连进去 \nmysql> exit \nBye \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 41 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 7000000 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec) \n新的参数值生效
\n", "_id"=>84}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Tips"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Textmate", "theme"], "comments_count"=>0, "category_id"=>4, "title"=>"Installing a New Textmate Theme", "body"=>"To install a new theme, select one of the .tmTheme links listed below, download it to your desktop and double-click on the file. This will place it in ~/Library/Application Support/TextMate/Themes, at which point the new theme will appear in the list found in Preferences → Fonts & Colors. This will also set it as the active theme. (Once the theme is installed, you may remove the .tmTheme from your desktop.)\n\nRails Envy TextMate Theme\n http://railsenvy.com/2008/9/18/rails-envy-textmate-theme\n\nUser Submitted Themes\n http://wiki.macromates.com/Themes/UserSubmittedThemes", "created_at"=>2010-02-04 18:24:02 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
To install a new theme, select one of the .tmTheme links listed below, download it to your desktop and double-click on the file. This will place it in ~/Library/Application Support/TextMate/Themes, at which point the new theme will appear in the list found in Preferences → Fonts & Colors. This will also set it as the active theme. (Once the theme is installed, you may remove the .tmTheme from your desktop.)
\n\nrestart teatmate and it's done!\n\nIn the TextMate preferences, advanced tab, shell variables, set the TM_GIT variable to point to your installation of git (ie /usr/local/bin/git)\nMany shortcuts are available from the Git-shortcut (Ctrl-Shift-G). Subversion commands are Command-Option-g. Less frequent commands are accessed via the menu.\nUpdate your bundle by running the “Update Git Bundle” command.", "created_at"=>2010-02-04 23:39:24 UTC, "updated_at"=>2012-06-24 15:43:51 UTC, "body_html"=>"
In the TextMate preferences, advanced tab, shell variables, set the TM_GIT variable to point to your installation of git (ie /usr/local/bin/git) \nMany shortcuts are available from the Git-shortcut (Ctrl-Shift-G). Subversion commands are Command-Option-g. Less frequent commands are accessed via the menu. \nUpdate your bundle by running the “Update Git Bundle” command.
SIMBL (SIMple Bundle Loader) - pronounced like \"symbol\" or \"cymbal\" - enables hacks and plugins. For instance, SIMBL enables PithHelmet to enhance Safari.
Install SIMBL and make sure you have latest SIMBL 0.9.x\nPlace Visor.bundle into ~/Library/Application Support/SIMBL/Plugins (create this directory if it does not exist)\nRelaunch Terminal.app - You should now see the Visor Status Menu Item\nConfigure your keyboard trigger by selecting the Visor Status Menu Item -> Visor Preferences ... and edit your keyboard hot-key\nYou can now trigger Visor with your hot-key from any application to get an instant terminal session.\n\nTo hide Visor, you can either:\nre-trigger with your key-combo\noptionally you can click off of the Visor window
如果你和我一样经常使用终端程序,这个小程序一定可以帮到你。他能将终端窗口变成类似雷神或CS那样的下拉窗口,非常酷。 \n可以从这里下载 http://visor.binaryage.com/ \n这个软件需要SIMBL ,如果你没有安装,要先安装这个。 \nhttp://www.culater.net/software/SIMBL/SIMBL.php \nSIMBL (SIMple Bundle Loader) - pronounced like "symbol" or "cymbal" - enables hacks and plugins. For instance, SIMBL enables PithHelmet to enhance Safari. \n之后将下载下来的文件解压,将解压后的文件拷贝至/Library/Application Support/SIMBL/Plugins,之后再重新启动你的终端你就可以看到效果了。 默认的快捷启动键是Ctrl+` \nvisor: http://visor.binaryage.com/
\n\n
Installation
\n\n
Install SIMBL and make sure you have latest SIMBL 0.9.x \nPlace Visor.bundle into ~/Library/Application Support/SIMBL/Plugins (create this directory if it does not exist) \nRelaunch Terminal.app - You should now see the Visor Status Menu Item \nConfigure your keyboard trigger by selecting the Visor Status Menu Item -> Visor Preferences ... and edit your keyboard hot-key \nYou can now trigger Visor with your hot-key from any application to get an instant terminal session.
\n\n
To hide Visor, you can either: \nre-trigger with your key-combo \noptionally you can click off of the Visor window
前段时间写了一篇《实例优化mysql配置文件my.cnf》,这几天看到效果非常明显,别的不说,单mysql cache_hits就很不错(之前竟然没注意到这个参数) \n# Increase query_cache_size from 0 to 128M \nquery_cache_size=128M
Rails 3 in Action by Yehuda Katz and Mike Gunderloy. Currently available is their Early Access Edition, which gives you access to chapters as they are written.
\n\t
Beginning Rails 3 by Jeffrey Allan Hardy , Cloves Carneiro Jr. & Rida Al Barazi
这次升级需要新装很多的gem,如下: \ngem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n \ngem install rails --pre \n期间遇到一个错误: \nDue to a rubygems bug, you must uninstall all older versions of bundler for 0.9 to work \n然后这边有N多关于Rails3的资料供参考:
\n\n
Rails 3 Tutorials & Blog Posts
\n\n
Edging your way towards Ruby 1.9.1 and Rails 3.0pre \n Unobtrusive JavaScript in Rails 3 by Zach Carter \n A Fresh Cup: Seed Data in Rails 3 tutorial – feature summary + code example by Mike Gunderloy. \n Rails3: Stepping off of the golden path slides by Matt Aimonetti \n Rails Magazine – RailsConf 2009 Edition page 5 has a section called The Unofficial Guide to What’s New in Rails 3 by Rupak Ganguly \n Jason Ting’s RailsConf 2009 Notes includes some basic notes about Rails 3 \n Noel Rappin: Railsconf 09 – After the RailsConfening article \n Yehuda Katz: Railsconf Wrapup blog – contains links to jQuery talk by Katz at RailsConf 09 \n How to Begin Playing With Rails 3 by Oscar Del Ben \n My Five Favorite Things About Rails 3 by Yehuda Katz \n Rails 3: The Great Decoupling by Yehuda Katz \n Rails Edge Architecture by Yehuda Katz \n How to Build Sinatra on Rails 3 by Yehuda Katz
\n\n
Rails 3 Presentations & Conference Talks
\n\n
Yehuda: What to Expect in Rails 3.0 webcast recording \n Scotland on Rails: Yehuda on Rails & Merb Merge video. For more Scotland on Rails videos, check out this Ruby Inside post. \n Yehuda Katz on Rails 3 and beyond interview by Mark Coleman \n RailsConf: Yehuda – The Russian Doll Pattern video \n RailsConf 09: DHH Keynote video – DHH previews unobtrusive javascript, default escaping & more.
\n\n
Rails 3 Books
\n\n
Rails 3 in Action by Yehuda Katz and Mike Gunderloy. Currently available is their Early Access Edition, which gives you access to chapters as they are written. \n Beginning Rails 3 by Jeffrey Allan Hardy , Cloves Carneiro Jr. & Rida Al Barazi
\n\n
Rails 3 Commentary
\n\n
Internet News: Rails 3 Gets Supersized With Merb \n eWeek: Rubyists Unite Ruby on Rails and Merb to Merge in Rails 3 \n CIO: Rails 3 to add security enhancement \n Yehuda Katz: Rails and Merb Merge \n RubyOnRails.org: Rails + Merb Merge Announcement
\n", "_id"=>89}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"02. 产品设计 | PM"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({"count"=>"categories", "query"=>{:name=>"02. 产品设计 | PM"}, "fields"=>nil}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"categories"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['categories'].insert([{"sort"=>0, "posts_count"=>0, "name"=>"02. 产品设计 | PM", "updated_at"=>2012-06-24 15:43:52 UTC, "created_at"=>2012-06-24 15:43:52 UTC, "_id"=>13}])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Axure", "Balsamiq Mockups", "原型设计"], "comments_count"=>0, "category_id"=>13, "title"=>"Balsamiq Mockups,理想的原型设计工具", "body"=>"由于经常要讨论产品,包括web和手机(\bAandroid,Iphone)的产品原型设计,尝试过很多的原型设计工具,例如Axure等,后来换了mac book,就一直找不到合适的原型设计工具,就一直在Google Doc中直接draw,其做了很多无用功。\n比较偶然的机会看到Balsamiq Mockups这个软件,和Pixelmator一样,是个人开发者(意大利人Peldi)开发的产品,其地址为http://www.balsamiq.com/ ,在其提供的demo页面上试了下http://www.balsamiq.com/demos/mockups/Mockups.html,效果很好,符合我的预期。\n虽然是由个人设计的,但功能却一点不弱于其他大牌的原型设计工具:\n操作方面,拖拽,控件分组,甚至元素之间的对齐都做得很贴心;\n预制了很多界面元素,从简单的输入框,下拉框,浏览器主要元素,到经常用得到的导航条,日历,表格,到复杂的Tag Cloud,Cover Flow, 地图,WYSWYG的格式工具栏等,有了这些不用从头画起,往往比用白板都快;\n界面元素的修改很简单,比如导航条的几个标签页的label,就是用逗号分隔的文字,下拉框的选项就是分行的文字;\n使用xml语言来记录和保存界面元素和布局,\n这使得每个设计都能被很好得放进SVN,Git,和CVS等工具中进行管理和跟踪;\n可以设计复杂的界面元素,保存后,以后可以重复使用(包括修改);\n可以将设计导出成PNG格式的图片;\n可以用命令行进行导出操作,这样就能让我写个脚本,从svn里checkout某个目录下的所有设计文件后,导出图片,打包后用邮件发到项目经理,工程师甚至客户那;\n跨平台,Balsamiq Mokups是用Flex和Air实现的,所以在Mac OS, Linux和Windows下都能使用;\n不仅仅有桌面版本,还有能集成在Confluence,JIRA,和XWiki中的版本,使得异地在线协作更方便有效。\n\n以下是关于Balsamiq Mockups的一些特点:\n易操作:从 Balsamiq Mockups 自带的元素里可以很方便地拖拽,效果图轻易形成;元素对齐很贴心;\n可偷懒:根据 Balsamiq Mockups 提供的 Wiki 风格的代码规则,画图时可以「偷懒」,输入文本符号则能生成图标。因此相比其它繁琐的软件操作,Balsamiq Mockups 也能更快地完成画图任务。\n控件足:Balsamiq Mockups 软件包括 50 多个控件, 70 多个图标。基本自带了所有常用的小控件,并在导航处进行分类;图标设计赏心悦目。要是 Balsamiq Mockups 允许用户导入自定义的控件就更好了,当然现有的也足够了 -\n新风格:让人眼前一亮的涂鸦风格,很能还原手绘效果;\n可中文:在菜单栏 View 里将 Use System Fonts 勾上,就能完美支持中文输入(注:非 Balsamiq Mockups 中文版);\n其它点:Balsamiq Mockups 使用 xml 记录,方便移植、二次利用;可导出为 png 格式图片。\n\n另外还有跨平台与多版本两个优点:\n跨平台:Balsamiq Mockups 基于 Air ,因此能同时在 Windows、Mac OS 及 Linux 下使用;\n多版本:包括桌面版本,以及集成于 Confluence、JIRA、XWiki、FogBugz 中的版本\n\n软件可以从其网站上下载,其中桌面版本售价是$79。但作者非常厚道,提供了几种免费使用的方式:http://www.balsamiq.com/products/mockups/desktop\n\nYou can download Mockups for Desktop for free. Some of the features of the app, like saving and loading multiple mockups or linking mockups together can only get unlocked using a license key.\n", "created_at"=>2010-02-21 18:39:26 UTC, "updated_at"=>2012-06-24 15:43:52 UTC, "body_html"=>"
You can download Mockups for Desktop for free. Some of the features of the app, like saving and loading multiple mockups or linking mockups together can only get unlocked using a license key.
\n", "_id"=>90}])
+MONGODB iceylog_development['categories'].find({:_id=>13}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>13}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "socket"], "comments_count"=>0, "category_id"=>3, "title"=>"Can’t connect to local MySQL server through socket 解决办法", "body"=>"Rails启动后报错,ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/temp/mysql.sock’ (2)\n\n1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.\n另外看看是不是权限问题.\n\n2、确定你的mysql.sock是不是在那个位置,\nmysql -u 你的mysql用户名 -p -S /var/lib/mysql/mysql.sock\n\n3、试试:service mysqld start\n\n4、如果是权限问题,则先改变权限 #chown -R mysql:mysql /var/lib/mysql\n\n[root@localhost ~]# /etc/init.d/mysqld start\n启动 MySQL: [ 确定 ]\n[root@localhost ~]# mysql -uroot -p", "created_at"=>2010-02-23 21:24:14 UTC, "updated_at"=>2012-06-24 15:43:52 UTC, "body_html"=>"
Rails启动后报错,ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/temp/mysql.sock’ (2)
\n\n
1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动. \n另外看看是不是权限问题.
\n", "_id"=>91}])
+MONGODB iceylog_development['categories'].find({:_id=>3}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>3}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Passenger", "REE"], "comments_count"=>0, "category_id"=>2, "title"=>"Download Ruby Enterprise Edition(REE)", "body"=>"前段时间用上了Passenger ,尔后就看到很多的人推荐使用Ruby Enterprise Edition(REE),今天得闲,试了一把。\nStep 1: Download\nSource code: version 1.8.7-2010.01\nStep 2: Install\nExtract it:\ntar xzvf ruby-enterprise-X.X.X.tar.gz\nRun the installer (completely safe, none of your system files will be touched!):\n./ruby-enterprise-X.X.X/installer\n
Welcome to the Ruby Enterprise Edition installer
\n
This installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.
\n
Don't worry, none of your system files will be touched if you don't want them
\n
to, so there is no risk that things will screw up.
\n
You can expect this from the installation process:
\n
1. Ruby Enterprise Edition will be compiled and optimized for speed for this
\n
system.
\n
2. Ruby on Rails will be installed for Ruby Enterprise Edition.
\n
3. You will learn how to tell Phusion Passenger to use Ruby Enterprise
\n
Edition instead of regular Ruby.
\n
Press Enter to continue, or Ctrl-C to abort.
\n
Welcome to the Ruby Enterprise Edition installerThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.Don't worry, none of your system files will be touched if you don't want themto, so there is no risk that things will screw up.\nYou can expect this from the installation process:\n1. Ruby Enterprise Edition will be compiled and optimized for speed for this system.\n\n2. Ruby on Rails will be installed for Ruby Enterprise Edition.\n\n3. You will learn how to tell Phusion Passenger to use Ruby Enterprise Edition instead of regular Ruby.\nPress Enter to continue, or Ctrl-C to abort.
\nStep 3: Make Phusion Passenger use Ruby Enterprise Edition instead of regular Ruby\nFollow the instructions that the Ruby Enterprise Edition installer gave you.", "created_at"=>2010-03-03 16:53:29 UTC, "updated_at"=>2012-06-24 15:43:52 UTC, "body_html"=>"
前段时间用上了Passenger ,尔后就看到很多的人推荐使用Ruby Enterprise Edition(REE),今天得闲,试了一把。 \nStep 1: Download \nSource code: version 1.8.7-2010.01 \nStep 2: Install \nExtract it: \ntar xzvf ruby-enterprise-X.X.X.tar.gz \nRun the installer (completely safe, none of your system files will be touched!): \n./ruby-enterprise-X.X.X/installer \nWelcome to the Ruby Enterprise Edition installer \nThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01. \nDon't worry, none of your system files will be touched if you don't want them \nto, so there is no risk that things will screw up. \nYou can expect this from the installation process: \n1. Ruby Enterprise Edition will be compiled and optimized for speed for this \nsystem. \n2. Ruby on Rails will be installed for Ruby Enterprise Edition. \n3. You will learn how to tell Phusion Passenger to use Ruby Enterprise \nEdition instead of regular Ruby. \nPress Enter to continue, or Ctrl-C to abort. \nWelcome to the Ruby Enterprise Edition installerThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.Don't worry, none of your system files will be touched if you don't want themto, so there is no risk that things will screw up. \nYou can expect this from the installation process: \n1. Ruby Enterprise Edition will be compiled and optimized for speed for this system.
\n\n\n
Ruby on Rails will be installed for Ruby Enterprise Edition.
\n
You will learn how to tell Phusion Passenger to use Ruby Enterprise Edition instead of regular Ruby. \nPress Enter to continue, or Ctrl-C to abort. \nStep 3: Make Phusion Passenger use Ruby Enterprise Edition instead of regular Ruby \nFollow the instructions that the Ruby Enterprise Edition installer gave you.
\n\n", "_id"=>92}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"02. 产品设计 | PM"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Border-radius", "css3"], "comments_count"=>0, "category_id"=>13, "title"=>"Border-radius: create rounded corners with CSS!", "body"=>"W3C has offered some new options for borders in CSS3, of which one is border-radius. Both Mozila/Firefox and Safari 3 have implemented this function, which allows you to create round corners on box-items. This is an example:\n\nMozilla/Firefox and Safari 3 users should see a nicely rounded box, with a nicely rounded border.\nThe code for this example above is actually quite simple:\n\nThese different corners can also each be handled on their own, Mozilla has other names for the feature than the spec says it should have though, as it has f.i. -moz-border-radius-topright as opposed to -webkit-border-top-right-radius:\n\nMozilla/Firefox and Safari 3 users should see a box with a rounded left upper corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded right upper corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded left lower corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded right lower corner.\nThese are handled by / should be handled by:\n\n````-moz-border-radius-topleft / -webkit-border-top-left-radius\n-moz-border-radius-topright / -webkit-border-top-right-radius\n-moz-border-radius-bottomleft / -webkit-border-bottom-left-radius\n-moz-border-radius-bottomright / -webkit-border-bottom-right-radius```", "created_at"=>2010-03-05 10:38:13 UTC, "updated_at"=>2012-06-24 15:43:52 UTC, "body_html"=>"
W3C has offered some new options for borders in CSS3, of which one is border-radius. Both Mozila/Firefox and Safari 3 have implemented this function, which allows you to create round corners on box-items. This is an example:
\n\n
Mozilla/Firefox and Safari 3 users should see a nicely rounded box, with a nicely rounded border. \nThe code for this example above is actually quite simple: \n \nThese different corners can also each be handled on their own, Mozilla has other names for the feature than the spec says it should have though, as it has f.i. -moz-border-radius-topright as opposed to -webkit-border-top-right-radius:
\n\n
Mozilla/Firefox and Safari 3 users should see a box with a rounded left upper corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded right upper corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded left lower corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded right lower corner. \nThese are handled by / should be handled by:
\n", "_id"=>95}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["action_mailer_optional_tls", "Gmail", "Redmine"], "comments_count"=>0, "category_id"=>2, "title"=>"Setup Redmine to send email using GMail", "body"=>"Redmine是用Rails写的一套很不错的项目管理系统,其提供了诸多很方便实用的功能,诸如里程碑管理,BUG跟踪,代码库变更管理等等。\n搭建以后在管理面板中测试邮件不通,主要原因是由于采用的Gmail的邮箱,于是找到一些解决方案,如下:\n1. Install the action_mailer_optional_tls plugin\nThe action_mailer_optional_tls_plugin adds a TLS option to Redmine's emailing library, ActionMailer. TLS is a version of SSL which is required by GMail in order to send email.\n\nTo install this plugin, use the script/plugin command in your Redmine directory:\n ./script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git\n\n2. Configure your email.yml\n# File: config/email.yml\nproduction:\n delivery_method: :smtp\n smtp_settings:\n tls: true\n address: \"smtp.gmail.com\"\n port: 587\n domain: \"www.YOURDOAMIN.com\" # 'your.domain.com' for GoogleApps\n authentication: :plain\n user_name: \"username@youdomain.com\"\n password: \"password\"\n\n3. Start up Redmine and test your Email\nNext it's time to start up Redmine and to send a test email. Make sure that you start Redmine in the same mode as you configured above (e.g. production). To send a test email:\nLogin as an administrator\nGo to the Administration panel\nGo into the Settings and select the \"Email notifications\" tab\nIn the bottom right, click the link to \"Send a test email\"", "created_at"=>2010-03-14 18:31:57 UTC, "updated_at"=>2012-06-24 15:43:52 UTC, "body_html"=>"
Redmine是用Rails写的一套很不错的项目管理系统,其提供了诸多很方便实用的功能,诸如里程碑管理,BUG跟踪,代码库变更管理等等。 \n搭建以后在管理面板中测试邮件不通,主要原因是由于采用的Gmail的邮箱,于是找到一些解决方案,如下: \n1. Install the action_mailer_optional_tls plugin \nThe action_mailer_optional_tls_plugin adds a TLS option to Redmine's emailing library, ActionMailer. TLS is a version of SSL which is required by GMail in order to send email.
\n\n
To install this plugin, use the script/plugin command in your Redmine directory: \n ./script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git
3. Start up Redmine and test your Email \nNext it's time to start up Redmine and to send a test email. Make sure that you start Redmine in the same mode as you configured above (e.g. production). To send a test email: \nLogin as an administrator \nGo to the Administration panel \nGo into the Settings and select the "Email notifications" tab \nIn the bottom right, click the link to "Send a test email"
\n", "_id"=>97}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["concat", "Database"], "comments_count"=>0, "category_id"=>3, "title"=>"MySQL CONCAT", "body"=>"MySQL CONCAT function is used to concatenate two strings to form a single string. Try out following example:\nmysql> SELECT CONCAT('FIRST ', 'SECOND');\n+----------------------------+\n| CONCAT('FIRST ', 'SECOND') |\n+----------------------------+\n| FIRST SECOND |\n+----------------------------+\n1 row in set (0.00 sec)\n\nie.\nmysql -u eoewallpapers -p123456123 wallpapers -e 'set names 'utf8'; select CONCAT(base_url,\"400\",title) from photos where state > 10 ' > photos_400.txt", "created_at"=>2010-03-19 20:34:34 UTC, "updated_at"=>2012-06-24 15:43:52 UTC, "body_html"=>"
MySQL CONCAT function is used to concatenate two strings to form a single string. Try out following example: \nmysql> SELECT CONCAT('FIRST ', 'SECOND'); \n+----------------------------+ \n| CONCAT('FIRST ', 'SECOND') | \n+----------------------------+ \n| FIRST SECOND | \n+----------------------------+ \n1 row in set (0.00 sec)
\n\n
ie. \nmysql -u eoewallpapers -p123456123 wallpapers -e 'set names 'utf8'; select CONCAT(base_url,"400",title) from photos where state > 10 ' > photos_400.txt
alias ls=”ls -G”是给”ls -G”起了一个别名,当执行ls时,就相当于执行了ls -G。
\n\n
CLICOLOR是用来设置是否进行颜色的显示。CLI是Command Line Interface的缩写。 \nLSCOLORS是用来设置当CLICOLOR被启用后,各种文件类型的颜色。LSCOLORS的值中每两个字母为一组,分别设置某个文件类型的文字颜色和背景颜色。LSCOLORS中一共11组颜色设置,按照先后顺序,分别对以下的文件类型进行设置:
\n\n
directory \nsymbolic link \nsocket \npipe \nexecutable \nblock special \ncharacter special \nexecutable with setuid bit set \nexecutable with setgid bit set \ndirectory writable to others, with sticky bit \ndirectory writable to others, without sticky bit \nLSCOLORS中,字母代表的颜色如下:
\n", "_id"=>103}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["10.6.3", "rails3", "railties"], "comments_count"=>0, "category_id"=>7, "title"=>"解决升级mac OS 10.6.3后rails3无法启动的问题", "body"=>"昨晚看hero的时候顺带update到mac OS 10.6.3,早上重启机器安装成功,发现rails3无法启动,报:\n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception)\nfrom /usr/bin/rails:19\n\n这个错误我之前安装rails3的时候遇到过,解决如下:\n1.先尝试下重新安装rails\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install rails --pre\nPassword:\nSuccessfully installed treetop-1.4.5\n1 gem installed\nInstalling ri documentation for treetop-1.4.5...\nInstalling RDoc documentation for treetop-1.4.5..\n发现多了个treetop的gem,查查是啥:\n
Treetop is a language for describing languages. Combining the elegance of Ruby with cutting-edge parsing expression grammars, it helps you analyze syntax with revolutionarily ease.
\n\n再次执行rails,发现\n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception)\n from /usr/bin/rails:19\n\n还是不行,那就是railties的问题了,重新装下\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install railties --pre\nSuccessfully installed railties-3.0.0.beta\n1 gem installed\nInstalling ri documentation for railties-3.0.0.beta...\nInstalling RDoc documentation for railties-3.0.0.beta...\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ rails -v\nRails 3.0.0.beta\n\nOK,可以了~", "created_at"=>2010-03-31 22:01:38 UTC, "updated_at"=>2012-06-24 15:43:52 UTC, "body_html"=>"
昨晚看hero的时候顺带update到mac OS 10.6.3,早上重启机器安装成功,发现rails3无法启动,报: \n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception) \nfrom /usr/bin/rails:19
\n\n
这个错误我之前安装rails3的时候遇到过,解决如下: \n1.先尝试下重新安装rails \nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install rails --pre \nPassword: \nSuccessfully installed treetop-1.4.5 \n1 gem installed \nInstalling ri documentation for treetop-1.4.5... \nInstalling RDoc documentation for treetop-1.4.5.. \n发现多了个treetop的gem,查查是啥: \nTreetop is a language for describing languages. Combining the elegance of Ruby with cutting-edge parsing expression grammars, it helps you analyze syntax with revolutionarily ease.
\n\n
再次执行rails,发现 \n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception) \n from /usr/bin/rails:19
做移动互联网的过程中,有这样一些词是必须知道的,如MO,MT,GSM,LINKID \n上行(MO)上行的意思就是短信发送到服务器端 MO又称 Mobile Original \n下行(MT)下行的意思就是短信从服务器端发回到手机上,MT又称Mobile Terminated \n简单的说,从手机发起一个的过程叫上行(MO),到手机结束的过程叫下行(MT),比如,平时给你的朋友发送一条短信,对你来说就是上行(MO),而对你的朋友来说,就是下行(MT)。在企业、行业应用中,从系统给手机发送信息的过程叫下行(MT),而手机发送信息给系统的过程叫上行(MO)。
\n", "_id"=>113}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["log", "rails3", "slice_before"], "comments_count"=>0, "category_id"=>2, "title"=>"Parse Rails 3 log file using Enumerable#slice_before", "body"=>"``def parse_rails_log_file(file)\n # Remove all empty lines\n lines = file.each_line.map(&:strip).reject(&:empty?)\n\n # Use +Enumerable#slice_before+ to slice log file into sections for each request\n lines.slice_before(/Started (GET|POST|PUT|DELETE)/).each_with_object({}) do |request_log, totals|\n # Only include successfully finished actions in report\n if duration = request_log.last[/Completed 200 OK in (?<duration>\\d+)ms/, :duration]\n action_name = request_log.first[/Started (GET|POST|PUT|DELETE) \"(?<action>.+?)\" for/, :action]\n totals[action_name] ||= 0\n totals[action_name] += duration.to_i\n end\n end\nend\n\nif __FILE__ == $PROGRAM_NAME\n require \"pp\"\n puts \"Parsing Rails 3 log file (extracting cumulative running time per request path):\"\n puts \"=================\"\n\n log_file = <<-LOG_FILE\n Started GET \"/index\" for 192.168.74.1 at 2010-03-09 11:37:40\n Processing by UpdatesController#index as HTML\n Update Load (0.5ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (16.7ms)\n Completed 200 OK in 71ms (Views: 44.3ms | ActiveRecord: 0.5ms)\n\n Started POST \"/updates\" for 192.168.74.1 at 2010-03-09 11:37:43\n Processing by UpdatesController#create as HTML\n Parameters: {\"commit\"=>\"Save changes\"}\n Update Load (0.4ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (1.3ms)\n Completed 200 OK in 60ms (Views: 32.1ms | ActiveRecord: 0.4ms)\n\n Started GET \"/updates\" for 192.168.74.1 at 2010-03-09 11:45:51\n Processing by UpdatesController#index as HTML\n\n TypeError (exception class/object expected):\n app/controllers/updates_controller.rb:3:in `raise'\n app/controllers/updates_controller.rb:3:in `index'\n\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.6ms)\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.9ms)\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb (23.9ms)\n\n Started GET \"/updates\" for 192.168.74.1 at 2010-03-09 11:45:58\n Processing by UpdatesController#index as HTML\n Update Load (0.3ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (1.1ms)\n Completed 200 OK in 100ms (Views: 29.3ms | ActiveRecord: 0.3ms)\n LOG_FILE\n\n pp parse_rails_log_file(log_file) # => {\"/index\"=>71, \"/updates\"=>160}\nend```", "created_at"=>2010-07-26 21:42:33 UTC, "updated_at"=>2012-06-24 15:43:52 UTC, "body_html"=>"
# Use +Enumerable#slice_before+ to slice log file into sections for each request \n lines.slice_before(/Started (GET|POST|PUT|DELETE)/).each_with_object({}) do |request_log, totals| \n # Only include successfully finished actions in report \n if duration = request_log.last[/Completed 200 OK in (?<duration>\\d+)ms/, :duration] \n action_name = request_log.first[/Started (GET|POST|PUT|DELETE) "(?<action>.+?)" for/, :action] \n totals[action_name] ||= 0 \n totals[action_name] += duration.to_i \n end \n end \nend
\n\n
if FILE == $PROGRAM_NAME \n require "pp" \n puts "Parsing Rails 3 log file (extracting cumulative running time per request path):" \n puts "================="
\n\n
log_file = <<-LOG_FILE \n Started GET "/index" for 192.168.74.1 at 2010-03-09 11:37:40 \n Processing by UpdatesController#index as HTML \n Update Load (0.5ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (16.7ms) \n Completed 200 OK in 71ms (Views: 44.3ms | ActiveRecord: 0.5ms)
\n\n
Started POST "/updates" for 192.168.74.1 at 2010-03-09 11:37:43 \n Processing by UpdatesController#create as HTML \n Parameters: {"commit"=>"Save changes"} \n Update Load (0.4ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (1.3ms) \n Completed 200 OK in 60ms (Views: 32.1ms | ActiveRecord: 0.4ms)
\n\n
Started GET "/updates" for 192.168.74.1 at 2010-03-09 11:45:51 \n Processing by UpdatesController#index as HTML
Started GET "/updates" for 192.168.74.1 at 2010-03-09 11:45:58 \n Processing by UpdatesController#index as HTML \n Update Load (0.3ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (1.1ms) \n Completed 200 OK in 100ms (Views: 29.3ms | ActiveRecord: 0.3ms) \n LOG_FILE
\n写完申明后,去看消息出处看到其竟然做了修改,我早料到其会做相关的行为,所有早些时候截了屏幕如下:\n\n\n\n而现在的文章被修改为:\n\n\n\n看我用鼠标标识的地方,对关键信息进行了修改,感兴趣的人可以去 http://mobile.venturebeat.com/2010/07/28/android-wallpaper-app-that-steals-your-data-was-downloaded-by-millions/ 查看原文,对于这种标题党用子虚乌有的事情炒作,等消息传播后再修改自己的内容算什么行为!而对国内部分媒体在传播时不但不对真实性进行验证,还添油加醋,歪曲意思的报道,我非常无奈(看到有人还说可以获取信用卡信息,还加密传输,我实在无语)。\n\n按照我个人的感觉,他们应该紧接着要开始拿这个事件来炒作自己的产品了,我个人懒得去关注,如果有人发现有人借此炒作自己的产品,请帮忙分析分析,看看到底是什么人用这样手法。\n\n再次update!!!\n\n通过email和mylookout的人取得联系,说明我取得诸如设备号,手机屏幕大小是为了更智能的给设备适配图片,而获取部分的sim卡号是后来用户反馈说自己换了手机还想使用之前的收藏记录才使用的,这些信息只在该应用中使用,并没提供给任何第三方!\n\n同时让其确认venturebeat上文章中说到的获取浏览器历史,短信息,密码等高敏感性信息是否是他们说的还是写文章的人自己写的(Lots of my users send me the email ask me why I collect their text message and voicemail passward, I just want to make sure whether you and your ceo said that I collected browsing history,text message ,voicemail passward during the meeting.)。\n\n其cto给我回复说他们没有说过我的应用获取过诸如text messages or browsing history这些信息( We never stated that the wallpaper applications gathered users text messages or browsing history.),是媒体在撰写和传播的时候错误报道了(A member of the press misreported our research and he has since corrected it. )。\n\n我非常无语~\n\n2010年8月4日第二次次update!\n\n多谢这些天很多朋友的关心,我很好,谢谢!这些天和google android组,lookout公司和venturebeat的作者,以及国内外很多媒体,博客们,记者们都有很多的接触。\n\n1. google就前段时间将应用暂停和我一起分析了这个应用,今天发来调查的结果:\n\nOur investigation has concluded that there's no obvious malicious code in your apps, though the implementation accesses data that it doesn't need to. We've restored your apps (and they'll be available on Market again once you publish them), and are looking forward to seeing them updated to use ANDROID_ID. We are likely to make a statement about this issue this week--I'll let you know.\n\n我早就说过,我配合调查,我把代码提供给他们,google也做出了公正的评判,另外也给我提了一些建议(ANDROID_ID)。\n\n2. 当时写这篇报道的venturebeat记者Dean Takahashi发来了mail,为自己犯的错误道歉,并道歉该事带来的恶劣影响,会再写一篇文章澄清这个事情以消除影响。\n\n3. 那个安全公司lookout的人写邮件来要于我一起“ We wanted to coordinate with you to prevent further misunderstandings. ”。\n\n4.好几个不认识的国外记者很负责任,发邮件和gt和我交流询问事情的真相,并帮我喊冤,谢谢这些有职业精神的记者们。\n\n这个事情到这差不多就结束了,其中看到很多假丑恶,也看到很多真善美!谢谢所有帮助过我的人(很多很多,就不一一列举)。", "created_at"=>2010-07-29 08:41:39 UTC, "updated_at"=>2012-06-24 15:43:52 UTC, "body_html"=>"
同时让其确认venturebeat上文章中说到的获取浏览器历史,短信息,密码等高敏感性信息是否是他们说的还是写文章的人自己写的(Lots of my users send me the email ask me why I collect their text message and voicemail passward, I just want to make sure whether you and your ceo said that I collected browsing history,text message ,voicemail passward during the meeting.)。
\n\n
其cto给我回复说他们没有说过我的应用获取过诸如text messages or browsing history这些信息( We never stated that the wallpaper applications gathered users text messages or browsing history.),是媒体在撰写和传播的时候错误报道了(A member of the press misreported our research and he has since corrected it. )。
Our investigation has concluded that there's no obvious malicious code in your apps, though the implementation accesses data that it doesn't need to. We've restored your apps (and they'll be available on Market again once you publish them), and are looking forward to seeing them updated to use ANDROID_ID. We are likely to make a statement about this issue this week--I'll let you know.
\n", "_id"=>115}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Munin", "netstat", "passive"], "comments_count"=>0, "category_id"=>7, "title"=>"Fix the passive netstat connections in Munin", "body"=>"\n\nIf your running Munin in WHM they you may have noticed the passive netstat connections have been rising steadily over the last couple of weeks. This isn't a problem with your server, its a Munin bug that can be easily fixed.\n\n\n\n\n\nApparently the problem stemms from Munin counting the passive connections rejected. You can fix this problem quite easily by following the instructions below\n\nEdit the following file:\n/usr/share/munin/plugins/netstat\n\nand change the line\n
If your running Munin in WHM they you may have noticed the passive netstat connections have been rising steadily over the last couple of weeks. This isn't a problem with your server, its a Munin bug that can be easily fixed.
\n\n\n\n
Apparently the problem stemms from Munin counting the passive connections rejected. You can fix this problem quite easily by following the instructions below
\n\n
Edit the following file: \n/usr/share/munin/plugins/netstat
\n", "_id"=>116}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Charts", "Highcharts", "rails"], "comments_count"=>0, "category_id"=>2, "title"=>"ChartsOnRails", "body"=>"这几天需要找到漂亮的Charts类库,找了几个,发现一个很不粗的,mark下待使用,介绍如下:\n\nHighcharts is a charting library written in pure JavaScript, offering an easy way of adding interactive charts to your web site or web application. Highcharts currently supports line, spline, area, areaspline, column, bar, pie and scatter chart types.\n\n有兴趣的可以参考如下连接去看看:\n\nhttp://highcharts.com/\n\nhttp://railscasts.com/episodes/223-charts\n\nhttp://www.spritle.com/blogs/?p=859", "created_at"=>2010-08-20 21:48:59 UTC, "updated_at"=>2012-06-24 15:43:52 UTC, "body_html"=>"
这几天需要找到漂亮的Charts类库,找了几个,发现一个很不粗的,mark下待使用,介绍如下:
\n\n
Highcharts is a charting library written in pure JavaScript, offering an easy way of adding interactive charts to your web site or web application. Highcharts currently supports line, spline, area, areaspline, column, bar, pie and scatter chart types.
Delete your debug certificate under ~/.android/debug.keystore (on Linux and Mac OS X); the directory is something like %USERHOME%/.androidon Windows.
\n\n
The Eclipse plugin should then generate a new certificate when you next try to build a debug package.
\n", "_id"=>122}])
+MONGODB iceylog_development['categories'].find({:_id=>12}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>12}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["brew"], "comments_count"=>0, "category_id"=>7, "title"=>"Installs Homebrew to /usr/local so you don't need sudo to `brew install`", "body"=>"$ curl https://raw.github.com/gist/323731/install_homebrew.rb -o /tmp/install_homebrew.rb\n % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n100 4569 100 4569 0 0 1605 0 0:00:02 0:00:02 --:--:-- 2346\n\n $ ruby /tmp/install_homebrew.rb\n==> This script will install:\n/usr/local/bin/brew\n/usr/local/Library/Formula/...\n/usr/local/Library/Homebrew/...\n==> The following directories will be made group writable:\n/usr/local/.\n/usr/local/bin\n==> The following directories will have their group set to admin:\n/usr/local/.\n/usr/local/bin\n\nPress enter to continue\n==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin\n==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin\n==> Downloading and Installing Homebrew...\nWarning: The following *evil* dylibs exist in /usr/local/lib\nThey may break builds or worse. You should consider deleting them:\n/usr/local/lib/libevent-1.4.2.1.3.dylib\n/usr/local/lib/libevent_core-1.4.2.1.3.dylib\n/usr/local/lib/libevent_extra-1.4.2.1.3.dylib\n/usr/local/lib/libkyotocabinet.4.8.0.dylib\n/usr/local/lib/libprotobuf-lite.6.dylib\n/usr/local/lib/libprotobuf.6.dylib\n/usr/local/lib/libprotoc.6.dylib\n==> Installation successful!\nNow type: brew help\n\n参考:https://gist.github.com/323731", "created_at"=>2011-09-03 08:29:42 UTC, "updated_at"=>2012-06-24 15:43:52 UTC, "body_html"=>"
$ curl https://raw.github.com/gist/323731/install_homebrew.rb -o /tmp/install_homebrew.rb \n % Total % Received % Xferd Average Speed Time Time Time Current \n Dload Upload Total Spent Left Speed \n100 4569 100 4569 0 0 1605 0 0:00:02 0:00:02 --:--:-- 2346
\n\n
$ ruby /tmp/install_homebrew.rb \n==> This script will install: \n/usr/local/bin/brew \n/usr/local/Library/Formula/... \n/usr/local/Library/Homebrew/... \n==> The following directories will be made group writable: \n/usr/local/. \n/usr/local/bin \n==> The following directories will have their group set to admin: \n/usr/local/. \n/usr/local/bin
\n\n
Press enter to continue \n==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin \n==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin \n==> Downloading and Installing Homebrew... \nWarning: The following evil dylibs exist in /usr/local/lib \nThey may break builds or worse. You should consider deleting them: \n/usr/local/lib/libevent-1.4.2.1.3.dylib \n/usr/local/lib/libevent_core-1.4.2.1.3.dylib \n/usr/local/lib/libevent_extra-1.4.2.1.3.dylib \n/usr/local/lib/libkyotocabinet.4.8.0.dylib \n/usr/local/lib/libprotobuf-lite.6.dylib \n/usr/local/lib/libprotobuf.6.dylib \n/usr/local/lib/libprotoc.6.dylib \n==> Installation successful! \nNow type: brew help
\n", "_id"=>123}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["perl", "Twig", "xml"], "comments_count"=>0, "category_id"=>7, "title"=>"install perl module for XML-Twig in RHEL-Red Hat/Fedora Linux?", "body"=>"This module provides a way to process XML documents. It is build on top of XML::Parser. XML::Twig offers a tree interface to the document, while allowing you to output the parts of it that have been completely processed. It allows minimal resource (CPU and memory) usage by building the tree only for the parts of the documents that need actual processing, through the use of the twig_roots and twig_print_outside_roots options.(as pointed by yum info)\r\n\r\nLet’s first search for the package\r\n$ yum search perl-XML-Twig\r\nperl-XML-Twig.noarch : A perl module for processing huge XML documents in tree\r\n\r\nNote that you must be the root/administrator to install the package. To install this package in Red Hat/Fedora Linux.\r\n$ yum install perl-XML-Twig.noarch\r\n\r\nYou can check the details of this package perl-XML-Twig\r\n$ yum info perl-XML-Twig.noarch\r\n\r\n或者:\r\nperl -MCPAN -e 'install XML::Twig'", "created_at"=>2011-12-10 10:53:02 UTC, "updated_at"=>2012-06-24 15:43:52 UTC, "body_html"=>"
This module provides a way to process XML documents. It is build on top of XML::Parser. XML::Twig offers a tree interface to the document, while allowing you to output the parts of it that have been completely processed. It allows minimal resource (CPU and memory) usage by building the tree only for the parts of the documents that need actual processing, through the use of the twig_roots and twig_print_outside_roots options.(as pointed by yum info)
\n\n
Let’s first search for the package \n$ yum search perl-XML-Twig \nperl-XML-Twig.noarch : A perl module for processing huge XML documents in tree
\n\n
Note that you must be the root/administrator to install the package. To install this package in Red Hat/Fedora Linux. \n$ yum install perl-XML-Twig.noarch
\n\n
You can check the details of this package perl-XML-Twig \n$ yum info perl-XML-Twig.noarch
\n\n
或者: \nperl -MCPAN -e 'install XML::Twig'
\n", "_id"=>124}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["nginx", "statistics", "upstream"], "comments_count"=>0, "category_id"=>9, "title"=>"NGINX upstream statistics", "body"=>"使用过nginx的应该都都晓得upstream,前面一篇文章说到《nginx upstream的5种配置方式》,例如如下是很常见的一段配置\r\n\r\n#create by ice 2011.12.22\r\nupstream unicon_v2_www {\r\n# This is the socket we configured in unicorn.rb\r\nserver unix:/var/www/v2/tmp/sockets/unicorn.sock backup;\r\nserver 192.168.0.1:5000 weight=9 max_fails=2 fail_timeout=30s;\r\nserver 192.168.0.2:5000 weight=3 max_fails=2 fail_timeout=30s;\r\n}\r\nserver {\r\nlisten 80;\r\nserver_name www.iceskysl.com;\r\nerror_log /opt/nginx/logs/error/error_v2_www.log;\r\naccess_log /opt/nginx/logs/access/access_v2_www.log main;\r\n\r\nroot /var/www/v2/public/;\r\nindex index.html index.htm;\r\n\r\nlocation / {\r\nproxy_redirect off;\r\nproxy_set_header X-Real-IP $remote_addr;\r\nproxy_set_header Host $host;\r\nproxy_set_header Content-Length $content_length;\r\nproxy_set_header X-Forwarded-For $remote_addr;\r\nclient_max_body_size 10m;\r\nclient_body_buffer_size 128k;\r\nproxy_connect_timeout 90;\r\nproxy_send_timeout 90;\r\nproxy_read_timeout 90;\r\nproxy_buffer_size 4k;\r\nproxy_buffers 4 32k;\r\nproxy_busy_buffers_size 64k;\r\nproxy_temp_file_write_size 64k;\r\nchunked_transfer_encoding off;\r\nproxy_pass http://unicon_v2_www/;\r\n}\r\n}\r\n\r\n其中upstream的这段配置:\r\nupstream unicon_v2_www {\r\n# This is the socket we configured in unicorn.rb\r\nserver unix:/var/www/v2/tmp/sockets/unicorn.sock backup;\r\nserver 192.168.0.1:5000 weight=9 max_fails=2 fail_timeout=30s;\r\nserver 192.168.0.2:5000 weight=3 max_fails=2 fail_timeout=30s;\r\n}\r\n\r\n我们了解到socket模式的这个是backup,其他两个机器分别weight=3和weight=9,于是我们想监控下upstream每个后端具体处理了多少请求,有没有问题等,这个好像就不好监控了,nginx自带的status模块只能监控总的请求数,无法区分每个upstream的具体情况。\r\n找到一个ustats(http://code.google.com/p/ustats/),其介绍是:NGINX basic upstream statistics module,具体的如下:\r\n
USTATS module provides basic statistics for each backend in nginx upstreams:\r\n\r\nNumber of requests\r\nHttp 499/500/503 errors count\r\nTcp errors\r\nHttp read/write timeouts\r\nFail timeout\r\nMax fails count\r\nLast failed access time\r\nTotal fails count\r\nBlacklisted backend highlighting\r\nDown backends highlighting\r\nThe module allows you to sort values in some columns for each separate upstream. The data can be retrieved as JSON by appending \"?json\" to the end of location on which the module was set to work on (see configuration instructions below).
我们了解到socket模式的这个是backup,其他两个机器分别weight=3和weight=9,于是我们想监控下upstream每个后端具体处理了多少请求,有没有问题等,这个好像就不好监控了,nginx自带的status模块只能监控总的请求数,无法区分每个upstream的具体情况。 \n找到一个ustats(http://code.google.com/p/ustats/),其介绍是:NGINX basic upstream statistics module,具体的如下:<!--more--> \nUSTATS module provides basic statistics for each backend in nginx upstreams:
\n\n
Number of requests \nHttp 499/500/503 errors count \nTcp errors \nHttp read/write timeouts \nFail timeout \nMax fails count \nLast failed access time \nTotal fails count \nBlacklisted backend highlighting \nDown backends highlighting \nThe module allows you to sort values in some columns for each separate upstream. The data can be retrieved as JSON by appending "?json" to the end of location on which the module was set to work on (see configuration instructions below). \n看上去正是我需要的,有时间试试看~(为啥nginx不学haproxy官方自带一个详细statistics的页面呢~haproxy那个statistics很详细很好用~) \n详细使用指南:http://code.google.com/p/ustats/
\r\nThe reason is simple. I installed an extension called SEO Site Tools which installs an icon on the right of the address bar. When you click the button, on the window displayed there is the option “Show no follo” which is an option for displaying links that have the value nofollow for the attribute rel of an HTML element.\r\n\r\nThis attribute instructs some search engines that a hyperlink should not influence the link target’s ranking in the search engine’s index. (Source: wikipedia.org)\r\n
\r\n\r\n修复的方法很简单,去掉“Show no follo”的勾选就好了~\r\n", "created_at"=>2012-01-28 01:48:36 UTC, "updated_at"=>2012-06-24 15:43:52 UTC, "body_html"=>"
经过检查(Library/Application Support/Google/Chrome/Default/User StyleSheets/Custom.css),发现不是本地的css配置,最后找到是一个叫“SEO Site Tools”导致的,具体原因是: \n \nThe reason is simple. I installed an extension called SEO Site Tools which installs an icon on the right of the address bar. When you click the button, on the window displayed there is the option “Show no follo” which is an option for displaying links that have the value nofollow for the attribute rel of an HTML element.
\n\n
This attribute instructs some search engines that a hyperlink should not influence the link target’s ranking in the search engine’s index. (Source: wikipedia.org)
\n\n
修复的方法很简单,去掉“Show no follo”的勾选就好了~
\n", "_id"=>127}])
+MONGODB iceylog_development['categories'].find({:_id=>10}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>10}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Html/css/js"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["CoffeeScript", "Connect", "Express", "jade", "JavaScript", "Node.js", "npm"], "comments_count"=>0, "category_id"=>10, "title"=>"CoffeeScript解决JavaScript不美,Node.js潜力巨大", "body"=>"如果你对JavaScript感兴趣,但是不喜欢写一大堆一大堆的JavaScript代码,那真的不是你的错,因为很多人都说JavaScript不美,究其原因,可以归纳为:JavaScript的诞生是个悲剧. 它是函数式+动态语言的优秀内核, 却硬被绑上了C/Java的语法。\r\n\r\n如果你真的喜欢JavaScript,那么你可以尝试了解更多~比如CoffeeScript,再比如Node.js,再比如Connect,再比如Express,再再比如jade,再再再比如npm等等,于是我们从安装npm(a package manager for node)开始~\r\n\r\n#装npm\r\nice@mac:~ > curl http://npmjs.org/install.sh | sh\r\n % Total % Received % Xferd Average Speed Time Time Time Current\r\n Dload Upload Total Spent Left Speed\r\n100 7881 100 7881 0 0 3664 0 0:00:02 0:00:02 --:--:-- 8584\r\ntar=/usr/bin/tar\r\nversion:\r\nbsdtar 2.8.3 - libarchive 2.8.3\r\ninstall npm@1.1\r\nfetching: http://registry.npmjs.org/npm/-/npm-1.1.0-3.tgz\r\n0.6.2\r\n1.1.0-3\r\ncleanup prefix=/usr/local\r\n\r\nAll clean!\r\n/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js\r\nnpm@1.1.0-3 /usr/local/lib/node_modules/npm\r\nIt worked\r\n\r\n#看看怎么用\r\nice@mac:~ > npm help\r\n\r\nUsage: npm \r\n\r\nwhere is one of:\r\n adduser, apihelp, author, bin, bugs, c, cache, completion,\r\n config, deprecate, docs, edit, explore, faq, find, get,\r\n help, help-search, home, i, info, init, install, la, link,\r\n list, ll, ln, login, ls, outdated, owner, pack, prefix,\r\n prune, publish, r, rb, rebuild, remove, restart, rm, root,\r\n run-script, s, se, search, set, show, star, start, stop,\r\n submodule, tag, test, un, uninstall, unlink, unpublish,\r\n unstar, up, update, version, view, whoami\r\n\r\nnpm -h quick help on \r\nnpm -l display full usage info\r\nnpm faq commonly asked questions\r\nnpm help search for help on \r\nnpm help npm involved overview\r\n\r\nSpecify configs in the ini-formatted file:\r\n /Users/ice/.npmrc\r\nor on the command line via: npm --key value\r\nConfig info can be viewed via: npm help config\r\n\r\nnpm@1.1.0-3 /usr/local/lib/node_modules/npm\r\n\r\n#用npm装connect\r\nice@mac:~ > npm install connect\r\nnpm http GET https://registry.npmjs.org/connect\r\nnpm http 200 https://registry.npmjs.org/connect\r\nnpm http GET https://registry.npmjs.org/connect/-/connect-1.8.5.tgz\r\nnpm http 200 https://registry.npmjs.org/connect/-/connect-1.8.5.tgz\r\nnpm http GET https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/mime\r\nnpm http GET https://registry.npmjs.org/formidable\r\nnpm http 200 https://registry.npmjs.org/formidable\r\nnpm http 200 https://registry.npmjs.org/mime\r\nnpm http 200 https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/formidable/-/formidable-1.0.8.tgz\r\nnpm http GET https://registry.npmjs.org/mime/-/mime-1.2.4.tgz\r\nnpm http GET https://registry.npmjs.org/qs/-/qs-0.4.1.tgz\r\nnpm http 200 https://registry.npmjs.org/mime/-/mime-1.2.4.tgz\r\nnpm http 200 https://registry.npmjs.org/formidable/-/formidable-1.0.8.tgz\r\nnpm http 200 https://registry.npmjs.org/qs/-/qs-0.4.1.tgz\r\nconnect@1.8.5 ./node_modules/connect \r\n├── mime@1.2.4\r\n├── qs@0.4.1\r\n└── formidable@1.0.8\r\n\r\n#用npm装express\r\nice@mac:~ > npm install express\r\nnpm http GET https://registry.npmjs.org/express\r\nnpm http 200 https://registry.npmjs.org/express\r\nnpm http GET https://registry.npmjs.org/express/-/express-2.5.6.tgz\r\nnpm http 200 https://registry.npmjs.org/express/-/express-2.5.6.tgz\r\nnpm http GET https://registry.npmjs.org/mime\r\nnpm http GET https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/mkdirp/0.0.7\r\nnpm http 304 https://registry.npmjs.org/qs\r\nnpm http 304 https://registry.npmjs.org/mime\r\nnpm http 200 https://registry.npmjs.org/mkdirp/0.0.7\r\nnpm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.0.7.tgz\r\nnpm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.0.7.tgz\r\nexpress@2.5.6 ./node_modules/express \r\n├── mkdirp@0.0.7\r\n├── mime@1.2.4\r\n└── qs@0.4.1\r\n\r\n#用npm装jade\r\nice@mac:~ > npm install jade\r\nnpm http GET https://registry.npmjs.org/jade\r\nnpm http 200 https://registry.npmjs.org/jade\r\nnpm http GET https://registry.npmjs.org/jade/-/jade-0.20.0.tgz\r\nnpm http 200 https://registry.npmjs.org/jade/-/jade-0.20.0.tgz\r\nnpm http GET https://registry.npmjs.org/commander\r\nnpm http GET https://registry.npmjs.org/mkdirp\r\nnpm http 200 https://registry.npmjs.org/mkdirp\r\nnpm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz\r\nnpm http 200 https://registry.npmjs.org/commander\r\nnpm http GET https://registry.npmjs.org/commander/-/commander-0.2.1.tgz\r\nnpm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz\r\nnpm http 200 https://registry.npmjs.org/commander/-/commander-0.2.1.tgz\r\njade@0.20.0 ./node_modules/jade \r\n├── commander@0.2.1\r\n└── mkdirp@0.3.0\r\n\r\n好了,你入门了,更多资料,请自行查看如下链接的资料吧~\r\n\r\n相关资料\r\n\r\nCoffeeScript: CoffeeScript is a little language that compiles into JavaScript\r\nhttp://coffeescript.org/\r\n\r\n为什么CoffeeScript这么美?\r\nhttp://cnodejs.org/blog/?p=1584\r\n\r\nCoffeeScript: The beautiful way to write JavaScript\r\nhttp://amix.dk/blog/post/19612\r\n\r\n10个让朋友对你刮目相看的CoffeeScript单行代码绝技\r\nhttp://heikezhi.com/2011/06/08/10-coffeescript-one-liners-to-impress-your-friends/\r\n\r\nnpm: a package manager for node\r\nhttps://github.com/isaacs/npm\r\n\r\nExpress:http://expressjs.com/\r\nHigh performance, high class web development for Node.js\r\n\r\nConnect: Connect is a middleware layer for Node.js\r\nhttp://www.senchalabs.org/connect/\r\n\r\njade: http://jade-lang.com/\r\nNode Template Engine\r\n\r\ncoffee-box: Blog engine for fashionable developers. Built upon Node.js, Express, MongoDB and CoffeeScript.\r\nhttps://github.com/qiao/coffee-box", "created_at"=>2012-01-28 14:57:06 UTC, "updated_at"=>2012-06-24 15:43:52 UTC, "body_html"=>"
如果你真的喜欢JavaScript,那么你可以尝试了解更多~比如CoffeeScript,再比如Node.js,再比如Connect,再比如Express,再再比如jade,再再再比如npm等等,于是我们从安装npm(a package manager for node)开始~
\n\n
#装npm \nice@mac:~ > curl http://npmjs.org/install.sh | sh \n % Total % Received % Xferd Average Speed Time Time Time Current \n Dload Upload Total Spent Left Speed \n100 7881 100 7881 0 0 3664 0 0:00:02 0:00:02 --:--:-- 8584 \ntar=/usr/bin/tar \nversion: \nbsdtar 2.8.3 - libarchive 2.8.3 \ninstall npm@1.1 \nfetching: http://registry.npmjs.org/npm/-/npm-1.1.0-3.tgz \n0.6.2 \n1.1.0-3 \ncleanup prefix=/usr/local
\n\n
All clean! \n/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js \nnpm@1.1.0-3 /usr/local/lib/node_modules/npm \nIt worked \n<!--more-->
npm -h quick help on \nnpm -l display full usage info \nnpm faq commonly asked questions \nnpm help search for help on \nnpm help npm involved overview
\n\n
Specify configs in the ini-formatted file: \n /Users/ice/.npmrc \nor on the command line via: npm --key value \nConfig info can be viewed via: npm help config
首先安装Graphviz \n% brew install cairo pango graphviz # Homebrew on Mac OS X \n% sudo port install graphviz # Macports on Mac OS X \n% sudo aptitude install graphviz # Debian and Ubuntu
更多信息参考:http://rails-erd.rubyforge.org/ \n<!--more--> \n附:常见错误处理: \nCould not find gem 'choice (~> 0.1.4) ruby', which is required by gem 'rails-erd (>= 0) ruby', in any of the sources.
\n\n
原因是rails-erd依赖choice这个gem,装下 \nice@mac:/www/trunk > sudo gem install choice \nPassword: \nSuccessfully installed choice-0.1.4 \n1 gem installed \nInstalling ri documentation for choice-0.1.4... \nInstalling RDoc documentation for choice-0.1.4...
\n", "_id"=>137}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["ruby"], "comments_count"=>0, "category_id"=>2, "title"=>"Check for nil and initialize on a single line", "body"=>"点评:关于ROR中的一中“遇nil赋值”的写法,这个很早的时候在书上看到的是||=操作符,也一直这么用,今天发现作者的另外这个写法也挺好的。\n\nSometimes, you want to initialize a variable to some value only if that variable is equal to nil. If you like to write your methods as short, clean and readable as possible, you can do that task in a single line instead of taking the traditionnal 3 lines approach. You have two options :\n\n1) You can use the if modifier 1. x = get_some_object if x.nil?Very easy to read. This is my favorite.\n\n2) Or you can use the ||= operator 1. x ||= get_some_object This one is even shorter. The ||= operator is a little bit less verbose and might confuse a ruby newcomer… but I’m not saying that it should be a reason for not using it. This is more a matter of personal taste than anything else.Both of these methods are better than this :\n\n1. #eeww… we don’t like this one.\n\n2. if(x.nil?)\n\n3. x = get_some_object 4. end", "created_at"=>2007-05-19 01:23:10 UTC, "updated_at"=>2012-06-24 15:45:28 UTC, "body_html"=>"
Sometimes, you want to initialize a variable to some value only if that variable is equal to nil. If you like to write your methods as short, clean and readable as possible, you can do that task in a single line instead of taking the traditionnal 3 lines approach. You have two options :
\n\n
1) You can use the if modifier 1. x = get_some_object if x.nil?Very easy to read. This is my favorite.
\n\n
2) Or you can use the ||= operator 1. x ||= get_some_object This one is even shorter. The ||= operator is a little bit less verbose and might confuse a ruby newcomer… but I’m not saying that it should be a reason for not using it. This is more a matter of personal taste than anything else.Both of these methods are better than this :
$ uname -a\r\nLinux oj-web03 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux
\r\n
[iceskysl@oj-web03 logs]$ cat /proc/version\r\nLinux version 2.4.21-27.ELsmp (bhcompile@bugs.build.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47)) #1 SMP Wed Dec 1 21:59:02 EST 20045、内存信息$ cat /proc/meminfo\r\n$ free -M6、CPU信息$cat /proc/cpuinfo7、硬盘信息\r\n$df\r\n\r\n
(1)用客户端连接到数据库,执行select * from v$instance查看version项 \n(2)select * from product_component_version \n(3)或查询V$VERSION查看组件级信息
\n\n
4、内核 \n$ uname -a \nLinux oj-web03 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux \n[iceskysl@oj-web03 logs]$ cat /proc/version \nLinux version 2.4.21-27.ELsmp (bhcompile@bugs.build.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47)) #1 SMP Wed Dec 1 21:59:02 EST 20045、内存信息$ cat /proc/meminfo \n$ free -M6、CPU信息$cat /proc/cpuinfo7、硬盘信息 \n$df
\n\n", "_id"=>140}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Security"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["ruby", "安全", "漏洞"], "comments_count"=>0, "category_id"=>8, "title"=>"Ruby暴出大量严重漏洞!", "body"=>"Drew Yao at Apple uncovered a handful of nasty security vulnerabilities affecting all current versions of Ruby. The details are still under wraps because an attacker can DoS you or possibly execute arbitrary code—holy crap! Better upgrade sooner than later.\n\nAccording to the official Ruby security advisory, the vulnerable Rubies are:\n\n* 1.8.4 and earlier\n* 1.8.5-p230 and earlier\n* 1.8.6-p229 and earlier\n* 1.8.7-p21 and earlier\n\nThose of us running Ruby 1.8.4 or earlier must upgrade to 1.8.5 or later for a fix. Those on 1.8.5-7 can grab the latest patchlevel release for a fix.\n\n(Please note: Ruby 1.8.7 breaks backward compatibility and is only compatible with Rails 2.1 and later, so don’t go overboard!)\n虽然暂时还没看到具体的细节公布出来,也没看到0day放出来,但是从其描述上不难看出,这些bug是ruby一致以来都有的,或许还有更多的bug,ruby走向成熟,离不开这样的检验。", "created_at"=>2008-06-25 06:05:42 UTC, "updated_at"=>2012-06-24 15:45:29 UTC, "body_html"=>"
Drew Yao at Apple uncovered a handful of nasty security vulnerabilities affecting all current versions of Ruby. The details are still under wraps because an attacker can DoS you or possibly execute arbitrary code—holy crap! Better upgrade sooner than later.
\n\n
According to the official Ruby security advisory, the vulnerable Rubies are:
\n\n
\n
1.8.4 and earlier
\n
1.8.5-p230 and earlier
\n
1.8.6-p229 and earlier
\n
1.8.7-p21 and earlier
\n
\n\n
Those of us running Ruby 1.8.4 or earlier must upgrade to 1.8.5 or later for a fix. Those on 1.8.5-7 can grab the latest patchlevel release for a fix.
\n\n
(Please note: Ruby 1.8.7 breaks backward compatibility and is only compatible with Rails 2.1 and later, so don’t go overboard!) \n虽然暂时还没看到具体的细节公布出来,也没看到0day放出来,但是从其描述上不难看出,这些bug是ruby一致以来都有的,或许还有更多的bug,ruby走向成熟,离不开这样的检验。
\n", "_id"=>142}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["rsync"], "comments_count"=>0, "category_id"=>9, "title"=>"同步利器rsync", "body"=>"rsync is a program that copies file from one location to another, with it you can make backups of your files, synchronize data on different locations and computers. It is commonly used by unix users to keep a safe backup of their files and is often recommended as the simplest solution for backups and safety copys.\r\n\r\n参考资料:\r\n\r\n1.rsync的安装和使用\r\n\r\n2. rsync", "created_at"=>2008-06-25 19:58:32 UTC, "updated_at"=>2012-06-24 15:45:29 UTC, "body_html"=>"
rsync is a program that copies file from one location to another, with it you can make backups of your files, synchronize data on different locations and computers. It is commonly used by unix users to keep a safe backup of their files and is often recommended as the simplest solution for backups and safety copys.
A gravatar, or globally recognized avatar, is quite simply an avatar image that follows you from weblog to weblog appearing beside your name when you comment on gravatar enabled sites. Avatars help identify your posts on web forums, so why not on weblogs?
\r\n看明白了么,就是一个你输入自己的Email,然后上传自己的图片标识,然后在其他支持 Gravatars的网站(blog居多)中发表评论的时候输入自己的Email地址,就可以在Gravatars上找到其对应的图片来显示了。\r\n\r\n这确实是个不错的Idea,相当简单,但是也做得有声有色的,有点意思。\r\n\r\n使用也很方便,其在“How the URL is constructed”上介绍了其URL的组成,中可以这么使用(来源Gravatars on Rails):\r\n\r\n\r\n\r\n1、首先在````application_helper.rb中增加一个helper方法```\r\n
这个世界有意思,多大的idea都可以做成网站,以前看过缩址的网站,现在有看到一个省份标识的网站, Gravatars,看他的介绍: \nA gravatar, or globally recognized avatar, is quite simply an avatar image that follows you from weblog to weblog appearing beside your name when you comment on gravatar enabled sites. Avatars help identify your posts on web forums, so why not on weblogs? \n看明白了么,就是一个你输入自己的Email,然后上传自己的图片标识,然后在其他支持 Gravatars的网站(blog居多)中发表评论的时候输入自己的Email地址,就可以在Gravatars上找到其对应的图片来显示了。
\n\n
这确实是个不错的Idea,相当简单,但是也做得有声有色的,有点意思。
\n\n
使用也很方便,其在“How the URL is constructed”上介绍了其URL的组成,中可以这么使用(来源Gravatars on Rails):
晓得TDD,BDD,RSpec这些东西很久了,也看了不少的资料和教程,但总感觉还在门外徘徊,始终不得其要,真是怪异。应该是没在实际项目中实践过的缘故吧。 \n本文记录一些RSpec和BDD(Behaviour Driven Development )的资料和文档,给我自己也给各位路过者提供一些资料,感兴趣的仔细看看吧。 \n \n http://rspec.info/ \n Telling a good story - Rspec stories from the trenches \n Slides from RailsConf \n rspec plain text stories + webrat = chunky bacon! \n http://chinaonrails.com/topic/view/220.html \n Story Driven Development with Rails - Part I: Up and Running \n \n另外,http://rspec.info/documentation/rails/上的资料非常棒。有路过的,玩BDD的朋友还望多多指教,领我进门,多谢!
\n", "_id"=>154}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Html/css/js"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Android & Java"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Thin"], "comments_count"=>0, "category_id"=>6, "title"=>"Thin version 1.0.0 is out!", "body"=>"Thin version 1.0.0 (codename That's What She Said) is out!\r\n\r\nYes 1.0! That doesn't mean it's bug free or anything. But, it does\r\nmean that it's been running on a number of servers and no show stopper\r\nbugs have been found since a while.\r\n\r\nAlso see http://macournoyer.wordpress.com/2008/09/30/thin-10/\r\n\r\n== What's new?\r\n\r\n* Fixed vlad.rake to allow TCP or socket [hellekin]\r\n* Updated Mack adapter to handle both <0.8.0 and >0.8.0 [Mark Bates]\r\n* rails rack adapter uses File.readable_real? so it recognizes ACL\r\npermissions [Ricardo Chimal]\r\n* Log a warning if Rack application returns nil body [Michael S.\r\nKlishin]\r\n* Handle nil and Time header values correctly [#76 state:resolved]\r\n[tmm1]\r\n* Add Content-Length header to response automatically when possible\r\n[#74 state:resolved] [dkubb]\r\n* Runner now remembers -r, -D and -V parameters so that clustered\r\nservers inherit those and\r\nkeep your parameters.\r\n* Make Set-Cookie header, in Rails adapter, compatible with current\r\nRack spec [Pedro Belo]\r\n[#73, state:resolved]\r\n* Add --no-epoll option to disable epoll usage on Linux [#61\r\nstate:resolved]\r\n* Add --force (-f) option to force stopping of a daemonized server\r\n[#72 state:resolved]\r\n* Update halycon adapter loader [mtodd]\r\n\r\n== Get it!\r\n\r\nInstall Thin from RubyForge:\r\n\r\ngem install thin\r\n\r\nOr using my mirror:\r\n\r\ngem install thin --source http://code.macournoyer.com\r\n\r\n参考文档:\r\nhttp://groups.google.com/group/thin-ruby/browse_thread/thread/402d51a6d9f2651d", "created_at"=>2008-10-07 09:56:27 UTC, "updated_at"=>2012-06-24 15:45:29 UTC, "body_html"=>"
Thin version 1.0.0 (codename That's What She Said) is out!
\n\n
Yes 1.0! That doesn't mean it's bug free or anything. But, it does \nmean that it's been running on a number of servers and no show stopper \nbugs have been found since a while.
Search directory arguments recursively for files to convert.
\r\n\t
-d or --delete
\r\n\t
delete input files after successful conversion. May not be safe yet!!!
\r\n\t
-v or --verbose
\r\n\t
makes sneetchalizer more chatty.
\r\n\t
-s or --show-output
\r\n\t
shows output from conversion tool.
\r\n\t
-p or --pretend
\r\n\t
don't convert anything. sneetchalizer will go through the motions and print out the commands it would run. Useful for preview- ing a complex command line to ensure it does what you intend. You should interpret this option's output with a grain of salt. For example, if you include the '--sanitize' option, the files will not really be renamed when using --pretend, and as such the command's output will not reflect that the filenames would be changed during an actual run.
\r\n\t
-t or --terminate
\r\n\t
terminate sneetchalizer options. This is useful if you have to convert '--coolDir' or '-groovySong.mp3'. This is the only option whose order on the command line is significant.
\r\n\t
-D ARG or --out-directory=ARG
\r\n\t
write all outfiles to a directory argument. This is useful if you want to (re)encode files directly to a mounted portable device.
\r\n\t
--strict and --pedantic
\r\n\t
many errors that sneetchalizer may encounter are recoverable, such as specifying a directory as argument that contains no files to convert, or conversion failures in general. By default the script will print an error message and move on to the next file. If you use '--strict' then sneetchalizer will bail out at the first sign of trouble except for tag errors. With '--pedantic' the script will stop even on tag errors.
\r\n\t
--stasis
\r\n\t
Preserve timestamp (mtime) of original file.
\r\n\t
--threads [N]
\r\n\t
Experimental. Use threads to create concurrent jobs. This option takes an optional integer argument which represents the number of threads to launch. The default is two. Preliminary tests suggest there is little advantage (and even diminishing returns) when setting this number greater than the number of cores/CPUs you have. Due to the asychronous nature of threads the --verbose and --show-output flags will be silently disabled and most screen output is supressed.
\r\n\t
--sanitize
\r\n\t
Removes ,, ;, :, ', \", %, @, #, and ` from filenames and tags.
\r\n\t
-n [FORMAT] or --rename[=FORMAT]
\r\n\t
rename all outfiles (and temporary wavs) according to FORMAT. FORMAT is a string with special designators to be pulled from the file tags. The following options are available:
\r\n\t
\r\n\t
* %t Song title
\r\n\t
* %b Album title
\r\n\t
* %n Track number
\r\n\t
* %a Artist name
\r\n\t
* %y Year
\r\n\t
* %g Genre
\r\n\t
* %c Comment field
\r\n\t
\r\n\t
Directories may be created with this command, as in \"%b/%n - %t\". The default value of FORMAT is \"%n %t\".
\r\n\t
\r\n\t
Bitrate/Quality/Compression options:
\r\n\t
\r\n\t
-b or --bitrate
\r\n\t
mp3/ogg/m4a bitrate.
\r\n\t
-q or --quality
\r\n\t
mp3/ogg quality.
\r\n\t
\r\n\t
quality and bitrate are passed directly to lame or oggenc depending on mp3 or ogg output format respectively. Both tools can handle either a bitrate or quality argument, so it is important to understand what values are valid for the underlying tool in your specific use case. faac will accept a bitrate argument, but not a quality argument. These options will be silently ignored for any output formats other than mp3, ogg or m4a. Make sure you know what you are doing if you decide to use both in one run, and read each tools manpage for valid values. If these options are omitted the tools builtin defaults are used (-q3 for oggenc and -q5 for lame).
\r\n\t
\r\n\t
-c or --compression
\r\n\t
flac/mac compression level.
\r\n\t
\r\n\t
this option allows you to pass a compression argument to flac and mac. See 'flac --help' and/or 'mac --help' if you don't know what this means.
\r\n\t
\r\n\t
Format Options:
\r\n\t
\r\n\t
--out=format
\r\n\t
output format. Default is wav.
\r\n\t
--in=format[,format..]
\r\n\t
input format(s). Default is wav.
\r\n\t
\r\n\t
Valid output formats are: \"aac\", \"aif\", \"aifc\", \"aiff\", \"aiffc\", \"ape\", \"au\", \"cdr\", \"cdda\", \"copy\", \"flac\", \"m4a\", \"m4b\", \"mpc\", \"mp4\", \"mpp\", \"mp3\", \"mp2\", \"ofr\", \"ofs\", \"ogg\", \"snd\", \"spx\", \"tta\", \"wav\", \"wv\". Valid input formats are all of the above plus \"wma\". You can specify multiple input formats using a comma: 'mp3,m4a,wma'. Input format is only neccesary when passing directory arguments, as file arguments are handled by context (read: file extension). The \"copy\" output option copies files directly, bypassing decoding/encoding steps (useful in conjunction with --rename).
\r\n\t
\r\n\t
Tagging Options:
\r\n\t
\r\n\t
--tt or --title
\r\n\t
Set 'title' tag.
\r\n\t
--ta or --artist
\r\n\t
Set 'artist' tag.
\r\n\t
--tl or --album
\r\n\t
Set 'album' tag.
\r\n\t
--ty or --year
\r\n\t
Set 'year' tag.
\r\n\t
--tc or --comment
\r\n\t
Set 'comment' tag.
\r\n\t
--tg or --genre
\r\n\t
Set 'genre' tag.
\r\n\t
--tn or --trackn
\r\n\t
Set 'track number' tag.
\r\n\t
\r\n\t
The short and long versions are different in an important way: Using the long version will clobber any existing tags. The short version will only set the tag if the existing tag has no value. Note that these tags will be placed in _every_ outfile during the run.
\r\n\t
\r\n\t
Alternative Encoder/Decoder Options:
\r\n\t
\r\n\t
--gogo
\r\n\t
use gogo to encode mp3 files.
\r\n\t
--bladeenc
\r\n\t
use bladeenc to encode mp3 files.
\r\n\t
\r\n\t
The default is still 'lame'. If 'lame' is not found, the script will search for one of these two encoders regardless if these options are passed or not.
\r\n\t
\r\n\t
Special Options:
\r\n\t
\r\n\t
--in-optionhook=ARG
\r\n\t
add ARG to infile conversion command. Possibly dangerous!
\r\n\t
--out-optionhook=ARG
\r\n\t
add ARG to outfile conversion command. Possibly dangerous!
Using the same --in and --out format allows us to resample/encode the file at a different bitrate or quality. Note that this will overwrite the original file so only do this on a copy, or use '-D' to write files to another directory.
直接下载其gz包,sneetchalizer-0.9.0是现在的最新版本。下载解包后可以看到: \n \nManifest: \n \n README - You're reading it now. \n LICENSE - A copy of the GPL, under which sneetchalizer is released. \n CHANGES - sneetchalizer's cvs/svn commit log. \n sneetchalizer - The script itself. \n sneetchalizer.1 - The manpage for sneetchalizer. \n sneetchalizer.desktop - A KDE service menu for converting with Konqueror. \n install.rb - A quick and dirty script to install the sneetchalizer. \n \n \n如果有root权限,可以直接运行install.rb,其会将sneetchalizer拷贝到/usr/bin下,将sneetchalizer.1拷贝到/usr/share/man/man1下。
\n\n
2、参数解释
\n\n
不翻译了,都挺简单明了的,如下: \n \nXML/HTML代码 \n \n General options: \n \n -h or --help \n Print quick or full usage details respectively. \n -r or --recursive \n Search directory arguments recursively for files to convert. \n -d or --delete \n delete input files after successful conversion. May not be safe yet!!! \n -v or --verbose \n makes sneetchalizer more chatty. \n -s or --show-output \n shows output from conversion tool. \n -p or --pretend \n don't convert anything. sneetchalizer will go through the motions and print out the commands it would run. Useful for preview- ing a complex command line to ensure it does what you intend. You should interpret this option's output with a grain of salt. For example, if you include the '--sanitize' option, the files will not really be renamed when using --pretend, and as such the command's output will not reflect that the filenames would be changed during an actual run. \n -t or --terminate \n terminate sneetchalizer options. This is useful if you have to convert '--coolDir' or '-groovySong.mp3'. This is the only option whose order on the command line is significant. \n -D ARG or --out-directory=ARG \n write all outfiles to a directory argument. This is useful if you want to (re)encode files directly to a mounted portable device. \n --strict and --pedantic \n many errors that sneetchalizer may encounter are recoverable, such as specifying a directory as argument that contains no files to convert, or conversion failures in general. By default the script will print an error message and move on to the next file. If you use '--strict' then sneetchalizer will bail out at the first sign of trouble except for tag errors. With '--pedantic' the script will stop even on tag errors. \n --stasis \n Preserve timestamp (mtime) of original file. \n --threads [N] \n Experimental. Use threads to create concurrent jobs. This option takes an optional integer argument which represents the number of threads to launch. The default is two. Preliminary tests suggest there is little advantage (and even diminishing returns) when setting this number greater than the number of cores/CPUs you have. Due to the asychronous nature of threads the --verbose and --show-output flags will be silently disabled and most screen output is supressed. \n --sanitize \n Removes ,, ;, :, ', ", %, @, #, and ` from filenames and tags. \n -n [FORMAT] or --rename[=FORMAT] \n rename all outfiles (and temporary wavs) according to FORMAT. FORMAT is a string with special designators to be pulled from the file tags. The following options are available: \n \n * %t Song title \n * %b Album title \n * %n Track number \n * %a Artist name \n * %y Year \n * %g Genre \n * %c Comment field \n \n Directories may be created with this command, as in "%b/%n - %t". The default value of FORMAT is "%n %t". \n \n Bitrate/Quality/Compression options: \n \n -b or --bitrate \n mp3/ogg/m4a bitrate. \n -q or --quality \n mp3/ogg quality. \n \n quality and bitrate are passed directly to lame or oggenc depending on mp3 or ogg output format respectively. Both tools can handle either a bitrate or quality argument, so it is important to understand what values are valid for the underlying tool in your specific use case. faac will accept a bitrate argument, but not a quality argument. These options will be silently ignored for any output formats other than mp3, ogg or m4a. Make sure you know what you are doing if you decide to use both in one run, and read each tools manpage for valid values. If these options are omitted the tools builtin defaults are used (-q3 for oggenc and -q5 for lame). \n \n -c or --compression \n flac/mac compression level. \n \n this option allows you to pass a compression argument to flac and mac. See 'flac --help' and/or 'mac --help' if you don't know what this means. \n \n Format Options: \n \n --out=format \n output format. Default is wav. \n --in=format[,format..] \n input format(s). Default is wav. \n \n Valid output formats are: "aac", "aif", "aifc", "aiff", "aiffc", "ape", "au", "cdr", "cdda", "copy", "flac", "m4a", "m4b", "mpc", "mp4", "mpp", "mp3", "mp2", "ofr", "ofs", "ogg", "snd", "spx", "tta", "wav", "wv". Valid input formats are all of the above plus "wma". You can specify multiple input formats using a comma: 'mp3,m4a,wma'. Input format is only neccesary when passing directory arguments, as file arguments are handled by context (read: file extension). The "copy" output option copies files directly, bypassing decoding/encoding steps (useful in conjunction with --rename). \n \n Tagging Options: \n \n --tt or --title \n Set 'title' tag. \n --ta or --artist \n Set 'artist' tag. \n --tl or --album \n Set 'album' tag. \n --ty or --year \n Set 'year' tag. \n --tc or --comment \n Set 'comment' tag. \n --tg or --genre \n Set 'genre' tag. \n --tn or --trackn \n Set 'track number' tag. \n \n The short and long versions are different in an important way: Using the long version will clobber any existing tags. The short version will only set the tag if the existing tag has no value. Note that these tags will be placed in _every_ outfile during the run. \n \n Alternative Encoder/Decoder Options: \n \n --gogo \n use gogo to encode mp3 files. \n --bladeenc \n use bladeenc to encode mp3 files. \n \n The default is still 'lame'. If 'lame' is not found, the script will search for one of these two encoders regardless if these options are passed or not. \n \n Special Options: \n \n --in-optionhook=ARG \n add ARG to infile conversion command. Possibly dangerous! \n --out-optionhook=ARG \n add ARG to outfile conversion command. Possibly dangerous! \n \n \n另外,你可以运行sneetchalizer -h看到简要的使用说明,也可以使用sneetchalizer --help看到详细的使用信息。
\n\n
3、使用示例
\n\n
如下简要的写几个使用的示例: \n \n使用示例: \n \n $ sneetchalizer song.mp3 \n \n The most simple possible example, creates 'song.wav'. \n \n $ sneetchalizer --out=ogg --in=flac -q5 /some/music/dir \n \n This example converts every flac file in '/some/music/dir' to ogg format at quality 5. \n \n $ sneetchalizer -d --out=mp3 --in=ogg,m4a,wma -b 160 . \n \n Converts every ogg, m4a, and wma file in the current directory to a 160 kbps constant bitrate mp3 file. The original files are deleted. \n \n $ sneetchalizer --out=mp3 --out-optionhook="--preset extreme" /some/wavs \n \n Here we encode every wav in '/some/wavs' to mp3 format passing '--preset extreme' directly to lame. \n \n $ sneetchalizer --in=ogg --out=ogg --quality=1 norvegianWood.ogg /some/more/oggs \n \n Using the same --in and --out format allows us to resample/encode the file at a different bitrate or quality. Note that this will overwrite the original file so only do this on a copy, or use '-D' to write files to another directory. \n \n $ sneetchalizer --in=ogg --out=m4a -D /mnt/ipod/ /some/oggs \n \n Here we re-encode some ogg files to m4a format and write them to our mounted iPod. \n \n \n4、注意事项
\n\n
本脚本只是粘合剂,其他的tool还是需要另外安装的。
\n\n
其他信息请参考其主页说明,如果您有这个方面的问题或经验,欢迎和我讨论。
\n\n\n
\n", "_id"=>156}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["架构"], "comments_count"=>0, "category_id"=>9, "title"=>"网站架构文章列表(持续更新中)", "body"=>"互联网越来越开放,技术人员也越来越乐于分享,分析构架、演变和遇到的问题,虽然说没有真正经历过,很多体验可能会没那么深,但是有些东西提前了解会有诸多好处。在很多地方看到类似的构架分析、分享的文章,统一收集整理如下,遇到其他的,我会持续更新,如果经历允许,我还会写一些读后感或者点评;如果你看到其他的类似文章或者点评,欢迎留言让我知道。\n\n对dbanotes等表示感谢。\n\nWikiPedia 技术架构学习分享\nhttp://www.dbanotes.net/opensource/wikipedia_arch.html\n\nYouTube 的架构扩展\nhttp://www.dbanotes.net/opensource/youtube_web_arch.html\n\nLinkedIn 架构笔记\nhttp://www.dbanotes.net/arch/linkedin.html\n\nLinkedIn 架构与开发过程\nhttp://www.dbanotes.net/arch/linkedin_soa.html\n\nInternet Archive 的海量存储浅析\nhttp://www.dbanotes.net/database/internet_archive_storage.html\n\nTailrank 网站架构\nhttp://www.dbanotes.net/review/tailrank_arch.html\n\nTwitter 的架构扩展: 100 倍性能提升\nhttp://www.dbanotes.net/arch/twitter_arch.html\n\n财帮子(caibangzi.com)网站架构\nhttp://www.dbanotes.net/arch/caibangzi_web_arch.html\n\nYupoo! 的网站技术架构\nhttp://www.dbanotes.net/arch/yupoo_arch.html\n\n37Signals 架构\nhttp://www.dbanotes.net/arch/37signals_arch.html\n\nFlickr 的访问统计实现以及其他\nhttp://www.dbanotes.net/arch/flickr_stats_and_dathan.html\n\nPlentyOfFish 网站架构学习\nhttp://www.dbanotes.net/arch/plentyoffish_arch.html\n\nYahoo!社区架构\nhttp://www.dbanotes.net/arch/yahoo_arch.html\n\n有关 Alexa 与 AOL 部署集群文件系统\nhttp://www.dbanotes.net/arch/alexa_ibrix_san_file_system.html\n\neBay 的存储一瞥\nhttp://www.dbanotes.net/arch/ebay_storage.html\n\neBay 的数据量\nhttp://www.dbanotes.net/database/ebay_storage.html\n\neBay 的数据库分布扩展架构\nhttp://www.dbanotes.net/database/ebay_database_scale_out.html\n\neBay 的数据层扩展经验\nhttp://www.dbanotes.net/arch/ebay_db_scale_out.html\n\neBay 的应用服务器规模\nhttp://www.dbanotes.net/web/ebay_application_server.html\n\n性能扩展问题要趁早\nhttp://www.dbanotes.net/arch/scaling_an_early_stage_startup.html\n\nScaling an early stage startup\nhttp://www.scribd.com/doc/429986/Scaling-an-early-stage-startup\n\nFacebook 的 PHP 性能与扩展性\nhttp://www.dbanotes.net/arch/facebook_php.html\n\nSkype 用 PostgreSQL 支撑海量用户\nhttp://www.dbanotes.net/arch/skype_postgresql.html\n\n闲谈 Web 图片服务器\nhttp://www.dbanotes.net/web/web_image_server.html\n\n说说北京奥运购票系统瘫痪这事儿\nhttp://www.dbanotes.net/review/beijing_olympic_ticketes_system_crash.html\n\nArchitectures You’ve Always Wondered About\nhttp://qcon.infoq.com/london-2008/tracks/show_track.jsp?trackOID=82\n\neBay’s Architectural Principles\nhttp://www.eos1.dk/qcon-london-2008/slides/RandyShoup_eBaysArchitecturalPrinciples.pdf\n\nBuilding a large scale SaaS app\nhttp://www.eos1.dk/qcon-london-2008/slides/Dan_Hanley_Building_a_large_scale_SaaS_app.pdf\n\nScaling an early stage startup\nhttp://www.scribd.com/doc/429986/Scaling-an-early-stage-startup\n\n互联星空播客架构(原文在张宴blog上,但是后来文章撤下,很可惜.此为转载)\nhttp://www.flashmov.com/blog_1632.html\n\nQQ游戏百万人同时在线服务器架构实现\nhttp://www.libing.net.cn/read.php?41\n\n大型Web2.0站点构建技术初探\nhttp://blog.csdn.net/heiyeshuwu/archive/2007/11/18/1890793.aspx\n\nWeb站点数据库分布存储浅谈\nhttp://blog.csdn.net/heiyeshuwu/archive/2007/11/18/1891639.aspx\n\nQQ的架构讨论\nhttp://groups.google.com/group/dev4server/browse_thread/thread/0d72668d11c4886b/a6d202489cabf285#a6d202489cabf285\n\nNotes from Scaling MySQL - Up or Out\nhttp://venublog.com/2008/04/16/notes-from-scaling-mysql-up-or-out/\n\nYapache-Yahoo! Apache 的秘密\nhttp://www.dbanotes.net/web/yapache_yahoo_apache.html\n\nScalability Best Practices: Lessons from eBay\nhttp://www.infoq.com/articles/ebay-scalability-best-practices", "created_at"=>2008-10-09 06:51:05 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
Google的产品很多都深得我心,一直在使用,整理整合了一些Gmail的快捷方式,备忘。 \n \n \n \n快捷键 \n定义 \n作用 \n \n \nc \nCompose \n撰写新邮件。“Shift+C”打开新窗口撰写新邮件 \n \n \n<tab> then <Enter> \nSend message \n新邮件撰写完后,先<tab>后<Enter>可发送邮件。(在Windows中,使用IE和Firefox有效) \n \n \nk \nMove to newer conversation \n在收件箱中,向上移动光标,按<Enter>查看邮件;在查看邮件时,打开下一封新邮件 \n \n \nj \nMove to older conversation \n在收件箱中,向下移动光标,按<Enter>查看邮件;在查看邮件时,打开下一封旧邮件 \n \n \nn \nNext message \n查看邮件时,定位光标到 \n \n \np \nPrevious message \n移动光标到前一个消息。<Enter>展开或折叠消息。(只在“会话模式”(Conversation View)中有效) \n \n \no or <Enter> \nOpen \n打开会话。在“Conversation View”中,也可用于打开消息。 \n \n \nu \nReturn to conversation list \n刷新页面、返回收件箱或返回会话列表 \n \n \ny \nArchive* \nRemove from current view \n \n删除会话或消息。 \n在收件箱中,<Y>可“存档”选中的会话
\n\n
在“已加星标示”中,<Y>可取消选中会话的星号; \n 在查看有标签的邮件时,<Y>可取消标签。 \n 在“垃圾邮件”、“已发邮件”和“所有邮件”中,<Y>没有作用 \n \n \n \n \nx \nSelect conversation \n选中会话,配合其他快捷键可为会话存档、添加标签或从下拉菜单中选择其他命令 \n \n \ns \nStar a message or conversation \n为会话或消息加星标。 \n \n \n! \nReport spam \n将消息标记为垃圾邮件并从会话中删除 \n \n \nr \nReply \n回复邮件或会话。“shift+r”可在新窗口中回复消息(只在“会话模式”中有效) \n \n \na \nReply all \n回复所有收件人。“Shift+a”可打开新窗口中回复。(PConline注:如果邮件有抄送地址,<r>回复发件人,<a>则回复所有抄送地址) \n \n \nf \nForward \n转发消息。“Shift+f”可打开新窗口转发。(只在“查看消息模式”(“Conversation View”)中有效) \n \n \n<Esc> \nEscape from input field \nRemoves the cursor from your current input field.(PConline注:在中文版Gmail中暂未有效果) \n \n \ny then o \nArchive and next \n存档选中的会话并打开下一个 \n \n \ng then a \nGo to 'All Mail' \n转到“所有邮件” \n \n \ng then s \nGo to 'Starred' \n转到“已加星标” \n \n \ng then c \nGo to 'Contacts' \n转到“通讯录” \n \n \ng then d \nGo to 'Drafts' \n转到“草稿” \n \n \ng then i \nGo to 'Inbox' \n转到“收件箱” \n \n \n/ \nSearch \n将光标定位到搜索栏中的输入框中 \n \n \n \n
\n", "_id"=>158}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["analyzer"], "comments_count"=>0, "category_id"=>7, "title"=>"Request-log-analyzer: Rails&Merb的日志分析", "body"=>"生产环境下,需要对环境持续监控以尽快的发现问题,找到耗费资源较多的地方加以改进,比较常见的做法是使用moint或者God实时监控;另外,还可以定期分析日志找到特定的请求,虽然可以是shell来做这件事,但是何必再造轮子呢,因为我们已经有了Request log analyzer :\r\n``简介:This is a simple command line tool to analyze request log files of both Rails andMerb. Its purpose is to find what actions are best candidates for optimization.This tool will parse all requests in the logfile and aggregate theinformation. Once it is finished parsing the log file, it will show therequests that take op most server time. Different metrics are used (cumulativetime, average time, blockers, DB time, etc)\r\n\r\n安装:gem sources -a http://gems.github.comsudo gem install wvanbergen-request-log-analyzer\r\n\r\n使用:Usage: request-log-analyzer [FILE] [OPTION]Analyze the given log FILE with the given OPTIONExample: request-log-analyzer mongrel.log\r\n\r\n --fast, -t: Only use completed requests --guess-database-time, -g: Guesses the database duration of requests if they are not in the log --output, -o: Comma-separated list of reports to show --amount, -c: Displays the top <amount> elements in the reports --colorize, -z: Fancy bash coloring\r\n\r\n示例:Note that this example was shortened for your viewing pleasure.$ request-log-analyzer /var/log/my_app.log\r\n\r\nRequest log analyzer, by Willem van Bergen and Bart ten Brinke\r\n\r\nProcessing all log lines...========================================================================Successfully analyzed 58908 requests from log file\r\n\r\nTimestamp first request: 2008-07-13T06:25:58+00:00Timestamp last request: 2008-07-20T06:18:53+00:00Total time analyzed: 7 daysMethods: DELETE (1%), GET (50%), POST (22%), PUT (25%).\r\n\r\nTop 10 most requested actions========================================================================/overview/:date/ : 19359 requests/overview/day/:date/ : 6365 requests/overview/:date/set/ : 5589 requests/overview/ : 3985 requests/clients/:id/ : 1976 requests........\r\n\r\nTop 10 actions by time - cumulative========================================================================/overview/:date/ : 9044.582s [19359 requests]/overview/ : 8478.767s [3985 requests]/overview/:date/set/ : 3309.041s [5589 requests]/clients/:id/products/:id/ : 1479.911s [924 requests]/clients/:id/ : 750.080s [1976 requests]........\r\n\r\nTop 10 actions by time - per request mean========================================================================/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]/clients/:id/ : 0.380s [1976 requests]........\r\n\r\nTop 10 worst DB offenders - cumulative time========================================================================/overview/:date/ : 8773.993s [19359 requests]/overview/ : 8394.754s [3985 requests]/overview/:date/set/ : 3307.928s [5589 requests]/clients/:id/products/:id/ : 1425.220s [924 requests]/clients/:id/ : 535.229s [1976 requests]........\r\n\r\nTop 10 worst DB offenders - mean time========================================================================/overview/:id/:id/:id/print/ : 6.994s [448 requests]/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]........\r\n\r\nMongrel process blockers (> 1.0 seconds)========================================================================/overview/:date/ : 7494.233s [3144 requests]/overview/ : 8320.293s [1549 requests]/overview/:date/set/ : 1149.235s [803 requests]/overview/:id/:id/:id/print/new/ : 613.693s [341 requests]/clients/:id/products/:id/ : 1370.693s [313 requests]........\r\n\r\nRequests graph - per hour======================================================================== ........ 7:00 - 2731 : XXXXXXX 8:00 - 6139 : XXXXXXXXXXXXXXXX 9:00 - 7465 : XXXXXXXXXXXXXXXXXXXX 10:00 - 7118 : XXXXXXXXXXXXXXXXXXX 11:00 - 7409 : XXXXXXXXXXXXXXXXXXX 12:00 - 6450 : XXXXXXXXXXXXXXXXX 13:00 - 5377 : XXXXXXXXXXXXXX 14:00 - 6058 : XXXXXXXXXXXXXXXX 15:00 - 4156 : XXXXXXXXXXX 16:00 - 2767 : XXXXXXX 17:00 - 1598 : XXXX 18:00 - 792 : XX ........\r\n\r\nErrors========================================================================ArgumentError: [237 requests] -> invalid dateStaleObjectError: [28 requests] -> Attempted to update a stale objectRuntimeError: [3 requests] -> Cannot destroy rule before it was createdStatementError: [2 requests] -> Mysql::Error: Deadlock found when trying to get lock; try restarting transactionNoMethodError: [1 requests] -> undefined method `code' for nil:NilClass```", "created_at"=>2008-10-13 08:45:11 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
生产环境下,需要对环境持续监控以尽快的发现问题,找到耗费资源较多的地方加以改进,比较常见的做法是使用moint或者God实时监控;另外,还可以定期分析日志找到特定的请求,虽然可以是shell来做这件事,但是何必再造轮子呢,因为我们已经有了Request log analyzer : \n``简介:This is a simple command line tool to analyze request log files of both Rails andMerb. Its purpose is to find what actions are best candidates for optimization.This tool will parse all requests in the logfile and aggregate theinformation. Once it is finished parsing the log file, it will show therequests that take op most server time. Different metrics are used (cumulativetime, average time, blockers, DB time, etc)
\n\n
安装:gem sources -a http://gems.github.comsudo gem install wvanbergen-request-log-analyzer
\n\n
使用:Usage: request-log-analyzer [FILE] [OPTION]Analyze the given log FILE with the given OPTIONExample: request-log-analyzer mongrel.log
\n\n
--fast, -t: Only use completed requests --guess-database-time, -g: Guesses the database duration of requests if they are not in the log --output, -o: Comma-separated list of reports to show --amount, -c: Displays the top <amount> elements in the reports --colorize, -z: Fancy bash coloring
\n\n
示例:Note that this example was shortened for your viewing pleasure.$ request-log-analyzer /var/log/my_app.log
\n\n
Request log analyzer, by Willem van Bergen and Bart ten Brinke
\n\n
Processing all log lines...========================================================================Successfully analyzed 58908 requests from log file
\n\n
Timestamp first request: 2008-07-13T06:25:58+00:00Timestamp last request: 2008-07-20T06:18:53+00:00Total time analyzed: 7 daysMethods: DELETE (1%), GET (50%), POST (22%), PUT (25%).
\n\n
Top 10 most requested actions========================================================================/overview/:date/ : 19359 requests/overview/day/:date/ : 6365 requests/overview/:date/set/ : 5589 requests/overview/ : 3985 requests/clients/:id/ : 1976 requests........
\n\n
Top 10 actions by time - cumulative========================================================================/overview/:date/ : 9044.582s [19359 requests]/overview/ : 8478.767s [3985 requests]/overview/:date/set/ : 3309.041s [5589 requests]/clients/:id/products/:id/ : 1479.911s [924 requests]/clients/:id/ : 750.080s [1976 requests]........
\n\n
Top 10 actions by time - per request mean========================================================================/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]/clients/:id/ : 0.380s [1976 requests]........
Errors========================================================================ArgumentError: [237 requests] -> invalid dateStaleObjectError: [28 requests] -> Attempted to update a stale objectRuntimeError: [3 requests] -> Cannot destroy rule before it was createdStatementError: [2 requests] -> Mysql::Error: Deadlock found when trying to get lock; try restarting transactionNoMethodError: [1 requests] -> undefined method code' for nil:NilClass``
Nginx有个Log Rotation模块,nginx will re-open it's logs in response to the USR1 signal.参考如下脚本: \n`$ mv access.log access.log.0$ kill -USR1cat master.nginx.pid`$ sleep 1$ gzip access.log.0 # do something with access.log.0
\r\n``2、Hpricot```Pros: Cool name, created by _why, faster than REXML, also does HTML, creative APICons: Not as fast as libxml-ruby, more of an HTML parser linguistically (ie: uses innerHTML instead of text or content, etc.)```\r\n
\r\n
Ruby代码
\r\n\r\n\t
%w[benchmark pp rubygems].each { |x| require x }
\r\n\t
gem 'hpricot', '>= 0.6'
\r\n\t
require 'hpricot'
\r\n\t
\r\n\t
##################################
\r\n\t
# Parsing Delicious API Response #
\r\n\t
##################################
\r\n\t
xml = File.read('posts.xml')
\r\n\t
puts Benchmark.measure {
\r\n\t
doc, posts = Hpricot::XML(xml), []
\r\n\t
(doc/:post).eachdo |p|
\r\n\t
posts << p.attributes
\r\n\t
end
\r\n\t
# pp posts
\r\n\t
}
\r\n\t
\r\n\t
################################
\r\n\t
# Parsing Twitter API Response #
\r\n\t
################################
\r\n\t
xml = File.read('timeline.xml')
\r\n\t
puts Benchmark.measure {
\r\n\t
doc, statuses = Hpricot::XML(xml), []
\r\n\t
(doc/:status).eachdo |s|
\r\n\t
h = {:user => {}}
\r\n\t
%w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].eachdo |a|
\r\n\t
h[a.intern] = s.at(a).innerHTML
\r\n\t
end
\r\n\t
%w[id name screen_name location description profile_image_url url protected followers_count].eachdo |a|
\r\n\t
h[:user][a.intern] = s.at('user').at(a).innerHTML
\r\n\t
end
\r\n\t
statuses << h
\r\n\t
end
\r\n\t
# pp statuses
\r\n\t
}
\r\n\r\n
\r\n3、libxml-ruby \r\n\r\nPros: Blistering fast\r\nCons: Hpricot has cooler name, REXML and Hpricot both feel easier to use out of the box\r\n
Ruby可以很方便的解析XML格式的文档,目前用的比较多的lib主要有三个,分别是:REXML, Hpricot, libxml-ruby,如下选取两个XML文档,分别使用这三个lib解析,感受下各自的速度和易用性。 \n一、原料 \n \n posts.xml – Uses xml element for object (post) and xml attributes for object attributes \n timeline.xml – Uses xml element for object (status) and child xml elements for attributes \n \n二、解析过程 \n1、REXML
\n\n
Pros: In the standard library \nCons: Slow, I don’t like the name \n \nRuby代码 \n \n %w[benchmark pp rexml/document].each { |x| require x } \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n doc, posts = REXML::Document.new(xml), [] \n doc.elements.each('posts/post') do |p| \n posts << p.attributes \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n doc, statuses = REXML::Document.new(xml), [] \n doc.elements.each('statuses/status') do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.elements[a].text \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.elements['user'].elements[a].text \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n<code class="ruby"><strong>2、Hpricot</strong><strong>Pros:</strong> Cool name, created by _why, faster than <span class="caps">REXML</span>, also does <span class="caps">HTML</span>, creative <span class="caps">API</span><strong>Cons:</strong> Not as fast as libxml-ruby, more of an <span class="caps">HTML</span> parser linguistically (ie: uses innerHTML instead of text or content, etc.)`` \n \nRuby代码 \n \n %w[benchmark pp rubygems].each { |x| require x } \n gem 'hpricot', '>= 0.6' \n require 'hpricot' \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n doc, posts = Hpricot::XML(xml), [] \n (doc/:post).each do |p| \n posts << p.attributes \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n doc, statuses = Hpricot::XML(xml), [] \n (doc/:status).each do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.at(a).innerHTML \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.at('user').at(a).innerHTML \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n3、libxml-ruby
\n\n
Pros: Blistering fast \nCons: Hpricot has cooler name, REXML and Hpricot both feel easier to use out of the box \n \nRuby代码 \n \n %w[benchmark pp rubygems].each { |x| require x } \n gem 'libxml-ruby', '>= 0.8.3' \n require 'xml' \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n parser, parser.string = XML::Parser.new, xml \n doc, posts = parser.parse, [] \n doc.find('//posts/post').each do |p| \n posts << p.attributes.inject({}) { |h, a| h[a.name] = a.value; h } \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n parser, parser.string = XML::Parser.new, xml \n doc, statuses = parser.parse, [] \n doc.find('//statuses/status').each do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.find(a).first.content \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.find('user').first.find(a).first.content \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n<code class="ruby"><strong>三、结论</strong> \n<div class="codeText"> \n<div class="codeHead">结果如下:</div> \n<ol class="dp-xml" start="1"> \n <li class="alt"><span><span>=rexml </span></span></li> \n <li><span>delicious 0.020000 0.000000 0.020000 ( 0.021139) </span></li> \n <li class="alt"><span>twitter 0.940000 0.020000 0.960000 ( 0.988666) </span></li> \n <li><span> </span></li> \n <li class="alt"><span>=hpricot </span></li> \n <li><span>delicious 0.010000 0.000000 0.010000 ( 0.005548) </span></li> \n <li class="alt"><span>twitter 0.250000 0.010000 0.260000 ( 0.258320) </span></li> \n <li><span> </span></li> \n <li class="alt"><span>=libxml-ruby </span></li> \n <li><span>delicious 0.000000 0.000000 0.000000 ( 0.007829) </span></li> \n <li class="alt"><span>twitter 0.030000 0.010000 0.040000 ( 0.034040) </span></li> \n</ol> \n</div> \n``<code class="ruby">参考文档:http://railstips.org/2008/8/12/parsing-xml-with-ruby``
\n", "_id"=>162}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Tips"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["oauth"], "comments_count"=>0, "category_id"=>4, "title"=>"初识oauth: 为API访问授权提供一个开放的标准", "body"=>"最近在准备一些API设计开发工作,初步了解了下oauth,OAuth是由Blaine Cook、Chris Messina、Larry Halff 及David Recordon共同发起的,目的在于为API访问授权提供一个开放的标准。\r\noauth目前看来进展比较顺利,可以看到其有主流语言的lib(Java、C#、Objective-C、Perl、PHP及Ruby语言),目前支持oauth的API有twitter,douban等应用。\r\n\r\nOAuth is the great new standard allowing your users to use your application to talk to their accounts on other applications. I won’t go more into it here as it’s pretty well covered on the OAuth site.\r\n\r\nOAuth’s Goal\r\nWebsite X can access your protected data at API Y\r\n
\r\n\t
All without sharing your password off-site
\r\n\t
especially when there isn’t one like with OpenID
\r\n
\r\n其基本流程为:\r\n\r\n\t
Register your consumer application with the OAuth compliant service to receive your Consumer Credentials (This is only done once)
\r\n\t
You initiate the OAuth Token exchange process for a user by requesting a RequestToken from the Service
\r\n\t
You store the RequestToken in your database or in the users session object
\r\n\t
You redirect your user to the service providers authorize_url with the RequestToken’s key appended
\r\n\t
Your user is asked by the service provider to authorize your RequestToken
\r\n\t
Your user clicks yes and is redirected to your CallBack URL
OAuth is the great new standard allowing your users to use your application to talk to their accounts on other applications. I won’t go more into it here as it’s pretty well covered on the OAuth site. \n \nOAuth’s Goal \nWebsite X can access your protected data at API Y \n \n All without sharing your password off-site \n especially when there isn’t one like with OpenID \n \n其基本流程为: \n \n Register your consumer application with the OAuth compliant service to receive your Consumer Credentials (This is only done once) \n You initiate the OAuth Token exchange process for a user by requesting a RequestToken from the Service \n You store the RequestToken in your database or in the users session object \n You redirect your user to the service providers authorize_url with the RequestToken’s key appended \n Your user is asked by the service provider to authorize your RequestToken \n Your user clicks yes and is redirected to your CallBack URL \n Your callback action exchanges the RequestToken for an AccessToken \n Now you can access your users data by performing http requests signed by your consumer credentials and the AccessToken. \n ???? \n PROFIT!!! \n \n如果你想了解,请参考如下文档,如果你有经验,请分享,谢谢! \n \n参考文档: \n \n Developing OAuth clients in Ruby \n How to turn your rails site into an OAuth Provider \n OAuth不断获得动力 \n Rails plugin for OAuth \n OAuth implementation for Ruby \n 豆瓣 API 认证授权说明 \n The How of OAuth --这个PPT挺不错 \n
\n", "_id"=>170}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Ruby&Rails", "to_xml"], "comments_count"=>0, "category_id"=>11, "title"=>"Rails: Disabling XML character escaping for to_xml & xml builder", "body"=>"
In my case, I had to genarate the xml view for api render,but in rails, i got a &XXX format string for non englisg, it also appears to_xml will automatically escape any entities into their corresponding &XXX representation. There's a piece in the documentation that says "If $KCODE is set to u and encoding set to UTF8, then escaping will NOT be performed." \n \nUnfortunately, this doesn't appear to be the case. Even after following the docs and ensuring that default_charset is indeed UTF-8 (actually the default for Rails nowadays), we still get encoded characters in to_xml output. \n \nSince our client is UTF-8 aware, we need to pass thru the UTF-8 data intact. The only way we've found to do this is thru the following horrible monkey-patch:
\n
\n
Ruby代码
\n\n
module Builder
\n
class XmlBase
\n
def _escape(text)
\n
text
\n
end
\n
end
\n
end
\n\n
\n
\nWhat's the proper way to do this? \n \nPS: \nsomebody say that to "set $KCODE='UTF8' in config/environment.rb can solve this issue." but it's not for me. \n \nmore infos: \nhttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2c13ad7c0f8c0781
In my case, I had to genarate the xml view for api render,but in rails, i got a &XXX format string for non englisg, it also appears to_xml will automatically escape any entities into their corresponding &XXX representation. There's a piece in the documentation that says "If $KCODE is set to u and encoding set to UTF8, then escaping will NOT be performed." \n \nUnfortunately, this doesn't appear to be the case. Even after following the docs and ensuring that default_charset is indeed UTF-8 (actually the default for Rails nowadays), we still get encoded characters in to_xml output. \n \nSince our client is UTF-8 aware, we need to pass thru the UTF-8 data intact. The only way we've found to do this is thru the following horrible monkey-patch: \n \nRuby代码 \n \n module Builder \n class XmlBase \n def _escape(text) \n text \n end \n end \n end \n \n \n \nWhat's the proper way to do this? \n \nPS: \nsomebody say that to "set $KCODE='UTF8' in config/environment.rb can solve this issue." but it's not for me. \n \nmore infos: \nhttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2c13ad7c0f8c0781 \n
\n", "_id"=>171}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["random", "ruby"], "comments_count"=>0, "category_id"=>11, "title"=>"Generate a random string", "body"=>"Generates a random string of lowercase letters. Great for email verification codes or user password salt....\n
Some tips for mount&umount ,maybe give you some help..
\n
cdrom: \n# mount -t is09660 /dev/cdrom /mnt/cdrom \n# umount /mnt/cdrom \n \nfloppy: \n# mount /dev/fd0 /mnt/floppy \n#umount /mnt/floppy \n \nusb: \n1.use 'fdisk -l' to show the usb nums,something like '/dev/sda'; \n2.then use 'mkdir /mnt/usb' to create a dir for mount this usb; \n3.at last,use '# mount -t msdos /dev/sda1 /mnt/usb" to mount it. \n4.#umount /mnt/usb \n \nhda: \n1.use 'fdisk -l' to show the disk nums,like '/dev/hda1'; \n2.then use 'make /mnt/vfat' to create a mount point; \n3.at last,use '# mount -t vfat /dev/hda1 /mnt/vfat'to mount it.. \n4.#umount /mnt/vfat
Some tips for mount&umount ,maybe give you some help.. \ncdrom:
\n\n
mount -t is09660 /dev/cdrom /mnt/cdrom
\n\n
umount /mnt/cdrom
\n\n
floppy:
\n\n
mount /dev/fd0 /mnt/floppy
\n\n
umount /mnt/floppy
\n\n
usb: \n1.use 'fdisk -l' to show the usb nums,something like '/dev/sda'; \n2.then use 'mkdir /mnt/usb' to create a dir for mount this usb; \n3.at last,use '# mount -t msdos /dev/sda1 /mnt/usb" to mount it. \n4.#umount /mnt/usb \n \nhda: \n1.use 'fdisk -l' to show the disk nums,like '/dev/hda1'; \n2.then use 'make /mnt/vfat' to create a mount point; \n3.at last,use '# mount -t vfat /dev/hda1 /mnt/vfat'to mount it.. \n4.#umount /mnt/vfat \nand some usefull resource links and docs here: \nhttp://unix-cd.com/unixcd12/article_3967.html \nhttp://blog.oracle.com.cn/index.php/121320/viewspace-6733.html
In my case, I need do send big files to users, yes, you can do it with nginx,just like others static files,but i need some control for the request action,The delivery of a static file which depends on an application header is known as the X-Sendfile feature. \nLighttpd has this feature and there is a mod_xsendfile for Apache2. \nNginx also has this feature, but implemented a little bit differently. In Nginx this feature is called X-Accel-Redirect. \nThere are two main differences:
\n\n
The header must contain a URI
\n
The location should be defined as internal; to prevent the client going directly to the URI
\n\n
\n
\n
Ruby代码
\n\n
location /files {
\n
root /var/www;
\n
internal;
\n
}
\n\n
\n
\n
Ruby代码
\n\n
// Get requested file name
\n
path = @params["path"]
\n
\n
# ...
\n
# Perform any required security checks, validation
In my case, I need do send big files to users, yes, you can do it with nginx,just like others static files,but i need some control for the request action,The delivery of a static file which depends on an application header is known as the X-Sendfile feature. \nLighttpd has this feature and there is a mod_xsendfile for Apache2. \nNginx also has this feature, but implemented a little bit differently. In Nginx this feature is called X-Accel-Redirect. \nThere are two main differences: \n \n The header must contain a URI \n The location should be defined as internal; to prevent the client going directly to the URI \n \n \n \nRuby代码 \n \n location /files { \n root /var/www; \n internal; \n } \n \n \n \nRuby代码 \n \n // Get requested file name \n path = @params["path"] \n \n # ... \n # Perform any required security checks, validation \n # and/or stats accounting \n # ... \n \n # And redirect user to internal location \n response.headers['X-Accel-Redirect'] = "/files/" + path \n \n \n \nsome userfull link resource come here: \n \n http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/ \n http://wiki.codemongers.com/NginxXSendfile \n http://www.motionstandingstill.com/using-nginx-to-send-files-with-x-accel-redirect/2008-09-03/ \n \n
I store user sessions in memcache,and then i want do share theres sessions with sub domains,but i notice some strange things when i put session into memcached,there are: \n1. In my older website(rails 2.0),It genenrated sessions key for memcached as \#{namespace}-\#{RAILS_ENV}:"session:\#{id}"; \n2.In my newer website(reails 2.3),It generated seesions key for memcached just as "\#{namespace}:\#{id}"; \n \nso,i can not get the same seesion datas with diff session keys. i do have spend lots of time for sove this , i do have some userfull dis, \n \n1. In rails2.3 ,it's vendor memcache-client-1.5.0.5 in ruby\\lib\\ruby\\gems\\1.8\\gems\\activesupport-2.3.0\\lib\\active_support\\vendor; \n2. you can config namespace in you environment.rb file like " ActionController::Base.session_options[:namespace] = 'session'" \n3. In rails2.0,when you use memcached,you will use cached_fu and act_as_cache plugins,and you may have a config file in your config dir named memcached.yml, and in this file,you can config defaults,production,test and developer..with lots of filed,like namespace,servers etc.. \n4. you will notice it generate memcached key as mentioned above. \n \nI track it,and got this:
I store user sessions in memcache,and then i want do share theres sessions with sub domains,but i notice some strange things when i put session into memcached,there are: \n1. In my older website(rails 2.0),It genenrated sessions key for memcached as \#{namespace}-\#{RAILS_ENV}:"session:\#{id}"; \n2.In my newer website(reails 2.3),It generated seesions key for memcached just as "\#{namespace}:\#{id}"; \n \nso,i can not get the same seesion datas with diff session keys. i do have spend lots of time for sove this , i do have some userfull dis, \n \n1. In rails2.3 ,it's vendor memcache-client-1.5.0.5 in ruby\\lib\\ruby\\gems\\1.8\\gems\\activesupport-2.3.0\\lib\\active_support\\vendor; \n2. you can config namespace in you environment.rb file like " ActionController::Base.session_options[:namespace] = 'session'" \n3. In rails2.0,when you use memcached,you will use cached_fu and act_as_cache plugins,and you may have a config file in your config dir named memcached.yml, and in this file,you can config defaults,production,test and developer..with lots of filed,like namespace,servers etc.. \n4. you will notice it generate memcached key as mentioned above. \n \nI track it,and got this: \n \nRuby代码 \n \n def setup_memcache(config) \n config[:namespace] << "-\#{RAILS_ENV}" \n \n silence_warnings do \n Object.const_set :CACHE, memcache_klass.new(config) \n end \n \n CACHE.servers = Array(config.delete(:servers)) \n \n setup_session_store if config[:sessions] \n setup_fragment_store! if config[:fragments] \n setup_fast_hash! if config[:fast_hash] \n setup_fastest_hash! if config[:fastest_hash] \n \n CACHE \n end \n \n \nshit,it append RAILS_ENV to namespace with "-",that's it...I hate some hardcode config in plugin,blalal.... \nsome userfull link resources... \n \n http://errtheblog.com/posts/22-sessions-n-such \n http://www.raecoo.com/2008/10/25/rails-store-format-in-memcache/ \n http://www.scribd.com/doc/2203398/Scaling-Rails-with-memcached \n http://railscasts.com/episodes/115-caching-in-rails-2-1
In some case,you may want do get Uniquely Identifying for a 'real' android phone,and you can do it like this:
\n
In Android.Provider.Settings.System we have some interesting values that could be of use, one specifically is “Android_ID”. From the documentation it is the following;
\n
\n
String \tANDROID_ID \tThe Android ID (a unique 64-bit value) as a hex string. \t“android_id”
\nAlso, note that in an emulator this will return “null”, though a real device will return an actual value. The nice thing about this tid-bit of code is that you are not required any special permissions to call it, since it’s essentially a passive call to get information. No write access is (obviously) required.\n
Garry Tan, cofounder of Posterous, lists 12 lessons for scaling that apply to more than just Rails,and i mark some word below. \n \nUse cloud storage for static files. --S3,I do not care it 's fine in china. \nUse HTTP Cache Control to tell the browser what it can cache. --this is true,etag is great. \nUse Sphinx for text search. --sometimes,you do have others chose. \nUse InnoDB for more crash resistant and faster writes. --maybe it's right. \nDon't use textbook Rails ActiveRecord objects. Use New Relic to find exactly what is slow in your system. --yep \nUse memcache later so you find your database bottlenecks now. --this is very important. \nUse mongrel proctitle to find your slow queries. You are only as fast as your slowest queries. -maybe mongrel is not only chose,think about thin,ok? \nUse asynchronous job queuing to do work in parallel. --yes,but sometimes crontab is enough. \nUse monitoring so you'll know when your site went down and why. --that's it,just do it. \nLearn by reading the source code, fixing problems, and submitting them back to the community. --very userfull when you got some strange questions.. \nUse new plugins. Old plugins can't be trusted. --and check chang histroy carefully. \nUse new information. Old information can't be trusted. --and what's this? \n \ngo to http://axonflux.com/building-and-scaling-a-startup for more infos.
When it asks for driver location choose the unzipped folderand install the driver for it.
\n
You'll see sth like "HTC Dream Composite ADB Interface" on success
\n
(Re)Start Eclipse
\n
Your G1 should now be listed in the DDMS-Perspective under Devices
\n
Go to the AndroidManifest.xml of your App and modify it to containandroid:debuggable="true"in the <application ... >-Tag,look like this:<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
\n
Go Debug as usual. \n
\n\nps: I do not upload the zip file here,you can find it via the link above,but if you can not download it,you can mail me to fetch one.
I konw,you can dev app and test it on the simulator,but if you had a real driver,G1,you can do debug on it,very great,here is the tips for this: \n \n On your G1, go to Settings Applications Development [X] USB debugging \n Download this file: android_usb_windows.zip \n Unzip it to a folder \n Connect your G1 with your PC \n When it asks for driver location choose the unzipped folder and install the driver for it. \n You'll see sth like "HTC Dream Composite ADB Interface" on success \n (Re)Start Eclipse \n Your G1 should now be listed in the DDMS-Perspective under Devices \n Go to the AndroidManifest.xml of your App and modify it to contain android:debuggable="true" in the <application ... >-Tag ,look like this:<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> \n Go Debug as usual. \n \n \nps: I do not upload the zip file here,you can find it via the link above,but if you can not download it,you can mail me to fetch one. \nBtw: \nYou can now install (signed)APKs via USB: \nD:\\dev\\Android\\android-sdk-windows-1.0_r1\\tools>adb -d install D:\\Workspace\\keytools\\AndNav_signed.apk \n1305 KB/s (1975987 bytes in 1.478s) \npkg: /data/local/tmp/AndNav_signed.apk \nSuccess \n \n \nAnd uninstall them: \nD:\\dev\\Android\\android-sdk-windows-1.0_r1\\tools>adb uninstall org.andnav \nSuccess \n \n
In some case,you may want do get Uniquely Identifying for a 'real' android phone,such as IMEI code,SimOperator etc, and we all kown ,the IMEI like ID card,and you can use TelephonyManager to get it,some usefull codes like this :
Apr 1 01:47:49 garden kernel: Linux version 2.6.18-92.1.17.el5 (mockbuild@builder10.centos.org) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)) #1 SMP Tue Nov 4 13:43:30 EST 2008
\n
\n \nlooks like something wrong about "ip_conntrack",and i do some check like this: \n\n
Installing ri documentation for fastercsv-1.4.0...
\n
Installing RDoc documentation for fastercsv-1.4.0...
\n
iceskysl ~/webroot: cd ..
\n\n
\nand do not forget to add "require 'fastercsv'" in your class file.", "created_at"=>2009-04-22 17:12:15 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
some tips is here. \n \nRuby代码 \n \n def self.imp_init_owner_data \n fp = "\#{RAILS_ROOT}/datas/inumbers/ini_owner.csv" \n FasterCSV.open(fp, "w") do |csv| \n InumberCate.find_all_by_typee("owner").each do |owner| \n csv << [owner.name,owner.id] \n end \n end \n end \n \n \ninstall fastercsv gems like this.. \n \n \n \nRuby代码 \n \n iceskysl ~/webroot: gem install fastercsv \n Successfully installed fastercsv-1.4.0 \n 1 gem installed \n Installing ri documentation for fastercsv-1.4.0... \n Installing RDoc documentation for fastercsv-1.4.0... \n iceskysl ~/webroot: cd .. \n \n \nand do not forget to add "require 'fastercsv'" in your class file.
you can use apt-spy to update sources.list ,here is some step and tips. \n1.open /etc/apt/sources.list and add this \ndeb http://http.us.debian.org/debian/ stable main \n2.do "apt-get update" \n3.then "apt-get install apt-spy" \n4.then "apt-spy update" \n5.last,"apt-spy -d unstable -a asia -t 5" \n \nref: \nhttp://http.us.debian.org/debian/README.mirrors.txt
you can use apt-spy to update sources.list ,here is some step and tips. \n1.open /etc/apt/sources.list and add this \ndeb http://http.us.debian.org/debian/ stable main \n2.do "apt-get update" \n3.then "apt-get install apt-spy" \n4.then "apt-spy update" \n5.last,"apt-spy -d unstable -a asia -t 5" \n \nref: \nhttp://http.us.debian.org/debian/README.mirrors.txt
\n", "_id"=>186}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["iowait"], "comments_count"=>0, "category_id"=>11, "title"=>"How can I find out what is generating iowait on my server?", "body"=>"
A question I’m asked daily is “How can I find out what is generating iowait on my server?” Sure, you can dig through pages of lsof output, restart services, or run strace, but it can be a frustrating process. I saw a process on this blog post, and a guy changed the regexes to fit Red Hat and CentOS systems a bit better: \n
A question I’m asked daily is “How can I find out what is generating iowait on my server?” Sure, you can dig through pages of lsof output, restart services, or run strace, but it can be a frustrating process. I saw a process on this blog post, and a guy changed the regexes to fit Red Hat and CentOS systems a bit better: \n \nRuby代码 \n \n [root@5-3 ~]# /etc/init.d/syslog stop \n Shutting down kernel logger: [ OK ] \n Shutting down system logger: [ OK ] \n [root@5-3 ~]# echo 1 > /proc/sys/vm/block_dump \n [root@5-3 ~]# dmesg | egrep "READ|WRITE|dirtied" | egrep -o '([a-zA-Z]*)' | sort | uniq -c | sort -rn | head \n 202 kjournald \n 16 egrep \n 9 irqbalance \n 9 bash \n 2 java \n 1 sda \n 1 mailserver \n [root@5-3 ~]# echo 0 > /proc/sys/vm/block_dump \n [root@5-3 ~]# /etc/init.d/syslog start \n Starting system logger: [ OK ] \n Starting kernel logger: [ OK ] \n \n \nIn my specific situation, it looks like kjournald is the biggest abuser of my disk. \nDon’t forget to set things back to their normal state when you’re done! \n \nXML/HTML代码 \n \n # echo 0 > /proc/sys/vm/block_dump \n # /etc/init.d/syslog start \n \n \n \n \nref: \nhttp://rackerhacker.com/2008/03/11/hunting-down-elusive-sources-of-iowait/ \nhttp://blog.eikke.com/index.php/ikke/2007/03/22/who_s_abusing_my_sata_controller \nhttp://hi.baidu.com/dipsey/blog/item/900bbbaf3e46dcc97cd92aba.html \nhttp://www.ducea.com/2009/03/11/howto-install-iotop-on-debian-etch/ \n \nhttp://www.cppblog.com/go-benny/archive/2008/04/23/47908.html \n
--attach PID Quit god when the attached process dies
\n
--no-events Disable the event system
\n
--bleakhouse Enable bleakhouse profiling
\n
[iceskysl@ws_api]#
\n\n
\n1.DYNAMICALLY LOADING CONFIG FILES INTO AN ALREADY RUNNING GOD\n
\n
God allows you to load or reload configurations into an already running instance. There are a few things to consider when doing this:
\n
\n
Existng Watches with the samename```as the incoming Watches will be overidden by the new config.
\n
All paths must be either absolute or relative to the path from which god was started.
\n
\n
To load a config into a running god, issue the following command:
\n
$ sudo god load path/to/config.god # god load /data/www/api/config/config_thin_api.god```\n
Config files that are loaded dynamically can contain anything that a normal config file contains, however, global options such asGod.pid_file_directory```blocks will be ignored (and produce a warning in the logs).
\n
\n
2.show logs
\n
\n
\n
XML/HTML代码
\n\n
[iceskysl@ws_api]# god log thin-thin-7514
\n
I, [2009-04-28T08:24:16.705870 #23174] INFO -- : thin-thin-7514 moved 'up' to 'up'
\n
I, [2009-04-28T08:24:16.706346 #23174] INFO -- : thin-thin-7514 [trigger] process is not running (ProcessRunning)
\n
I, [2009-04-28T08:24:16.888477 #23174] INFO -- : thin-thin-7514 sent email to iceskysl@gmail.com (Email)
\n
I, [2009-04-28T08:24:16.888642 #23174] INFO -- : thin-thin-7514 move 'up' to 'start'
\n
I, [2009-04-28T08:24:16.888976 #23174] INFO -- : thin-thin-7514 before_start: no pid file to delete (CleanPidFile)
\n
I, [2009-04-28T08:24:16.889109 #23174] INFO -- : thin-thin-7514 start: thin start -C /data/www/web/current/config/thin.yml -o 7514
some days before,i posted a article 《God: 比Monit更好用的monitoring》,today,i will post more useful tips for God. \n \n \nRuby代码 \n \n [iceskysl@ws_api]# god --help \n Usage: \n Starting: \n god [-c <config file>] [-p <port> | -b] [-P <file>] [-l <file>] [-D] \n \n Querying: \n god <command> <argument> [-p <port>] \n god <command> [-p <port>] \n god -v \n god -V (must be run as root to be accurate on Linux) \n \n Commands: \n start <task or group name> start task or group \n restart <task or group name> restart task or group \n stop <task or group name> stop task or group \n monitor <task or group name> monitor task or group \n unmonitor <task or group name> unmonitor task or group \n remove <task or group name> remove task or group from god \n load <file> load a config into a running god \n log <task name> show realtime log for given task \n status show status of each task \n quit stop god \n terminate stop god and all tasks \n check run self diagnostic \n \n Options: \n -c, --config-file CONFIG Configuration file \n -p, --port PORT Communications port (default 17165) \n -b, --auto-bind Auto-bind to an unused port number \n -P, --pid FILE Where to write the PID file \n -l, --log FILE Where to write the log file \n -D, --no-daemonize Don't daemonize \n -v, --version Print the version number and exit \n -V Print extended version and build information \n --log-level LEVEL Log level [debug|info|warn|error|fatal] \n --no-syslog Disable output to syslog \n --attach PID Quit god when the attached process dies \n --no-events Disable the event system \n --bleakhouse Enable bleakhouse profiling \n [iceskysl@ws_api]# \n \n \n1.DYNAMICALLY LOADING CONFIG FILES INTO AN ALREADY RUNNING GOD \n \nGod allows you to load or reload configurations into an already running instance. There are a few things to consider when doing this: \n \n Existng Watches with the same name<span class="Apple-converted-space"> </span>as the incoming Watches will be overidden by the new config.</li> \n <li style="margin: 0px; font-size: 13px;">All paths must be either absolute or relative to the path from which god was started.</li> \n</ul> \n<p style="margin: 0px 0px 1em; font-size: 13px;">To load a config into a running god, issue the following command:</p> \n<pre style="border: 1px solid rgb(204, 204, 204); margin: 1em 0px; padding: 1em; font-size: 10px; line-height: 1.3; background-color: rgb(239, 239, 239);">$ sudo god load path/to/config.god<br /># god load /data/www/api/config/config_thin_api.god \nConfig files that are loaded dynamically can contain anything that a normal config file contains, however, global options such as God.pid_file_directory``` blocks will be ignored (and produce a warning in the logs). \n \n2.show logs \n \n \nXML/HTML代码 \n \n [iceskysl@ws_api]# god log thin-thin-7514 \n I, [2009-04-28T08:24:16.705870 #23174] INFO -- : thin-thin-7514 moved 'up' to 'up' \n I, [2009-04-28T08:24:16.706346 #23174] INFO -- : thin-thin-7514 [trigger] process is not running (ProcessRunning) \n I, [2009-04-28T08:24:16.888477 #23174] INFO -- : thin-thin-7514 sent email to iceskysl@gmail.com (Email) \n I, [2009-04-28T08:24:16.888642 #23174] INFO -- : thin-thin-7514 move 'up' to 'start' \n I, [2009-04-28T08:24:16.888976 #23174] INFO -- : thin-thin-7514 before_start: no pid file to delete (CleanPidFile) \n I, [2009-04-28T08:24:16.889109 #23174] INFO -- : thin-thin-7514 start: thin start -C /data/www/web/current/config/thin.yml -o 7514 \n \n \n \nresource links: \nhttp://god.rubyforge.org/ \n
If you have recently updated to Rails 2.2.2, you may encounter this error when you want to start your application: \n \n/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in \n`load_missing_constant': uninitialized constant Inflector (NameError) \n \nthe usage of Inflector class is changed a bit. You can see the difference when you compare the inflections.rb files. Path of the file is yourApp/config/initializers/inflections.rb \n \n
\n
inflections.rb (Rails 2.1.0)
\n\n
\n
\n
Inflector.inflections do |inflect|
\n
.
\n
.
\n
.
\n
end
\n\n
\n \n
\n
inflections.rb (Rails 2.2.2)
\n\n
ActiveSupport::Inflector.inflections do |inflect|
\n
.
\n
.
\n
.
\n
end
\n\n
\nthe situation changing Inflector to ActiveSupport::Inflector was enough to solve the problem.", "created_at"=>2009-05-05 13:37:01 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
If you have recently updated to Rails 2.2.2, you may encounter this error when you want to start your application: \n \n/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in \n`load_missing_constant': uninitialized constant Inflector (NameError) \n \nthe usage of Inflector class is changed a bit. You can see the difference when you compare the inflections.rb files. Path of the file is yourApp/config/initializers/inflections.rb \n \n \ninflections.rb (Rails 2.1.0) \n \n \n \n Inflector.inflections do |inflect| \n . \n . \n . \n end \n \n \n \n \ninflections.rb (Rails 2.2.2) \n \n ActiveSupport::Inflector.inflections do |inflect| \n . \n . \n . \n end \n \n \nthe situation changing Inflector to ActiveSupport::Inflector was enough to solve the problem.
\n", "_id"=>190}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["God", "ruby", "Ruby&Rails"], "comments_count"=>0, "category_id"=>11, "title"=>"Socket Errno::EAFNOSUPPORT with God in ruby", "body"=>"
when i start god.sh,then give some error msg like this:
\n
\n
\n
XML/HTML代码
\n\n
I [2009-05-16 21:25:41] INFO: Using pid file directory: /var/run/god
\n
/usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `initialize': Address family not supported by protocol - socket(2) (Errno::EAFNOSUPPORT)
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `open'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `open_server_inaddr_any'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:863:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:759:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in `each'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1340:in `initialize'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in `new'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in `start_service'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:78:in `start'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:43:in `initialize'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in `new'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in `start'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:633:in `at_exit'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:666
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/cli/run.rb:87
\n\n
\nok,then i find some userful messsage,like here:\n
Errno::EAFNOSUPPORT - the specifiedsockaddrisnot a valid address for the family of the callingsocket
\n
and here, i notice where is the problen,the god find hostname,name map it to ip address,then create some sockets on the ip,and the error point is here,so i nano my /etc/hosts file,and add map for hostname and 127.0.0.1,that's it! \n
when i start god.sh,then give some error msg like this: \n \n \nXML/HTML代码 \n \n I [2009-05-16 21:25:41] INFO: Using pid file directory: /var/run/god \n /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in initialize': Address family not supported by protocol - socket(2) (Errno::EAFNOSUPPORT) </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in open' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in open_server_inaddr_any' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:863:in open_server' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:759:in open_server' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in each' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in open_server' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1340:in initialize' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in new' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in start_service' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:78:in start' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:43:in initialize' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in new' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in start' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:633:in `at_exit' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:666 \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/cli/run.rb:87 \n \n \nok,then i find some userful messsage,like here: \nErrno::EAFNOSUPPORT - the specified sockaddr isnot a valid address for the family of the calling socket \nand here, i notice where is the problen,the god find hostname,name map it to ip address,then create some sockets on the ip,and the error point is here,so i nano my /etc/hosts file,and add map for hostname and 127.0.0.1,that's it!
\n", "_id"=>191}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["书"], "comments_count"=>0, "category_id"=>6, "title"=>"我写的书:《Google Android开发入门与实战》等即将上市.", "body"=>"这篇文章是非技术性的,所以使用中文写,免得写了大家看不懂,呵呵。\r\n\r\n写书不是第一次,出版却是第一本,至于原因,就不详述了,去年9月开始参与一些图书的翻译和撰写中,截至到目前,这段时间一共参与了三本书,按照参与的先后顺序,分别是《The Rails Way》,《Google API 编程.开发.实例》以及《Google Android开发入门与实战》。\r\n\r\n其中《The Rails Way》是做为译者参与,其他翻译者都是国内第一批Rails技术人员,分散在全国各地,还有一名译者在加拿大,我一共翻译了5章内容,分别是第2章“Working_with_Controllers”,第10章“ActionView”,第13章“Session__Session_Management”,第15章“XML_and_ActiveResource”和第16章“ActionMailer”,翻译很早前就结束了,目前好像还在审稿、校核工作,由YiTan在跟,至于何时出版,我还真不知道。\r\n\r\n《Google API 编程.开发.实例》我是从去年9月份介入,开始参与选题和策划,截至撰写相关内容,因为我自身是Google重度使用者,平时也比较多的使用和了解GoogleAPI,所以写起来得心应手,一共写了“Google Account Authentication”,“Google AJAX Language API”,“Google Chart API”,“Blogger Data API”,“Feedburner API”,“Google Code Search Data API”和“Google Book Search Book Viewability API”这些章节,前前后后也花了不少零碎的时间。其他作者大多都Google内部的同学,本书已经进入出版流程,由博文视点出版社策划出版,应该在6.5号Google开发者大会上可以看到,如下是本书第一版封面。\r\n\r\n\r\n\r\n本书特点:本书覆盖了Google绝大多数的API,其中针对每个API就其原理、用法做了详细说明,最后基本上都有实际的例子演示如何使用。\r\n\r\n《Google Android开发入门与实战》是08年11月份开始撰写的,和另外一个朋友一起,两个人陆续的差不多用了半年时间,在09年4月份差不多全部写完,后面主要是都在校核和审稿,由人民邮电出版社出版,5月底6月初即可上市,封面如下:\r\n\r\n\r\n\r\n \r\n
《Google API 编程.开发.实例》我是从去年9月份介入,开始参与选题和策划,截至撰写相关内容,因为我自身是Google重度使用者,平时也比较多的使用和了解GoogleAPI,所以写起来得心应手,一共写了“Google Account Authentication”,“Google AJAX Language API”,“Google Chart API”,“Blogger Data API”,“Feedburner API”,“Google Code Search Data API”和“Google Book Search Book Viewability API”这些章节,前前后后也花了不少零碎的时间。其他作者大多都Google内部的同学,本书已经进入出版流程,由博文视点出版社策划出版,应该在6.5号Google开发者大会上可以看到,如下是本书第一版封面。
and now,you can open a cmd shell,and input sqlite3 like this: \n
\n
C:\\Documents and Settings\\Administrator>sqlite3 \nSQLite version 3.5.9 \nEnter ".help" for instructions
\n
and some help infos is here:
\n
sqlite> .help \n.bail ON|OFF Stop after hitting an error. Default OFF \n.databases List names and files of attached databases \n.dump ?TABLE? ... Dump the database in an SQL text format \n.echo ON|OFF Turn command echo on or off \n.exit Exit this program \n.explain ON|OFF Turn output mode suitable for EXPLAIN on or off. \n.header(s) ON|OFF Turn display of headers on or off \n.help Show this message \n.import FILE TABLE Import data from FILE into TABLE \n.indices TABLE Show names of all indices on TABLE \n.load FILE ?ENTRY? Load an extension library \n.mode MODE ?TABLE? Set output mode where MODE is one of: \n csv Comma-separated values \n column Left-aligned columns. (See .width) \n html HTML <table> code \n insert SQL insert statements for TABLE \n line One value per line \n list Values delimited by .separator string \n tabs Tab-separated values \n tcl TCL list elements \n.nullvalue STRING Print STRING in place of NULL values \n.output FILENAME Send output to FILENAME \n.output stdout Send output to the screen \n.prompt MAIN CONTINUE Replace the standard prompts \n.quit Exit this program \n.read FILENAME Execute SQL in FILENAME \n.schema ?TABLE? Show the CREATE statements \n.separator STRING Change separator used by output mode and .import \n.show Show the current values for various settings \n.tables ?PATTERN? List names of tables matching a LIKE pattern \n.timeout MS Try opening locked tables for MS milliseconds \n.width NUM NUM ... Set column widths for "column" mode
Install SQLite3 for Windows by downloading the following 2 zip files and unzipping them into /WINDOWS/system32 \nhttp://www.sqlite.org/sqlite-3_6_14_1.zip \nhttp://www.sqlite.org/sqlitedll-3_6_14_1.zip \nIf those don't work try the official download site here \nand now,you can open a cmd shell,and input sqlite3 like this: \n \nC:\\Documents and Settings\\Administrator>sqlite3 \nSQLite version 3.5.9 \nEnter ".help" for instructions \nand some help infos is here: \nsqlite> .help \n.bail ON|OFF Stop after hitting an error. Default OFF \n.databases List names and files of attached databases \n.dump ?TABLE? ... Dump the database in an SQL text format \n.echo ON|OFF Turn command echo on or off \n.exit Exit this program \n.explain ON|OFF Turn output mode suitable for EXPLAIN on or off. \n.header(s) ON|OFF Turn display of headers on or off \n.help Show this message \n.import FILE TABLE Import data from FILE into TABLE \n.indices TABLE Show names of all indices on TABLE \n.load FILE ?ENTRY? Load an extension library \n.mode MODE ?TABLE? Set output mode where MODE is one of: \n csv Comma-separated values \n column Left-aligned columns. (See .width) \n html HTML <table> code \n insert SQL insert statements for TABLE \n line One value per line \n list Values delimited by .separator string \n tabs Tab-separated values \n tcl TCL list elements \n.nullvalue STRING Print STRING in place of NULL values \n.output FILENAME Send output to FILENAME \n.output stdout Send output to the screen \n.prompt MAIN CONTINUE Replace the standard prompts \n.quit Exit this program \n.read FILENAME Execute SQL in FILENAME \n.schema ?TABLE? Show the CREATE statements \n.separator STRING Change separator used by output mode and .import \n.show Show the current values for various settings \n.tables ?PATTERN? List names of tables matching a LIKE pattern \n.timeout MS Try opening locked tables for MS milliseconds \n.width NUM NUM ... Set column widths for "column" mode
add this line into /etc/lftp.conf \nset net:limit-rate 10240000,40960 \n \nthat's limit upload rate to 10M,and download to 40K \n \nsome useful resource:
\ncURL figures out which protocol to use from the URL you provide, and when \"http:\" is specified will, unless otherwise instructed (using -0), default to using HTTP 1.1. The first argument, -u, instructs cURL to use the next two parameters (separated by a colon) as the account name and password for basic authentication. The next argument, -d, specifies the data (maximum 140 characters) to be sent via a POST request.\n\nOf course what cURL expects is a response to the POST request so the result will be the requested page (update.xml) sent to stdout. This page will be encoded according to the file type used in the request, thus as we just requested update.xml we’ll get XML-formatted data. The alternatives are JSON (JavaScript Object Notation), RSS and Atom formats.\n\nfrom:\nhttp://www.networkworld.com/columnists/2008/052108-gearhead.html?page=2", "created_at"=>2009-09-27 18:26:17 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
curl -u email:passw -d status="text" http://twitter.com/statuses/update.xml \ncURL figures out which protocol to use from the URL you provide, and when "http:" is specified will, unless otherwise instructed (using -0), default to using HTTP 1.1. The first argument, -u, instructs cURL to use the next two parameters (separated by a colon) as the account name and password for basic authentication. The next argument, -d, specifies the data (maximum 140 characters) to be sent via a POST request.
\n\n
Of course what cURL expects is a response to the POST request so the result will be the requested page (update.xml) sent to stdout. This page will be encoded according to the file type used in the request, thus as we just requested update.xml we’ll get XML-formatted data. The alternatives are JSON (JavaScript Object Notation), RSS and Atom formats.
项目中使用nginx,上传一个大文件,出来错误提示,413 Request Entity Too Large! \n查了下资料,解决方法:打开nginx主配置文件nginx.conf,找到http{}段,添加
\n\n
client_max_body_size 20m;
\n\n
最好也调整下: \n keepalive_timeout 105; \n免得链接超时被关!
\n\n
该文件一般在/etc/nginx/nginx.conf
\n", "_id"=>201}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["rails", "rails-2.3.4"], "comments_count"=>0, "category_id"=>6, "title"=>"rails-2.3.4 发布了", "body"=>"Ruby on Rails 2.3.4, this release fixes bugs and introduces a few minor features. Due to the inclusion of two security fixes, all users of the 2.3 series are recommended to upgrade as soon as possible.\n\nC:\\Documents and Settings\\Administrator>gem install rails\nSuccessfully installed activesupport-2.3.4\nSuccessfully installed activerecord-2.3.4\nSuccessfully installed actionpack-2.3.4\nSuccessfully installed actionmailer-2.3.4\nSuccessfully installed activeresource-2.3.4\nSuccessfully installed rails-2.3.4\n6 gems installed\nInstalling ri documentation for activesupport-2.3.4...\nInstalling ri documentation for activerecord-2.3.4...\nInstalling ri documentation for actionpack-2.3.4...\nInstalling ri documentation for actionmailer-2.3.4...\nInstalling ri documentation for activeresource-2.3.4...\nInstalling RDoc documentation for activesupport-2.3.4...\nInstalling RDoc documentation for activerecord-2.3.4...\nInstalling RDoc documentation for actionpack-2.3.4...\nInstalling RDoc documentation for actionmailer-2.3.4...\nInstalling RDoc documentation for activeresource-2.3.4...\n\n详细信息:\n\nhttp://weblog.rubyonrails.org/2009/9/4/ruby-on-rails-2-3-4", "created_at"=>2009-10-14 07:47:04 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
Ruby on Rails 2.3.4, this release fixes bugs and introduces a few minor features. Due to the inclusion of two security fixes, all users of the 2.3 series are recommended to upgrade as soon as possible.
\n\n
C:\\Documents and Settings\\Administrator>gem install rails \nSuccessfully installed activesupport-2.3.4 \nSuccessfully installed activerecord-2.3.4 \nSuccessfully installed actionpack-2.3.4 \nSuccessfully installed actionmailer-2.3.4 \nSuccessfully installed activeresource-2.3.4 \nSuccessfully installed rails-2.3.4 \n6 gems installed \nInstalling ri documentation for activesupport-2.3.4... \nInstalling ri documentation for activerecord-2.3.4... \nInstalling ri documentation for actionpack-2.3.4... \nInstalling ri documentation for actionmailer-2.3.4... \nInstalling ri documentation for activeresource-2.3.4... \nInstalling RDoc documentation for activesupport-2.3.4... \nInstalling RDoc documentation for activerecord-2.3.4... \nInstalling RDoc documentation for actionpack-2.3.4... \nInstalling RDoc documentation for actionmailer-2.3.4... \nInstalling RDoc documentation for activeresource-2.3.4...
\n", "_id"=>203}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["package", "ubuntu", "uninstall"], "comments_count"=>0, "category_id"=>7, "title"=>"Uninstall / Delete / Remove Package", "body"=>"Just use the following syntax:\n\nsudo apt-get remove {package-name}\n\nFor example remove package called mplayer, enter:\n$ sudo apt-get remove mplayer\n\nRemove package called lighttpd along with all configuration files, enter:\n$ sudo apt-get --purge remove lighttpd\n\nTo list all installed package, enter:\\\ndpkg --list\ndpkg --list | less\ndpkg --list | grep -i 'http'", "created_at"=>2009-11-22 18:48:23 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
Just use the following syntax:
\n\n
sudo apt-get remove {package-name}
\n\n
For example remove package called mplayer, enter: \n$ sudo apt-get remove mplayer
\n\n
Remove package called lighttpd along with all configuration files, enter: \n$ sudo apt-get --purge remove lighttpd
\n\n
To list all installed package, enter:\\ \ndpkg --list \ndpkg --list | less \ndpkg --list | grep -i 'http'
\n", "_id"=>204}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["delegate", "ImageMagick"], "comments_count"=>0, "category_id"=>7, "title"=>"ImageMagick够折腾得,no decode delegate", "body"=>"估计RP出问题了,以前安装和今天在mac上安装都很顺利,但是在服务器上装得时候,出现一大堆得问题,极度诡异,最后查了N多资料,改了N多东西,也不晓得最后是哪个生效了,终于折腾好了.\n记录下我参考过得资料:\nhttp://www.imagemagick.org/script/command-line-processing.php\nhttp://wanguan2000.blog.ubuntu.org.cn/2009/01/04/ubuntu-下rmagick的安装/\nhttp://infrastacks.com/?p=57\nhttp://hi.baidu.com/yttxuehui/blog/item/9f1a21978d6fa96a55fb96d5.html\nhttp://www.blogjava.net/fl1429/archive/2009/06/17/282895.html\nhttp://hi.baidu.com/countryroadtao/blog/item/225c72dad2adc16cd0164e97.html\nhttp://www.cnscn.org/htm_data/602/0705/8717.html\nhttp://stackoverflow.com/questions/1483968/imagemagick-convert-error-wrong-jpeg-library-version-library-is-62-caller-expe\n我读最后一个问题印象深刻\n\"Looks like it is reading the wrong jpeg ibrary, but I have jpeg 7 installed. How do i tell ImageMagick to look up the right JPEG library version(I don't care 62 or 70 as long as it works).\"\nroot@li84-64:/data/soft/ImageMagick-6.5.7-9# convert -list format | grep JPEG\n see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS),\n and supplement 61 which adds JPEG-2000 encoding.\n JNG* PNG rw- JPEG Network Graphics\n JP2* JP2 rw- JPEG-2000 File Format Syntax\n JPC* JPC rw- JPEG-2000 Code Stream Syntax\n JPEG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n JPG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n JPX* JPX rw- JPEG-2000 File Format Syntax\n PGX* PGX r-- JPEG-2000 VM Format\n PJPEG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n\n看到其需要得JPEG得lib是70,但是我装得是\n\nroot@li84-64:/data/soft/ImageMagick-6.5.7-9# dpkg --list | grep \"magick\"\nrc imagemagick 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation programs\nii libmagick++10 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library\nii libmagick++9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library - develop\nii libmagick10 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library\nii libmagick9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library - development fil\nii libmagickcore1 7:6.4.5.4.dfsg1-1ubuntu3.1 low-level image manipulation library\nii libmagickwand1 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation library\nii librmagick-ruby 1.15.11-1ubuntu1 ImageMagick API for Ruby\nii librmagick-ruby1.8 1.15.11-1ubuntu1 ImageMagick API for Ruby", "created_at"=>2009-11-22 20:30:32 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
root@li84-64:/data/soft/ImageMagick-6.5.7-9# dpkg --list | grep "magick" \nrc imagemagick 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation programs \nii libmagick++10 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library \nii libmagick++9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library - develop \nii libmagick10 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library \nii libmagick9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library - development fil \nii libmagickcore1 7:6.4.5.4.dfsg1-1ubuntu3.1 low-level image manipulation library \nii libmagickwand1 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation library \nii librmagick-ruby 1.15.11-1ubuntu1 ImageMagick API for Ruby \nii librmagick-ruby1.8 1.15.11-1ubuntu1 ImageMagick API for Ruby
\n", "_id"=>205}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["find", "inject", "rails", "ruby", "select"], "comments_count"=>0, "category_id"=>5, "title"=>"用Ruby在已知数组中找到和目标最匹配得元素", "body"=>"有个需求,给定一个数组,然后给出一个变量,需要在这个数组中找到和这个变量得值最接近得那个元素,开始用find或者select都不是很合适,最后找到inject,很好得解决了这个需求,现在记录下:\n首先看下inject这个函数\n````\nenum.inject(initial) {| memo, obj | block } => obj\nenum.inject {| memo, obj | block } => obj\nCombines the elements of enum by applying the block to an accumulator value (memo) and each element in turn. At each step, memo is set to the value returned by the block. The first form lets you supply an initial value for memo. The second form uses the first element of the collection as a the initial value (and skips that element while iterating).\n\n # Sum some numbers\n (5..10).inject {|sum, n| sum + n } #=> 45\n # Multiply some numbers\n (5..10).inject(1) {|product, n| product * n } #=> 151200\n\n # find the longest word\n longest = %w{ cat sheep bear }.inject do |memo,word|\n memo.length > word.length ? memo : word\n end\n longest #=> \"sheep\"\n\n # find the length of the longest word\n longest = %w{ cat sheep bear }.inject(0) do |memo,word|\n memo >= word.length ? memo : word.length\n end\n longest #=> 5\n```\n\n然后根据我得需求,写出一个函数如下:\n````\n # find the min abs size\n def self.select_h(h)\n if ALL_FORMATS.include?(h)\n return h\n else\n ok_size = ALL_FORMATS.inject do |i,j|\n (i-h).abs < (j-h).abs ? i : j\n end\n return ok_size\n end\n end\n```\n首先看是否包含这个变量,如果又,直接返回,如果没有就inject来取一个最合适得。", "created_at"=>2009-11-24 08:06:13 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
有个需求,给定一个数组,然后给出一个变量,需要在这个数组中找到和这个变量得值最接近得那个元素,开始用find或者select都不是很合适,最后找到inject,很好得解决了这个需求,现在记录下: \n首先看下inject这个函数 \n```` \nenum.inject(initial) {| memo, obj | block } => obj \nenum.inject {| memo, obj | block } => obj \nCombines the elements of enum by applying the block to an accumulator value (memo) and each element in turn. At each step, memo is set to the value returned by the block. The first form lets you supply an initial value for memo. The second form uses the first element of the collection as a the initial value (and skips that element while iterating).
\n\n
# Sum some numbers \n (5..10).inject {|sum, n| sum + n } #=> 45 \n # Multiply some numbers \n (5..10).inject(1) {|product, n| product * n } #=> 151200
\n\n
# find the longest word \n longest = %w{ cat sheep bear }.inject do |memo,word| \n memo.length > word.length ? memo : word \n end \n longest #=> "sheep"
\n\n
# find the length of the longest word \n longest = %w{ cat sheep bear }.inject(0) do |memo,word| \n memo >= word.length ? memo : word.length \n end \n longest #=> 5 \n```
\n\n
然后根据我得需求,写出一个函数如下: \n` \n # find the min abs size \n def self.select_h(h) \n if ALL_FORMATS.include?(h) \n return h \n else \n ok_size = ALL_FORMATS.inject do |i,j| \n (i-h).abs < (j-h).abs ? i : j \n end \n return ok_size \n end \n end \n \n首先看是否包含这个变量,如果又,直接返回,如果没有就inject来取一个最合适得。
\n", "_id"=>208}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["GD", "php", "ubuntu"], "comments_count"=>0, "category_id"=>7, "title"=>"Install GD Support for PHP in Ubuntu", "body"=>"I am in the process of building my blog using wordpress ,then i install SI CAPTCHA Anti-Spam ,but it's say i didn’t have GD support for PHP5 installed on my server. so i need to do:\n\nOpen terminal and type in the following command:\n
\n\nThere you go, you now have GD Support for PHP5 in Ubuntu. Get your Drupal on!", "created_at"=>2010-01-13 02:25:36 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
I am in the process of building my blog using wordpress ,then i install SI CAPTCHA Anti-Spam ,but it's say i didn’t have GD support for PHP5 installed on my server. so i need to do:
\n\n
Open terminal and type in the following command: \n$ sudo apt-get install php5-gd
\n\n
Now restart Apache \n# sudo /etc/init.d/apache2 restart
\n\n
or restart spawn-fcgi \n/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9100 -u www-data -g www-data -f /usr/bin/php-cgi -C 10
\n\n
There you go, you now have GD Support for PHP5 in Ubuntu. Get your Drupal on!
\n", "_id"=>209}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["centOS", "Swap"], "comments_count"=>0, "category_id"=>7, "title"=>"Swap Space in centOS", "body"=>"Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.\n\nSwap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.\n\nSwap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.\n\nSo, if:\n\nM = Amount of RAM in GB, and S = Amount of swap in GB, then\n
If M < 2\n\tS = M *2\nElse\n\tS = M + 2
\nUsing this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.\n\nFor systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).\n\nsource:http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-swapspace.html", "created_at"=>2010-01-21 02:01:34 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.
\n\n
Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
\n\n
Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.
\n\n
So, if:
\n\n
M = Amount of RAM in GB, and S = Amount of swap in GB, then \nIf M < 2 \n S = M *2 \nElse \n S = M + 2 \nUsing this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.
\n\n
For systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).
\n", "_id"=>210}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["劫持", "电信"], "comments_count"=>0, "category_id"=>5, "title"=>"深圳电信耍流氓,劫持浏览器", "body"=>"今天无意发现在浏览器的左下角经常出现一个页面无法打开的提示,如下\nThe webpage at http://121.15.207.133:4022/logo.jpg?p=undefined|778|1276|24|800|1280might be temporarily down or it may have moved permanently to a new web address.\n\n看其样式是请求了一个121.15.207.133上的一个logo图片,然后传入了几个参数,但是这个图片的服务器貌似除了电问题,导致请求不到。\n无缘无故的,咋会去请求这个玩意呢,查了吓这个IP归属,属于:\n
\n", "_id"=>211}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["C", "ruby", "RubyInline"], "comments_count"=>0, "category_id"=>2, "title"=>"RubyInline, Making Making Things Faster Easier", "body"=>"发现一篇好文,讲的是如何使用RubyInline,在Ruby中直接嵌入C并运行,相比之前些lib,要方便的多,由于这个文章在墙外,就转了一份过来,可以翻墙的可以去看原文\nhttp://on-ruby.blogspot.com/2006/07/rubyinline-making-making-things-faster.html\n\nToday on ruby-talk, I caught a thread called \"For Performance, Write it in C\". I'd like to present a slight amendment to that thesis. Let me explain.\n\nIt all started with an email at work. Someone was passing around a bunch of prime number printers in various languages (C, Java, C#, Perl, and Python). They all used the same (ugly) algorithm, and were supposed to show just how 'performant the languages were. Since I'm the local Ruby evangelist, I was asked to write a Ruby version. Here's what I came up with (warning, ugly algorithm ahead):\n\n#!/usr/bin/ruby\n\nfor num in 1..10_000 do\nis_prime = 1\nfor x in 2..(num - 1) do\nif (num % x == 0)\nis_prime = x\nbreak\nend\nend\nif is_prime == 1\nputs \"\#{num} is a prime number\"\nelse\nputs \"\#{num} equals \#{is_prime} * \#{num/is_prime}\"\nend\nend\nHow fast is it? Well, time says:\n\n$ time ./primes.rb > /dev/null\n\nreal 0m2.905s\nuser 0m2.716s\nsys 0m0.004s\n$\n\nCertainly, nothing to write home about, but not too far from Perl or Python either.\nWanting to improve it, and not being able to touch the algorithm (we want to be comparing apples to quinces after all, not apples to oranges). I know my only hope is to find the bottleneck(s) and rewrite it (them?) in C. My first step is to grab Ruby's profiler and see what it says (oh, by the way, I reduced the value of num to 100 so that this would complete in my lifetime ... the profiler is slow).\n\n$ ruby -rprofile primes.rb > /dev/null\n% cumulative self self total\ntime seconds seconds calls ms/call ms/call name\n63.64 0.14 0.14 101 1.39 3.56 Range#each\n13.64 0.17 0.03 1133 0.03 0.03 Fixnum#%\n9.09 0.19 0.02 1233 0.02 0.02 Fixnum#==\n4.55 0.20 0.01 100 0.10 0.20 Kernel.puts\n4.55 0.21 0.01 200 0.05 0.05 IO#write\n4.55 0.22 0.01 248 0.04 0.04 Fixnum#to_s\n0.00 0.22 0.00 74 0.00 0.00 Fixnum#/\n0.00 0.22 0.00 100 0.00 0.00 Fixnum#-\n0.00 0.22 0.00 1 0.00 220.00 #toplevel\n$\n\nWhich tells me that most of my time is spent in each (well, it's actually spent in the block I sent to each. It's taking a whopping 1.39 msec per call, compared to .0X msec for everything else. What would happen if I rewrote just that block?\nEnter RubyInline (A great tool written by zenspider and Eric Hodel). I'm not a C wiz by any stretch of the imagination, but this stuff is pretty easy to bang out. My new code looks like this:\n\n#!/usr/bin/ruby\n\nrequire \"rubygems\"\nrequire \"inline\"\n\nclass Primes\ninline do |builder|\nbuilder.c '\nint prime(int num) {\nint x;\nfor (x = 2; x < (num - 1) ; x++) { if (num == 2) { return 1; } if (num % x == 0) { return x; } } return 1; }' end end p = Primes.new for num in 2..10_000 do is_prime = p.prime(num) if is_prime == 1 puts \"\#{num} is a prime number\" else puts \"\#{num} equals \#{is_prime} * \#{num/is_prime}\" end end Not too ugly. At least I can still see what's happening. The main loop being in Ruby helps a lot too (especially if this were a much bigger program). How much of a difference does it make? time says: $ time ./cprimes.rb > /dev/null\n\nreal 0m0.328s\nuser 0m0.288s\nsys 0m0.020s\n\nAn order of magnitude improvement. Not too shabby.\nWhat's the lesson here? Optimize what you need to (and only what you need to), profile find out what that is (it may be slow, but profiling is your friend), and use the right tools (rewriting a bit of code with RubyInline is way better than rewriting the whole app in C).", "created_at"=>2010-01-24 10:51:47 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
Today on ruby-talk, I caught a thread called "For Performance, Write it in C". I'd like to present a slight amendment to that thesis. Let me explain.
\n\n
It all started with an email at work. Someone was passing around a bunch of prime number printers in various languages (C, Java, C#, Perl, and Python). They all used the same (ugly) algorithm, and were supposed to show just how 'performant the languages were. Since I'm the local Ruby evangelist, I was asked to write a Ruby version. Here's what I came up with (warning, ugly algorithm ahead):
\n\n
!/usr/bin/ruby
\n\n
for num in 1..10_000 do \nis_prime = 1 \nfor x in 2..(num - 1) do \nif (num % x == 0) \nis_prime = x \nbreak \nend \nend \nif is_prime == 1 \nputs "\#{num} is a prime number" \nelse \nputs "\#{num} equals \#{is_prime} * \#{num/is_prime}" \nend \nend \nHow fast is it? Well, time says:
\n\n
$ time ./primes.rb > /dev/null
\n\n
real 0m2.905s \nuser 0m2.716s \nsys 0m0.004s \n$
\n\n
Certainly, nothing to write home about, but not too far from Perl or Python either. \nWanting to improve it, and not being able to touch the algorithm (we want to be comparing apples to quinces after all, not apples to oranges). I know my only hope is to find the bottleneck(s) and rewrite it (them?) in C. My first step is to grab Ruby's profiler and see what it says (oh, by the way, I reduced the value of num to 100 so that this would complete in my lifetime ... the profiler is slow).
Which tells me that most of my time is spent in each (well, it's actually spent in the block I sent to each. It's taking a whopping 1.39 msec per call, compared to .0X msec for everything else. What would happen if I rewrote just that block? \nEnter RubyInline (A great tool written by zenspider and Eric Hodel). I'm not a C wiz by any stretch of the imagination, but this stuff is pretty easy to bang out. My new code looks like this:
\n\n
!/usr/bin/ruby
\n\n
require "rubygems" \nrequire "inline"
\n\n
class Primes \ninline do |builder| \nbuilder.c ' \nint prime(int num) { \nint x; \nfor (x = 2; x < (num - 1) ; x++) { if (num == 2) { return 1; } if (num % x == 0) { return x; } } return 1; }' end end p = Primes.new for num in 2..10_000 do is_prime = p.prime(num) if is_prime == 1 puts "\#{num} is a prime number" else puts "\#{num} equals \#{is_prime} * \#{num/is_prime}" end end Not too ugly. At least I can still see what's happening. The main loop being in Ruby helps a lot too (especially if this were a much bigger program). How much of a difference does it make? time says: $ time ./cprimes.rb > /dev/null
\n\n
real 0m0.328s \nuser 0m0.288s \nsys 0m0.020s
\n\n
An order of magnitude improvement. Not too shabby. \nWhat's the lesson here? Optimize what you need to (and only what you need to), profile find out what that is (it may be slow, but profiling is your friend), and use the right tools (rewriting a bit of code with RubyInline is way better than rewriting the whole app in C).
\n# Example MySQL config file for large systems.\n#\n# This is for a large system with memory = 512M where the system runs mainly\n# MySQL.\n#\n# You can copy this file to\n# /etc/my.cnf to set global options,\n# mysql-data-dir/my.cnf to set server-specific options (in this\n# installation this directory is /var/lib/mysql) or\n# ~/.my.cnf to set user-specific options.\n#\n# In this file, you can use all long options that a program supports.\n# If you want to know which options a program supports, run the program\n# with the \"--help\" option.\n\n# The following options will be passed to all MySQL clients\n[client]\nport = 3306\nsocket = /var/lib/mysql/mysql.sock\n\n# Here follows entries for some specific programs\n\n# The MySQL server\n[mysqld]\ndatadir=/var/lib/mysql\nsocket=/var/lib/mysql/mysql.sock\nuser=mysql\nskip-locking\n\n# By default, the wait_timeout value is 28800. Unless you want MySQL to keep waiting for 28800 seconds (480 minutes or 8 hours),\n# please decrease its value according to your application needs.\nwait_timeout=60\n# Increase connect_timeout from 5 to 10\nconnect_timeout=10\n# Decrease interactive_timeout from 28800 to 100\ninteractive_timeout=120\n# Increase join_buffer_size from 131072 to 1M\njoin_buffer_size=1M\n# Increase query_cache_size from 0 to 128M\nquery_cache_size=32M\n# Increase query cache limit from 1048576 to 2M\nquery_cache_limit=2M\n# Increase max allowed packet size from 1M to 16M\nmax_allowed_packet=2M\n# Increase table cache cache from 256 to 1024\ntable_cache=1024\n# Increase sort buffer size from 1M\nsort_buffer_size=2M\n# Increase read buffer size from 1M\nread_buffer_size=2M\n# Increase read_rnd_buffer_size to 4M\nread_rnd_buffer_size=4M\n\n#Other settings\nsort_buffer_size=8M\nkey_buffer = 256M\nkey_buffer_size=64M\nmyisam_sort_buffer_size = 64M\nthread_cache_size = 8\n# Try number of CPU's*2 for thread_concurrency\nthread_concurrency = 2\n\n\n# Don't listen on a TCP/IP port at all. This can be a security enhancement,\n# if all processes that need to connect to mysqld run on the same host.\n# All interaction with mysqld must be made via Unix sockets or named pipes.\n# Note that using this option without enabling named pipes on Windows\n# (via the \"enable-named-pipe\" option) will render mysqld useless!\n#\n#skip-networking\n\n# Disable Federated by default\nskip-federated\n\nold_passwords=1\n\n#for slow queries\nlog-slow-queries = /var/log/mysql-slow.log\nlong_query_time = 3\n\n[mysqldump]\nquick\nmax_allowed_packet = 16M\n\n[mysql]\nno-auto-rehash\n# Remove the next comment character if you are not familiar with SQL\n#safe-updates\n\n[isamchk]\nkey_buffer = 128M\nsort_buffer_size = 128M\nread_buffer = 2M\nwrite_buffer = 2M\n\n[myisamchk]\nkey_buffer = 128M\nsort_buffer_size = 128M\nread_buffer = 2M\nwrite_buffer = 2M\n\n[mysqlhotcopy]\ninteractive-timeout\n\n[mysqld_safe]\nlog-error=/var/log/mysqld.log\npid-file=/var/run/mysqld/mysqld.pid\n
mysql> SHOW VARIABLES like \"%sort%\";\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| max_length_for_sort_data | 1024 |\n| max_sort_length | 1024 |\n| myisam_max_sort_file_size | 2146435072 |\n| myisam_sort_buffer_size | 67108864 |\n| sort_buffer_size | 8388608 |\n+---------------------------+------------+\n5 rows in set (0.00 sec)
\n\n不晓得是做啥用的,查了下资料:\n
http://forge.mysql.com/wiki/MySQL_Internals_Algorithms\n\nUsing the modified filesort algorithm, the tuples are longer than the pairs used in the original method, and fewer of them fit in the sort buffer (the size of which is given by sort_buffer_size). As a result, it is possible for the extra I/O to make the modified approach slower, not faster. To avoid a slowdown, the optimization is used only if the total size of the extra columns in the sort tuple does not exceed the value of the max_length_for_sort_data system variable. (A symptom of setting the value of this variable too high is that you should see high disk activity and low CPU activity.)
Using the modified filesort algorithm, the tuples are longer than the pairs used in the original method, and fewer of them fit in the sort buffer (the size of which is given by sort_buffer_size). As a result, it is possible for the extra I/O to make the modified approach slower, not faster. To avoid a slowdown, the optimization is used only if the total size of the extra columns in the sort tuple does not exceed the value of the max_length_for_sort_data system variable. (A symptom of setting the value of this variable too high is that you should see high disk activity and low CPU activity.)
\n", "_id"=>217}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "filesort"], "comments_count"=>0, "category_id"=>11, "title"=>"What does Using filesort mean in MySQL?", "body"=>"一直以来,只要我看到explain出来的结果有“Using filesort ”,我就要想方设法的优化和改善,因为我以前以为这个的意思就是使用文件系统来排序(那该多慢呀!),其实不是这样的。\n在mysqlperformanceblog上看到一篇文章《What does Using filesort mean in MySQL?》其中作者说自己每次面世的时候都会问“what does Using filesort mean in EXPLAIN,” 结果没有一个人回答的是对的,结果让其比较郁闷,就写了这个文章说明:\n
The usual answer is something like “rows are being placed into a temporary table which is too big to fit in memory, so it gets sorted on disk.” Unfortunately, this is not the same thing. First of all, this is Using temporary. Secondly, temporary tables may go to disk if they are too big, but EXPLAIN doesn’t show that. (If I interview you, I might ask you what “too big” means, or I might ask you the other reason temporary tables go to disk!)
The truth is, filesort is badly named. Anytime a sort can’t be performed from an index, it’s a filesort. It has nothing to do with files. Filesort should be called “sort.” It is quicksort at heart.
\n正解是,filesort这个名字有问题,容易给人误解,在mysql中,任何不能通过index进行的sort都称之为filesort,这里的filesort和文件没有任何关系,应该称之为“sort”而不是“filesort”,它的内部实现就是快速排序。\n\n参考资料:\nWhat does Using filesort mean in MySQL?\nhttp://www.mysqlperformanceblog.com/2009/03/05/what-does-using-filesort-mean-in-mysql/\n\nHow MySQL executes ORDER BY\nhttp://s.petrunia.net/blog/?p=24", "created_at"=>2010-02-03 03:51:36 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
一直以来,只要我看到explain出来的结果有“Using filesort ”,我就要想方设法的优化和改善,因为我以前以为这个的意思就是使用文件系统来排序(那该多慢呀!),其实不是这样的。 \n在mysqlperformanceblog上看到一篇文章《What does Using filesort mean in MySQL?》其中作者说自己每次面世的时候都会问“what does Using filesort mean in EXPLAIN,” 结果没有一个人回答的是对的,结果让其比较郁闷,就写了这个文章说明: \nThe usual answer is something like “rows are being placed into a temporary table which is too big to fit in memory, so it gets sorted on disk.” Unfortunately, this is not the same thing. First of all, this is Using temporary. Secondly, temporary tables may go to disk if they are too big, but EXPLAIN doesn’t show that. (If I interview you, I might ask you what “too big” means, or I might ask you the other reason temporary tables go to disk!) \n通常的解释是:选择出来的记录太多了,需要排序时内存中放不下了,所以会存储在磁盘中,并通过操作磁盘的文件的方式来排序。但是呢,这是不对的。
\n\n
The truth is, filesort is badly named. Anytime a sort can’t be performed from an index, it’s a filesort. It has nothing to do with files. Filesort should be called “sort.” It is quicksort at heart. \n正解是,filesort这个名字有问题,容易给人误解,在mysql中,任何不能通过index进行的sort都称之为filesort,这里的filesort和文件没有任何关系,应该称之为“sort”而不是“filesort”,它的内部实现就是快速排序。
\n", "_id"=>218}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "variables"], "comments_count"=>0, "category_id"=>11, "title"=>"Mysql动态修改参数", "body"=>"mysql数据库也像ORACLE数据库一样,可以动态的修改参数,可以修改会话级变量只对当前会话产生影响;也可以修改全局变量,对所有新连接的会话都产生影响。\n\n修改会话级变量\n用show variables 命令查看当前参数的值,like 'pattern'用于模式匹配,查找指定的参数\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n用set SESSION命令设置会话级变量的新值\n\nmysql> set SESSION sort_buffer_size=7000000;\nQuery OK, 0 rows affected (0.00 sec)\n\n--修改会话级变量对当前会话来说立刻生效\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 7000000 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\nmysql> exit\nBye\n退出重新连接后,此参数恢复原值\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 40 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n修改全局变量\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 40 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n用set GLOBAL 命令设置全局变量\n\nmysql> set GLOBAL sort_buffer_size = 7000000;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n当前此参数的值并不发生变化,先退出,然后重新连进去\nmysql> exit\nBye\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 41 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 7000000 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n新的参数值生效", "created_at"=>2010-02-03 04:00:12 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
--修改会话级变量对当前会话来说立刻生效 \nmysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 7000000 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
mysql> exit \nBye \n退出重新连接后,此参数恢复原值 \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 40 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
修改全局变量 \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 40 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
用set GLOBAL 命令设置全局变量
\n\n
mysql> set GLOBAL sort_buffer_size = 7000000; \nQuery OK, 0 rows affected (0.00 sec)
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec) \n当前此参数的值并不发生变化,先退出,然后重新连进去 \nmysql> exit \nBye \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 41 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 7000000 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec) \n新的参数值生效
\n", "_id"=>220}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Tips"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Textmate", "theme"], "comments_count"=>0, "category_id"=>4, "title"=>"Installing a New Textmate Theme", "body"=>"To install a new theme, select one of the .tmTheme links listed below, download it to your desktop and double-click on the file. This will place it in ~/Library/Application Support/TextMate/Themes, at which point the new theme will appear in the list found in Preferences → Fonts & Colors. This will also set it as the active theme. (Once the theme is installed, you may remove the .tmTheme from your desktop.)\n\nRails Envy TextMate Theme\n http://railsenvy.com/2008/9/18/rails-envy-textmate-theme\n\nUser Submitted Themes\n http://wiki.macromates.com/Themes/UserSubmittedThemes", "created_at"=>2010-02-04 18:24:02 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
To install a new theme, select one of the .tmTheme links listed below, download it to your desktop and double-click on the file. This will place it in ~/Library/Application Support/TextMate/Themes, at which point the new theme will appear in the list found in Preferences → Fonts & Colors. This will also set it as the active theme. (Once the theme is installed, you may remove the .tmTheme from your desktop.)
\n\nrestart teatmate and it's done!\n\nIn the TextMate preferences, advanced tab, shell variables, set the TM_GIT variable to point to your installation of git (ie /usr/local/bin/git)\nMany shortcuts are available from the Git-shortcut (Ctrl-Shift-G). Subversion commands are Command-Option-g. Less frequent commands are accessed via the menu.\nUpdate your bundle by running the “Update Git Bundle” command.", "created_at"=>2010-02-04 23:39:24 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
In the TextMate preferences, advanced tab, shell variables, set the TM_GIT variable to point to your installation of git (ie /usr/local/bin/git) \nMany shortcuts are available from the Git-shortcut (Ctrl-Shift-G). Subversion commands are Command-Option-g. Less frequent commands are accessed via the menu. \nUpdate your bundle by running the “Update Git Bundle” command.
SIMBL (SIMple Bundle Loader) - pronounced like \"symbol\" or \"cymbal\" - enables hacks and plugins. For instance, SIMBL enables PithHelmet to enhance Safari.
Install SIMBL and make sure you have latest SIMBL 0.9.x\nPlace Visor.bundle into ~/Library/Application Support/SIMBL/Plugins (create this directory if it does not exist)\nRelaunch Terminal.app - You should now see the Visor Status Menu Item\nConfigure your keyboard trigger by selecting the Visor Status Menu Item -> Visor Preferences ... and edit your keyboard hot-key\nYou can now trigger Visor with your hot-key from any application to get an instant terminal session.\n\nTo hide Visor, you can either:\nre-trigger with your key-combo\noptionally you can click off of the Visor window
如果你和我一样经常使用终端程序,这个小程序一定可以帮到你。他能将终端窗口变成类似雷神或CS那样的下拉窗口,非常酷。 \n可以从这里下载 http://visor.binaryage.com/ \n这个软件需要SIMBL ,如果你没有安装,要先安装这个。 \nhttp://www.culater.net/software/SIMBL/SIMBL.php \nSIMBL (SIMple Bundle Loader) - pronounced like "symbol" or "cymbal" - enables hacks and plugins. For instance, SIMBL enables PithHelmet to enhance Safari. \n之后将下载下来的文件解压,将解压后的文件拷贝至/Library/Application Support/SIMBL/Plugins,之后再重新启动你的终端你就可以看到效果了。 默认的快捷启动键是Ctrl+` \nvisor: http://visor.binaryage.com/
\n\n
Installation
\n\n
Install SIMBL and make sure you have latest SIMBL 0.9.x \nPlace Visor.bundle into ~/Library/Application Support/SIMBL/Plugins (create this directory if it does not exist) \nRelaunch Terminal.app - You should now see the Visor Status Menu Item \nConfigure your keyboard trigger by selecting the Visor Status Menu Item -> Visor Preferences ... and edit your keyboard hot-key \nYou can now trigger Visor with your hot-key from any application to get an instant terminal session.
\n\n
To hide Visor, you can either: \nre-trigger with your key-combo \noptionally you can click off of the Visor window
前段时间写了一篇《实例优化mysql配置文件my.cnf》,这几天看到效果非常明显,别的不说,单mysql cache_hits就很不错(之前竟然没注意到这个参数) \n# Increase query_cache_size from 0 to 128M \nquery_cache_size=128M
Rails 3 in Action by Yehuda Katz and Mike Gunderloy. Currently available is their Early Access Edition, which gives you access to chapters as they are written.
\n\t
Beginning Rails 3 by Jeffrey Allan Hardy , Cloves Carneiro Jr. & Rida Al Barazi
这次升级需要新装很多的gem,如下: \ngem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n \ngem install rails --pre \n期间遇到一个错误: \nDue to a rubygems bug, you must uninstall all older versions of bundler for 0.9 to work \n然后这边有N多关于Rails3的资料供参考:
\n\n
Rails 3 Tutorials & Blog Posts
\n\n
Edging your way towards Ruby 1.9.1 and Rails 3.0pre \n Unobtrusive JavaScript in Rails 3 by Zach Carter \n A Fresh Cup: Seed Data in Rails 3 tutorial – feature summary + code example by Mike Gunderloy. \n Rails3: Stepping off of the golden path slides by Matt Aimonetti \n Rails Magazine – RailsConf 2009 Edition page 5 has a section called The Unofficial Guide to What’s New in Rails 3 by Rupak Ganguly \n Jason Ting’s RailsConf 2009 Notes includes some basic notes about Rails 3 \n Noel Rappin: Railsconf 09 – After the RailsConfening article \n Yehuda Katz: Railsconf Wrapup blog – contains links to jQuery talk by Katz at RailsConf 09 \n How to Begin Playing With Rails 3 by Oscar Del Ben \n My Five Favorite Things About Rails 3 by Yehuda Katz \n Rails 3: The Great Decoupling by Yehuda Katz \n Rails Edge Architecture by Yehuda Katz \n How to Build Sinatra on Rails 3 by Yehuda Katz
\n\n
Rails 3 Presentations & Conference Talks
\n\n
Yehuda: What to Expect in Rails 3.0 webcast recording \n Scotland on Rails: Yehuda on Rails & Merb Merge video. For more Scotland on Rails videos, check out this Ruby Inside post. \n Yehuda Katz on Rails 3 and beyond interview by Mark Coleman \n RailsConf: Yehuda – The Russian Doll Pattern video \n RailsConf 09: DHH Keynote video – DHH previews unobtrusive javascript, default escaping & more.
\n\n
Rails 3 Books
\n\n
Rails 3 in Action by Yehuda Katz and Mike Gunderloy. Currently available is their Early Access Edition, which gives you access to chapters as they are written. \n Beginning Rails 3 by Jeffrey Allan Hardy , Cloves Carneiro Jr. & Rida Al Barazi
\n\n
Rails 3 Commentary
\n\n
Internet News: Rails 3 Gets Supersized With Merb \n eWeek: Rubyists Unite Ruby on Rails and Merb to Merge in Rails 3 \n CIO: Rails 3 to add security enhancement \n Yehuda Katz: Rails and Merb Merge \n RubyOnRails.org: Rails + Merb Merge Announcement
\n", "_id"=>225}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"02. 产品设计 | PM"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Axure", "Balsamiq Mockups", "原型设计"], "comments_count"=>0, "category_id"=>13, "title"=>"Balsamiq Mockups,理想的原型设计工具", "body"=>"由于经常要讨论产品,包括web和手机(\bAandroid,Iphone)的产品原型设计,尝试过很多的原型设计工具,例如Axure等,后来换了mac book,就一直找不到合适的原型设计工具,就一直在Google Doc中直接draw,其做了很多无用功。\n比较偶然的机会看到Balsamiq Mockups这个软件,和Pixelmator一样,是个人开发者(意大利人Peldi)开发的产品,其地址为http://www.balsamiq.com/ ,在其提供的demo页面上试了下http://www.balsamiq.com/demos/mockups/Mockups.html,效果很好,符合我的预期。\n虽然是由个人设计的,但功能却一点不弱于其他大牌的原型设计工具:\n操作方面,拖拽,控件分组,甚至元素之间的对齐都做得很贴心;\n预制了很多界面元素,从简单的输入框,下拉框,浏览器主要元素,到经常用得到的导航条,日历,表格,到复杂的Tag Cloud,Cover Flow, 地图,WYSWYG的格式工具栏等,有了这些不用从头画起,往往比用白板都快;\n界面元素的修改很简单,比如导航条的几个标签页的label,就是用逗号分隔的文字,下拉框的选项就是分行的文字;\n使用xml语言来记录和保存界面元素和布局,\n这使得每个设计都能被很好得放进SVN,Git,和CVS等工具中进行管理和跟踪;\n可以设计复杂的界面元素,保存后,以后可以重复使用(包括修改);\n可以将设计导出成PNG格式的图片;\n可以用命令行进行导出操作,这样就能让我写个脚本,从svn里checkout某个目录下的所有设计文件后,导出图片,打包后用邮件发到项目经理,工程师甚至客户那;\n跨平台,Balsamiq Mokups是用Flex和Air实现的,所以在Mac OS, Linux和Windows下都能使用;\n不仅仅有桌面版本,还有能集成在Confluence,JIRA,和XWiki中的版本,使得异地在线协作更方便有效。\n\n以下是关于Balsamiq Mockups的一些特点:\n易操作:从 Balsamiq Mockups 自带的元素里可以很方便地拖拽,效果图轻易形成;元素对齐很贴心;\n可偷懒:根据 Balsamiq Mockups 提供的 Wiki 风格的代码规则,画图时可以「偷懒」,输入文本符号则能生成图标。因此相比其它繁琐的软件操作,Balsamiq Mockups 也能更快地完成画图任务。\n控件足:Balsamiq Mockups 软件包括 50 多个控件, 70 多个图标。基本自带了所有常用的小控件,并在导航处进行分类;图标设计赏心悦目。要是 Balsamiq Mockups 允许用户导入自定义的控件就更好了,当然现有的也足够了 -\n新风格:让人眼前一亮的涂鸦风格,很能还原手绘效果;\n可中文:在菜单栏 View 里将 Use System Fonts 勾上,就能完美支持中文输入(注:非 Balsamiq Mockups 中文版);\n其它点:Balsamiq Mockups 使用 xml 记录,方便移植、二次利用;可导出为 png 格式图片。\n\n另外还有跨平台与多版本两个优点:\n跨平台:Balsamiq Mockups 基于 Air ,因此能同时在 Windows、Mac OS 及 Linux 下使用;\n多版本:包括桌面版本,以及集成于 Confluence、JIRA、XWiki、FogBugz 中的版本\n\n软件可以从其网站上下载,其中桌面版本售价是$79。但作者非常厚道,提供了几种免费使用的方式:http://www.balsamiq.com/products/mockups/desktop\n\nYou can download Mockups for Desktop for free. Some of the features of the app, like saving and loading multiple mockups or linking mockups together can only get unlocked using a license key.\n", "created_at"=>2010-02-21 18:39:26 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
You can download Mockups for Desktop for free. Some of the features of the app, like saving and loading multiple mockups or linking mockups together can only get unlocked using a license key.
\n", "_id"=>226}])
+MONGODB iceylog_development['categories'].find({:_id=>13}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>13}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "socket"], "comments_count"=>0, "category_id"=>3, "title"=>"Can’t connect to local MySQL server through socket 解决办法", "body"=>"Rails启动后报错,ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/temp/mysql.sock’ (2)\n\n1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.\n另外看看是不是权限问题.\n\n2、确定你的mysql.sock是不是在那个位置,\nmysql -u 你的mysql用户名 -p -S /var/lib/mysql/mysql.sock\n\n3、试试:service mysqld start\n\n4、如果是权限问题,则先改变权限 #chown -R mysql:mysql /var/lib/mysql\n\n[root@localhost ~]# /etc/init.d/mysqld start\n启动 MySQL: [ 确定 ]\n[root@localhost ~]# mysql -uroot -p", "created_at"=>2010-02-23 21:24:14 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
Rails启动后报错,ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/temp/mysql.sock’ (2)
\n\n
1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动. \n另外看看是不是权限问题.
\n", "_id"=>227}])
+MONGODB iceylog_development['categories'].find({:_id=>3}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>3}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Passenger", "REE"], "comments_count"=>0, "category_id"=>2, "title"=>"Download Ruby Enterprise Edition(REE)", "body"=>"前段时间用上了Passenger ,尔后就看到很多的人推荐使用Ruby Enterprise Edition(REE),今天得闲,试了一把。\nStep 1: Download\nSource code: version 1.8.7-2010.01\nStep 2: Install\nExtract it:\ntar xzvf ruby-enterprise-X.X.X.tar.gz\nRun the installer (completely safe, none of your system files will be touched!):\n./ruby-enterprise-X.X.X/installer\n
Welcome to the Ruby Enterprise Edition installer
\n
This installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.
\n
Don't worry, none of your system files will be touched if you don't want them
\n
to, so there is no risk that things will screw up.
\n
You can expect this from the installation process:
\n
1. Ruby Enterprise Edition will be compiled and optimized for speed for this
\n
system.
\n
2. Ruby on Rails will be installed for Ruby Enterprise Edition.
\n
3. You will learn how to tell Phusion Passenger to use Ruby Enterprise
\n
Edition instead of regular Ruby.
\n
Press Enter to continue, or Ctrl-C to abort.
\n
Welcome to the Ruby Enterprise Edition installerThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.Don't worry, none of your system files will be touched if you don't want themto, so there is no risk that things will screw up.\nYou can expect this from the installation process:\n1. Ruby Enterprise Edition will be compiled and optimized for speed for this system.\n\n2. Ruby on Rails will be installed for Ruby Enterprise Edition.\n\n3. You will learn how to tell Phusion Passenger to use Ruby Enterprise Edition instead of regular Ruby.\nPress Enter to continue, or Ctrl-C to abort.
\nStep 3: Make Phusion Passenger use Ruby Enterprise Edition instead of regular Ruby\nFollow the instructions that the Ruby Enterprise Edition installer gave you.", "created_at"=>2010-03-03 16:53:29 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
前段时间用上了Passenger ,尔后就看到很多的人推荐使用Ruby Enterprise Edition(REE),今天得闲,试了一把。 \nStep 1: Download \nSource code: version 1.8.7-2010.01 \nStep 2: Install \nExtract it: \ntar xzvf ruby-enterprise-X.X.X.tar.gz \nRun the installer (completely safe, none of your system files will be touched!): \n./ruby-enterprise-X.X.X/installer \nWelcome to the Ruby Enterprise Edition installer \nThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01. \nDon't worry, none of your system files will be touched if you don't want them \nto, so there is no risk that things will screw up. \nYou can expect this from the installation process: \n1. Ruby Enterprise Edition will be compiled and optimized for speed for this \nsystem. \n2. Ruby on Rails will be installed for Ruby Enterprise Edition. \n3. You will learn how to tell Phusion Passenger to use Ruby Enterprise \nEdition instead of regular Ruby. \nPress Enter to continue, or Ctrl-C to abort. \nWelcome to the Ruby Enterprise Edition installerThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.Don't worry, none of your system files will be touched if you don't want themto, so there is no risk that things will screw up. \nYou can expect this from the installation process: \n1. Ruby Enterprise Edition will be compiled and optimized for speed for this system.
\n\n\n
Ruby on Rails will be installed for Ruby Enterprise Edition.
\n
You will learn how to tell Phusion Passenger to use Ruby Enterprise Edition instead of regular Ruby. \nPress Enter to continue, or Ctrl-C to abort. \nStep 3: Make Phusion Passenger use Ruby Enterprise Edition instead of regular Ruby \nFollow the instructions that the Ruby Enterprise Edition installer gave you.
\n\n", "_id"=>228}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"02. 产品设计 | PM"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Border-radius", "css3"], "comments_count"=>0, "category_id"=>13, "title"=>"Border-radius: create rounded corners with CSS!", "body"=>"W3C has offered some new options for borders in CSS3, of which one is border-radius. Both Mozila/Firefox and Safari 3 have implemented this function, which allows you to create round corners on box-items. This is an example:\n\nMozilla/Firefox and Safari 3 users should see a nicely rounded box, with a nicely rounded border.\nThe code for this example above is actually quite simple:\n\nThese different corners can also each be handled on their own, Mozilla has other names for the feature than the spec says it should have though, as it has f.i. -moz-border-radius-topright as opposed to -webkit-border-top-right-radius:\n\nMozilla/Firefox and Safari 3 users should see a box with a rounded left upper corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded right upper corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded left lower corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded right lower corner.\nThese are handled by / should be handled by:\n\n````-moz-border-radius-topleft / -webkit-border-top-left-radius\n-moz-border-radius-topright / -webkit-border-top-right-radius\n-moz-border-radius-bottomleft / -webkit-border-bottom-left-radius\n-moz-border-radius-bottomright / -webkit-border-bottom-right-radius```", "created_at"=>2010-03-05 10:38:13 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
W3C has offered some new options for borders in CSS3, of which one is border-radius. Both Mozila/Firefox and Safari 3 have implemented this function, which allows you to create round corners on box-items. This is an example:
\n\n
Mozilla/Firefox and Safari 3 users should see a nicely rounded box, with a nicely rounded border. \nThe code for this example above is actually quite simple: \n \nThese different corners can also each be handled on their own, Mozilla has other names for the feature than the spec says it should have though, as it has f.i. -moz-border-radius-topright as opposed to -webkit-border-top-right-radius:
\n\n
Mozilla/Firefox and Safari 3 users should see a box with a rounded left upper corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded right upper corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded left lower corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded right lower corner. \nThese are handled by / should be handled by:
\n", "_id"=>231}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["action_mailer_optional_tls", "Gmail", "Redmine"], "comments_count"=>0, "category_id"=>2, "title"=>"Setup Redmine to send email using GMail", "body"=>"Redmine是用Rails写的一套很不错的项目管理系统,其提供了诸多很方便实用的功能,诸如里程碑管理,BUG跟踪,代码库变更管理等等。\n搭建以后在管理面板中测试邮件不通,主要原因是由于采用的Gmail的邮箱,于是找到一些解决方案,如下:\n1. Install the action_mailer_optional_tls plugin\nThe action_mailer_optional_tls_plugin adds a TLS option to Redmine's emailing library, ActionMailer. TLS is a version of SSL which is required by GMail in order to send email.\n\nTo install this plugin, use the script/plugin command in your Redmine directory:\n ./script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git\n\n2. Configure your email.yml\n# File: config/email.yml\nproduction:\n delivery_method: :smtp\n smtp_settings:\n tls: true\n address: \"smtp.gmail.com\"\n port: 587\n domain: \"www.YOURDOAMIN.com\" # 'your.domain.com' for GoogleApps\n authentication: :plain\n user_name: \"username@youdomain.com\"\n password: \"password\"\n\n3. Start up Redmine and test your Email\nNext it's time to start up Redmine and to send a test email. Make sure that you start Redmine in the same mode as you configured above (e.g. production). To send a test email:\nLogin as an administrator\nGo to the Administration panel\nGo into the Settings and select the \"Email notifications\" tab\nIn the bottom right, click the link to \"Send a test email\"", "created_at"=>2010-03-14 18:31:57 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
Redmine是用Rails写的一套很不错的项目管理系统,其提供了诸多很方便实用的功能,诸如里程碑管理,BUG跟踪,代码库变更管理等等。 \n搭建以后在管理面板中测试邮件不通,主要原因是由于采用的Gmail的邮箱,于是找到一些解决方案,如下: \n1. Install the action_mailer_optional_tls plugin \nThe action_mailer_optional_tls_plugin adds a TLS option to Redmine's emailing library, ActionMailer. TLS is a version of SSL which is required by GMail in order to send email.
\n\n
To install this plugin, use the script/plugin command in your Redmine directory: \n ./script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git
3. Start up Redmine and test your Email \nNext it's time to start up Redmine and to send a test email. Make sure that you start Redmine in the same mode as you configured above (e.g. production). To send a test email: \nLogin as an administrator \nGo to the Administration panel \nGo into the Settings and select the "Email notifications" tab \nIn the bottom right, click the link to "Send a test email"
\n", "_id"=>233}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["concat", "Database"], "comments_count"=>0, "category_id"=>3, "title"=>"MySQL CONCAT", "body"=>"MySQL CONCAT function is used to concatenate two strings to form a single string. Try out following example:\nmysql> SELECT CONCAT('FIRST ', 'SECOND');\n+----------------------------+\n| CONCAT('FIRST ', 'SECOND') |\n+----------------------------+\n| FIRST SECOND |\n+----------------------------+\n1 row in set (0.00 sec)\n\nie.\nmysql -u eoewallpapers -p123456123 wallpapers -e 'set names 'utf8'; select CONCAT(base_url,\"400\",title) from photos where state > 10 ' > photos_400.txt", "created_at"=>2010-03-19 20:34:34 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
MySQL CONCAT function is used to concatenate two strings to form a single string. Try out following example: \nmysql> SELECT CONCAT('FIRST ', 'SECOND'); \n+----------------------------+ \n| CONCAT('FIRST ', 'SECOND') | \n+----------------------------+ \n| FIRST SECOND | \n+----------------------------+ \n1 row in set (0.00 sec)
\n\n
ie. \nmysql -u eoewallpapers -p123456123 wallpapers -e 'set names 'utf8'; select CONCAT(base_url,"400",title) from photos where state > 10 ' > photos_400.txt
alias ls=”ls -G”是给”ls -G”起了一个别名,当执行ls时,就相当于执行了ls -G。
\n\n
CLICOLOR是用来设置是否进行颜色的显示。CLI是Command Line Interface的缩写。 \nLSCOLORS是用来设置当CLICOLOR被启用后,各种文件类型的颜色。LSCOLORS的值中每两个字母为一组,分别设置某个文件类型的文字颜色和背景颜色。LSCOLORS中一共11组颜色设置,按照先后顺序,分别对以下的文件类型进行设置:
\n\n
directory \nsymbolic link \nsocket \npipe \nexecutable \nblock special \ncharacter special \nexecutable with setuid bit set \nexecutable with setgid bit set \ndirectory writable to others, with sticky bit \ndirectory writable to others, without sticky bit \nLSCOLORS中,字母代表的颜色如下:
\n", "_id"=>239}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["10.6.3", "rails3", "railties"], "comments_count"=>0, "category_id"=>7, "title"=>"解决升级mac OS 10.6.3后rails3无法启动的问题", "body"=>"昨晚看hero的时候顺带update到mac OS 10.6.3,早上重启机器安装成功,发现rails3无法启动,报:\n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception)\nfrom /usr/bin/rails:19\n\n这个错误我之前安装rails3的时候遇到过,解决如下:\n1.先尝试下重新安装rails\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install rails --pre\nPassword:\nSuccessfully installed treetop-1.4.5\n1 gem installed\nInstalling ri documentation for treetop-1.4.5...\nInstalling RDoc documentation for treetop-1.4.5..\n发现多了个treetop的gem,查查是啥:\n
Treetop is a language for describing languages. Combining the elegance of Ruby with cutting-edge parsing expression grammars, it helps you analyze syntax with revolutionarily ease.
\n\n再次执行rails,发现\n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception)\n from /usr/bin/rails:19\n\n还是不行,那就是railties的问题了,重新装下\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install railties --pre\nSuccessfully installed railties-3.0.0.beta\n1 gem installed\nInstalling ri documentation for railties-3.0.0.beta...\nInstalling RDoc documentation for railties-3.0.0.beta...\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ rails -v\nRails 3.0.0.beta\n\nOK,可以了~", "created_at"=>2010-03-31 22:01:38 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
昨晚看hero的时候顺带update到mac OS 10.6.3,早上重启机器安装成功,发现rails3无法启动,报: \n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception) \nfrom /usr/bin/rails:19
\n\n
这个错误我之前安装rails3的时候遇到过,解决如下: \n1.先尝试下重新安装rails \nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install rails --pre \nPassword: \nSuccessfully installed treetop-1.4.5 \n1 gem installed \nInstalling ri documentation for treetop-1.4.5... \nInstalling RDoc documentation for treetop-1.4.5.. \n发现多了个treetop的gem,查查是啥: \nTreetop is a language for describing languages. Combining the elegance of Ruby with cutting-edge parsing expression grammars, it helps you analyze syntax with revolutionarily ease.
\n\n
再次执行rails,发现 \n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception) \n from /usr/bin/rails:19
做移动互联网的过程中,有这样一些词是必须知道的,如MO,MT,GSM,LINKID \n上行(MO)上行的意思就是短信发送到服务器端 MO又称 Mobile Original \n下行(MT)下行的意思就是短信从服务器端发回到手机上,MT又称Mobile Terminated \n简单的说,从手机发起一个的过程叫上行(MO),到手机结束的过程叫下行(MT),比如,平时给你的朋友发送一条短信,对你来说就是上行(MO),而对你的朋友来说,就是下行(MT)。在企业、行业应用中,从系统给手机发送信息的过程叫下行(MT),而手机发送信息给系统的过程叫上行(MO)。
\n", "_id"=>249}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["log", "rails3", "slice_before"], "comments_count"=>0, "category_id"=>2, "title"=>"Parse Rails 3 log file using Enumerable#slice_before", "body"=>"``def parse_rails_log_file(file)\n # Remove all empty lines\n lines = file.each_line.map(&:strip).reject(&:empty?)\n\n # Use +Enumerable#slice_before+ to slice log file into sections for each request\n lines.slice_before(/Started (GET|POST|PUT|DELETE)/).each_with_object({}) do |request_log, totals|\n # Only include successfully finished actions in report\n if duration = request_log.last[/Completed 200 OK in (?<duration>\\d+)ms/, :duration]\n action_name = request_log.first[/Started (GET|POST|PUT|DELETE) \"(?<action>.+?)\" for/, :action]\n totals[action_name] ||= 0\n totals[action_name] += duration.to_i\n end\n end\nend\n\nif __FILE__ == $PROGRAM_NAME\n require \"pp\"\n puts \"Parsing Rails 3 log file (extracting cumulative running time per request path):\"\n puts \"=================\"\n\n log_file = <<-LOG_FILE\n Started GET \"/index\" for 192.168.74.1 at 2010-03-09 11:37:40\n Processing by UpdatesController#index as HTML\n Update Load (0.5ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (16.7ms)\n Completed 200 OK in 71ms (Views: 44.3ms | ActiveRecord: 0.5ms)\n\n Started POST \"/updates\" for 192.168.74.1 at 2010-03-09 11:37:43\n Processing by UpdatesController#create as HTML\n Parameters: {\"commit\"=>\"Save changes\"}\n Update Load (0.4ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (1.3ms)\n Completed 200 OK in 60ms (Views: 32.1ms | ActiveRecord: 0.4ms)\n\n Started GET \"/updates\" for 192.168.74.1 at 2010-03-09 11:45:51\n Processing by UpdatesController#index as HTML\n\n TypeError (exception class/object expected):\n app/controllers/updates_controller.rb:3:in `raise'\n app/controllers/updates_controller.rb:3:in `index'\n\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.6ms)\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.9ms)\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb (23.9ms)\n\n Started GET \"/updates\" for 192.168.74.1 at 2010-03-09 11:45:58\n Processing by UpdatesController#index as HTML\n Update Load (0.3ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (1.1ms)\n Completed 200 OK in 100ms (Views: 29.3ms | ActiveRecord: 0.3ms)\n LOG_FILE\n\n pp parse_rails_log_file(log_file) # => {\"/index\"=>71, \"/updates\"=>160}\nend```", "created_at"=>2010-07-26 21:42:33 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
# Use +Enumerable#slice_before+ to slice log file into sections for each request \n lines.slice_before(/Started (GET|POST|PUT|DELETE)/).each_with_object({}) do |request_log, totals| \n # Only include successfully finished actions in report \n if duration = request_log.last[/Completed 200 OK in (?<duration>\\d+)ms/, :duration] \n action_name = request_log.first[/Started (GET|POST|PUT|DELETE) "(?<action>.+?)" for/, :action] \n totals[action_name] ||= 0 \n totals[action_name] += duration.to_i \n end \n end \nend
\n\n
if FILE == $PROGRAM_NAME \n require "pp" \n puts "Parsing Rails 3 log file (extracting cumulative running time per request path):" \n puts "================="
\n\n
log_file = <<-LOG_FILE \n Started GET "/index" for 192.168.74.1 at 2010-03-09 11:37:40 \n Processing by UpdatesController#index as HTML \n Update Load (0.5ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (16.7ms) \n Completed 200 OK in 71ms (Views: 44.3ms | ActiveRecord: 0.5ms)
\n\n
Started POST "/updates" for 192.168.74.1 at 2010-03-09 11:37:43 \n Processing by UpdatesController#create as HTML \n Parameters: {"commit"=>"Save changes"} \n Update Load (0.4ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (1.3ms) \n Completed 200 OK in 60ms (Views: 32.1ms | ActiveRecord: 0.4ms)
\n\n
Started GET "/updates" for 192.168.74.1 at 2010-03-09 11:45:51 \n Processing by UpdatesController#index as HTML
Started GET "/updates" for 192.168.74.1 at 2010-03-09 11:45:58 \n Processing by UpdatesController#index as HTML \n Update Load (0.3ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (1.1ms) \n Completed 200 OK in 100ms (Views: 29.3ms | ActiveRecord: 0.3ms) \n LOG_FILE
\n写完申明后,去看消息出处看到其竟然做了修改,我早料到其会做相关的行为,所有早些时候截了屏幕如下:\n\n\n\n而现在的文章被修改为:\n\n\n\n看我用鼠标标识的地方,对关键信息进行了修改,感兴趣的人可以去 http://mobile.venturebeat.com/2010/07/28/android-wallpaper-app-that-steals-your-data-was-downloaded-by-millions/ 查看原文,对于这种标题党用子虚乌有的事情炒作,等消息传播后再修改自己的内容算什么行为!而对国内部分媒体在传播时不但不对真实性进行验证,还添油加醋,歪曲意思的报道,我非常无奈(看到有人还说可以获取信用卡信息,还加密传输,我实在无语)。\n\n按照我个人的感觉,他们应该紧接着要开始拿这个事件来炒作自己的产品了,我个人懒得去关注,如果有人发现有人借此炒作自己的产品,请帮忙分析分析,看看到底是什么人用这样手法。\n\n再次update!!!\n\n通过email和mylookout的人取得联系,说明我取得诸如设备号,手机屏幕大小是为了更智能的给设备适配图片,而获取部分的sim卡号是后来用户反馈说自己换了手机还想使用之前的收藏记录才使用的,这些信息只在该应用中使用,并没提供给任何第三方!\n\n同时让其确认venturebeat上文章中说到的获取浏览器历史,短信息,密码等高敏感性信息是否是他们说的还是写文章的人自己写的(Lots of my users send me the email ask me why I collect their text message and voicemail passward, I just want to make sure whether you and your ceo said that I collected browsing history,text message ,voicemail passward during the meeting.)。\n\n其cto给我回复说他们没有说过我的应用获取过诸如text messages or browsing history这些信息( We never stated that the wallpaper applications gathered users text messages or browsing history.),是媒体在撰写和传播的时候错误报道了(A member of the press misreported our research and he has since corrected it. )。\n\n我非常无语~\n\n2010年8月4日第二次次update!\n\n多谢这些天很多朋友的关心,我很好,谢谢!这些天和google android组,lookout公司和venturebeat的作者,以及国内外很多媒体,博客们,记者们都有很多的接触。\n\n1. google就前段时间将应用暂停和我一起分析了这个应用,今天发来调查的结果:\n\nOur investigation has concluded that there's no obvious malicious code in your apps, though the implementation accesses data that it doesn't need to. We've restored your apps (and they'll be available on Market again once you publish them), and are looking forward to seeing them updated to use ANDROID_ID. We are likely to make a statement about this issue this week--I'll let you know.\n\n我早就说过,我配合调查,我把代码提供给他们,google也做出了公正的评判,另外也给我提了一些建议(ANDROID_ID)。\n\n2. 当时写这篇报道的venturebeat记者Dean Takahashi发来了mail,为自己犯的错误道歉,并道歉该事带来的恶劣影响,会再写一篇文章澄清这个事情以消除影响。\n\n3. 那个安全公司lookout的人写邮件来要于我一起“ We wanted to coordinate with you to prevent further misunderstandings. ”。\n\n4.好几个不认识的国外记者很负责任,发邮件和gt和我交流询问事情的真相,并帮我喊冤,谢谢这些有职业精神的记者们。\n\n这个事情到这差不多就结束了,其中看到很多假丑恶,也看到很多真善美!谢谢所有帮助过我的人(很多很多,就不一一列举)。", "created_at"=>2010-07-29 08:41:39 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
同时让其确认venturebeat上文章中说到的获取浏览器历史,短信息,密码等高敏感性信息是否是他们说的还是写文章的人自己写的(Lots of my users send me the email ask me why I collect their text message and voicemail passward, I just want to make sure whether you and your ceo said that I collected browsing history,text message ,voicemail passward during the meeting.)。
\n\n
其cto给我回复说他们没有说过我的应用获取过诸如text messages or browsing history这些信息( We never stated that the wallpaper applications gathered users text messages or browsing history.),是媒体在撰写和传播的时候错误报道了(A member of the press misreported our research and he has since corrected it. )。
Our investigation has concluded that there's no obvious malicious code in your apps, though the implementation accesses data that it doesn't need to. We've restored your apps (and they'll be available on Market again once you publish them), and are looking forward to seeing them updated to use ANDROID_ID. We are likely to make a statement about this issue this week--I'll let you know.
\n", "_id"=>251}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Munin", "netstat", "passive"], "comments_count"=>0, "category_id"=>7, "title"=>"Fix the passive netstat connections in Munin", "body"=>"\n\nIf your running Munin in WHM they you may have noticed the passive netstat connections have been rising steadily over the last couple of weeks. This isn't a problem with your server, its a Munin bug that can be easily fixed.\n\n\n\n\n\nApparently the problem stemms from Munin counting the passive connections rejected. You can fix this problem quite easily by following the instructions below\n\nEdit the following file:\n/usr/share/munin/plugins/netstat\n\nand change the line\n
If your running Munin in WHM they you may have noticed the passive netstat connections have been rising steadily over the last couple of weeks. This isn't a problem with your server, its a Munin bug that can be easily fixed.
\n\n\n\n
Apparently the problem stemms from Munin counting the passive connections rejected. You can fix this problem quite easily by following the instructions below
\n\n
Edit the following file: \n/usr/share/munin/plugins/netstat
\n", "_id"=>252}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Charts", "Highcharts", "rails"], "comments_count"=>0, "category_id"=>2, "title"=>"ChartsOnRails", "body"=>"这几天需要找到漂亮的Charts类库,找了几个,发现一个很不粗的,mark下待使用,介绍如下:\n\nHighcharts is a charting library written in pure JavaScript, offering an easy way of adding interactive charts to your web site or web application. Highcharts currently supports line, spline, area, areaspline, column, bar, pie and scatter chart types.\n\n有兴趣的可以参考如下连接去看看:\n\nhttp://highcharts.com/\n\nhttp://railscasts.com/episodes/223-charts\n\nhttp://www.spritle.com/blogs/?p=859", "created_at"=>2010-08-20 21:48:59 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
这几天需要找到漂亮的Charts类库,找了几个,发现一个很不粗的,mark下待使用,介绍如下:
\n\n
Highcharts is a charting library written in pure JavaScript, offering an easy way of adding interactive charts to your web site or web application. Highcharts currently supports line, spline, area, areaspline, column, bar, pie and scatter chart types.
Delete your debug certificate under ~/.android/debug.keystore (on Linux and Mac OS X); the directory is something like %USERHOME%/.androidon Windows.
\n\n
The Eclipse plugin should then generate a new certificate when you next try to build a debug package.
\n", "_id"=>258}])
+MONGODB iceylog_development['categories'].find({:_id=>12}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>12}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["brew"], "comments_count"=>0, "category_id"=>7, "title"=>"Installs Homebrew to /usr/local so you don't need sudo to `brew install`", "body"=>"$ curl https://raw.github.com/gist/323731/install_homebrew.rb -o /tmp/install_homebrew.rb\n % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n100 4569 100 4569 0 0 1605 0 0:00:02 0:00:02 --:--:-- 2346\n\n $ ruby /tmp/install_homebrew.rb\n==> This script will install:\n/usr/local/bin/brew\n/usr/local/Library/Formula/...\n/usr/local/Library/Homebrew/...\n==> The following directories will be made group writable:\n/usr/local/.\n/usr/local/bin\n==> The following directories will have their group set to admin:\n/usr/local/.\n/usr/local/bin\n\nPress enter to continue\n==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin\n==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin\n==> Downloading and Installing Homebrew...\nWarning: The following *evil* dylibs exist in /usr/local/lib\nThey may break builds or worse. You should consider deleting them:\n/usr/local/lib/libevent-1.4.2.1.3.dylib\n/usr/local/lib/libevent_core-1.4.2.1.3.dylib\n/usr/local/lib/libevent_extra-1.4.2.1.3.dylib\n/usr/local/lib/libkyotocabinet.4.8.0.dylib\n/usr/local/lib/libprotobuf-lite.6.dylib\n/usr/local/lib/libprotobuf.6.dylib\n/usr/local/lib/libprotoc.6.dylib\n==> Installation successful!\nNow type: brew help\n\n参考:https://gist.github.com/323731", "created_at"=>2011-09-03 08:29:42 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
$ curl https://raw.github.com/gist/323731/install_homebrew.rb -o /tmp/install_homebrew.rb \n % Total % Received % Xferd Average Speed Time Time Time Current \n Dload Upload Total Spent Left Speed \n100 4569 100 4569 0 0 1605 0 0:00:02 0:00:02 --:--:-- 2346
\n\n
$ ruby /tmp/install_homebrew.rb \n==> This script will install: \n/usr/local/bin/brew \n/usr/local/Library/Formula/... \n/usr/local/Library/Homebrew/... \n==> The following directories will be made group writable: \n/usr/local/. \n/usr/local/bin \n==> The following directories will have their group set to admin: \n/usr/local/. \n/usr/local/bin
\n\n
Press enter to continue \n==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin \n==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin \n==> Downloading and Installing Homebrew... \nWarning: The following evil dylibs exist in /usr/local/lib \nThey may break builds or worse. You should consider deleting them: \n/usr/local/lib/libevent-1.4.2.1.3.dylib \n/usr/local/lib/libevent_core-1.4.2.1.3.dylib \n/usr/local/lib/libevent_extra-1.4.2.1.3.dylib \n/usr/local/lib/libkyotocabinet.4.8.0.dylib \n/usr/local/lib/libprotobuf-lite.6.dylib \n/usr/local/lib/libprotobuf.6.dylib \n/usr/local/lib/libprotoc.6.dylib \n==> Installation successful! \nNow type: brew help
\n", "_id"=>259}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["perl", "Twig", "xml"], "comments_count"=>0, "category_id"=>7, "title"=>"install perl module for XML-Twig in RHEL-Red Hat/Fedora Linux?", "body"=>"This module provides a way to process XML documents. It is build on top of XML::Parser. XML::Twig offers a tree interface to the document, while allowing you to output the parts of it that have been completely processed. It allows minimal resource (CPU and memory) usage by building the tree only for the parts of the documents that need actual processing, through the use of the twig_roots and twig_print_outside_roots options.(as pointed by yum info)\r\n\r\nLet’s first search for the package\r\n$ yum search perl-XML-Twig\r\nperl-XML-Twig.noarch : A perl module for processing huge XML documents in tree\r\n\r\nNote that you must be the root/administrator to install the package. To install this package in Red Hat/Fedora Linux.\r\n$ yum install perl-XML-Twig.noarch\r\n\r\nYou can check the details of this package perl-XML-Twig\r\n$ yum info perl-XML-Twig.noarch\r\n\r\n或者:\r\nperl -MCPAN -e 'install XML::Twig'", "created_at"=>2011-12-10 10:53:02 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
This module provides a way to process XML documents. It is build on top of XML::Parser. XML::Twig offers a tree interface to the document, while allowing you to output the parts of it that have been completely processed. It allows minimal resource (CPU and memory) usage by building the tree only for the parts of the documents that need actual processing, through the use of the twig_roots and twig_print_outside_roots options.(as pointed by yum info)
\n\n
Let’s first search for the package \n$ yum search perl-XML-Twig \nperl-XML-Twig.noarch : A perl module for processing huge XML documents in tree
\n\n
Note that you must be the root/administrator to install the package. To install this package in Red Hat/Fedora Linux. \n$ yum install perl-XML-Twig.noarch
\n\n
You can check the details of this package perl-XML-Twig \n$ yum info perl-XML-Twig.noarch
\n\n
或者: \nperl -MCPAN -e 'install XML::Twig'
\n", "_id"=>260}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["nginx", "statistics", "upstream"], "comments_count"=>0, "category_id"=>9, "title"=>"NGINX upstream statistics", "body"=>"使用过nginx的应该都都晓得upstream,前面一篇文章说到《nginx upstream的5种配置方式》,例如如下是很常见的一段配置\r\n\r\n#create by ice 2011.12.22\r\nupstream unicon_v2_www {\r\n# This is the socket we configured in unicorn.rb\r\nserver unix:/var/www/v2/tmp/sockets/unicorn.sock backup;\r\nserver 192.168.0.1:5000 weight=9 max_fails=2 fail_timeout=30s;\r\nserver 192.168.0.2:5000 weight=3 max_fails=2 fail_timeout=30s;\r\n}\r\nserver {\r\nlisten 80;\r\nserver_name www.iceskysl.com;\r\nerror_log /opt/nginx/logs/error/error_v2_www.log;\r\naccess_log /opt/nginx/logs/access/access_v2_www.log main;\r\n\r\nroot /var/www/v2/public/;\r\nindex index.html index.htm;\r\n\r\nlocation / {\r\nproxy_redirect off;\r\nproxy_set_header X-Real-IP $remote_addr;\r\nproxy_set_header Host $host;\r\nproxy_set_header Content-Length $content_length;\r\nproxy_set_header X-Forwarded-For $remote_addr;\r\nclient_max_body_size 10m;\r\nclient_body_buffer_size 128k;\r\nproxy_connect_timeout 90;\r\nproxy_send_timeout 90;\r\nproxy_read_timeout 90;\r\nproxy_buffer_size 4k;\r\nproxy_buffers 4 32k;\r\nproxy_busy_buffers_size 64k;\r\nproxy_temp_file_write_size 64k;\r\nchunked_transfer_encoding off;\r\nproxy_pass http://unicon_v2_www/;\r\n}\r\n}\r\n\r\n其中upstream的这段配置:\r\nupstream unicon_v2_www {\r\n# This is the socket we configured in unicorn.rb\r\nserver unix:/var/www/v2/tmp/sockets/unicorn.sock backup;\r\nserver 192.168.0.1:5000 weight=9 max_fails=2 fail_timeout=30s;\r\nserver 192.168.0.2:5000 weight=3 max_fails=2 fail_timeout=30s;\r\n}\r\n\r\n我们了解到socket模式的这个是backup,其他两个机器分别weight=3和weight=9,于是我们想监控下upstream每个后端具体处理了多少请求,有没有问题等,这个好像就不好监控了,nginx自带的status模块只能监控总的请求数,无法区分每个upstream的具体情况。\r\n找到一个ustats(http://code.google.com/p/ustats/),其介绍是:NGINX basic upstream statistics module,具体的如下:\r\n
USTATS module provides basic statistics for each backend in nginx upstreams:\r\n\r\nNumber of requests\r\nHttp 499/500/503 errors count\r\nTcp errors\r\nHttp read/write timeouts\r\nFail timeout\r\nMax fails count\r\nLast failed access time\r\nTotal fails count\r\nBlacklisted backend highlighting\r\nDown backends highlighting\r\nThe module allows you to sort values in some columns for each separate upstream. The data can be retrieved as JSON by appending \"?json\" to the end of location on which the module was set to work on (see configuration instructions below).
我们了解到socket模式的这个是backup,其他两个机器分别weight=3和weight=9,于是我们想监控下upstream每个后端具体处理了多少请求,有没有问题等,这个好像就不好监控了,nginx自带的status模块只能监控总的请求数,无法区分每个upstream的具体情况。 \n找到一个ustats(http://code.google.com/p/ustats/),其介绍是:NGINX basic upstream statistics module,具体的如下:<!--more--> \nUSTATS module provides basic statistics for each backend in nginx upstreams:
\n\n
Number of requests \nHttp 499/500/503 errors count \nTcp errors \nHttp read/write timeouts \nFail timeout \nMax fails count \nLast failed access time \nTotal fails count \nBlacklisted backend highlighting \nDown backends highlighting \nThe module allows you to sort values in some columns for each separate upstream. The data can be retrieved as JSON by appending "?json" to the end of location on which the module was set to work on (see configuration instructions below). \n看上去正是我需要的,有时间试试看~(为啥nginx不学haproxy官方自带一个详细statistics的页面呢~haproxy那个statistics很详细很好用~) \n详细使用指南:http://code.google.com/p/ustats/
\r\nThe reason is simple. I installed an extension called SEO Site Tools which installs an icon on the right of the address bar. When you click the button, on the window displayed there is the option “Show no follo” which is an option for displaying links that have the value nofollow for the attribute rel of an HTML element.\r\n\r\nThis attribute instructs some search engines that a hyperlink should not influence the link target’s ranking in the search engine’s index. (Source: wikipedia.org)\r\n
\r\n\r\n修复的方法很简单,去掉“Show no follo”的勾选就好了~\r\n", "created_at"=>2012-01-28 01:48:36 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
经过检查(Library/Application Support/Google/Chrome/Default/User StyleSheets/Custom.css),发现不是本地的css配置,最后找到是一个叫“SEO Site Tools”导致的,具体原因是: \n \nThe reason is simple. I installed an extension called SEO Site Tools which installs an icon on the right of the address bar. When you click the button, on the window displayed there is the option “Show no follo” which is an option for displaying links that have the value nofollow for the attribute rel of an HTML element.
\n\n
This attribute instructs some search engines that a hyperlink should not influence the link target’s ranking in the search engine’s index. (Source: wikipedia.org)
\n\n
修复的方法很简单,去掉“Show no follo”的勾选就好了~
\n", "_id"=>263}])
+MONGODB iceylog_development['categories'].find({:_id=>10}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>10}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Html/css/js"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["CoffeeScript", "Connect", "Express", "jade", "JavaScript", "Node.js", "npm"], "comments_count"=>0, "category_id"=>10, "title"=>"CoffeeScript解决JavaScript不美,Node.js潜力巨大", "body"=>"如果你对JavaScript感兴趣,但是不喜欢写一大堆一大堆的JavaScript代码,那真的不是你的错,因为很多人都说JavaScript不美,究其原因,可以归纳为:JavaScript的诞生是个悲剧. 它是函数式+动态语言的优秀内核, 却硬被绑上了C/Java的语法。\r\n\r\n如果你真的喜欢JavaScript,那么你可以尝试了解更多~比如CoffeeScript,再比如Node.js,再比如Connect,再比如Express,再再比如jade,再再再比如npm等等,于是我们从安装npm(a package manager for node)开始~\r\n\r\n#装npm\r\nice@mac:~ > curl http://npmjs.org/install.sh | sh\r\n % Total % Received % Xferd Average Speed Time Time Time Current\r\n Dload Upload Total Spent Left Speed\r\n100 7881 100 7881 0 0 3664 0 0:00:02 0:00:02 --:--:-- 8584\r\ntar=/usr/bin/tar\r\nversion:\r\nbsdtar 2.8.3 - libarchive 2.8.3\r\ninstall npm@1.1\r\nfetching: http://registry.npmjs.org/npm/-/npm-1.1.0-3.tgz\r\n0.6.2\r\n1.1.0-3\r\ncleanup prefix=/usr/local\r\n\r\nAll clean!\r\n/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js\r\nnpm@1.1.0-3 /usr/local/lib/node_modules/npm\r\nIt worked\r\n\r\n#看看怎么用\r\nice@mac:~ > npm help\r\n\r\nUsage: npm \r\n\r\nwhere is one of:\r\n adduser, apihelp, author, bin, bugs, c, cache, completion,\r\n config, deprecate, docs, edit, explore, faq, find, get,\r\n help, help-search, home, i, info, init, install, la, link,\r\n list, ll, ln, login, ls, outdated, owner, pack, prefix,\r\n prune, publish, r, rb, rebuild, remove, restart, rm, root,\r\n run-script, s, se, search, set, show, star, start, stop,\r\n submodule, tag, test, un, uninstall, unlink, unpublish,\r\n unstar, up, update, version, view, whoami\r\n\r\nnpm -h quick help on \r\nnpm -l display full usage info\r\nnpm faq commonly asked questions\r\nnpm help search for help on \r\nnpm help npm involved overview\r\n\r\nSpecify configs in the ini-formatted file:\r\n /Users/ice/.npmrc\r\nor on the command line via: npm --key value\r\nConfig info can be viewed via: npm help config\r\n\r\nnpm@1.1.0-3 /usr/local/lib/node_modules/npm\r\n\r\n#用npm装connect\r\nice@mac:~ > npm install connect\r\nnpm http GET https://registry.npmjs.org/connect\r\nnpm http 200 https://registry.npmjs.org/connect\r\nnpm http GET https://registry.npmjs.org/connect/-/connect-1.8.5.tgz\r\nnpm http 200 https://registry.npmjs.org/connect/-/connect-1.8.5.tgz\r\nnpm http GET https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/mime\r\nnpm http GET https://registry.npmjs.org/formidable\r\nnpm http 200 https://registry.npmjs.org/formidable\r\nnpm http 200 https://registry.npmjs.org/mime\r\nnpm http 200 https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/formidable/-/formidable-1.0.8.tgz\r\nnpm http GET https://registry.npmjs.org/mime/-/mime-1.2.4.tgz\r\nnpm http GET https://registry.npmjs.org/qs/-/qs-0.4.1.tgz\r\nnpm http 200 https://registry.npmjs.org/mime/-/mime-1.2.4.tgz\r\nnpm http 200 https://registry.npmjs.org/formidable/-/formidable-1.0.8.tgz\r\nnpm http 200 https://registry.npmjs.org/qs/-/qs-0.4.1.tgz\r\nconnect@1.8.5 ./node_modules/connect \r\n├── mime@1.2.4\r\n├── qs@0.4.1\r\n└── formidable@1.0.8\r\n\r\n#用npm装express\r\nice@mac:~ > npm install express\r\nnpm http GET https://registry.npmjs.org/express\r\nnpm http 200 https://registry.npmjs.org/express\r\nnpm http GET https://registry.npmjs.org/express/-/express-2.5.6.tgz\r\nnpm http 200 https://registry.npmjs.org/express/-/express-2.5.6.tgz\r\nnpm http GET https://registry.npmjs.org/mime\r\nnpm http GET https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/mkdirp/0.0.7\r\nnpm http 304 https://registry.npmjs.org/qs\r\nnpm http 304 https://registry.npmjs.org/mime\r\nnpm http 200 https://registry.npmjs.org/mkdirp/0.0.7\r\nnpm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.0.7.tgz\r\nnpm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.0.7.tgz\r\nexpress@2.5.6 ./node_modules/express \r\n├── mkdirp@0.0.7\r\n├── mime@1.2.4\r\n└── qs@0.4.1\r\n\r\n#用npm装jade\r\nice@mac:~ > npm install jade\r\nnpm http GET https://registry.npmjs.org/jade\r\nnpm http 200 https://registry.npmjs.org/jade\r\nnpm http GET https://registry.npmjs.org/jade/-/jade-0.20.0.tgz\r\nnpm http 200 https://registry.npmjs.org/jade/-/jade-0.20.0.tgz\r\nnpm http GET https://registry.npmjs.org/commander\r\nnpm http GET https://registry.npmjs.org/mkdirp\r\nnpm http 200 https://registry.npmjs.org/mkdirp\r\nnpm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz\r\nnpm http 200 https://registry.npmjs.org/commander\r\nnpm http GET https://registry.npmjs.org/commander/-/commander-0.2.1.tgz\r\nnpm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz\r\nnpm http 200 https://registry.npmjs.org/commander/-/commander-0.2.1.tgz\r\njade@0.20.0 ./node_modules/jade \r\n├── commander@0.2.1\r\n└── mkdirp@0.3.0\r\n\r\n好了,你入门了,更多资料,请自行查看如下链接的资料吧~\r\n\r\n相关资料\r\n\r\nCoffeeScript: CoffeeScript is a little language that compiles into JavaScript\r\nhttp://coffeescript.org/\r\n\r\n为什么CoffeeScript这么美?\r\nhttp://cnodejs.org/blog/?p=1584\r\n\r\nCoffeeScript: The beautiful way to write JavaScript\r\nhttp://amix.dk/blog/post/19612\r\n\r\n10个让朋友对你刮目相看的CoffeeScript单行代码绝技\r\nhttp://heikezhi.com/2011/06/08/10-coffeescript-one-liners-to-impress-your-friends/\r\n\r\nnpm: a package manager for node\r\nhttps://github.com/isaacs/npm\r\n\r\nExpress:http://expressjs.com/\r\nHigh performance, high class web development for Node.js\r\n\r\nConnect: Connect is a middleware layer for Node.js\r\nhttp://www.senchalabs.org/connect/\r\n\r\njade: http://jade-lang.com/\r\nNode Template Engine\r\n\r\ncoffee-box: Blog engine for fashionable developers. Built upon Node.js, Express, MongoDB and CoffeeScript.\r\nhttps://github.com/qiao/coffee-box", "created_at"=>2012-01-28 14:57:06 UTC, "updated_at"=>2012-06-24 15:45:30 UTC, "body_html"=>"
如果你真的喜欢JavaScript,那么你可以尝试了解更多~比如CoffeeScript,再比如Node.js,再比如Connect,再比如Express,再再比如jade,再再再比如npm等等,于是我们从安装npm(a package manager for node)开始~
\n\n
#装npm \nice@mac:~ > curl http://npmjs.org/install.sh | sh \n % Total % Received % Xferd Average Speed Time Time Time Current \n Dload Upload Total Spent Left Speed \n100 7881 100 7881 0 0 3664 0 0:00:02 0:00:02 --:--:-- 8584 \ntar=/usr/bin/tar \nversion: \nbsdtar 2.8.3 - libarchive 2.8.3 \ninstall npm@1.1 \nfetching: http://registry.npmjs.org/npm/-/npm-1.1.0-3.tgz \n0.6.2 \n1.1.0-3 \ncleanup prefix=/usr/local
\n\n
All clean! \n/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js \nnpm@1.1.0-3 /usr/local/lib/node_modules/npm \nIt worked \n<!--more-->
npm -h quick help on \nnpm -l display full usage info \nnpm faq commonly asked questions \nnpm help search for help on \nnpm help npm involved overview
\n\n
Specify configs in the ini-formatted file: \n /Users/ice/.npmrc \nor on the command line via: npm --key value \nConfig info can be viewed via: npm help config
首先安装Graphviz \n% brew install cairo pango graphviz # Homebrew on Mac OS X \n% sudo port install graphviz # Macports on Mac OS X \n% sudo aptitude install graphviz # Debian and Ubuntu
更多信息参考:http://rails-erd.rubyforge.org/ \n<!--more--> \n附:常见错误处理: \nCould not find gem 'choice (~> 0.1.4) ruby', which is required by gem 'rails-erd (>= 0) ruby', in any of the sources.
\n\n
原因是rails-erd依赖choice这个gem,装下 \nice@mac:/www/trunk > sudo gem install choice \nPassword: \nSuccessfully installed choice-0.1.4 \n1 gem installed \nInstalling ri documentation for choice-0.1.4... \nInstalling RDoc documentation for choice-0.1.4...
\n", "_id"=>273}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["ruby"], "comments_count"=>0, "category_id"=>2, "title"=>"Check for nil and initialize on a single line", "body"=>"点评:关于ROR中的一中“遇nil赋值”的写法,这个很早的时候在书上看到的是||=操作符,也一直这么用,今天发现作者的另外这个写法也挺好的。\n\nSometimes, you want to initialize a variable to some value only if that variable is equal to nil. If you like to write your methods as short, clean and readable as possible, you can do that task in a single line instead of taking the traditionnal 3 lines approach. You have two options :\n\n1) You can use the if modifier 1. x = get_some_object if x.nil?Very easy to read. This is my favorite.\n\n2) Or you can use the ||= operator 1. x ||= get_some_object This one is even shorter. The ||= operator is a little bit less verbose and might confuse a ruby newcomer… but I’m not saying that it should be a reason for not using it. This is more a matter of personal taste than anything else.Both of these methods are better than this :\n\n1. #eeww… we don’t like this one.\n\n2. if(x.nil?)\n\n3. x = get_some_object 4. end", "created_at"=>2007-05-19 01:23:10 UTC, "updated_at"=>2012-06-24 15:45:35 UTC, "body_html"=>"
Sometimes, you want to initialize a variable to some value only if that variable is equal to nil. If you like to write your methods as short, clean and readable as possible, you can do that task in a single line instead of taking the traditionnal 3 lines approach. You have two options :
\n\n
1) You can use the if modifier 1. x = get_some_object if x.nil?Very easy to read. This is my favorite.
\n\n
2) Or you can use the ||= operator 1. x ||= get_some_object This one is even shorter. The ||= operator is a little bit less verbose and might confuse a ruby newcomer… but I’m not saying that it should be a reason for not using it. This is more a matter of personal taste than anything else.Both of these methods are better than this :
$ uname -a\r\nLinux oj-web03 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux
\r\n
[iceskysl@oj-web03 logs]$ cat /proc/version\r\nLinux version 2.4.21-27.ELsmp (bhcompile@bugs.build.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47)) #1 SMP Wed Dec 1 21:59:02 EST 20045、内存信息$ cat /proc/meminfo\r\n$ free -M6、CPU信息$cat /proc/cpuinfo7、硬盘信息\r\n$df\r\n\r\n
(1)用客户端连接到数据库,执行select * from v$instance查看version项 \n(2)select * from product_component_version \n(3)或查询V$VERSION查看组件级信息
\n\n
4、内核 \n$ uname -a \nLinux oj-web03 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux \n[iceskysl@oj-web03 logs]$ cat /proc/version \nLinux version 2.4.21-27.ELsmp (bhcompile@bugs.build.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47)) #1 SMP Wed Dec 1 21:59:02 EST 20045、内存信息$ cat /proc/meminfo \n$ free -M6、CPU信息$cat /proc/cpuinfo7、硬盘信息 \n$df
\n\n", "_id"=>276}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Security"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["ruby", "安全", "漏洞"], "comments_count"=>0, "category_id"=>8, "title"=>"Ruby暴出大量严重漏洞!", "body"=>"Drew Yao at Apple uncovered a handful of nasty security vulnerabilities affecting all current versions of Ruby. The details are still under wraps because an attacker can DoS you or possibly execute arbitrary code—holy crap! Better upgrade sooner than later.\n\nAccording to the official Ruby security advisory, the vulnerable Rubies are:\n\n* 1.8.4 and earlier\n* 1.8.5-p230 and earlier\n* 1.8.6-p229 and earlier\n* 1.8.7-p21 and earlier\n\nThose of us running Ruby 1.8.4 or earlier must upgrade to 1.8.5 or later for a fix. Those on 1.8.5-7 can grab the latest patchlevel release for a fix.\n\n(Please note: Ruby 1.8.7 breaks backward compatibility and is only compatible with Rails 2.1 and later, so don’t go overboard!)\n虽然暂时还没看到具体的细节公布出来,也没看到0day放出来,但是从其描述上不难看出,这些bug是ruby一致以来都有的,或许还有更多的bug,ruby走向成熟,离不开这样的检验。", "created_at"=>2008-06-25 06:05:42 UTC, "updated_at"=>2012-06-24 15:45:36 UTC, "body_html"=>"
Drew Yao at Apple uncovered a handful of nasty security vulnerabilities affecting all current versions of Ruby. The details are still under wraps because an attacker can DoS you or possibly execute arbitrary code—holy crap! Better upgrade sooner than later.
\n\n
According to the official Ruby security advisory, the vulnerable Rubies are:
\n\n
\n
1.8.4 and earlier
\n
1.8.5-p230 and earlier
\n
1.8.6-p229 and earlier
\n
1.8.7-p21 and earlier
\n
\n\n
Those of us running Ruby 1.8.4 or earlier must upgrade to 1.8.5 or later for a fix. Those on 1.8.5-7 can grab the latest patchlevel release for a fix.
\n\n
(Please note: Ruby 1.8.7 breaks backward compatibility and is only compatible with Rails 2.1 and later, so don’t go overboard!) \n虽然暂时还没看到具体的细节公布出来,也没看到0day放出来,但是从其描述上不难看出,这些bug是ruby一致以来都有的,或许还有更多的bug,ruby走向成熟,离不开这样的检验。
\n", "_id"=>278}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["rsync"], "comments_count"=>0, "category_id"=>9, "title"=>"同步利器rsync", "body"=>"rsync is a program that copies file from one location to another, with it you can make backups of your files, synchronize data on different locations and computers. It is commonly used by unix users to keep a safe backup of their files and is often recommended as the simplest solution for backups and safety copys.\r\n\r\n参考资料:\r\n\r\n1.rsync的安装和使用\r\n\r\n2. rsync", "created_at"=>2008-06-25 19:58:32 UTC, "updated_at"=>2012-06-24 15:45:36 UTC, "body_html"=>"
rsync is a program that copies file from one location to another, with it you can make backups of your files, synchronize data on different locations and computers. It is commonly used by unix users to keep a safe backup of their files and is often recommended as the simplest solution for backups and safety copys.
A gravatar, or globally recognized avatar, is quite simply an avatar image that follows you from weblog to weblog appearing beside your name when you comment on gravatar enabled sites. Avatars help identify your posts on web forums, so why not on weblogs?
\r\n看明白了么,就是一个你输入自己的Email,然后上传自己的图片标识,然后在其他支持 Gravatars的网站(blog居多)中发表评论的时候输入自己的Email地址,就可以在Gravatars上找到其对应的图片来显示了。\r\n\r\n这确实是个不错的Idea,相当简单,但是也做得有声有色的,有点意思。\r\n\r\n使用也很方便,其在“How the URL is constructed”上介绍了其URL的组成,中可以这么使用(来源Gravatars on Rails):\r\n\r\n\r\n\r\n1、首先在````application_helper.rb中增加一个helper方法```\r\n
这个世界有意思,多大的idea都可以做成网站,以前看过缩址的网站,现在有看到一个省份标识的网站, Gravatars,看他的介绍: \nA gravatar, or globally recognized avatar, is quite simply an avatar image that follows you from weblog to weblog appearing beside your name when you comment on gravatar enabled sites. Avatars help identify your posts on web forums, so why not on weblogs? \n看明白了么,就是一个你输入自己的Email,然后上传自己的图片标识,然后在其他支持 Gravatars的网站(blog居多)中发表评论的时候输入自己的Email地址,就可以在Gravatars上找到其对应的图片来显示了。
\n\n
这确实是个不错的Idea,相当简单,但是也做得有声有色的,有点意思。
\n\n
使用也很方便,其在“How the URL is constructed”上介绍了其URL的组成,中可以这么使用(来源Gravatars on Rails):
晓得TDD,BDD,RSpec这些东西很久了,也看了不少的资料和教程,但总感觉还在门外徘徊,始终不得其要,真是怪异。应该是没在实际项目中实践过的缘故吧。 \n本文记录一些RSpec和BDD(Behaviour Driven Development )的资料和文档,给我自己也给各位路过者提供一些资料,感兴趣的仔细看看吧。 \n \n http://rspec.info/ \n Telling a good story - Rspec stories from the trenches \n Slides from RailsConf \n rspec plain text stories + webrat = chunky bacon! \n http://chinaonrails.com/topic/view/220.html \n Story Driven Development with Rails - Part I: Up and Running \n \n另外,http://rspec.info/documentation/rails/上的资料非常棒。有路过的,玩BDD的朋友还望多多指教,领我进门,多谢!
\n", "_id"=>290}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Html/css/js"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Android & Java"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Thin"], "comments_count"=>0, "category_id"=>6, "title"=>"Thin version 1.0.0 is out!", "body"=>"Thin version 1.0.0 (codename That's What She Said) is out!\r\n\r\nYes 1.0! That doesn't mean it's bug free or anything. But, it does\r\nmean that it's been running on a number of servers and no show stopper\r\nbugs have been found since a while.\r\n\r\nAlso see http://macournoyer.wordpress.com/2008/09/30/thin-10/\r\n\r\n== What's new?\r\n\r\n* Fixed vlad.rake to allow TCP or socket [hellekin]\r\n* Updated Mack adapter to handle both <0.8.0 and >0.8.0 [Mark Bates]\r\n* rails rack adapter uses File.readable_real? so it recognizes ACL\r\npermissions [Ricardo Chimal]\r\n* Log a warning if Rack application returns nil body [Michael S.\r\nKlishin]\r\n* Handle nil and Time header values correctly [#76 state:resolved]\r\n[tmm1]\r\n* Add Content-Length header to response automatically when possible\r\n[#74 state:resolved] [dkubb]\r\n* Runner now remembers -r, -D and -V parameters so that clustered\r\nservers inherit those and\r\nkeep your parameters.\r\n* Make Set-Cookie header, in Rails adapter, compatible with current\r\nRack spec [Pedro Belo]\r\n[#73, state:resolved]\r\n* Add --no-epoll option to disable epoll usage on Linux [#61\r\nstate:resolved]\r\n* Add --force (-f) option to force stopping of a daemonized server\r\n[#72 state:resolved]\r\n* Update halycon adapter loader [mtodd]\r\n\r\n== Get it!\r\n\r\nInstall Thin from RubyForge:\r\n\r\ngem install thin\r\n\r\nOr using my mirror:\r\n\r\ngem install thin --source http://code.macournoyer.com\r\n\r\n参考文档:\r\nhttp://groups.google.com/group/thin-ruby/browse_thread/thread/402d51a6d9f2651d", "created_at"=>2008-10-07 09:56:27 UTC, "updated_at"=>2012-06-24 15:45:36 UTC, "body_html"=>"
Thin version 1.0.0 (codename That's What She Said) is out!
\n\n
Yes 1.0! That doesn't mean it's bug free or anything. But, it does \nmean that it's been running on a number of servers and no show stopper \nbugs have been found since a while.
Search directory arguments recursively for files to convert.
\r\n\t
-d or --delete
\r\n\t
delete input files after successful conversion. May not be safe yet!!!
\r\n\t
-v or --verbose
\r\n\t
makes sneetchalizer more chatty.
\r\n\t
-s or --show-output
\r\n\t
shows output from conversion tool.
\r\n\t
-p or --pretend
\r\n\t
don't convert anything. sneetchalizer will go through the motions and print out the commands it would run. Useful for preview- ing a complex command line to ensure it does what you intend. You should interpret this option's output with a grain of salt. For example, if you include the '--sanitize' option, the files will not really be renamed when using --pretend, and as such the command's output will not reflect that the filenames would be changed during an actual run.
\r\n\t
-t or --terminate
\r\n\t
terminate sneetchalizer options. This is useful if you have to convert '--coolDir' or '-groovySong.mp3'. This is the only option whose order on the command line is significant.
\r\n\t
-D ARG or --out-directory=ARG
\r\n\t
write all outfiles to a directory argument. This is useful if you want to (re)encode files directly to a mounted portable device.
\r\n\t
--strict and --pedantic
\r\n\t
many errors that sneetchalizer may encounter are recoverable, such as specifying a directory as argument that contains no files to convert, or conversion failures in general. By default the script will print an error message and move on to the next file. If you use '--strict' then sneetchalizer will bail out at the first sign of trouble except for tag errors. With '--pedantic' the script will stop even on tag errors.
\r\n\t
--stasis
\r\n\t
Preserve timestamp (mtime) of original file.
\r\n\t
--threads [N]
\r\n\t
Experimental. Use threads to create concurrent jobs. This option takes an optional integer argument which represents the number of threads to launch. The default is two. Preliminary tests suggest there is little advantage (and even diminishing returns) when setting this number greater than the number of cores/CPUs you have. Due to the asychronous nature of threads the --verbose and --show-output flags will be silently disabled and most screen output is supressed.
\r\n\t
--sanitize
\r\n\t
Removes ,, ;, :, ', \", %, @, #, and ` from filenames and tags.
\r\n\t
-n [FORMAT] or --rename[=FORMAT]
\r\n\t
rename all outfiles (and temporary wavs) according to FORMAT. FORMAT is a string with special designators to be pulled from the file tags. The following options are available:
\r\n\t
\r\n\t
* %t Song title
\r\n\t
* %b Album title
\r\n\t
* %n Track number
\r\n\t
* %a Artist name
\r\n\t
* %y Year
\r\n\t
* %g Genre
\r\n\t
* %c Comment field
\r\n\t
\r\n\t
Directories may be created with this command, as in \"%b/%n - %t\". The default value of FORMAT is \"%n %t\".
\r\n\t
\r\n\t
Bitrate/Quality/Compression options:
\r\n\t
\r\n\t
-b or --bitrate
\r\n\t
mp3/ogg/m4a bitrate.
\r\n\t
-q or --quality
\r\n\t
mp3/ogg quality.
\r\n\t
\r\n\t
quality and bitrate are passed directly to lame or oggenc depending on mp3 or ogg output format respectively. Both tools can handle either a bitrate or quality argument, so it is important to understand what values are valid for the underlying tool in your specific use case. faac will accept a bitrate argument, but not a quality argument. These options will be silently ignored for any output formats other than mp3, ogg or m4a. Make sure you know what you are doing if you decide to use both in one run, and read each tools manpage for valid values. If these options are omitted the tools builtin defaults are used (-q3 for oggenc and -q5 for lame).
\r\n\t
\r\n\t
-c or --compression
\r\n\t
flac/mac compression level.
\r\n\t
\r\n\t
this option allows you to pass a compression argument to flac and mac. See 'flac --help' and/or 'mac --help' if you don't know what this means.
\r\n\t
\r\n\t
Format Options:
\r\n\t
\r\n\t
--out=format
\r\n\t
output format. Default is wav.
\r\n\t
--in=format[,format..]
\r\n\t
input format(s). Default is wav.
\r\n\t
\r\n\t
Valid output formats are: \"aac\", \"aif\", \"aifc\", \"aiff\", \"aiffc\", \"ape\", \"au\", \"cdr\", \"cdda\", \"copy\", \"flac\", \"m4a\", \"m4b\", \"mpc\", \"mp4\", \"mpp\", \"mp3\", \"mp2\", \"ofr\", \"ofs\", \"ogg\", \"snd\", \"spx\", \"tta\", \"wav\", \"wv\". Valid input formats are all of the above plus \"wma\". You can specify multiple input formats using a comma: 'mp3,m4a,wma'. Input format is only neccesary when passing directory arguments, as file arguments are handled by context (read: file extension). The \"copy\" output option copies files directly, bypassing decoding/encoding steps (useful in conjunction with --rename).
\r\n\t
\r\n\t
Tagging Options:
\r\n\t
\r\n\t
--tt or --title
\r\n\t
Set 'title' tag.
\r\n\t
--ta or --artist
\r\n\t
Set 'artist' tag.
\r\n\t
--tl or --album
\r\n\t
Set 'album' tag.
\r\n\t
--ty or --year
\r\n\t
Set 'year' tag.
\r\n\t
--tc or --comment
\r\n\t
Set 'comment' tag.
\r\n\t
--tg or --genre
\r\n\t
Set 'genre' tag.
\r\n\t
--tn or --trackn
\r\n\t
Set 'track number' tag.
\r\n\t
\r\n\t
The short and long versions are different in an important way: Using the long version will clobber any existing tags. The short version will only set the tag if the existing tag has no value. Note that these tags will be placed in _every_ outfile during the run.
\r\n\t
\r\n\t
Alternative Encoder/Decoder Options:
\r\n\t
\r\n\t
--gogo
\r\n\t
use gogo to encode mp3 files.
\r\n\t
--bladeenc
\r\n\t
use bladeenc to encode mp3 files.
\r\n\t
\r\n\t
The default is still 'lame'. If 'lame' is not found, the script will search for one of these two encoders regardless if these options are passed or not.
\r\n\t
\r\n\t
Special Options:
\r\n\t
\r\n\t
--in-optionhook=ARG
\r\n\t
add ARG to infile conversion command. Possibly dangerous!
\r\n\t
--out-optionhook=ARG
\r\n\t
add ARG to outfile conversion command. Possibly dangerous!
Using the same --in and --out format allows us to resample/encode the file at a different bitrate or quality. Note that this will overwrite the original file so only do this on a copy, or use '-D' to write files to another directory.
直接下载其gz包,sneetchalizer-0.9.0是现在的最新版本。下载解包后可以看到: \n \nManifest: \n \n README - You're reading it now. \n LICENSE - A copy of the GPL, under which sneetchalizer is released. \n CHANGES - sneetchalizer's cvs/svn commit log. \n sneetchalizer - The script itself. \n sneetchalizer.1 - The manpage for sneetchalizer. \n sneetchalizer.desktop - A KDE service menu for converting with Konqueror. \n install.rb - A quick and dirty script to install the sneetchalizer. \n \n \n如果有root权限,可以直接运行install.rb,其会将sneetchalizer拷贝到/usr/bin下,将sneetchalizer.1拷贝到/usr/share/man/man1下。
\n\n
2、参数解释
\n\n
不翻译了,都挺简单明了的,如下: \n \nXML/HTML代码 \n \n General options: \n \n -h or --help \n Print quick or full usage details respectively. \n -r or --recursive \n Search directory arguments recursively for files to convert. \n -d or --delete \n delete input files after successful conversion. May not be safe yet!!! \n -v or --verbose \n makes sneetchalizer more chatty. \n -s or --show-output \n shows output from conversion tool. \n -p or --pretend \n don't convert anything. sneetchalizer will go through the motions and print out the commands it would run. Useful for preview- ing a complex command line to ensure it does what you intend. You should interpret this option's output with a grain of salt. For example, if you include the '--sanitize' option, the files will not really be renamed when using --pretend, and as such the command's output will not reflect that the filenames would be changed during an actual run. \n -t or --terminate \n terminate sneetchalizer options. This is useful if you have to convert '--coolDir' or '-groovySong.mp3'. This is the only option whose order on the command line is significant. \n -D ARG or --out-directory=ARG \n write all outfiles to a directory argument. This is useful if you want to (re)encode files directly to a mounted portable device. \n --strict and --pedantic \n many errors that sneetchalizer may encounter are recoverable, such as specifying a directory as argument that contains no files to convert, or conversion failures in general. By default the script will print an error message and move on to the next file. If you use '--strict' then sneetchalizer will bail out at the first sign of trouble except for tag errors. With '--pedantic' the script will stop even on tag errors. \n --stasis \n Preserve timestamp (mtime) of original file. \n --threads [N] \n Experimental. Use threads to create concurrent jobs. This option takes an optional integer argument which represents the number of threads to launch. The default is two. Preliminary tests suggest there is little advantage (and even diminishing returns) when setting this number greater than the number of cores/CPUs you have. Due to the asychronous nature of threads the --verbose and --show-output flags will be silently disabled and most screen output is supressed. \n --sanitize \n Removes ,, ;, :, ', ", %, @, #, and ` from filenames and tags. \n -n [FORMAT] or --rename[=FORMAT] \n rename all outfiles (and temporary wavs) according to FORMAT. FORMAT is a string with special designators to be pulled from the file tags. The following options are available: \n \n * %t Song title \n * %b Album title \n * %n Track number \n * %a Artist name \n * %y Year \n * %g Genre \n * %c Comment field \n \n Directories may be created with this command, as in "%b/%n - %t". The default value of FORMAT is "%n %t". \n \n Bitrate/Quality/Compression options: \n \n -b or --bitrate \n mp3/ogg/m4a bitrate. \n -q or --quality \n mp3/ogg quality. \n \n quality and bitrate are passed directly to lame or oggenc depending on mp3 or ogg output format respectively. Both tools can handle either a bitrate or quality argument, so it is important to understand what values are valid for the underlying tool in your specific use case. faac will accept a bitrate argument, but not a quality argument. These options will be silently ignored for any output formats other than mp3, ogg or m4a. Make sure you know what you are doing if you decide to use both in one run, and read each tools manpage for valid values. If these options are omitted the tools builtin defaults are used (-q3 for oggenc and -q5 for lame). \n \n -c or --compression \n flac/mac compression level. \n \n this option allows you to pass a compression argument to flac and mac. See 'flac --help' and/or 'mac --help' if you don't know what this means. \n \n Format Options: \n \n --out=format \n output format. Default is wav. \n --in=format[,format..] \n input format(s). Default is wav. \n \n Valid output formats are: "aac", "aif", "aifc", "aiff", "aiffc", "ape", "au", "cdr", "cdda", "copy", "flac", "m4a", "m4b", "mpc", "mp4", "mpp", "mp3", "mp2", "ofr", "ofs", "ogg", "snd", "spx", "tta", "wav", "wv". Valid input formats are all of the above plus "wma". You can specify multiple input formats using a comma: 'mp3,m4a,wma'. Input format is only neccesary when passing directory arguments, as file arguments are handled by context (read: file extension). The "copy" output option copies files directly, bypassing decoding/encoding steps (useful in conjunction with --rename). \n \n Tagging Options: \n \n --tt or --title \n Set 'title' tag. \n --ta or --artist \n Set 'artist' tag. \n --tl or --album \n Set 'album' tag. \n --ty or --year \n Set 'year' tag. \n --tc or --comment \n Set 'comment' tag. \n --tg or --genre \n Set 'genre' tag. \n --tn or --trackn \n Set 'track number' tag. \n \n The short and long versions are different in an important way: Using the long version will clobber any existing tags. The short version will only set the tag if the existing tag has no value. Note that these tags will be placed in _every_ outfile during the run. \n \n Alternative Encoder/Decoder Options: \n \n --gogo \n use gogo to encode mp3 files. \n --bladeenc \n use bladeenc to encode mp3 files. \n \n The default is still 'lame'. If 'lame' is not found, the script will search for one of these two encoders regardless if these options are passed or not. \n \n Special Options: \n \n --in-optionhook=ARG \n add ARG to infile conversion command. Possibly dangerous! \n --out-optionhook=ARG \n add ARG to outfile conversion command. Possibly dangerous! \n \n \n另外,你可以运行sneetchalizer -h看到简要的使用说明,也可以使用sneetchalizer --help看到详细的使用信息。
\n\n
3、使用示例
\n\n
如下简要的写几个使用的示例: \n \n使用示例: \n \n $ sneetchalizer song.mp3 \n \n The most simple possible example, creates 'song.wav'. \n \n $ sneetchalizer --out=ogg --in=flac -q5 /some/music/dir \n \n This example converts every flac file in '/some/music/dir' to ogg format at quality 5. \n \n $ sneetchalizer -d --out=mp3 --in=ogg,m4a,wma -b 160 . \n \n Converts every ogg, m4a, and wma file in the current directory to a 160 kbps constant bitrate mp3 file. The original files are deleted. \n \n $ sneetchalizer --out=mp3 --out-optionhook="--preset extreme" /some/wavs \n \n Here we encode every wav in '/some/wavs' to mp3 format passing '--preset extreme' directly to lame. \n \n $ sneetchalizer --in=ogg --out=ogg --quality=1 norvegianWood.ogg /some/more/oggs \n \n Using the same --in and --out format allows us to resample/encode the file at a different bitrate or quality. Note that this will overwrite the original file so only do this on a copy, or use '-D' to write files to another directory. \n \n $ sneetchalizer --in=ogg --out=m4a -D /mnt/ipod/ /some/oggs \n \n Here we re-encode some ogg files to m4a format and write them to our mounted iPod. \n \n \n4、注意事项
\n\n
本脚本只是粘合剂,其他的tool还是需要另外安装的。
\n\n
其他信息请参考其主页说明,如果您有这个方面的问题或经验,欢迎和我讨论。
\n\n\n
\n", "_id"=>292}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["架构"], "comments_count"=>0, "category_id"=>9, "title"=>"网站架构文章列表(持续更新中)", "body"=>"互联网越来越开放,技术人员也越来越乐于分享,分析构架、演变和遇到的问题,虽然说没有真正经历过,很多体验可能会没那么深,但是有些东西提前了解会有诸多好处。在很多地方看到类似的构架分析、分享的文章,统一收集整理如下,遇到其他的,我会持续更新,如果经历允许,我还会写一些读后感或者点评;如果你看到其他的类似文章或者点评,欢迎留言让我知道。\n\n对dbanotes等表示感谢。\n\nWikiPedia 技术架构学习分享\nhttp://www.dbanotes.net/opensource/wikipedia_arch.html\n\nYouTube 的架构扩展\nhttp://www.dbanotes.net/opensource/youtube_web_arch.html\n\nLinkedIn 架构笔记\nhttp://www.dbanotes.net/arch/linkedin.html\n\nLinkedIn 架构与开发过程\nhttp://www.dbanotes.net/arch/linkedin_soa.html\n\nInternet Archive 的海量存储浅析\nhttp://www.dbanotes.net/database/internet_archive_storage.html\n\nTailrank 网站架构\nhttp://www.dbanotes.net/review/tailrank_arch.html\n\nTwitter 的架构扩展: 100 倍性能提升\nhttp://www.dbanotes.net/arch/twitter_arch.html\n\n财帮子(caibangzi.com)网站架构\nhttp://www.dbanotes.net/arch/caibangzi_web_arch.html\n\nYupoo! 的网站技术架构\nhttp://www.dbanotes.net/arch/yupoo_arch.html\n\n37Signals 架构\nhttp://www.dbanotes.net/arch/37signals_arch.html\n\nFlickr 的访问统计实现以及其他\nhttp://www.dbanotes.net/arch/flickr_stats_and_dathan.html\n\nPlentyOfFish 网站架构学习\nhttp://www.dbanotes.net/arch/plentyoffish_arch.html\n\nYahoo!社区架构\nhttp://www.dbanotes.net/arch/yahoo_arch.html\n\n有关 Alexa 与 AOL 部署集群文件系统\nhttp://www.dbanotes.net/arch/alexa_ibrix_san_file_system.html\n\neBay 的存储一瞥\nhttp://www.dbanotes.net/arch/ebay_storage.html\n\neBay 的数据量\nhttp://www.dbanotes.net/database/ebay_storage.html\n\neBay 的数据库分布扩展架构\nhttp://www.dbanotes.net/database/ebay_database_scale_out.html\n\neBay 的数据层扩展经验\nhttp://www.dbanotes.net/arch/ebay_db_scale_out.html\n\neBay 的应用服务器规模\nhttp://www.dbanotes.net/web/ebay_application_server.html\n\n性能扩展问题要趁早\nhttp://www.dbanotes.net/arch/scaling_an_early_stage_startup.html\n\nScaling an early stage startup\nhttp://www.scribd.com/doc/429986/Scaling-an-early-stage-startup\n\nFacebook 的 PHP 性能与扩展性\nhttp://www.dbanotes.net/arch/facebook_php.html\n\nSkype 用 PostgreSQL 支撑海量用户\nhttp://www.dbanotes.net/arch/skype_postgresql.html\n\n闲谈 Web 图片服务器\nhttp://www.dbanotes.net/web/web_image_server.html\n\n说说北京奥运购票系统瘫痪这事儿\nhttp://www.dbanotes.net/review/beijing_olympic_ticketes_system_crash.html\n\nArchitectures You’ve Always Wondered About\nhttp://qcon.infoq.com/london-2008/tracks/show_track.jsp?trackOID=82\n\neBay’s Architectural Principles\nhttp://www.eos1.dk/qcon-london-2008/slides/RandyShoup_eBaysArchitecturalPrinciples.pdf\n\nBuilding a large scale SaaS app\nhttp://www.eos1.dk/qcon-london-2008/slides/Dan_Hanley_Building_a_large_scale_SaaS_app.pdf\n\nScaling an early stage startup\nhttp://www.scribd.com/doc/429986/Scaling-an-early-stage-startup\n\n互联星空播客架构(原文在张宴blog上,但是后来文章撤下,很可惜.此为转载)\nhttp://www.flashmov.com/blog_1632.html\n\nQQ游戏百万人同时在线服务器架构实现\nhttp://www.libing.net.cn/read.php?41\n\n大型Web2.0站点构建技术初探\nhttp://blog.csdn.net/heiyeshuwu/archive/2007/11/18/1890793.aspx\n\nWeb站点数据库分布存储浅谈\nhttp://blog.csdn.net/heiyeshuwu/archive/2007/11/18/1891639.aspx\n\nQQ的架构讨论\nhttp://groups.google.com/group/dev4server/browse_thread/thread/0d72668d11c4886b/a6d202489cabf285#a6d202489cabf285\n\nNotes from Scaling MySQL - Up or Out\nhttp://venublog.com/2008/04/16/notes-from-scaling-mysql-up-or-out/\n\nYapache-Yahoo! Apache 的秘密\nhttp://www.dbanotes.net/web/yapache_yahoo_apache.html\n\nScalability Best Practices: Lessons from eBay\nhttp://www.infoq.com/articles/ebay-scalability-best-practices", "created_at"=>2008-10-09 06:51:05 UTC, "updated_at"=>2012-06-24 15:45:36 UTC, "body_html"=>"
Google的产品很多都深得我心,一直在使用,整理整合了一些Gmail的快捷方式,备忘。 \n \n \n \n快捷键 \n定义 \n作用 \n \n \nc \nCompose \n撰写新邮件。“Shift+C”打开新窗口撰写新邮件 \n \n \n<tab> then <Enter> \nSend message \n新邮件撰写完后,先<tab>后<Enter>可发送邮件。(在Windows中,使用IE和Firefox有效) \n \n \nk \nMove to newer conversation \n在收件箱中,向上移动光标,按<Enter>查看邮件;在查看邮件时,打开下一封新邮件 \n \n \nj \nMove to older conversation \n在收件箱中,向下移动光标,按<Enter>查看邮件;在查看邮件时,打开下一封旧邮件 \n \n \nn \nNext message \n查看邮件时,定位光标到 \n \n \np \nPrevious message \n移动光标到前一个消息。<Enter>展开或折叠消息。(只在“会话模式”(Conversation View)中有效) \n \n \no or <Enter> \nOpen \n打开会话。在“Conversation View”中,也可用于打开消息。 \n \n \nu \nReturn to conversation list \n刷新页面、返回收件箱或返回会话列表 \n \n \ny \nArchive* \nRemove from current view \n \n删除会话或消息。 \n在收件箱中,<Y>可“存档”选中的会话
\n\n
在“已加星标示”中,<Y>可取消选中会话的星号; \n 在查看有标签的邮件时,<Y>可取消标签。 \n 在“垃圾邮件”、“已发邮件”和“所有邮件”中,<Y>没有作用 \n \n \n \n \nx \nSelect conversation \n选中会话,配合其他快捷键可为会话存档、添加标签或从下拉菜单中选择其他命令 \n \n \ns \nStar a message or conversation \n为会话或消息加星标。 \n \n \n! \nReport spam \n将消息标记为垃圾邮件并从会话中删除 \n \n \nr \nReply \n回复邮件或会话。“shift+r”可在新窗口中回复消息(只在“会话模式”中有效) \n \n \na \nReply all \n回复所有收件人。“Shift+a”可打开新窗口中回复。(PConline注:如果邮件有抄送地址,<r>回复发件人,<a>则回复所有抄送地址) \n \n \nf \nForward \n转发消息。“Shift+f”可打开新窗口转发。(只在“查看消息模式”(“Conversation View”)中有效) \n \n \n<Esc> \nEscape from input field \nRemoves the cursor from your current input field.(PConline注:在中文版Gmail中暂未有效果) \n \n \ny then o \nArchive and next \n存档选中的会话并打开下一个 \n \n \ng then a \nGo to 'All Mail' \n转到“所有邮件” \n \n \ng then s \nGo to 'Starred' \n转到“已加星标” \n \n \ng then c \nGo to 'Contacts' \n转到“通讯录” \n \n \ng then d \nGo to 'Drafts' \n转到“草稿” \n \n \ng then i \nGo to 'Inbox' \n转到“收件箱” \n \n \n/ \nSearch \n将光标定位到搜索栏中的输入框中 \n \n \n \n
\n", "_id"=>294}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["analyzer"], "comments_count"=>0, "category_id"=>7, "title"=>"Request-log-analyzer: Rails&Merb的日志分析", "body"=>"生产环境下,需要对环境持续监控以尽快的发现问题,找到耗费资源较多的地方加以改进,比较常见的做法是使用moint或者God实时监控;另外,还可以定期分析日志找到特定的请求,虽然可以是shell来做这件事,但是何必再造轮子呢,因为我们已经有了Request log analyzer :\r\n``简介:This is a simple command line tool to analyze request log files of both Rails andMerb. Its purpose is to find what actions are best candidates for optimization.This tool will parse all requests in the logfile and aggregate theinformation. Once it is finished parsing the log file, it will show therequests that take op most server time. Different metrics are used (cumulativetime, average time, blockers, DB time, etc)\r\n\r\n安装:gem sources -a http://gems.github.comsudo gem install wvanbergen-request-log-analyzer\r\n\r\n使用:Usage: request-log-analyzer [FILE] [OPTION]Analyze the given log FILE with the given OPTIONExample: request-log-analyzer mongrel.log\r\n\r\n --fast, -t: Only use completed requests --guess-database-time, -g: Guesses the database duration of requests if they are not in the log --output, -o: Comma-separated list of reports to show --amount, -c: Displays the top <amount> elements in the reports --colorize, -z: Fancy bash coloring\r\n\r\n示例:Note that this example was shortened for your viewing pleasure.$ request-log-analyzer /var/log/my_app.log\r\n\r\nRequest log analyzer, by Willem van Bergen and Bart ten Brinke\r\n\r\nProcessing all log lines...========================================================================Successfully analyzed 58908 requests from log file\r\n\r\nTimestamp first request: 2008-07-13T06:25:58+00:00Timestamp last request: 2008-07-20T06:18:53+00:00Total time analyzed: 7 daysMethods: DELETE (1%), GET (50%), POST (22%), PUT (25%).\r\n\r\nTop 10 most requested actions========================================================================/overview/:date/ : 19359 requests/overview/day/:date/ : 6365 requests/overview/:date/set/ : 5589 requests/overview/ : 3985 requests/clients/:id/ : 1976 requests........\r\n\r\nTop 10 actions by time - cumulative========================================================================/overview/:date/ : 9044.582s [19359 requests]/overview/ : 8478.767s [3985 requests]/overview/:date/set/ : 3309.041s [5589 requests]/clients/:id/products/:id/ : 1479.911s [924 requests]/clients/:id/ : 750.080s [1976 requests]........\r\n\r\nTop 10 actions by time - per request mean========================================================================/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]/clients/:id/ : 0.380s [1976 requests]........\r\n\r\nTop 10 worst DB offenders - cumulative time========================================================================/overview/:date/ : 8773.993s [19359 requests]/overview/ : 8394.754s [3985 requests]/overview/:date/set/ : 3307.928s [5589 requests]/clients/:id/products/:id/ : 1425.220s [924 requests]/clients/:id/ : 535.229s [1976 requests]........\r\n\r\nTop 10 worst DB offenders - mean time========================================================================/overview/:id/:id/:id/print/ : 6.994s [448 requests]/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]........\r\n\r\nMongrel process blockers (> 1.0 seconds)========================================================================/overview/:date/ : 7494.233s [3144 requests]/overview/ : 8320.293s [1549 requests]/overview/:date/set/ : 1149.235s [803 requests]/overview/:id/:id/:id/print/new/ : 613.693s [341 requests]/clients/:id/products/:id/ : 1370.693s [313 requests]........\r\n\r\nRequests graph - per hour======================================================================== ........ 7:00 - 2731 : XXXXXXX 8:00 - 6139 : XXXXXXXXXXXXXXXX 9:00 - 7465 : XXXXXXXXXXXXXXXXXXXX 10:00 - 7118 : XXXXXXXXXXXXXXXXXXX 11:00 - 7409 : XXXXXXXXXXXXXXXXXXX 12:00 - 6450 : XXXXXXXXXXXXXXXXX 13:00 - 5377 : XXXXXXXXXXXXXX 14:00 - 6058 : XXXXXXXXXXXXXXXX 15:00 - 4156 : XXXXXXXXXXX 16:00 - 2767 : XXXXXXX 17:00 - 1598 : XXXX 18:00 - 792 : XX ........\r\n\r\nErrors========================================================================ArgumentError: [237 requests] -> invalid dateStaleObjectError: [28 requests] -> Attempted to update a stale objectRuntimeError: [3 requests] -> Cannot destroy rule before it was createdStatementError: [2 requests] -> Mysql::Error: Deadlock found when trying to get lock; try restarting transactionNoMethodError: [1 requests] -> undefined method `code' for nil:NilClass```", "created_at"=>2008-10-13 08:45:11 UTC, "updated_at"=>2012-06-24 15:45:36 UTC, "body_html"=>"
生产环境下,需要对环境持续监控以尽快的发现问题,找到耗费资源较多的地方加以改进,比较常见的做法是使用moint或者God实时监控;另外,还可以定期分析日志找到特定的请求,虽然可以是shell来做这件事,但是何必再造轮子呢,因为我们已经有了Request log analyzer : \n``简介:This is a simple command line tool to analyze request log files of both Rails andMerb. Its purpose is to find what actions are best candidates for optimization.This tool will parse all requests in the logfile and aggregate theinformation. Once it is finished parsing the log file, it will show therequests that take op most server time. Different metrics are used (cumulativetime, average time, blockers, DB time, etc)
\n\n
安装:gem sources -a http://gems.github.comsudo gem install wvanbergen-request-log-analyzer
\n\n
使用:Usage: request-log-analyzer [FILE] [OPTION]Analyze the given log FILE with the given OPTIONExample: request-log-analyzer mongrel.log
\n\n
--fast, -t: Only use completed requests --guess-database-time, -g: Guesses the database duration of requests if they are not in the log --output, -o: Comma-separated list of reports to show --amount, -c: Displays the top <amount> elements in the reports --colorize, -z: Fancy bash coloring
\n\n
示例:Note that this example was shortened for your viewing pleasure.$ request-log-analyzer /var/log/my_app.log
\n\n
Request log analyzer, by Willem van Bergen and Bart ten Brinke
\n\n
Processing all log lines...========================================================================Successfully analyzed 58908 requests from log file
\n\n
Timestamp first request: 2008-07-13T06:25:58+00:00Timestamp last request: 2008-07-20T06:18:53+00:00Total time analyzed: 7 daysMethods: DELETE (1%), GET (50%), POST (22%), PUT (25%).
\n\n
Top 10 most requested actions========================================================================/overview/:date/ : 19359 requests/overview/day/:date/ : 6365 requests/overview/:date/set/ : 5589 requests/overview/ : 3985 requests/clients/:id/ : 1976 requests........
\n\n
Top 10 actions by time - cumulative========================================================================/overview/:date/ : 9044.582s [19359 requests]/overview/ : 8478.767s [3985 requests]/overview/:date/set/ : 3309.041s [5589 requests]/clients/:id/products/:id/ : 1479.911s [924 requests]/clients/:id/ : 750.080s [1976 requests]........
\n\n
Top 10 actions by time - per request mean========================================================================/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]/clients/:id/ : 0.380s [1976 requests]........
Errors========================================================================ArgumentError: [237 requests] -> invalid dateStaleObjectError: [28 requests] -> Attempted to update a stale objectRuntimeError: [3 requests] -> Cannot destroy rule before it was createdStatementError: [2 requests] -> Mysql::Error: Deadlock found when trying to get lock; try restarting transactionNoMethodError: [1 requests] -> undefined method code' for nil:NilClass``
Nginx有个Log Rotation模块,nginx will re-open it's logs in response to the USR1 signal.参考如下脚本: \n`$ mv access.log access.log.0$ kill -USR1cat master.nginx.pid`$ sleep 1$ gzip access.log.0 # do something with access.log.0
\r\n``2、Hpricot```Pros: Cool name, created by _why, faster than REXML, also does HTML, creative APICons: Not as fast as libxml-ruby, more of an HTML parser linguistically (ie: uses innerHTML instead of text or content, etc.)```\r\n
\r\n
Ruby代码
\r\n\r\n\t
%w[benchmark pp rubygems].each { |x| require x }
\r\n\t
gem 'hpricot', '>= 0.6'
\r\n\t
require 'hpricot'
\r\n\t
\r\n\t
##################################
\r\n\t
# Parsing Delicious API Response #
\r\n\t
##################################
\r\n\t
xml = File.read('posts.xml')
\r\n\t
puts Benchmark.measure {
\r\n\t
doc, posts = Hpricot::XML(xml), []
\r\n\t
(doc/:post).eachdo |p|
\r\n\t
posts << p.attributes
\r\n\t
end
\r\n\t
# pp posts
\r\n\t
}
\r\n\t
\r\n\t
################################
\r\n\t
# Parsing Twitter API Response #
\r\n\t
################################
\r\n\t
xml = File.read('timeline.xml')
\r\n\t
puts Benchmark.measure {
\r\n\t
doc, statuses = Hpricot::XML(xml), []
\r\n\t
(doc/:status).eachdo |s|
\r\n\t
h = {:user => {}}
\r\n\t
%w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].eachdo |a|
\r\n\t
h[a.intern] = s.at(a).innerHTML
\r\n\t
end
\r\n\t
%w[id name screen_name location description profile_image_url url protected followers_count].eachdo |a|
\r\n\t
h[:user][a.intern] = s.at('user').at(a).innerHTML
\r\n\t
end
\r\n\t
statuses << h
\r\n\t
end
\r\n\t
# pp statuses
\r\n\t
}
\r\n\r\n
\r\n3、libxml-ruby \r\n\r\nPros: Blistering fast\r\nCons: Hpricot has cooler name, REXML and Hpricot both feel easier to use out of the box\r\n
Ruby可以很方便的解析XML格式的文档,目前用的比较多的lib主要有三个,分别是:REXML, Hpricot, libxml-ruby,如下选取两个XML文档,分别使用这三个lib解析,感受下各自的速度和易用性。 \n一、原料 \n \n posts.xml – Uses xml element for object (post) and xml attributes for object attributes \n timeline.xml – Uses xml element for object (status) and child xml elements for attributes \n \n二、解析过程 \n1、REXML
\n\n
Pros: In the standard library \nCons: Slow, I don’t like the name \n \nRuby代码 \n \n %w[benchmark pp rexml/document].each { |x| require x } \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n doc, posts = REXML::Document.new(xml), [] \n doc.elements.each('posts/post') do |p| \n posts << p.attributes \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n doc, statuses = REXML::Document.new(xml), [] \n doc.elements.each('statuses/status') do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.elements[a].text \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.elements['user'].elements[a].text \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n<code class="ruby"><strong>2、Hpricot</strong><strong>Pros:</strong> Cool name, created by _why, faster than <span class="caps">REXML</span>, also does <span class="caps">HTML</span>, creative <span class="caps">API</span><strong>Cons:</strong> Not as fast as libxml-ruby, more of an <span class="caps">HTML</span> parser linguistically (ie: uses innerHTML instead of text or content, etc.)`` \n \nRuby代码 \n \n %w[benchmark pp rubygems].each { |x| require x } \n gem 'hpricot', '>= 0.6' \n require 'hpricot' \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n doc, posts = Hpricot::XML(xml), [] \n (doc/:post).each do |p| \n posts << p.attributes \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n doc, statuses = Hpricot::XML(xml), [] \n (doc/:status).each do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.at(a).innerHTML \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.at('user').at(a).innerHTML \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n3、libxml-ruby
\n\n
Pros: Blistering fast \nCons: Hpricot has cooler name, REXML and Hpricot both feel easier to use out of the box \n \nRuby代码 \n \n %w[benchmark pp rubygems].each { |x| require x } \n gem 'libxml-ruby', '>= 0.8.3' \n require 'xml' \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n parser, parser.string = XML::Parser.new, xml \n doc, posts = parser.parse, [] \n doc.find('//posts/post').each do |p| \n posts << p.attributes.inject({}) { |h, a| h[a.name] = a.value; h } \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n parser, parser.string = XML::Parser.new, xml \n doc, statuses = parser.parse, [] \n doc.find('//statuses/status').each do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.find(a).first.content \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.find('user').first.find(a).first.content \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n<code class="ruby"><strong>三、结论</strong> \n<div class="codeText"> \n<div class="codeHead">结果如下:</div> \n<ol class="dp-xml" start="1"> \n <li class="alt"><span><span>=rexml </span></span></li> \n <li><span>delicious 0.020000 0.000000 0.020000 ( 0.021139) </span></li> \n <li class="alt"><span>twitter 0.940000 0.020000 0.960000 ( 0.988666) </span></li> \n <li><span> </span></li> \n <li class="alt"><span>=hpricot </span></li> \n <li><span>delicious 0.010000 0.000000 0.010000 ( 0.005548) </span></li> \n <li class="alt"><span>twitter 0.250000 0.010000 0.260000 ( 0.258320) </span></li> \n <li><span> </span></li> \n <li class="alt"><span>=libxml-ruby </span></li> \n <li><span>delicious 0.000000 0.000000 0.000000 ( 0.007829) </span></li> \n <li class="alt"><span>twitter 0.030000 0.010000 0.040000 ( 0.034040) </span></li> \n</ol> \n</div> \n``<code class="ruby">参考文档:http://railstips.org/2008/8/12/parsing-xml-with-ruby``
\n", "_id"=>298}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Tips"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["oauth"], "comments_count"=>0, "category_id"=>4, "title"=>"初识oauth: 为API访问授权提供一个开放的标准", "body"=>"最近在准备一些API设计开发工作,初步了解了下oauth,OAuth是由Blaine Cook、Chris Messina、Larry Halff 及David Recordon共同发起的,目的在于为API访问授权提供一个开放的标准。\r\noauth目前看来进展比较顺利,可以看到其有主流语言的lib(Java、C#、Objective-C、Perl、PHP及Ruby语言),目前支持oauth的API有twitter,douban等应用。\r\n\r\nOAuth is the great new standard allowing your users to use your application to talk to their accounts on other applications. I won’t go more into it here as it’s pretty well covered on the OAuth site.\r\n\r\nOAuth’s Goal\r\nWebsite X can access your protected data at API Y\r\n
\r\n\t
All without sharing your password off-site
\r\n\t
especially when there isn’t one like with OpenID
\r\n
\r\n其基本流程为:\r\n\r\n\t
Register your consumer application with the OAuth compliant service to receive your Consumer Credentials (This is only done once)
\r\n\t
You initiate the OAuth Token exchange process for a user by requesting a RequestToken from the Service
\r\n\t
You store the RequestToken in your database or in the users session object
\r\n\t
You redirect your user to the service providers authorize_url with the RequestToken’s key appended
\r\n\t
Your user is asked by the service provider to authorize your RequestToken
\r\n\t
Your user clicks yes and is redirected to your CallBack URL
OAuth is the great new standard allowing your users to use your application to talk to their accounts on other applications. I won’t go more into it here as it’s pretty well covered on the OAuth site. \n \nOAuth’s Goal \nWebsite X can access your protected data at API Y \n \n All without sharing your password off-site \n especially when there isn’t one like with OpenID \n \n其基本流程为: \n \n Register your consumer application with the OAuth compliant service to receive your Consumer Credentials (This is only done once) \n You initiate the OAuth Token exchange process for a user by requesting a RequestToken from the Service \n You store the RequestToken in your database or in the users session object \n You redirect your user to the service providers authorize_url with the RequestToken’s key appended \n Your user is asked by the service provider to authorize your RequestToken \n Your user clicks yes and is redirected to your CallBack URL \n Your callback action exchanges the RequestToken for an AccessToken \n Now you can access your users data by performing http requests signed by your consumer credentials and the AccessToken. \n ???? \n PROFIT!!! \n \n如果你想了解,请参考如下文档,如果你有经验,请分享,谢谢! \n \n参考文档: \n \n Developing OAuth clients in Ruby \n How to turn your rails site into an OAuth Provider \n OAuth不断获得动力 \n Rails plugin for OAuth \n OAuth implementation for Ruby \n 豆瓣 API 认证授权说明 \n The How of OAuth --这个PPT挺不错 \n
\n", "_id"=>306}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Ruby&Rails", "to_xml"], "comments_count"=>0, "category_id"=>11, "title"=>"Rails: Disabling XML character escaping for to_xml & xml builder", "body"=>"
In my case, I had to genarate the xml view for api render,but in rails, i got a &XXX format string for non englisg, it also appears to_xml will automatically escape any entities into their corresponding &XXX representation. There's a piece in the documentation that says "If $KCODE is set to u and encoding set to UTF8, then escaping will NOT be performed." \n \nUnfortunately, this doesn't appear to be the case. Even after following the docs and ensuring that default_charset is indeed UTF-8 (actually the default for Rails nowadays), we still get encoded characters in to_xml output. \n \nSince our client is UTF-8 aware, we need to pass thru the UTF-8 data intact. The only way we've found to do this is thru the following horrible monkey-patch:
\n
\n
Ruby代码
\n\n
module Builder
\n
class XmlBase
\n
def _escape(text)
\n
text
\n
end
\n
end
\n
end
\n\n
\n
\nWhat's the proper way to do this? \n \nPS: \nsomebody say that to "set $KCODE='UTF8' in config/environment.rb can solve this issue." but it's not for me. \n \nmore infos: \nhttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2c13ad7c0f8c0781
In my case, I had to genarate the xml view for api render,but in rails, i got a &XXX format string for non englisg, it also appears to_xml will automatically escape any entities into their corresponding &XXX representation. There's a piece in the documentation that says "If $KCODE is set to u and encoding set to UTF8, then escaping will NOT be performed." \n \nUnfortunately, this doesn't appear to be the case. Even after following the docs and ensuring that default_charset is indeed UTF-8 (actually the default for Rails nowadays), we still get encoded characters in to_xml output. \n \nSince our client is UTF-8 aware, we need to pass thru the UTF-8 data intact. The only way we've found to do this is thru the following horrible monkey-patch: \n \nRuby代码 \n \n module Builder \n class XmlBase \n def _escape(text) \n text \n end \n end \n end \n \n \n \nWhat's the proper way to do this? \n \nPS: \nsomebody say that to "set $KCODE='UTF8' in config/environment.rb can solve this issue." but it's not for me. \n \nmore infos: \nhttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2c13ad7c0f8c0781 \n
\n", "_id"=>307}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["random", "ruby"], "comments_count"=>0, "category_id"=>11, "title"=>"Generate a random string", "body"=>"Generates a random string of lowercase letters. Great for email verification codes or user password salt....\n
Some tips for mount&umount ,maybe give you some help..
\n
cdrom: \n# mount -t is09660 /dev/cdrom /mnt/cdrom \n# umount /mnt/cdrom \n \nfloppy: \n# mount /dev/fd0 /mnt/floppy \n#umount /mnt/floppy \n \nusb: \n1.use 'fdisk -l' to show the usb nums,something like '/dev/sda'; \n2.then use 'mkdir /mnt/usb' to create a dir for mount this usb; \n3.at last,use '# mount -t msdos /dev/sda1 /mnt/usb" to mount it. \n4.#umount /mnt/usb \n \nhda: \n1.use 'fdisk -l' to show the disk nums,like '/dev/hda1'; \n2.then use 'make /mnt/vfat' to create a mount point; \n3.at last,use '# mount -t vfat /dev/hda1 /mnt/vfat'to mount it.. \n4.#umount /mnt/vfat
Some tips for mount&umount ,maybe give you some help.. \ncdrom:
\n\n
mount -t is09660 /dev/cdrom /mnt/cdrom
\n\n
umount /mnt/cdrom
\n\n
floppy:
\n\n
mount /dev/fd0 /mnt/floppy
\n\n
umount /mnt/floppy
\n\n
usb: \n1.use 'fdisk -l' to show the usb nums,something like '/dev/sda'; \n2.then use 'mkdir /mnt/usb' to create a dir for mount this usb; \n3.at last,use '# mount -t msdos /dev/sda1 /mnt/usb" to mount it. \n4.#umount /mnt/usb \n \nhda: \n1.use 'fdisk -l' to show the disk nums,like '/dev/hda1'; \n2.then use 'make /mnt/vfat' to create a mount point; \n3.at last,use '# mount -t vfat /dev/hda1 /mnt/vfat'to mount it.. \n4.#umount /mnt/vfat \nand some usefull resource links and docs here: \nhttp://unix-cd.com/unixcd12/article_3967.html \nhttp://blog.oracle.com.cn/index.php/121320/viewspace-6733.html
In my case, I need do send big files to users, yes, you can do it with nginx,just like others static files,but i need some control for the request action,The delivery of a static file which depends on an application header is known as the X-Sendfile feature. \nLighttpd has this feature and there is a mod_xsendfile for Apache2. \nNginx also has this feature, but implemented a little bit differently. In Nginx this feature is called X-Accel-Redirect. \nThere are two main differences:
\n\n
The header must contain a URI
\n
The location should be defined as internal; to prevent the client going directly to the URI
\n\n
\n
\n
Ruby代码
\n\n
location /files {
\n
root /var/www;
\n
internal;
\n
}
\n\n
\n
\n
Ruby代码
\n\n
// Get requested file name
\n
path = @params["path"]
\n
\n
# ...
\n
# Perform any required security checks, validation
In my case, I need do send big files to users, yes, you can do it with nginx,just like others static files,but i need some control for the request action,The delivery of a static file which depends on an application header is known as the X-Sendfile feature. \nLighttpd has this feature and there is a mod_xsendfile for Apache2. \nNginx also has this feature, but implemented a little bit differently. In Nginx this feature is called X-Accel-Redirect. \nThere are two main differences: \n \n The header must contain a URI \n The location should be defined as internal; to prevent the client going directly to the URI \n \n \n \nRuby代码 \n \n location /files { \n root /var/www; \n internal; \n } \n \n \n \nRuby代码 \n \n // Get requested file name \n path = @params["path"] \n \n # ... \n # Perform any required security checks, validation \n # and/or stats accounting \n # ... \n \n # And redirect user to internal location \n response.headers['X-Accel-Redirect'] = "/files/" + path \n \n \n \nsome userfull link resource come here: \n \n http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/ \n http://wiki.codemongers.com/NginxXSendfile \n http://www.motionstandingstill.com/using-nginx-to-send-files-with-x-accel-redirect/2008-09-03/ \n \n
I store user sessions in memcache,and then i want do share theres sessions with sub domains,but i notice some strange things when i put session into memcached,there are: \n1. In my older website(rails 2.0),It genenrated sessions key for memcached as \#{namespace}-\#{RAILS_ENV}:"session:\#{id}"; \n2.In my newer website(reails 2.3),It generated seesions key for memcached just as "\#{namespace}:\#{id}"; \n \nso,i can not get the same seesion datas with diff session keys. i do have spend lots of time for sove this , i do have some userfull dis, \n \n1. In rails2.3 ,it's vendor memcache-client-1.5.0.5 in ruby\\lib\\ruby\\gems\\1.8\\gems\\activesupport-2.3.0\\lib\\active_support\\vendor; \n2. you can config namespace in you environment.rb file like " ActionController::Base.session_options[:namespace] = 'session'" \n3. In rails2.0,when you use memcached,you will use cached_fu and act_as_cache plugins,and you may have a config file in your config dir named memcached.yml, and in this file,you can config defaults,production,test and developer..with lots of filed,like namespace,servers etc.. \n4. you will notice it generate memcached key as mentioned above. \n \nI track it,and got this:
I store user sessions in memcache,and then i want do share theres sessions with sub domains,but i notice some strange things when i put session into memcached,there are: \n1. In my older website(rails 2.0),It genenrated sessions key for memcached as \#{namespace}-\#{RAILS_ENV}:"session:\#{id}"; \n2.In my newer website(reails 2.3),It generated seesions key for memcached just as "\#{namespace}:\#{id}"; \n \nso,i can not get the same seesion datas with diff session keys. i do have spend lots of time for sove this , i do have some userfull dis, \n \n1. In rails2.3 ,it's vendor memcache-client-1.5.0.5 in ruby\\lib\\ruby\\gems\\1.8\\gems\\activesupport-2.3.0\\lib\\active_support\\vendor; \n2. you can config namespace in you environment.rb file like " ActionController::Base.session_options[:namespace] = 'session'" \n3. In rails2.0,when you use memcached,you will use cached_fu and act_as_cache plugins,and you may have a config file in your config dir named memcached.yml, and in this file,you can config defaults,production,test and developer..with lots of filed,like namespace,servers etc.. \n4. you will notice it generate memcached key as mentioned above. \n \nI track it,and got this: \n \nRuby代码 \n \n def setup_memcache(config) \n config[:namespace] << "-\#{RAILS_ENV}" \n \n silence_warnings do \n Object.const_set :CACHE, memcache_klass.new(config) \n end \n \n CACHE.servers = Array(config.delete(:servers)) \n \n setup_session_store if config[:sessions] \n setup_fragment_store! if config[:fragments] \n setup_fast_hash! if config[:fast_hash] \n setup_fastest_hash! if config[:fastest_hash] \n \n CACHE \n end \n \n \nshit,it append RAILS_ENV to namespace with "-",that's it...I hate some hardcode config in plugin,blalal.... \nsome userfull link resources... \n \n http://errtheblog.com/posts/22-sessions-n-such \n http://www.raecoo.com/2008/10/25/rails-store-format-in-memcache/ \n http://www.scribd.com/doc/2203398/Scaling-Rails-with-memcached \n http://railscasts.com/episodes/115-caching-in-rails-2-1
In some case,you may want do get Uniquely Identifying for a 'real' android phone,and you can do it like this:
\n
In Android.Provider.Settings.System we have some interesting values that could be of use, one specifically is “Android_ID”. From the documentation it is the following;
\n
\n
String \tANDROID_ID \tThe Android ID (a unique 64-bit value) as a hex string. \t“android_id”
\nAlso, note that in an emulator this will return “null”, though a real device will return an actual value. The nice thing about this tid-bit of code is that you are not required any special permissions to call it, since it’s essentially a passive call to get information. No write access is (obviously) required.\n
Garry Tan, cofounder of Posterous, lists 12 lessons for scaling that apply to more than just Rails,and i mark some word below. \n \nUse cloud storage for static files. --S3,I do not care it 's fine in china. \nUse HTTP Cache Control to tell the browser what it can cache. --this is true,etag is great. \nUse Sphinx for text search. --sometimes,you do have others chose. \nUse InnoDB for more crash resistant and faster writes. --maybe it's right. \nDon't use textbook Rails ActiveRecord objects. Use New Relic to find exactly what is slow in your system. --yep \nUse memcache later so you find your database bottlenecks now. --this is very important. \nUse mongrel proctitle to find your slow queries. You are only as fast as your slowest queries. -maybe mongrel is not only chose,think about thin,ok? \nUse asynchronous job queuing to do work in parallel. --yes,but sometimes crontab is enough. \nUse monitoring so you'll know when your site went down and why. --that's it,just do it. \nLearn by reading the source code, fixing problems, and submitting them back to the community. --very userfull when you got some strange questions.. \nUse new plugins. Old plugins can't be trusted. --and check chang histroy carefully. \nUse new information. Old information can't be trusted. --and what's this? \n \ngo to http://axonflux.com/building-and-scaling-a-startup for more infos.
When it asks for driver location choose the unzipped folderand install the driver for it.
\n
You'll see sth like "HTC Dream Composite ADB Interface" on success
\n
(Re)Start Eclipse
\n
Your G1 should now be listed in the DDMS-Perspective under Devices
\n
Go to the AndroidManifest.xml of your App and modify it to containandroid:debuggable="true"in the <application ... >-Tag,look like this:<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
\n
Go Debug as usual. \n
\n\nps: I do not upload the zip file here,you can find it via the link above,but if you can not download it,you can mail me to fetch one.
I konw,you can dev app and test it on the simulator,but if you had a real driver,G1,you can do debug on it,very great,here is the tips for this: \n \n On your G1, go to Settings Applications Development [X] USB debugging \n Download this file: android_usb_windows.zip \n Unzip it to a folder \n Connect your G1 with your PC \n When it asks for driver location choose the unzipped folder and install the driver for it. \n You'll see sth like "HTC Dream Composite ADB Interface" on success \n (Re)Start Eclipse \n Your G1 should now be listed in the DDMS-Perspective under Devices \n Go to the AndroidManifest.xml of your App and modify it to contain android:debuggable="true" in the <application ... >-Tag ,look like this:<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> \n Go Debug as usual. \n \n \nps: I do not upload the zip file here,you can find it via the link above,but if you can not download it,you can mail me to fetch one. \nBtw: \nYou can now install (signed)APKs via USB: \nD:\\dev\\Android\\android-sdk-windows-1.0_r1\\tools>adb -d install D:\\Workspace\\keytools\\AndNav_signed.apk \n1305 KB/s (1975987 bytes in 1.478s) \npkg: /data/local/tmp/AndNav_signed.apk \nSuccess \n \n \nAnd uninstall them: \nD:\\dev\\Android\\android-sdk-windows-1.0_r1\\tools>adb uninstall org.andnav \nSuccess \n \n
In some case,you may want do get Uniquely Identifying for a 'real' android phone,such as IMEI code,SimOperator etc, and we all kown ,the IMEI like ID card,and you can use TelephonyManager to get it,some usefull codes like this :
Apr 1 01:47:49 garden kernel: Linux version 2.6.18-92.1.17.el5 (mockbuild@builder10.centos.org) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)) #1 SMP Tue Nov 4 13:43:30 EST 2008
\n
\n \nlooks like something wrong about "ip_conntrack",and i do some check like this: \n\n
Installing ri documentation for fastercsv-1.4.0...
\n
Installing RDoc documentation for fastercsv-1.4.0...
\n
iceskysl ~/webroot: cd ..
\n\n
\nand do not forget to add "require 'fastercsv'" in your class file.", "created_at"=>2009-04-22 17:12:15 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
some tips is here. \n \nRuby代码 \n \n def self.imp_init_owner_data \n fp = "\#{RAILS_ROOT}/datas/inumbers/ini_owner.csv" \n FasterCSV.open(fp, "w") do |csv| \n InumberCate.find_all_by_typee("owner").each do |owner| \n csv << [owner.name,owner.id] \n end \n end \n end \n \n \ninstall fastercsv gems like this.. \n \n \n \nRuby代码 \n \n iceskysl ~/webroot: gem install fastercsv \n Successfully installed fastercsv-1.4.0 \n 1 gem installed \n Installing ri documentation for fastercsv-1.4.0... \n Installing RDoc documentation for fastercsv-1.4.0... \n iceskysl ~/webroot: cd .. \n \n \nand do not forget to add "require 'fastercsv'" in your class file.
you can use apt-spy to update sources.list ,here is some step and tips. \n1.open /etc/apt/sources.list and add this \ndeb http://http.us.debian.org/debian/ stable main \n2.do "apt-get update" \n3.then "apt-get install apt-spy" \n4.then "apt-spy update" \n5.last,"apt-spy -d unstable -a asia -t 5" \n \nref: \nhttp://http.us.debian.org/debian/README.mirrors.txt
you can use apt-spy to update sources.list ,here is some step and tips. \n1.open /etc/apt/sources.list and add this \ndeb http://http.us.debian.org/debian/ stable main \n2.do "apt-get update" \n3.then "apt-get install apt-spy" \n4.then "apt-spy update" \n5.last,"apt-spy -d unstable -a asia -t 5" \n \nref: \nhttp://http.us.debian.org/debian/README.mirrors.txt
\n", "_id"=>322}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["iowait"], "comments_count"=>0, "category_id"=>11, "title"=>"How can I find out what is generating iowait on my server?", "body"=>"
A question I’m asked daily is “How can I find out what is generating iowait on my server?” Sure, you can dig through pages of lsof output, restart services, or run strace, but it can be a frustrating process. I saw a process on this blog post, and a guy changed the regexes to fit Red Hat and CentOS systems a bit better: \n
A question I’m asked daily is “How can I find out what is generating iowait on my server?” Sure, you can dig through pages of lsof output, restart services, or run strace, but it can be a frustrating process. I saw a process on this blog post, and a guy changed the regexes to fit Red Hat and CentOS systems a bit better: \n \nRuby代码 \n \n [root@5-3 ~]# /etc/init.d/syslog stop \n Shutting down kernel logger: [ OK ] \n Shutting down system logger: [ OK ] \n [root@5-3 ~]# echo 1 > /proc/sys/vm/block_dump \n [root@5-3 ~]# dmesg | egrep "READ|WRITE|dirtied" | egrep -o '([a-zA-Z]*)' | sort | uniq -c | sort -rn | head \n 202 kjournald \n 16 egrep \n 9 irqbalance \n 9 bash \n 2 java \n 1 sda \n 1 mailserver \n [root@5-3 ~]# echo 0 > /proc/sys/vm/block_dump \n [root@5-3 ~]# /etc/init.d/syslog start \n Starting system logger: [ OK ] \n Starting kernel logger: [ OK ] \n \n \nIn my specific situation, it looks like kjournald is the biggest abuser of my disk. \nDon’t forget to set things back to their normal state when you’re done! \n \nXML/HTML代码 \n \n # echo 0 > /proc/sys/vm/block_dump \n # /etc/init.d/syslog start \n \n \n \n \nref: \nhttp://rackerhacker.com/2008/03/11/hunting-down-elusive-sources-of-iowait/ \nhttp://blog.eikke.com/index.php/ikke/2007/03/22/who_s_abusing_my_sata_controller \nhttp://hi.baidu.com/dipsey/blog/item/900bbbaf3e46dcc97cd92aba.html \nhttp://www.ducea.com/2009/03/11/howto-install-iotop-on-debian-etch/ \n \nhttp://www.cppblog.com/go-benny/archive/2008/04/23/47908.html \n
--attach PID Quit god when the attached process dies
\n
--no-events Disable the event system
\n
--bleakhouse Enable bleakhouse profiling
\n
[iceskysl@ws_api]#
\n\n
\n1.DYNAMICALLY LOADING CONFIG FILES INTO AN ALREADY RUNNING GOD\n
\n
God allows you to load or reload configurations into an already running instance. There are a few things to consider when doing this:
\n
\n
Existng Watches with the samename```as the incoming Watches will be overidden by the new config.
\n
All paths must be either absolute or relative to the path from which god was started.
\n
\n
To load a config into a running god, issue the following command:
\n
$ sudo god load path/to/config.god # god load /data/www/api/config/config_thin_api.god```\n
Config files that are loaded dynamically can contain anything that a normal config file contains, however, global options such asGod.pid_file_directory```blocks will be ignored (and produce a warning in the logs).
\n
\n
2.show logs
\n
\n
\n
XML/HTML代码
\n\n
[iceskysl@ws_api]# god log thin-thin-7514
\n
I, [2009-04-28T08:24:16.705870 #23174] INFO -- : thin-thin-7514 moved 'up' to 'up'
\n
I, [2009-04-28T08:24:16.706346 #23174] INFO -- : thin-thin-7514 [trigger] process is not running (ProcessRunning)
\n
I, [2009-04-28T08:24:16.888477 #23174] INFO -- : thin-thin-7514 sent email to iceskysl@gmail.com (Email)
\n
I, [2009-04-28T08:24:16.888642 #23174] INFO -- : thin-thin-7514 move 'up' to 'start'
\n
I, [2009-04-28T08:24:16.888976 #23174] INFO -- : thin-thin-7514 before_start: no pid file to delete (CleanPidFile)
\n
I, [2009-04-28T08:24:16.889109 #23174] INFO -- : thin-thin-7514 start: thin start -C /data/www/web/current/config/thin.yml -o 7514
some days before,i posted a article 《God: 比Monit更好用的monitoring》,today,i will post more useful tips for God. \n \n \nRuby代码 \n \n [iceskysl@ws_api]# god --help \n Usage: \n Starting: \n god [-c <config file>] [-p <port> | -b] [-P <file>] [-l <file>] [-D] \n \n Querying: \n god <command> <argument> [-p <port>] \n god <command> [-p <port>] \n god -v \n god -V (must be run as root to be accurate on Linux) \n \n Commands: \n start <task or group name> start task or group \n restart <task or group name> restart task or group \n stop <task or group name> stop task or group \n monitor <task or group name> monitor task or group \n unmonitor <task or group name> unmonitor task or group \n remove <task or group name> remove task or group from god \n load <file> load a config into a running god \n log <task name> show realtime log for given task \n status show status of each task \n quit stop god \n terminate stop god and all tasks \n check run self diagnostic \n \n Options: \n -c, --config-file CONFIG Configuration file \n -p, --port PORT Communications port (default 17165) \n -b, --auto-bind Auto-bind to an unused port number \n -P, --pid FILE Where to write the PID file \n -l, --log FILE Where to write the log file \n -D, --no-daemonize Don't daemonize \n -v, --version Print the version number and exit \n -V Print extended version and build information \n --log-level LEVEL Log level [debug|info|warn|error|fatal] \n --no-syslog Disable output to syslog \n --attach PID Quit god when the attached process dies \n --no-events Disable the event system \n --bleakhouse Enable bleakhouse profiling \n [iceskysl@ws_api]# \n \n \n1.DYNAMICALLY LOADING CONFIG FILES INTO AN ALREADY RUNNING GOD \n \nGod allows you to load or reload configurations into an already running instance. There are a few things to consider when doing this: \n \n Existng Watches with the same name<span class="Apple-converted-space"> </span>as the incoming Watches will be overidden by the new config.</li> \n <li style="margin: 0px; font-size: 13px;">All paths must be either absolute or relative to the path from which god was started.</li> \n</ul> \n<p style="margin: 0px 0px 1em; font-size: 13px;">To load a config into a running god, issue the following command:</p> \n<pre style="border: 1px solid rgb(204, 204, 204); margin: 1em 0px; padding: 1em; font-size: 10px; line-height: 1.3; background-color: rgb(239, 239, 239);">$ sudo god load path/to/config.god<br /># god load /data/www/api/config/config_thin_api.god \nConfig files that are loaded dynamically can contain anything that a normal config file contains, however, global options such as God.pid_file_directory``` blocks will be ignored (and produce a warning in the logs). \n \n2.show logs \n \n \nXML/HTML代码 \n \n [iceskysl@ws_api]# god log thin-thin-7514 \n I, [2009-04-28T08:24:16.705870 #23174] INFO -- : thin-thin-7514 moved 'up' to 'up' \n I, [2009-04-28T08:24:16.706346 #23174] INFO -- : thin-thin-7514 [trigger] process is not running (ProcessRunning) \n I, [2009-04-28T08:24:16.888477 #23174] INFO -- : thin-thin-7514 sent email to iceskysl@gmail.com (Email) \n I, [2009-04-28T08:24:16.888642 #23174] INFO -- : thin-thin-7514 move 'up' to 'start' \n I, [2009-04-28T08:24:16.888976 #23174] INFO -- : thin-thin-7514 before_start: no pid file to delete (CleanPidFile) \n I, [2009-04-28T08:24:16.889109 #23174] INFO -- : thin-thin-7514 start: thin start -C /data/www/web/current/config/thin.yml -o 7514 \n \n \n \nresource links: \nhttp://god.rubyforge.org/ \n
If you have recently updated to Rails 2.2.2, you may encounter this error when you want to start your application: \n \n/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in \n`load_missing_constant': uninitialized constant Inflector (NameError) \n \nthe usage of Inflector class is changed a bit. You can see the difference when you compare the inflections.rb files. Path of the file is yourApp/config/initializers/inflections.rb \n \n
\n
inflections.rb (Rails 2.1.0)
\n\n
\n
\n
Inflector.inflections do |inflect|
\n
.
\n
.
\n
.
\n
end
\n\n
\n \n
\n
inflections.rb (Rails 2.2.2)
\n\n
ActiveSupport::Inflector.inflections do |inflect|
\n
.
\n
.
\n
.
\n
end
\n\n
\nthe situation changing Inflector to ActiveSupport::Inflector was enough to solve the problem.", "created_at"=>2009-05-05 13:37:01 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
If you have recently updated to Rails 2.2.2, you may encounter this error when you want to start your application: \n \n/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in \n`load_missing_constant': uninitialized constant Inflector (NameError) \n \nthe usage of Inflector class is changed a bit. You can see the difference when you compare the inflections.rb files. Path of the file is yourApp/config/initializers/inflections.rb \n \n \ninflections.rb (Rails 2.1.0) \n \n \n \n Inflector.inflections do |inflect| \n . \n . \n . \n end \n \n \n \n \ninflections.rb (Rails 2.2.2) \n \n ActiveSupport::Inflector.inflections do |inflect| \n . \n . \n . \n end \n \n \nthe situation changing Inflector to ActiveSupport::Inflector was enough to solve the problem.
\n", "_id"=>326}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["God", "ruby", "Ruby&Rails"], "comments_count"=>0, "category_id"=>11, "title"=>"Socket Errno::EAFNOSUPPORT with God in ruby", "body"=>"
when i start god.sh,then give some error msg like this:
\n
\n
\n
XML/HTML代码
\n\n
I [2009-05-16 21:25:41] INFO: Using pid file directory: /var/run/god
\n
/usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `initialize': Address family not supported by protocol - socket(2) (Errno::EAFNOSUPPORT)
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `open'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `open_server_inaddr_any'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:863:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:759:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in `each'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1340:in `initialize'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in `new'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in `start_service'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:78:in `start'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:43:in `initialize'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in `new'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in `start'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:633:in `at_exit'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:666
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/cli/run.rb:87
\n\n
\nok,then i find some userful messsage,like here:\n
Errno::EAFNOSUPPORT - the specifiedsockaddrisnot a valid address for the family of the callingsocket
\n
and here, i notice where is the problen,the god find hostname,name map it to ip address,then create some sockets on the ip,and the error point is here,so i nano my /etc/hosts file,and add map for hostname and 127.0.0.1,that's it! \n
when i start god.sh,then give some error msg like this: \n \n \nXML/HTML代码 \n \n I [2009-05-16 21:25:41] INFO: Using pid file directory: /var/run/god \n /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in initialize': Address family not supported by protocol - socket(2) (Errno::EAFNOSUPPORT) </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in open' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in open_server_inaddr_any' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:863:in open_server' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:759:in open_server' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in each' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in open_server' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1340:in initialize' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in new' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in start_service' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:78:in start' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:43:in initialize' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in new' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in start' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:633:in `at_exit' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:666 \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/cli/run.rb:87 \n \n \nok,then i find some userful messsage,like here: \nErrno::EAFNOSUPPORT - the specified sockaddr isnot a valid address for the family of the calling socket \nand here, i notice where is the problen,the god find hostname,name map it to ip address,then create some sockets on the ip,and the error point is here,so i nano my /etc/hosts file,and add map for hostname and 127.0.0.1,that's it!
\n", "_id"=>327}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["书"], "comments_count"=>0, "category_id"=>6, "title"=>"我写的书:《Google Android开发入门与实战》等即将上市.", "body"=>"这篇文章是非技术性的,所以使用中文写,免得写了大家看不懂,呵呵。\r\n\r\n写书不是第一次,出版却是第一本,至于原因,就不详述了,去年9月开始参与一些图书的翻译和撰写中,截至到目前,这段时间一共参与了三本书,按照参与的先后顺序,分别是《The Rails Way》,《Google API 编程.开发.实例》以及《Google Android开发入门与实战》。\r\n\r\n其中《The Rails Way》是做为译者参与,其他翻译者都是国内第一批Rails技术人员,分散在全国各地,还有一名译者在加拿大,我一共翻译了5章内容,分别是第2章“Working_with_Controllers”,第10章“ActionView”,第13章“Session__Session_Management”,第15章“XML_and_ActiveResource”和第16章“ActionMailer”,翻译很早前就结束了,目前好像还在审稿、校核工作,由YiTan在跟,至于何时出版,我还真不知道。\r\n\r\n《Google API 编程.开发.实例》我是从去年9月份介入,开始参与选题和策划,截至撰写相关内容,因为我自身是Google重度使用者,平时也比较多的使用和了解GoogleAPI,所以写起来得心应手,一共写了“Google Account Authentication”,“Google AJAX Language API”,“Google Chart API”,“Blogger Data API”,“Feedburner API”,“Google Code Search Data API”和“Google Book Search Book Viewability API”这些章节,前前后后也花了不少零碎的时间。其他作者大多都Google内部的同学,本书已经进入出版流程,由博文视点出版社策划出版,应该在6.5号Google开发者大会上可以看到,如下是本书第一版封面。\r\n\r\n\r\n\r\n本书特点:本书覆盖了Google绝大多数的API,其中针对每个API就其原理、用法做了详细说明,最后基本上都有实际的例子演示如何使用。\r\n\r\n《Google Android开发入门与实战》是08年11月份开始撰写的,和另外一个朋友一起,两个人陆续的差不多用了半年时间,在09年4月份差不多全部写完,后面主要是都在校核和审稿,由人民邮电出版社出版,5月底6月初即可上市,封面如下:\r\n\r\n\r\n\r\n \r\n
《Google API 编程.开发.实例》我是从去年9月份介入,开始参与选题和策划,截至撰写相关内容,因为我自身是Google重度使用者,平时也比较多的使用和了解GoogleAPI,所以写起来得心应手,一共写了“Google Account Authentication”,“Google AJAX Language API”,“Google Chart API”,“Blogger Data API”,“Feedburner API”,“Google Code Search Data API”和“Google Book Search Book Viewability API”这些章节,前前后后也花了不少零碎的时间。其他作者大多都Google内部的同学,本书已经进入出版流程,由博文视点出版社策划出版,应该在6.5号Google开发者大会上可以看到,如下是本书第一版封面。
and now,you can open a cmd shell,and input sqlite3 like this: \n
\n
C:\\Documents and Settings\\Administrator>sqlite3 \nSQLite version 3.5.9 \nEnter ".help" for instructions
\n
and some help infos is here:
\n
sqlite> .help \n.bail ON|OFF Stop after hitting an error. Default OFF \n.databases List names and files of attached databases \n.dump ?TABLE? ... Dump the database in an SQL text format \n.echo ON|OFF Turn command echo on or off \n.exit Exit this program \n.explain ON|OFF Turn output mode suitable for EXPLAIN on or off. \n.header(s) ON|OFF Turn display of headers on or off \n.help Show this message \n.import FILE TABLE Import data from FILE into TABLE \n.indices TABLE Show names of all indices on TABLE \n.load FILE ?ENTRY? Load an extension library \n.mode MODE ?TABLE? Set output mode where MODE is one of: \n csv Comma-separated values \n column Left-aligned columns. (See .width) \n html HTML <table> code \n insert SQL insert statements for TABLE \n line One value per line \n list Values delimited by .separator string \n tabs Tab-separated values \n tcl TCL list elements \n.nullvalue STRING Print STRING in place of NULL values \n.output FILENAME Send output to FILENAME \n.output stdout Send output to the screen \n.prompt MAIN CONTINUE Replace the standard prompts \n.quit Exit this program \n.read FILENAME Execute SQL in FILENAME \n.schema ?TABLE? Show the CREATE statements \n.separator STRING Change separator used by output mode and .import \n.show Show the current values for various settings \n.tables ?PATTERN? List names of tables matching a LIKE pattern \n.timeout MS Try opening locked tables for MS milliseconds \n.width NUM NUM ... Set column widths for "column" mode
Install SQLite3 for Windows by downloading the following 2 zip files and unzipping them into /WINDOWS/system32 \nhttp://www.sqlite.org/sqlite-3_6_14_1.zip \nhttp://www.sqlite.org/sqlitedll-3_6_14_1.zip \nIf those don't work try the official download site here \nand now,you can open a cmd shell,and input sqlite3 like this: \n \nC:\\Documents and Settings\\Administrator>sqlite3 \nSQLite version 3.5.9 \nEnter ".help" for instructions \nand some help infos is here: \nsqlite> .help \n.bail ON|OFF Stop after hitting an error. Default OFF \n.databases List names and files of attached databases \n.dump ?TABLE? ... Dump the database in an SQL text format \n.echo ON|OFF Turn command echo on or off \n.exit Exit this program \n.explain ON|OFF Turn output mode suitable for EXPLAIN on or off. \n.header(s) ON|OFF Turn display of headers on or off \n.help Show this message \n.import FILE TABLE Import data from FILE into TABLE \n.indices TABLE Show names of all indices on TABLE \n.load FILE ?ENTRY? Load an extension library \n.mode MODE ?TABLE? Set output mode where MODE is one of: \n csv Comma-separated values \n column Left-aligned columns. (See .width) \n html HTML <table> code \n insert SQL insert statements for TABLE \n line One value per line \n list Values delimited by .separator string \n tabs Tab-separated values \n tcl TCL list elements \n.nullvalue STRING Print STRING in place of NULL values \n.output FILENAME Send output to FILENAME \n.output stdout Send output to the screen \n.prompt MAIN CONTINUE Replace the standard prompts \n.quit Exit this program \n.read FILENAME Execute SQL in FILENAME \n.schema ?TABLE? Show the CREATE statements \n.separator STRING Change separator used by output mode and .import \n.show Show the current values for various settings \n.tables ?PATTERN? List names of tables matching a LIKE pattern \n.timeout MS Try opening locked tables for MS milliseconds \n.width NUM NUM ... Set column widths for "column" mode
add this line into /etc/lftp.conf \nset net:limit-rate 10240000,40960 \n \nthat's limit upload rate to 10M,and download to 40K \n \nsome useful resource:
\ncURL figures out which protocol to use from the URL you provide, and when \"http:\" is specified will, unless otherwise instructed (using -0), default to using HTTP 1.1. The first argument, -u, instructs cURL to use the next two parameters (separated by a colon) as the account name and password for basic authentication. The next argument, -d, specifies the data (maximum 140 characters) to be sent via a POST request.\n\nOf course what cURL expects is a response to the POST request so the result will be the requested page (update.xml) sent to stdout. This page will be encoded according to the file type used in the request, thus as we just requested update.xml we’ll get XML-formatted data. The alternatives are JSON (JavaScript Object Notation), RSS and Atom formats.\n\nfrom:\nhttp://www.networkworld.com/columnists/2008/052108-gearhead.html?page=2", "created_at"=>2009-09-27 18:26:17 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
curl -u email:passw -d status="text" http://twitter.com/statuses/update.xml \ncURL figures out which protocol to use from the URL you provide, and when "http:" is specified will, unless otherwise instructed (using -0), default to using HTTP 1.1. The first argument, -u, instructs cURL to use the next two parameters (separated by a colon) as the account name and password for basic authentication. The next argument, -d, specifies the data (maximum 140 characters) to be sent via a POST request.
\n\n
Of course what cURL expects is a response to the POST request so the result will be the requested page (update.xml) sent to stdout. This page will be encoded according to the file type used in the request, thus as we just requested update.xml we’ll get XML-formatted data. The alternatives are JSON (JavaScript Object Notation), RSS and Atom formats.
项目中使用nginx,上传一个大文件,出来错误提示,413 Request Entity Too Large! \n查了下资料,解决方法:打开nginx主配置文件nginx.conf,找到http{}段,添加
\n\n
client_max_body_size 20m;
\n\n
最好也调整下: \n keepalive_timeout 105; \n免得链接超时被关!
\n\n
该文件一般在/etc/nginx/nginx.conf
\n", "_id"=>337}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["rails", "rails-2.3.4"], "comments_count"=>0, "category_id"=>6, "title"=>"rails-2.3.4 发布了", "body"=>"Ruby on Rails 2.3.4, this release fixes bugs and introduces a few minor features. Due to the inclusion of two security fixes, all users of the 2.3 series are recommended to upgrade as soon as possible.\n\nC:\\Documents and Settings\\Administrator>gem install rails\nSuccessfully installed activesupport-2.3.4\nSuccessfully installed activerecord-2.3.4\nSuccessfully installed actionpack-2.3.4\nSuccessfully installed actionmailer-2.3.4\nSuccessfully installed activeresource-2.3.4\nSuccessfully installed rails-2.3.4\n6 gems installed\nInstalling ri documentation for activesupport-2.3.4...\nInstalling ri documentation for activerecord-2.3.4...\nInstalling ri documentation for actionpack-2.3.4...\nInstalling ri documentation for actionmailer-2.3.4...\nInstalling ri documentation for activeresource-2.3.4...\nInstalling RDoc documentation for activesupport-2.3.4...\nInstalling RDoc documentation for activerecord-2.3.4...\nInstalling RDoc documentation for actionpack-2.3.4...\nInstalling RDoc documentation for actionmailer-2.3.4...\nInstalling RDoc documentation for activeresource-2.3.4...\n\n详细信息:\n\nhttp://weblog.rubyonrails.org/2009/9/4/ruby-on-rails-2-3-4", "created_at"=>2009-10-14 07:47:04 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
Ruby on Rails 2.3.4, this release fixes bugs and introduces a few minor features. Due to the inclusion of two security fixes, all users of the 2.3 series are recommended to upgrade as soon as possible.
\n\n
C:\\Documents and Settings\\Administrator>gem install rails \nSuccessfully installed activesupport-2.3.4 \nSuccessfully installed activerecord-2.3.4 \nSuccessfully installed actionpack-2.3.4 \nSuccessfully installed actionmailer-2.3.4 \nSuccessfully installed activeresource-2.3.4 \nSuccessfully installed rails-2.3.4 \n6 gems installed \nInstalling ri documentation for activesupport-2.3.4... \nInstalling ri documentation for activerecord-2.3.4... \nInstalling ri documentation for actionpack-2.3.4... \nInstalling ri documentation for actionmailer-2.3.4... \nInstalling ri documentation for activeresource-2.3.4... \nInstalling RDoc documentation for activesupport-2.3.4... \nInstalling RDoc documentation for activerecord-2.3.4... \nInstalling RDoc documentation for actionpack-2.3.4... \nInstalling RDoc documentation for actionmailer-2.3.4... \nInstalling RDoc documentation for activeresource-2.3.4...
\n", "_id"=>339}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["package", "ubuntu", "uninstall"], "comments_count"=>0, "category_id"=>7, "title"=>"Uninstall / Delete / Remove Package", "body"=>"Just use the following syntax:\n\nsudo apt-get remove {package-name}\n\nFor example remove package called mplayer, enter:\n$ sudo apt-get remove mplayer\n\nRemove package called lighttpd along with all configuration files, enter:\n$ sudo apt-get --purge remove lighttpd\n\nTo list all installed package, enter:\\\ndpkg --list\ndpkg --list | less\ndpkg --list | grep -i 'http'", "created_at"=>2009-11-22 18:48:23 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
Just use the following syntax:
\n\n
sudo apt-get remove {package-name}
\n\n
For example remove package called mplayer, enter: \n$ sudo apt-get remove mplayer
\n\n
Remove package called lighttpd along with all configuration files, enter: \n$ sudo apt-get --purge remove lighttpd
\n\n
To list all installed package, enter:\\ \ndpkg --list \ndpkg --list | less \ndpkg --list | grep -i 'http'
\n", "_id"=>340}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["delegate", "ImageMagick"], "comments_count"=>0, "category_id"=>7, "title"=>"ImageMagick够折腾得,no decode delegate", "body"=>"估计RP出问题了,以前安装和今天在mac上安装都很顺利,但是在服务器上装得时候,出现一大堆得问题,极度诡异,最后查了N多资料,改了N多东西,也不晓得最后是哪个生效了,终于折腾好了.\n记录下我参考过得资料:\nhttp://www.imagemagick.org/script/command-line-processing.php\nhttp://wanguan2000.blog.ubuntu.org.cn/2009/01/04/ubuntu-下rmagick的安装/\nhttp://infrastacks.com/?p=57\nhttp://hi.baidu.com/yttxuehui/blog/item/9f1a21978d6fa96a55fb96d5.html\nhttp://www.blogjava.net/fl1429/archive/2009/06/17/282895.html\nhttp://hi.baidu.com/countryroadtao/blog/item/225c72dad2adc16cd0164e97.html\nhttp://www.cnscn.org/htm_data/602/0705/8717.html\nhttp://stackoverflow.com/questions/1483968/imagemagick-convert-error-wrong-jpeg-library-version-library-is-62-caller-expe\n我读最后一个问题印象深刻\n\"Looks like it is reading the wrong jpeg ibrary, but I have jpeg 7 installed. How do i tell ImageMagick to look up the right JPEG library version(I don't care 62 or 70 as long as it works).\"\nroot@li84-64:/data/soft/ImageMagick-6.5.7-9# convert -list format | grep JPEG\n see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS),\n and supplement 61 which adds JPEG-2000 encoding.\n JNG* PNG rw- JPEG Network Graphics\n JP2* JP2 rw- JPEG-2000 File Format Syntax\n JPC* JPC rw- JPEG-2000 Code Stream Syntax\n JPEG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n JPG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n JPX* JPX rw- JPEG-2000 File Format Syntax\n PGX* PGX r-- JPEG-2000 VM Format\n PJPEG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n\n看到其需要得JPEG得lib是70,但是我装得是\n\nroot@li84-64:/data/soft/ImageMagick-6.5.7-9# dpkg --list | grep \"magick\"\nrc imagemagick 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation programs\nii libmagick++10 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library\nii libmagick++9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library - develop\nii libmagick10 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library\nii libmagick9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library - development fil\nii libmagickcore1 7:6.4.5.4.dfsg1-1ubuntu3.1 low-level image manipulation library\nii libmagickwand1 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation library\nii librmagick-ruby 1.15.11-1ubuntu1 ImageMagick API for Ruby\nii librmagick-ruby1.8 1.15.11-1ubuntu1 ImageMagick API for Ruby", "created_at"=>2009-11-22 20:30:32 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
root@li84-64:/data/soft/ImageMagick-6.5.7-9# dpkg --list | grep "magick" \nrc imagemagick 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation programs \nii libmagick++10 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library \nii libmagick++9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library - develop \nii libmagick10 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library \nii libmagick9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library - development fil \nii libmagickcore1 7:6.4.5.4.dfsg1-1ubuntu3.1 low-level image manipulation library \nii libmagickwand1 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation library \nii librmagick-ruby 1.15.11-1ubuntu1 ImageMagick API for Ruby \nii librmagick-ruby1.8 1.15.11-1ubuntu1 ImageMagick API for Ruby
\n", "_id"=>341}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["find", "inject", "rails", "ruby", "select"], "comments_count"=>0, "category_id"=>5, "title"=>"用Ruby在已知数组中找到和目标最匹配得元素", "body"=>"有个需求,给定一个数组,然后给出一个变量,需要在这个数组中找到和这个变量得值最接近得那个元素,开始用find或者select都不是很合适,最后找到inject,很好得解决了这个需求,现在记录下:\n首先看下inject这个函数\n````\nenum.inject(initial) {| memo, obj | block } => obj\nenum.inject {| memo, obj | block } => obj\nCombines the elements of enum by applying the block to an accumulator value (memo) and each element in turn. At each step, memo is set to the value returned by the block. The first form lets you supply an initial value for memo. The second form uses the first element of the collection as a the initial value (and skips that element while iterating).\n\n # Sum some numbers\n (5..10).inject {|sum, n| sum + n } #=> 45\n # Multiply some numbers\n (5..10).inject(1) {|product, n| product * n } #=> 151200\n\n # find the longest word\n longest = %w{ cat sheep bear }.inject do |memo,word|\n memo.length > word.length ? memo : word\n end\n longest #=> \"sheep\"\n\n # find the length of the longest word\n longest = %w{ cat sheep bear }.inject(0) do |memo,word|\n memo >= word.length ? memo : word.length\n end\n longest #=> 5\n```\n\n然后根据我得需求,写出一个函数如下:\n````\n # find the min abs size\n def self.select_h(h)\n if ALL_FORMATS.include?(h)\n return h\n else\n ok_size = ALL_FORMATS.inject do |i,j|\n (i-h).abs < (j-h).abs ? i : j\n end\n return ok_size\n end\n end\n```\n首先看是否包含这个变量,如果又,直接返回,如果没有就inject来取一个最合适得。", "created_at"=>2009-11-24 08:06:13 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
有个需求,给定一个数组,然后给出一个变量,需要在这个数组中找到和这个变量得值最接近得那个元素,开始用find或者select都不是很合适,最后找到inject,很好得解决了这个需求,现在记录下: \n首先看下inject这个函数 \n```` \nenum.inject(initial) {| memo, obj | block } => obj \nenum.inject {| memo, obj | block } => obj \nCombines the elements of enum by applying the block to an accumulator value (memo) and each element in turn. At each step, memo is set to the value returned by the block. The first form lets you supply an initial value for memo. The second form uses the first element of the collection as a the initial value (and skips that element while iterating).
\n\n
# Sum some numbers \n (5..10).inject {|sum, n| sum + n } #=> 45 \n # Multiply some numbers \n (5..10).inject(1) {|product, n| product * n } #=> 151200
\n\n
# find the longest word \n longest = %w{ cat sheep bear }.inject do |memo,word| \n memo.length > word.length ? memo : word \n end \n longest #=> "sheep"
\n\n
# find the length of the longest word \n longest = %w{ cat sheep bear }.inject(0) do |memo,word| \n memo >= word.length ? memo : word.length \n end \n longest #=> 5 \n```
\n\n
然后根据我得需求,写出一个函数如下: \n` \n # find the min abs size \n def self.select_h(h) \n if ALL_FORMATS.include?(h) \n return h \n else \n ok_size = ALL_FORMATS.inject do |i,j| \n (i-h).abs < (j-h).abs ? i : j \n end \n return ok_size \n end \n end \n \n首先看是否包含这个变量,如果又,直接返回,如果没有就inject来取一个最合适得。
\n", "_id"=>344}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["GD", "php", "ubuntu"], "comments_count"=>0, "category_id"=>7, "title"=>"Install GD Support for PHP in Ubuntu", "body"=>"I am in the process of building my blog using wordpress ,then i install SI CAPTCHA Anti-Spam ,but it's say i didn’t have GD support for PHP5 installed on my server. so i need to do:\n\nOpen terminal and type in the following command:\n
\n\nThere you go, you now have GD Support for PHP5 in Ubuntu. Get your Drupal on!", "created_at"=>2010-01-13 02:25:36 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
I am in the process of building my blog using wordpress ,then i install SI CAPTCHA Anti-Spam ,but it's say i didn’t have GD support for PHP5 installed on my server. so i need to do:
\n\n
Open terminal and type in the following command: \n$ sudo apt-get install php5-gd
\n\n
Now restart Apache \n# sudo /etc/init.d/apache2 restart
\n\n
or restart spawn-fcgi \n/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9100 -u www-data -g www-data -f /usr/bin/php-cgi -C 10
\n\n
There you go, you now have GD Support for PHP5 in Ubuntu. Get your Drupal on!
\n", "_id"=>345}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["centOS", "Swap"], "comments_count"=>0, "category_id"=>7, "title"=>"Swap Space in centOS", "body"=>"Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.\n\nSwap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.\n\nSwap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.\n\nSo, if:\n\nM = Amount of RAM in GB, and S = Amount of swap in GB, then\n
If M < 2\n\tS = M *2\nElse\n\tS = M + 2
\nUsing this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.\n\nFor systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).\n\nsource:http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-swapspace.html", "created_at"=>2010-01-21 02:01:34 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.
\n\n
Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
\n\n
Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.
\n\n
So, if:
\n\n
M = Amount of RAM in GB, and S = Amount of swap in GB, then \nIf M < 2 \n S = M *2 \nElse \n S = M + 2 \nUsing this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.
\n\n
For systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).
\n", "_id"=>346}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["劫持", "电信"], "comments_count"=>0, "category_id"=>5, "title"=>"深圳电信耍流氓,劫持浏览器", "body"=>"今天无意发现在浏览器的左下角经常出现一个页面无法打开的提示,如下\nThe webpage at http://121.15.207.133:4022/logo.jpg?p=undefined|778|1276|24|800|1280might be temporarily down or it may have moved permanently to a new web address.\n\n看其样式是请求了一个121.15.207.133上的一个logo图片,然后传入了几个参数,但是这个图片的服务器貌似除了电问题,导致请求不到。\n无缘无故的,咋会去请求这个玩意呢,查了吓这个IP归属,属于:\n
\n", "_id"=>347}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["C", "ruby", "RubyInline"], "comments_count"=>0, "category_id"=>2, "title"=>"RubyInline, Making Making Things Faster Easier", "body"=>"发现一篇好文,讲的是如何使用RubyInline,在Ruby中直接嵌入C并运行,相比之前些lib,要方便的多,由于这个文章在墙外,就转了一份过来,可以翻墙的可以去看原文\nhttp://on-ruby.blogspot.com/2006/07/rubyinline-making-making-things-faster.html\n\nToday on ruby-talk, I caught a thread called \"For Performance, Write it in C\". I'd like to present a slight amendment to that thesis. Let me explain.\n\nIt all started with an email at work. Someone was passing around a bunch of prime number printers in various languages (C, Java, C#, Perl, and Python). They all used the same (ugly) algorithm, and were supposed to show just how 'performant the languages were. Since I'm the local Ruby evangelist, I was asked to write a Ruby version. Here's what I came up with (warning, ugly algorithm ahead):\n\n#!/usr/bin/ruby\n\nfor num in 1..10_000 do\nis_prime = 1\nfor x in 2..(num - 1) do\nif (num % x == 0)\nis_prime = x\nbreak\nend\nend\nif is_prime == 1\nputs \"\#{num} is a prime number\"\nelse\nputs \"\#{num} equals \#{is_prime} * \#{num/is_prime}\"\nend\nend\nHow fast is it? Well, time says:\n\n$ time ./primes.rb > /dev/null\n\nreal 0m2.905s\nuser 0m2.716s\nsys 0m0.004s\n$\n\nCertainly, nothing to write home about, but not too far from Perl or Python either.\nWanting to improve it, and not being able to touch the algorithm (we want to be comparing apples to quinces after all, not apples to oranges). I know my only hope is to find the bottleneck(s) and rewrite it (them?) in C. My first step is to grab Ruby's profiler and see what it says (oh, by the way, I reduced the value of num to 100 so that this would complete in my lifetime ... the profiler is slow).\n\n$ ruby -rprofile primes.rb > /dev/null\n% cumulative self self total\ntime seconds seconds calls ms/call ms/call name\n63.64 0.14 0.14 101 1.39 3.56 Range#each\n13.64 0.17 0.03 1133 0.03 0.03 Fixnum#%\n9.09 0.19 0.02 1233 0.02 0.02 Fixnum#==\n4.55 0.20 0.01 100 0.10 0.20 Kernel.puts\n4.55 0.21 0.01 200 0.05 0.05 IO#write\n4.55 0.22 0.01 248 0.04 0.04 Fixnum#to_s\n0.00 0.22 0.00 74 0.00 0.00 Fixnum#/\n0.00 0.22 0.00 100 0.00 0.00 Fixnum#-\n0.00 0.22 0.00 1 0.00 220.00 #toplevel\n$\n\nWhich tells me that most of my time is spent in each (well, it's actually spent in the block I sent to each. It's taking a whopping 1.39 msec per call, compared to .0X msec for everything else. What would happen if I rewrote just that block?\nEnter RubyInline (A great tool written by zenspider and Eric Hodel). I'm not a C wiz by any stretch of the imagination, but this stuff is pretty easy to bang out. My new code looks like this:\n\n#!/usr/bin/ruby\n\nrequire \"rubygems\"\nrequire \"inline\"\n\nclass Primes\ninline do |builder|\nbuilder.c '\nint prime(int num) {\nint x;\nfor (x = 2; x < (num - 1) ; x++) { if (num == 2) { return 1; } if (num % x == 0) { return x; } } return 1; }' end end p = Primes.new for num in 2..10_000 do is_prime = p.prime(num) if is_prime == 1 puts \"\#{num} is a prime number\" else puts \"\#{num} equals \#{is_prime} * \#{num/is_prime}\" end end Not too ugly. At least I can still see what's happening. The main loop being in Ruby helps a lot too (especially if this were a much bigger program). How much of a difference does it make? time says: $ time ./cprimes.rb > /dev/null\n\nreal 0m0.328s\nuser 0m0.288s\nsys 0m0.020s\n\nAn order of magnitude improvement. Not too shabby.\nWhat's the lesson here? Optimize what you need to (and only what you need to), profile find out what that is (it may be slow, but profiling is your friend), and use the right tools (rewriting a bit of code with RubyInline is way better than rewriting the whole app in C).", "created_at"=>2010-01-24 10:51:47 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
Today on ruby-talk, I caught a thread called "For Performance, Write it in C". I'd like to present a slight amendment to that thesis. Let me explain.
\n\n
It all started with an email at work. Someone was passing around a bunch of prime number printers in various languages (C, Java, C#, Perl, and Python). They all used the same (ugly) algorithm, and were supposed to show just how 'performant the languages were. Since I'm the local Ruby evangelist, I was asked to write a Ruby version. Here's what I came up with (warning, ugly algorithm ahead):
\n\n
!/usr/bin/ruby
\n\n
for num in 1..10_000 do \nis_prime = 1 \nfor x in 2..(num - 1) do \nif (num % x == 0) \nis_prime = x \nbreak \nend \nend \nif is_prime == 1 \nputs "\#{num} is a prime number" \nelse \nputs "\#{num} equals \#{is_prime} * \#{num/is_prime}" \nend \nend \nHow fast is it? Well, time says:
\n\n
$ time ./primes.rb > /dev/null
\n\n
real 0m2.905s \nuser 0m2.716s \nsys 0m0.004s \n$
\n\n
Certainly, nothing to write home about, but not too far from Perl or Python either. \nWanting to improve it, and not being able to touch the algorithm (we want to be comparing apples to quinces after all, not apples to oranges). I know my only hope is to find the bottleneck(s) and rewrite it (them?) in C. My first step is to grab Ruby's profiler and see what it says (oh, by the way, I reduced the value of num to 100 so that this would complete in my lifetime ... the profiler is slow).
Which tells me that most of my time is spent in each (well, it's actually spent in the block I sent to each. It's taking a whopping 1.39 msec per call, compared to .0X msec for everything else. What would happen if I rewrote just that block? \nEnter RubyInline (A great tool written by zenspider and Eric Hodel). I'm not a C wiz by any stretch of the imagination, but this stuff is pretty easy to bang out. My new code looks like this:
\n\n
!/usr/bin/ruby
\n\n
require "rubygems" \nrequire "inline"
\n\n
class Primes \ninline do |builder| \nbuilder.c ' \nint prime(int num) { \nint x; \nfor (x = 2; x < (num - 1) ; x++) { if (num == 2) { return 1; } if (num % x == 0) { return x; } } return 1; }' end end p = Primes.new for num in 2..10_000 do is_prime = p.prime(num) if is_prime == 1 puts "\#{num} is a prime number" else puts "\#{num} equals \#{is_prime} * \#{num/is_prime}" end end Not too ugly. At least I can still see what's happening. The main loop being in Ruby helps a lot too (especially if this were a much bigger program). How much of a difference does it make? time says: $ time ./cprimes.rb > /dev/null
\n\n
real 0m0.328s \nuser 0m0.288s \nsys 0m0.020s
\n\n
An order of magnitude improvement. Not too shabby. \nWhat's the lesson here? Optimize what you need to (and only what you need to), profile find out what that is (it may be slow, but profiling is your friend), and use the right tools (rewriting a bit of code with RubyInline is way better than rewriting the whole app in C).
\n# Example MySQL config file for large systems.\n#\n# This is for a large system with memory = 512M where the system runs mainly\n# MySQL.\n#\n# You can copy this file to\n# /etc/my.cnf to set global options,\n# mysql-data-dir/my.cnf to set server-specific options (in this\n# installation this directory is /var/lib/mysql) or\n# ~/.my.cnf to set user-specific options.\n#\n# In this file, you can use all long options that a program supports.\n# If you want to know which options a program supports, run the program\n# with the \"--help\" option.\n\n# The following options will be passed to all MySQL clients\n[client]\nport = 3306\nsocket = /var/lib/mysql/mysql.sock\n\n# Here follows entries for some specific programs\n\n# The MySQL server\n[mysqld]\ndatadir=/var/lib/mysql\nsocket=/var/lib/mysql/mysql.sock\nuser=mysql\nskip-locking\n\n# By default, the wait_timeout value is 28800. Unless you want MySQL to keep waiting for 28800 seconds (480 minutes or 8 hours),\n# please decrease its value according to your application needs.\nwait_timeout=60\n# Increase connect_timeout from 5 to 10\nconnect_timeout=10\n# Decrease interactive_timeout from 28800 to 100\ninteractive_timeout=120\n# Increase join_buffer_size from 131072 to 1M\njoin_buffer_size=1M\n# Increase query_cache_size from 0 to 128M\nquery_cache_size=32M\n# Increase query cache limit from 1048576 to 2M\nquery_cache_limit=2M\n# Increase max allowed packet size from 1M to 16M\nmax_allowed_packet=2M\n# Increase table cache cache from 256 to 1024\ntable_cache=1024\n# Increase sort buffer size from 1M\nsort_buffer_size=2M\n# Increase read buffer size from 1M\nread_buffer_size=2M\n# Increase read_rnd_buffer_size to 4M\nread_rnd_buffer_size=4M\n\n#Other settings\nsort_buffer_size=8M\nkey_buffer = 256M\nkey_buffer_size=64M\nmyisam_sort_buffer_size = 64M\nthread_cache_size = 8\n# Try number of CPU's*2 for thread_concurrency\nthread_concurrency = 2\n\n\n# Don't listen on a TCP/IP port at all. This can be a security enhancement,\n# if all processes that need to connect to mysqld run on the same host.\n# All interaction with mysqld must be made via Unix sockets or named pipes.\n# Note that using this option without enabling named pipes on Windows\n# (via the \"enable-named-pipe\" option) will render mysqld useless!\n#\n#skip-networking\n\n# Disable Federated by default\nskip-federated\n\nold_passwords=1\n\n#for slow queries\nlog-slow-queries = /var/log/mysql-slow.log\nlong_query_time = 3\n\n[mysqldump]\nquick\nmax_allowed_packet = 16M\n\n[mysql]\nno-auto-rehash\n# Remove the next comment character if you are not familiar with SQL\n#safe-updates\n\n[isamchk]\nkey_buffer = 128M\nsort_buffer_size = 128M\nread_buffer = 2M\nwrite_buffer = 2M\n\n[myisamchk]\nkey_buffer = 128M\nsort_buffer_size = 128M\nread_buffer = 2M\nwrite_buffer = 2M\n\n[mysqlhotcopy]\ninteractive-timeout\n\n[mysqld_safe]\nlog-error=/var/log/mysqld.log\npid-file=/var/run/mysqld/mysqld.pid\n
mysql> SHOW VARIABLES like \"%sort%\";\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| max_length_for_sort_data | 1024 |\n| max_sort_length | 1024 |\n| myisam_max_sort_file_size | 2146435072 |\n| myisam_sort_buffer_size | 67108864 |\n| sort_buffer_size | 8388608 |\n+---------------------------+------------+\n5 rows in set (0.00 sec)
\n\n不晓得是做啥用的,查了下资料:\n
http://forge.mysql.com/wiki/MySQL_Internals_Algorithms\n\nUsing the modified filesort algorithm, the tuples are longer than the pairs used in the original method, and fewer of them fit in the sort buffer (the size of which is given by sort_buffer_size). As a result, it is possible for the extra I/O to make the modified approach slower, not faster. To avoid a slowdown, the optimization is used only if the total size of the extra columns in the sort tuple does not exceed the value of the max_length_for_sort_data system variable. (A symptom of setting the value of this variable too high is that you should see high disk activity and low CPU activity.)
Using the modified filesort algorithm, the tuples are longer than the pairs used in the original method, and fewer of them fit in the sort buffer (the size of which is given by sort_buffer_size). As a result, it is possible for the extra I/O to make the modified approach slower, not faster. To avoid a slowdown, the optimization is used only if the total size of the extra columns in the sort tuple does not exceed the value of the max_length_for_sort_data system variable. (A symptom of setting the value of this variable too high is that you should see high disk activity and low CPU activity.)
\n", "_id"=>353}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "filesort"], "comments_count"=>0, "category_id"=>11, "title"=>"What does Using filesort mean in MySQL?", "body"=>"一直以来,只要我看到explain出来的结果有“Using filesort ”,我就要想方设法的优化和改善,因为我以前以为这个的意思就是使用文件系统来排序(那该多慢呀!),其实不是这样的。\n在mysqlperformanceblog上看到一篇文章《What does Using filesort mean in MySQL?》其中作者说自己每次面世的时候都会问“what does Using filesort mean in EXPLAIN,” 结果没有一个人回答的是对的,结果让其比较郁闷,就写了这个文章说明:\n
The usual answer is something like “rows are being placed into a temporary table which is too big to fit in memory, so it gets sorted on disk.” Unfortunately, this is not the same thing. First of all, this is Using temporary. Secondly, temporary tables may go to disk if they are too big, but EXPLAIN doesn’t show that. (If I interview you, I might ask you what “too big” means, or I might ask you the other reason temporary tables go to disk!)
The truth is, filesort is badly named. Anytime a sort can’t be performed from an index, it’s a filesort. It has nothing to do with files. Filesort should be called “sort.” It is quicksort at heart.
\n正解是,filesort这个名字有问题,容易给人误解,在mysql中,任何不能通过index进行的sort都称之为filesort,这里的filesort和文件没有任何关系,应该称之为“sort”而不是“filesort”,它的内部实现就是快速排序。\n\n参考资料:\nWhat does Using filesort mean in MySQL?\nhttp://www.mysqlperformanceblog.com/2009/03/05/what-does-using-filesort-mean-in-mysql/\n\nHow MySQL executes ORDER BY\nhttp://s.petrunia.net/blog/?p=24", "created_at"=>2010-02-03 03:51:36 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
一直以来,只要我看到explain出来的结果有“Using filesort ”,我就要想方设法的优化和改善,因为我以前以为这个的意思就是使用文件系统来排序(那该多慢呀!),其实不是这样的。 \n在mysqlperformanceblog上看到一篇文章《What does Using filesort mean in MySQL?》其中作者说自己每次面世的时候都会问“what does Using filesort mean in EXPLAIN,” 结果没有一个人回答的是对的,结果让其比较郁闷,就写了这个文章说明: \nThe usual answer is something like “rows are being placed into a temporary table which is too big to fit in memory, so it gets sorted on disk.” Unfortunately, this is not the same thing. First of all, this is Using temporary. Secondly, temporary tables may go to disk if they are too big, but EXPLAIN doesn’t show that. (If I interview you, I might ask you what “too big” means, or I might ask you the other reason temporary tables go to disk!) \n通常的解释是:选择出来的记录太多了,需要排序时内存中放不下了,所以会存储在磁盘中,并通过操作磁盘的文件的方式来排序。但是呢,这是不对的。
\n\n
The truth is, filesort is badly named. Anytime a sort can’t be performed from an index, it’s a filesort. It has nothing to do with files. Filesort should be called “sort.” It is quicksort at heart. \n正解是,filesort这个名字有问题,容易给人误解,在mysql中,任何不能通过index进行的sort都称之为filesort,这里的filesort和文件没有任何关系,应该称之为“sort”而不是“filesort”,它的内部实现就是快速排序。
\n", "_id"=>354}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "variables"], "comments_count"=>0, "category_id"=>11, "title"=>"Mysql动态修改参数", "body"=>"mysql数据库也像ORACLE数据库一样,可以动态的修改参数,可以修改会话级变量只对当前会话产生影响;也可以修改全局变量,对所有新连接的会话都产生影响。\n\n修改会话级变量\n用show variables 命令查看当前参数的值,like 'pattern'用于模式匹配,查找指定的参数\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n用set SESSION命令设置会话级变量的新值\n\nmysql> set SESSION sort_buffer_size=7000000;\nQuery OK, 0 rows affected (0.00 sec)\n\n--修改会话级变量对当前会话来说立刻生效\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 7000000 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\nmysql> exit\nBye\n退出重新连接后,此参数恢复原值\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 40 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n修改全局变量\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 40 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n用set GLOBAL 命令设置全局变量\n\nmysql> set GLOBAL sort_buffer_size = 7000000;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n当前此参数的值并不发生变化,先退出,然后重新连进去\nmysql> exit\nBye\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 41 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 7000000 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n新的参数值生效", "created_at"=>2010-02-03 04:00:12 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
--修改会话级变量对当前会话来说立刻生效 \nmysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 7000000 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
mysql> exit \nBye \n退出重新连接后,此参数恢复原值 \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 40 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
修改全局变量 \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 40 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
用set GLOBAL 命令设置全局变量
\n\n
mysql> set GLOBAL sort_buffer_size = 7000000; \nQuery OK, 0 rows affected (0.00 sec)
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec) \n当前此参数的值并不发生变化,先退出,然后重新连进去 \nmysql> exit \nBye \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 41 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 7000000 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec) \n新的参数值生效
\n", "_id"=>356}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Tips"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Textmate", "theme"], "comments_count"=>0, "category_id"=>4, "title"=>"Installing a New Textmate Theme", "body"=>"To install a new theme, select one of the .tmTheme links listed below, download it to your desktop and double-click on the file. This will place it in ~/Library/Application Support/TextMate/Themes, at which point the new theme will appear in the list found in Preferences → Fonts & Colors. This will also set it as the active theme. (Once the theme is installed, you may remove the .tmTheme from your desktop.)\n\nRails Envy TextMate Theme\n http://railsenvy.com/2008/9/18/rails-envy-textmate-theme\n\nUser Submitted Themes\n http://wiki.macromates.com/Themes/UserSubmittedThemes", "created_at"=>2010-02-04 18:24:02 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
To install a new theme, select one of the .tmTheme links listed below, download it to your desktop and double-click on the file. This will place it in ~/Library/Application Support/TextMate/Themes, at which point the new theme will appear in the list found in Preferences → Fonts & Colors. This will also set it as the active theme. (Once the theme is installed, you may remove the .tmTheme from your desktop.)
\n\nrestart teatmate and it's done!\n\nIn the TextMate preferences, advanced tab, shell variables, set the TM_GIT variable to point to your installation of git (ie /usr/local/bin/git)\nMany shortcuts are available from the Git-shortcut (Ctrl-Shift-G). Subversion commands are Command-Option-g. Less frequent commands are accessed via the menu.\nUpdate your bundle by running the “Update Git Bundle” command.", "created_at"=>2010-02-04 23:39:24 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
In the TextMate preferences, advanced tab, shell variables, set the TM_GIT variable to point to your installation of git (ie /usr/local/bin/git) \nMany shortcuts are available from the Git-shortcut (Ctrl-Shift-G). Subversion commands are Command-Option-g. Less frequent commands are accessed via the menu. \nUpdate your bundle by running the “Update Git Bundle” command.
SIMBL (SIMple Bundle Loader) - pronounced like \"symbol\" or \"cymbal\" - enables hacks and plugins. For instance, SIMBL enables PithHelmet to enhance Safari.
Install SIMBL and make sure you have latest SIMBL 0.9.x\nPlace Visor.bundle into ~/Library/Application Support/SIMBL/Plugins (create this directory if it does not exist)\nRelaunch Terminal.app - You should now see the Visor Status Menu Item\nConfigure your keyboard trigger by selecting the Visor Status Menu Item -> Visor Preferences ... and edit your keyboard hot-key\nYou can now trigger Visor with your hot-key from any application to get an instant terminal session.\n\nTo hide Visor, you can either:\nre-trigger with your key-combo\noptionally you can click off of the Visor window
如果你和我一样经常使用终端程序,这个小程序一定可以帮到你。他能将终端窗口变成类似雷神或CS那样的下拉窗口,非常酷。 \n可以从这里下载 http://visor.binaryage.com/ \n这个软件需要SIMBL ,如果你没有安装,要先安装这个。 \nhttp://www.culater.net/software/SIMBL/SIMBL.php \nSIMBL (SIMple Bundle Loader) - pronounced like "symbol" or "cymbal" - enables hacks and plugins. For instance, SIMBL enables PithHelmet to enhance Safari. \n之后将下载下来的文件解压,将解压后的文件拷贝至/Library/Application Support/SIMBL/Plugins,之后再重新启动你的终端你就可以看到效果了。 默认的快捷启动键是Ctrl+` \nvisor: http://visor.binaryage.com/
\n\n
Installation
\n\n
Install SIMBL and make sure you have latest SIMBL 0.9.x \nPlace Visor.bundle into ~/Library/Application Support/SIMBL/Plugins (create this directory if it does not exist) \nRelaunch Terminal.app - You should now see the Visor Status Menu Item \nConfigure your keyboard trigger by selecting the Visor Status Menu Item -> Visor Preferences ... and edit your keyboard hot-key \nYou can now trigger Visor with your hot-key from any application to get an instant terminal session.
\n\n
To hide Visor, you can either: \nre-trigger with your key-combo \noptionally you can click off of the Visor window
前段时间写了一篇《实例优化mysql配置文件my.cnf》,这几天看到效果非常明显,别的不说,单mysql cache_hits就很不错(之前竟然没注意到这个参数) \n# Increase query_cache_size from 0 to 128M \nquery_cache_size=128M
Rails 3 in Action by Yehuda Katz and Mike Gunderloy. Currently available is their Early Access Edition, which gives you access to chapters as they are written.
\n\t
Beginning Rails 3 by Jeffrey Allan Hardy , Cloves Carneiro Jr. & Rida Al Barazi
这次升级需要新装很多的gem,如下: \ngem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n \ngem install rails --pre \n期间遇到一个错误: \nDue to a rubygems bug, you must uninstall all older versions of bundler for 0.9 to work \n然后这边有N多关于Rails3的资料供参考:
\n\n
Rails 3 Tutorials & Blog Posts
\n\n
Edging your way towards Ruby 1.9.1 and Rails 3.0pre \n Unobtrusive JavaScript in Rails 3 by Zach Carter \n A Fresh Cup: Seed Data in Rails 3 tutorial – feature summary + code example by Mike Gunderloy. \n Rails3: Stepping off of the golden path slides by Matt Aimonetti \n Rails Magazine – RailsConf 2009 Edition page 5 has a section called The Unofficial Guide to What’s New in Rails 3 by Rupak Ganguly \n Jason Ting’s RailsConf 2009 Notes includes some basic notes about Rails 3 \n Noel Rappin: Railsconf 09 – After the RailsConfening article \n Yehuda Katz: Railsconf Wrapup blog – contains links to jQuery talk by Katz at RailsConf 09 \n How to Begin Playing With Rails 3 by Oscar Del Ben \n My Five Favorite Things About Rails 3 by Yehuda Katz \n Rails 3: The Great Decoupling by Yehuda Katz \n Rails Edge Architecture by Yehuda Katz \n How to Build Sinatra on Rails 3 by Yehuda Katz
\n\n
Rails 3 Presentations & Conference Talks
\n\n
Yehuda: What to Expect in Rails 3.0 webcast recording \n Scotland on Rails: Yehuda on Rails & Merb Merge video. For more Scotland on Rails videos, check out this Ruby Inside post. \n Yehuda Katz on Rails 3 and beyond interview by Mark Coleman \n RailsConf: Yehuda – The Russian Doll Pattern video \n RailsConf 09: DHH Keynote video – DHH previews unobtrusive javascript, default escaping & more.
\n\n
Rails 3 Books
\n\n
Rails 3 in Action by Yehuda Katz and Mike Gunderloy. Currently available is their Early Access Edition, which gives you access to chapters as they are written. \n Beginning Rails 3 by Jeffrey Allan Hardy , Cloves Carneiro Jr. & Rida Al Barazi
\n\n
Rails 3 Commentary
\n\n
Internet News: Rails 3 Gets Supersized With Merb \n eWeek: Rubyists Unite Ruby on Rails and Merb to Merge in Rails 3 \n CIO: Rails 3 to add security enhancement \n Yehuda Katz: Rails and Merb Merge \n RubyOnRails.org: Rails + Merb Merge Announcement
\n", "_id"=>361}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"02. 产品设计 | PM"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Axure", "Balsamiq Mockups", "原型设计"], "comments_count"=>0, "category_id"=>13, "title"=>"Balsamiq Mockups,理想的原型设计工具", "body"=>"由于经常要讨论产品,包括web和手机(\bAandroid,Iphone)的产品原型设计,尝试过很多的原型设计工具,例如Axure等,后来换了mac book,就一直找不到合适的原型设计工具,就一直在Google Doc中直接draw,其做了很多无用功。\n比较偶然的机会看到Balsamiq Mockups这个软件,和Pixelmator一样,是个人开发者(意大利人Peldi)开发的产品,其地址为http://www.balsamiq.com/ ,在其提供的demo页面上试了下http://www.balsamiq.com/demos/mockups/Mockups.html,效果很好,符合我的预期。\n虽然是由个人设计的,但功能却一点不弱于其他大牌的原型设计工具:\n操作方面,拖拽,控件分组,甚至元素之间的对齐都做得很贴心;\n预制了很多界面元素,从简单的输入框,下拉框,浏览器主要元素,到经常用得到的导航条,日历,表格,到复杂的Tag Cloud,Cover Flow, 地图,WYSWYG的格式工具栏等,有了这些不用从头画起,往往比用白板都快;\n界面元素的修改很简单,比如导航条的几个标签页的label,就是用逗号分隔的文字,下拉框的选项就是分行的文字;\n使用xml语言来记录和保存界面元素和布局,\n这使得每个设计都能被很好得放进SVN,Git,和CVS等工具中进行管理和跟踪;\n可以设计复杂的界面元素,保存后,以后可以重复使用(包括修改);\n可以将设计导出成PNG格式的图片;\n可以用命令行进行导出操作,这样就能让我写个脚本,从svn里checkout某个目录下的所有设计文件后,导出图片,打包后用邮件发到项目经理,工程师甚至客户那;\n跨平台,Balsamiq Mokups是用Flex和Air实现的,所以在Mac OS, Linux和Windows下都能使用;\n不仅仅有桌面版本,还有能集成在Confluence,JIRA,和XWiki中的版本,使得异地在线协作更方便有效。\n\n以下是关于Balsamiq Mockups的一些特点:\n易操作:从 Balsamiq Mockups 自带的元素里可以很方便地拖拽,效果图轻易形成;元素对齐很贴心;\n可偷懒:根据 Balsamiq Mockups 提供的 Wiki 风格的代码规则,画图时可以「偷懒」,输入文本符号则能生成图标。因此相比其它繁琐的软件操作,Balsamiq Mockups 也能更快地完成画图任务。\n控件足:Balsamiq Mockups 软件包括 50 多个控件, 70 多个图标。基本自带了所有常用的小控件,并在导航处进行分类;图标设计赏心悦目。要是 Balsamiq Mockups 允许用户导入自定义的控件就更好了,当然现有的也足够了 -\n新风格:让人眼前一亮的涂鸦风格,很能还原手绘效果;\n可中文:在菜单栏 View 里将 Use System Fonts 勾上,就能完美支持中文输入(注:非 Balsamiq Mockups 中文版);\n其它点:Balsamiq Mockups 使用 xml 记录,方便移植、二次利用;可导出为 png 格式图片。\n\n另外还有跨平台与多版本两个优点:\n跨平台:Balsamiq Mockups 基于 Air ,因此能同时在 Windows、Mac OS 及 Linux 下使用;\n多版本:包括桌面版本,以及集成于 Confluence、JIRA、XWiki、FogBugz 中的版本\n\n软件可以从其网站上下载,其中桌面版本售价是$79。但作者非常厚道,提供了几种免费使用的方式:http://www.balsamiq.com/products/mockups/desktop\n\nYou can download Mockups for Desktop for free. Some of the features of the app, like saving and loading multiple mockups or linking mockups together can only get unlocked using a license key.\n", "created_at"=>2010-02-21 18:39:26 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
You can download Mockups for Desktop for free. Some of the features of the app, like saving and loading multiple mockups or linking mockups together can only get unlocked using a license key.
\n", "_id"=>362}])
+MONGODB iceylog_development['categories'].find({:_id=>13}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>13}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "socket"], "comments_count"=>0, "category_id"=>3, "title"=>"Can’t connect to local MySQL server through socket 解决办法", "body"=>"Rails启动后报错,ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/temp/mysql.sock’ (2)\n\n1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.\n另外看看是不是权限问题.\n\n2、确定你的mysql.sock是不是在那个位置,\nmysql -u 你的mysql用户名 -p -S /var/lib/mysql/mysql.sock\n\n3、试试:service mysqld start\n\n4、如果是权限问题,则先改变权限 #chown -R mysql:mysql /var/lib/mysql\n\n[root@localhost ~]# /etc/init.d/mysqld start\n启动 MySQL: [ 确定 ]\n[root@localhost ~]# mysql -uroot -p", "created_at"=>2010-02-23 21:24:14 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
Rails启动后报错,ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/temp/mysql.sock’ (2)
\n\n
1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动. \n另外看看是不是权限问题.
\n", "_id"=>363}])
+MONGODB iceylog_development['categories'].find({:_id=>3}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>3}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Passenger", "REE"], "comments_count"=>0, "category_id"=>2, "title"=>"Download Ruby Enterprise Edition(REE)", "body"=>"前段时间用上了Passenger ,尔后就看到很多的人推荐使用Ruby Enterprise Edition(REE),今天得闲,试了一把。\nStep 1: Download\nSource code: version 1.8.7-2010.01\nStep 2: Install\nExtract it:\ntar xzvf ruby-enterprise-X.X.X.tar.gz\nRun the installer (completely safe, none of your system files will be touched!):\n./ruby-enterprise-X.X.X/installer\n
Welcome to the Ruby Enterprise Edition installer
\n
This installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.
\n
Don't worry, none of your system files will be touched if you don't want them
\n
to, so there is no risk that things will screw up.
\n
You can expect this from the installation process:
\n
1. Ruby Enterprise Edition will be compiled and optimized for speed for this
\n
system.
\n
2. Ruby on Rails will be installed for Ruby Enterprise Edition.
\n
3. You will learn how to tell Phusion Passenger to use Ruby Enterprise
\n
Edition instead of regular Ruby.
\n
Press Enter to continue, or Ctrl-C to abort.
\n
Welcome to the Ruby Enterprise Edition installerThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.Don't worry, none of your system files will be touched if you don't want themto, so there is no risk that things will screw up.\nYou can expect this from the installation process:\n1. Ruby Enterprise Edition will be compiled and optimized for speed for this system.\n\n2. Ruby on Rails will be installed for Ruby Enterprise Edition.\n\n3. You will learn how to tell Phusion Passenger to use Ruby Enterprise Edition instead of regular Ruby.\nPress Enter to continue, or Ctrl-C to abort.
\nStep 3: Make Phusion Passenger use Ruby Enterprise Edition instead of regular Ruby\nFollow the instructions that the Ruby Enterprise Edition installer gave you.", "created_at"=>2010-03-03 16:53:29 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
前段时间用上了Passenger ,尔后就看到很多的人推荐使用Ruby Enterprise Edition(REE),今天得闲,试了一把。 \nStep 1: Download \nSource code: version 1.8.7-2010.01 \nStep 2: Install \nExtract it: \ntar xzvf ruby-enterprise-X.X.X.tar.gz \nRun the installer (completely safe, none of your system files will be touched!): \n./ruby-enterprise-X.X.X/installer \nWelcome to the Ruby Enterprise Edition installer \nThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01. \nDon't worry, none of your system files will be touched if you don't want them \nto, so there is no risk that things will screw up. \nYou can expect this from the installation process: \n1. Ruby Enterprise Edition will be compiled and optimized for speed for this \nsystem. \n2. Ruby on Rails will be installed for Ruby Enterprise Edition. \n3. You will learn how to tell Phusion Passenger to use Ruby Enterprise \nEdition instead of regular Ruby. \nPress Enter to continue, or Ctrl-C to abort. \nWelcome to the Ruby Enterprise Edition installerThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.Don't worry, none of your system files will be touched if you don't want themto, so there is no risk that things will screw up. \nYou can expect this from the installation process: \n1. Ruby Enterprise Edition will be compiled and optimized for speed for this system.
\n\n\n
Ruby on Rails will be installed for Ruby Enterprise Edition.
\n
You will learn how to tell Phusion Passenger to use Ruby Enterprise Edition instead of regular Ruby. \nPress Enter to continue, or Ctrl-C to abort. \nStep 3: Make Phusion Passenger use Ruby Enterprise Edition instead of regular Ruby \nFollow the instructions that the Ruby Enterprise Edition installer gave you.
\n\n", "_id"=>364}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"02. 产品设计 | PM"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Border-radius", "css3"], "comments_count"=>0, "category_id"=>13, "title"=>"Border-radius: create rounded corners with CSS!", "body"=>"W3C has offered some new options for borders in CSS3, of which one is border-radius. Both Mozila/Firefox and Safari 3 have implemented this function, which allows you to create round corners on box-items. This is an example:\n\nMozilla/Firefox and Safari 3 users should see a nicely rounded box, with a nicely rounded border.\nThe code for this example above is actually quite simple:\n\nThese different corners can also each be handled on their own, Mozilla has other names for the feature than the spec says it should have though, as it has f.i. -moz-border-radius-topright as opposed to -webkit-border-top-right-radius:\n\nMozilla/Firefox and Safari 3 users should see a box with a rounded left upper corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded right upper corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded left lower corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded right lower corner.\nThese are handled by / should be handled by:\n\n````-moz-border-radius-topleft / -webkit-border-top-left-radius\n-moz-border-radius-topright / -webkit-border-top-right-radius\n-moz-border-radius-bottomleft / -webkit-border-bottom-left-radius\n-moz-border-radius-bottomright / -webkit-border-bottom-right-radius```", "created_at"=>2010-03-05 10:38:13 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
W3C has offered some new options for borders in CSS3, of which one is border-radius. Both Mozila/Firefox and Safari 3 have implemented this function, which allows you to create round corners on box-items. This is an example:
\n\n
Mozilla/Firefox and Safari 3 users should see a nicely rounded box, with a nicely rounded border. \nThe code for this example above is actually quite simple: \n \nThese different corners can also each be handled on their own, Mozilla has other names for the feature than the spec says it should have though, as it has f.i. -moz-border-radius-topright as opposed to -webkit-border-top-right-radius:
\n\n
Mozilla/Firefox and Safari 3 users should see a box with a rounded left upper corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded right upper corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded left lower corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded right lower corner. \nThese are handled by / should be handled by:
\n", "_id"=>367}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["action_mailer_optional_tls", "Gmail", "Redmine"], "comments_count"=>0, "category_id"=>2, "title"=>"Setup Redmine to send email using GMail", "body"=>"Redmine是用Rails写的一套很不错的项目管理系统,其提供了诸多很方便实用的功能,诸如里程碑管理,BUG跟踪,代码库变更管理等等。\n搭建以后在管理面板中测试邮件不通,主要原因是由于采用的Gmail的邮箱,于是找到一些解决方案,如下:\n1. Install the action_mailer_optional_tls plugin\nThe action_mailer_optional_tls_plugin adds a TLS option to Redmine's emailing library, ActionMailer. TLS is a version of SSL which is required by GMail in order to send email.\n\nTo install this plugin, use the script/plugin command in your Redmine directory:\n ./script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git\n\n2. Configure your email.yml\n# File: config/email.yml\nproduction:\n delivery_method: :smtp\n smtp_settings:\n tls: true\n address: \"smtp.gmail.com\"\n port: 587\n domain: \"www.YOURDOAMIN.com\" # 'your.domain.com' for GoogleApps\n authentication: :plain\n user_name: \"username@youdomain.com\"\n password: \"password\"\n\n3. Start up Redmine and test your Email\nNext it's time to start up Redmine and to send a test email. Make sure that you start Redmine in the same mode as you configured above (e.g. production). To send a test email:\nLogin as an administrator\nGo to the Administration panel\nGo into the Settings and select the \"Email notifications\" tab\nIn the bottom right, click the link to \"Send a test email\"", "created_at"=>2010-03-14 18:31:57 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
Redmine是用Rails写的一套很不错的项目管理系统,其提供了诸多很方便实用的功能,诸如里程碑管理,BUG跟踪,代码库变更管理等等。 \n搭建以后在管理面板中测试邮件不通,主要原因是由于采用的Gmail的邮箱,于是找到一些解决方案,如下: \n1. Install the action_mailer_optional_tls plugin \nThe action_mailer_optional_tls_plugin adds a TLS option to Redmine's emailing library, ActionMailer. TLS is a version of SSL which is required by GMail in order to send email.
\n\n
To install this plugin, use the script/plugin command in your Redmine directory: \n ./script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git
3. Start up Redmine and test your Email \nNext it's time to start up Redmine and to send a test email. Make sure that you start Redmine in the same mode as you configured above (e.g. production). To send a test email: \nLogin as an administrator \nGo to the Administration panel \nGo into the Settings and select the "Email notifications" tab \nIn the bottom right, click the link to "Send a test email"
\n", "_id"=>369}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["concat", "Database"], "comments_count"=>0, "category_id"=>3, "title"=>"MySQL CONCAT", "body"=>"MySQL CONCAT function is used to concatenate two strings to form a single string. Try out following example:\nmysql> SELECT CONCAT('FIRST ', 'SECOND');\n+----------------------------+\n| CONCAT('FIRST ', 'SECOND') |\n+----------------------------+\n| FIRST SECOND |\n+----------------------------+\n1 row in set (0.00 sec)\n\nie.\nmysql -u eoewallpapers -p123456123 wallpapers -e 'set names 'utf8'; select CONCAT(base_url,\"400\",title) from photos where state > 10 ' > photos_400.txt", "created_at"=>2010-03-19 20:34:34 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
MySQL CONCAT function is used to concatenate two strings to form a single string. Try out following example: \nmysql> SELECT CONCAT('FIRST ', 'SECOND'); \n+----------------------------+ \n| CONCAT('FIRST ', 'SECOND') | \n+----------------------------+ \n| FIRST SECOND | \n+----------------------------+ \n1 row in set (0.00 sec)
\n\n
ie. \nmysql -u eoewallpapers -p123456123 wallpapers -e 'set names 'utf8'; select CONCAT(base_url,"400",title) from photos where state > 10 ' > photos_400.txt
alias ls=”ls -G”是给”ls -G”起了一个别名,当执行ls时,就相当于执行了ls -G。
\n\n
CLICOLOR是用来设置是否进行颜色的显示。CLI是Command Line Interface的缩写。 \nLSCOLORS是用来设置当CLICOLOR被启用后,各种文件类型的颜色。LSCOLORS的值中每两个字母为一组,分别设置某个文件类型的文字颜色和背景颜色。LSCOLORS中一共11组颜色设置,按照先后顺序,分别对以下的文件类型进行设置:
\n\n
directory \nsymbolic link \nsocket \npipe \nexecutable \nblock special \ncharacter special \nexecutable with setuid bit set \nexecutable with setgid bit set \ndirectory writable to others, with sticky bit \ndirectory writable to others, without sticky bit \nLSCOLORS中,字母代表的颜色如下:
\n", "_id"=>375}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["10.6.3", "rails3", "railties"], "comments_count"=>0, "category_id"=>7, "title"=>"解决升级mac OS 10.6.3后rails3无法启动的问题", "body"=>"昨晚看hero的时候顺带update到mac OS 10.6.3,早上重启机器安装成功,发现rails3无法启动,报:\n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception)\nfrom /usr/bin/rails:19\n\n这个错误我之前安装rails3的时候遇到过,解决如下:\n1.先尝试下重新安装rails\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install rails --pre\nPassword:\nSuccessfully installed treetop-1.4.5\n1 gem installed\nInstalling ri documentation for treetop-1.4.5...\nInstalling RDoc documentation for treetop-1.4.5..\n发现多了个treetop的gem,查查是啥:\n
Treetop is a language for describing languages. Combining the elegance of Ruby with cutting-edge parsing expression grammars, it helps you analyze syntax with revolutionarily ease.
\n\n再次执行rails,发现\n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception)\n from /usr/bin/rails:19\n\n还是不行,那就是railties的问题了,重新装下\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install railties --pre\nSuccessfully installed railties-3.0.0.beta\n1 gem installed\nInstalling ri documentation for railties-3.0.0.beta...\nInstalling RDoc documentation for railties-3.0.0.beta...\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ rails -v\nRails 3.0.0.beta\n\nOK,可以了~", "created_at"=>2010-03-31 22:01:38 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
昨晚看hero的时候顺带update到mac OS 10.6.3,早上重启机器安装成功,发现rails3无法启动,报: \n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception) \nfrom /usr/bin/rails:19
\n\n
这个错误我之前安装rails3的时候遇到过,解决如下: \n1.先尝试下重新安装rails \nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install rails --pre \nPassword: \nSuccessfully installed treetop-1.4.5 \n1 gem installed \nInstalling ri documentation for treetop-1.4.5... \nInstalling RDoc documentation for treetop-1.4.5.. \n发现多了个treetop的gem,查查是啥: \nTreetop is a language for describing languages. Combining the elegance of Ruby with cutting-edge parsing expression grammars, it helps you analyze syntax with revolutionarily ease.
\n\n
再次执行rails,发现 \n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception) \n from /usr/bin/rails:19
做移动互联网的过程中,有这样一些词是必须知道的,如MO,MT,GSM,LINKID \n上行(MO)上行的意思就是短信发送到服务器端 MO又称 Mobile Original \n下行(MT)下行的意思就是短信从服务器端发回到手机上,MT又称Mobile Terminated \n简单的说,从手机发起一个的过程叫上行(MO),到手机结束的过程叫下行(MT),比如,平时给你的朋友发送一条短信,对你来说就是上行(MO),而对你的朋友来说,就是下行(MT)。在企业、行业应用中,从系统给手机发送信息的过程叫下行(MT),而手机发送信息给系统的过程叫上行(MO)。
\n", "_id"=>385}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["log", "rails3", "slice_before"], "comments_count"=>0, "category_id"=>2, "title"=>"Parse Rails 3 log file using Enumerable#slice_before", "body"=>"``def parse_rails_log_file(file)\n # Remove all empty lines\n lines = file.each_line.map(&:strip).reject(&:empty?)\n\n # Use +Enumerable#slice_before+ to slice log file into sections for each request\n lines.slice_before(/Started (GET|POST|PUT|DELETE)/).each_with_object({}) do |request_log, totals|\n # Only include successfully finished actions in report\n if duration = request_log.last[/Completed 200 OK in (?<duration>\\d+)ms/, :duration]\n action_name = request_log.first[/Started (GET|POST|PUT|DELETE) \"(?<action>.+?)\" for/, :action]\n totals[action_name] ||= 0\n totals[action_name] += duration.to_i\n end\n end\nend\n\nif __FILE__ == $PROGRAM_NAME\n require \"pp\"\n puts \"Parsing Rails 3 log file (extracting cumulative running time per request path):\"\n puts \"=================\"\n\n log_file = <<-LOG_FILE\n Started GET \"/index\" for 192.168.74.1 at 2010-03-09 11:37:40\n Processing by UpdatesController#index as HTML\n Update Load (0.5ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (16.7ms)\n Completed 200 OK in 71ms (Views: 44.3ms | ActiveRecord: 0.5ms)\n\n Started POST \"/updates\" for 192.168.74.1 at 2010-03-09 11:37:43\n Processing by UpdatesController#create as HTML\n Parameters: {\"commit\"=>\"Save changes\"}\n Update Load (0.4ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (1.3ms)\n Completed 200 OK in 60ms (Views: 32.1ms | ActiveRecord: 0.4ms)\n\n Started GET \"/updates\" for 192.168.74.1 at 2010-03-09 11:45:51\n Processing by UpdatesController#index as HTML\n\n TypeError (exception class/object expected):\n app/controllers/updates_controller.rb:3:in `raise'\n app/controllers/updates_controller.rb:3:in `index'\n\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.6ms)\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.9ms)\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb (23.9ms)\n\n Started GET \"/updates\" for 192.168.74.1 at 2010-03-09 11:45:58\n Processing by UpdatesController#index as HTML\n Update Load (0.3ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (1.1ms)\n Completed 200 OK in 100ms (Views: 29.3ms | ActiveRecord: 0.3ms)\n LOG_FILE\n\n pp parse_rails_log_file(log_file) # => {\"/index\"=>71, \"/updates\"=>160}\nend```", "created_at"=>2010-07-26 21:42:33 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
# Use +Enumerable#slice_before+ to slice log file into sections for each request \n lines.slice_before(/Started (GET|POST|PUT|DELETE)/).each_with_object({}) do |request_log, totals| \n # Only include successfully finished actions in report \n if duration = request_log.last[/Completed 200 OK in (?<duration>\\d+)ms/, :duration] \n action_name = request_log.first[/Started (GET|POST|PUT|DELETE) "(?<action>.+?)" for/, :action] \n totals[action_name] ||= 0 \n totals[action_name] += duration.to_i \n end \n end \nend
\n\n
if FILE == $PROGRAM_NAME \n require "pp" \n puts "Parsing Rails 3 log file (extracting cumulative running time per request path):" \n puts "================="
\n\n
log_file = <<-LOG_FILE \n Started GET "/index" for 192.168.74.1 at 2010-03-09 11:37:40 \n Processing by UpdatesController#index as HTML \n Update Load (0.5ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (16.7ms) \n Completed 200 OK in 71ms (Views: 44.3ms | ActiveRecord: 0.5ms)
\n\n
Started POST "/updates" for 192.168.74.1 at 2010-03-09 11:37:43 \n Processing by UpdatesController#create as HTML \n Parameters: {"commit"=>"Save changes"} \n Update Load (0.4ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (1.3ms) \n Completed 200 OK in 60ms (Views: 32.1ms | ActiveRecord: 0.4ms)
\n\n
Started GET "/updates" for 192.168.74.1 at 2010-03-09 11:45:51 \n Processing by UpdatesController#index as HTML
Started GET "/updates" for 192.168.74.1 at 2010-03-09 11:45:58 \n Processing by UpdatesController#index as HTML \n Update Load (0.3ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (1.1ms) \n Completed 200 OK in 100ms (Views: 29.3ms | ActiveRecord: 0.3ms) \n LOG_FILE
\n写完申明后,去看消息出处看到其竟然做了修改,我早料到其会做相关的行为,所有早些时候截了屏幕如下:\n\n\n\n而现在的文章被修改为:\n\n\n\n看我用鼠标标识的地方,对关键信息进行了修改,感兴趣的人可以去 http://mobile.venturebeat.com/2010/07/28/android-wallpaper-app-that-steals-your-data-was-downloaded-by-millions/ 查看原文,对于这种标题党用子虚乌有的事情炒作,等消息传播后再修改自己的内容算什么行为!而对国内部分媒体在传播时不但不对真实性进行验证,还添油加醋,歪曲意思的报道,我非常无奈(看到有人还说可以获取信用卡信息,还加密传输,我实在无语)。\n\n按照我个人的感觉,他们应该紧接着要开始拿这个事件来炒作自己的产品了,我个人懒得去关注,如果有人发现有人借此炒作自己的产品,请帮忙分析分析,看看到底是什么人用这样手法。\n\n再次update!!!\n\n通过email和mylookout的人取得联系,说明我取得诸如设备号,手机屏幕大小是为了更智能的给设备适配图片,而获取部分的sim卡号是后来用户反馈说自己换了手机还想使用之前的收藏记录才使用的,这些信息只在该应用中使用,并没提供给任何第三方!\n\n同时让其确认venturebeat上文章中说到的获取浏览器历史,短信息,密码等高敏感性信息是否是他们说的还是写文章的人自己写的(Lots of my users send me the email ask me why I collect their text message and voicemail passward, I just want to make sure whether you and your ceo said that I collected browsing history,text message ,voicemail passward during the meeting.)。\n\n其cto给我回复说他们没有说过我的应用获取过诸如text messages or browsing history这些信息( We never stated that the wallpaper applications gathered users text messages or browsing history.),是媒体在撰写和传播的时候错误报道了(A member of the press misreported our research and he has since corrected it. )。\n\n我非常无语~\n\n2010年8月4日第二次次update!\n\n多谢这些天很多朋友的关心,我很好,谢谢!这些天和google android组,lookout公司和venturebeat的作者,以及国内外很多媒体,博客们,记者们都有很多的接触。\n\n1. google就前段时间将应用暂停和我一起分析了这个应用,今天发来调查的结果:\n\nOur investigation has concluded that there's no obvious malicious code in your apps, though the implementation accesses data that it doesn't need to. We've restored your apps (and they'll be available on Market again once you publish them), and are looking forward to seeing them updated to use ANDROID_ID. We are likely to make a statement about this issue this week--I'll let you know.\n\n我早就说过,我配合调查,我把代码提供给他们,google也做出了公正的评判,另外也给我提了一些建议(ANDROID_ID)。\n\n2. 当时写这篇报道的venturebeat记者Dean Takahashi发来了mail,为自己犯的错误道歉,并道歉该事带来的恶劣影响,会再写一篇文章澄清这个事情以消除影响。\n\n3. 那个安全公司lookout的人写邮件来要于我一起“ We wanted to coordinate with you to prevent further misunderstandings. ”。\n\n4.好几个不认识的国外记者很负责任,发邮件和gt和我交流询问事情的真相,并帮我喊冤,谢谢这些有职业精神的记者们。\n\n这个事情到这差不多就结束了,其中看到很多假丑恶,也看到很多真善美!谢谢所有帮助过我的人(很多很多,就不一一列举)。", "created_at"=>2010-07-29 08:41:39 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
同时让其确认venturebeat上文章中说到的获取浏览器历史,短信息,密码等高敏感性信息是否是他们说的还是写文章的人自己写的(Lots of my users send me the email ask me why I collect their text message and voicemail passward, I just want to make sure whether you and your ceo said that I collected browsing history,text message ,voicemail passward during the meeting.)。
\n\n
其cto给我回复说他们没有说过我的应用获取过诸如text messages or browsing history这些信息( We never stated that the wallpaper applications gathered users text messages or browsing history.),是媒体在撰写和传播的时候错误报道了(A member of the press misreported our research and he has since corrected it. )。
Our investigation has concluded that there's no obvious malicious code in your apps, though the implementation accesses data that it doesn't need to. We've restored your apps (and they'll be available on Market again once you publish them), and are looking forward to seeing them updated to use ANDROID_ID. We are likely to make a statement about this issue this week--I'll let you know.
\n", "_id"=>387}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Munin", "netstat", "passive"], "comments_count"=>0, "category_id"=>7, "title"=>"Fix the passive netstat connections in Munin", "body"=>"\n\nIf your running Munin in WHM they you may have noticed the passive netstat connections have been rising steadily over the last couple of weeks. This isn't a problem with your server, its a Munin bug that can be easily fixed.\n\n\n\n\n\nApparently the problem stemms from Munin counting the passive connections rejected. You can fix this problem quite easily by following the instructions below\n\nEdit the following file:\n/usr/share/munin/plugins/netstat\n\nand change the line\n
If your running Munin in WHM they you may have noticed the passive netstat connections have been rising steadily over the last couple of weeks. This isn't a problem with your server, its a Munin bug that can be easily fixed.
\n\n\n\n
Apparently the problem stemms from Munin counting the passive connections rejected. You can fix this problem quite easily by following the instructions below
\n\n
Edit the following file: \n/usr/share/munin/plugins/netstat
\n", "_id"=>388}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Charts", "Highcharts", "rails"], "comments_count"=>0, "category_id"=>2, "title"=>"ChartsOnRails", "body"=>"这几天需要找到漂亮的Charts类库,找了几个,发现一个很不粗的,mark下待使用,介绍如下:\n\nHighcharts is a charting library written in pure JavaScript, offering an easy way of adding interactive charts to your web site or web application. Highcharts currently supports line, spline, area, areaspline, column, bar, pie and scatter chart types.\n\n有兴趣的可以参考如下连接去看看:\n\nhttp://highcharts.com/\n\nhttp://railscasts.com/episodes/223-charts\n\nhttp://www.spritle.com/blogs/?p=859", "created_at"=>2010-08-20 21:48:59 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
这几天需要找到漂亮的Charts类库,找了几个,发现一个很不粗的,mark下待使用,介绍如下:
\n\n
Highcharts is a charting library written in pure JavaScript, offering an easy way of adding interactive charts to your web site or web application. Highcharts currently supports line, spline, area, areaspline, column, bar, pie and scatter chart types.
Delete your debug certificate under ~/.android/debug.keystore (on Linux and Mac OS X); the directory is something like %USERHOME%/.androidon Windows.
\n\n
The Eclipse plugin should then generate a new certificate when you next try to build a debug package.
\n", "_id"=>394}])
+MONGODB iceylog_development['categories'].find({:_id=>12}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>12}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["brew"], "comments_count"=>0, "category_id"=>7, "title"=>"Installs Homebrew to /usr/local so you don't need sudo to `brew install`", "body"=>"$ curl https://raw.github.com/gist/323731/install_homebrew.rb -o /tmp/install_homebrew.rb\n % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n100 4569 100 4569 0 0 1605 0 0:00:02 0:00:02 --:--:-- 2346\n\n $ ruby /tmp/install_homebrew.rb\n==> This script will install:\n/usr/local/bin/brew\n/usr/local/Library/Formula/...\n/usr/local/Library/Homebrew/...\n==> The following directories will be made group writable:\n/usr/local/.\n/usr/local/bin\n==> The following directories will have their group set to admin:\n/usr/local/.\n/usr/local/bin\n\nPress enter to continue\n==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin\n==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin\n==> Downloading and Installing Homebrew...\nWarning: The following *evil* dylibs exist in /usr/local/lib\nThey may break builds or worse. You should consider deleting them:\n/usr/local/lib/libevent-1.4.2.1.3.dylib\n/usr/local/lib/libevent_core-1.4.2.1.3.dylib\n/usr/local/lib/libevent_extra-1.4.2.1.3.dylib\n/usr/local/lib/libkyotocabinet.4.8.0.dylib\n/usr/local/lib/libprotobuf-lite.6.dylib\n/usr/local/lib/libprotobuf.6.dylib\n/usr/local/lib/libprotoc.6.dylib\n==> Installation successful!\nNow type: brew help\n\n参考:https://gist.github.com/323731", "created_at"=>2011-09-03 08:29:42 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
$ curl https://raw.github.com/gist/323731/install_homebrew.rb -o /tmp/install_homebrew.rb \n % Total % Received % Xferd Average Speed Time Time Time Current \n Dload Upload Total Spent Left Speed \n100 4569 100 4569 0 0 1605 0 0:00:02 0:00:02 --:--:-- 2346
\n\n
$ ruby /tmp/install_homebrew.rb \n==> This script will install: \n/usr/local/bin/brew \n/usr/local/Library/Formula/... \n/usr/local/Library/Homebrew/... \n==> The following directories will be made group writable: \n/usr/local/. \n/usr/local/bin \n==> The following directories will have their group set to admin: \n/usr/local/. \n/usr/local/bin
\n\n
Press enter to continue \n==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin \n==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin \n==> Downloading and Installing Homebrew... \nWarning: The following evil dylibs exist in /usr/local/lib \nThey may break builds or worse. You should consider deleting them: \n/usr/local/lib/libevent-1.4.2.1.3.dylib \n/usr/local/lib/libevent_core-1.4.2.1.3.dylib \n/usr/local/lib/libevent_extra-1.4.2.1.3.dylib \n/usr/local/lib/libkyotocabinet.4.8.0.dylib \n/usr/local/lib/libprotobuf-lite.6.dylib \n/usr/local/lib/libprotobuf.6.dylib \n/usr/local/lib/libprotoc.6.dylib \n==> Installation successful! \nNow type: brew help
\n", "_id"=>395}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["perl", "Twig", "xml"], "comments_count"=>0, "category_id"=>7, "title"=>"install perl module for XML-Twig in RHEL-Red Hat/Fedora Linux?", "body"=>"This module provides a way to process XML documents. It is build on top of XML::Parser. XML::Twig offers a tree interface to the document, while allowing you to output the parts of it that have been completely processed. It allows minimal resource (CPU and memory) usage by building the tree only for the parts of the documents that need actual processing, through the use of the twig_roots and twig_print_outside_roots options.(as pointed by yum info)\r\n\r\nLet’s first search for the package\r\n$ yum search perl-XML-Twig\r\nperl-XML-Twig.noarch : A perl module for processing huge XML documents in tree\r\n\r\nNote that you must be the root/administrator to install the package. To install this package in Red Hat/Fedora Linux.\r\n$ yum install perl-XML-Twig.noarch\r\n\r\nYou can check the details of this package perl-XML-Twig\r\n$ yum info perl-XML-Twig.noarch\r\n\r\n或者:\r\nperl -MCPAN -e 'install XML::Twig'", "created_at"=>2011-12-10 10:53:02 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
This module provides a way to process XML documents. It is build on top of XML::Parser. XML::Twig offers a tree interface to the document, while allowing you to output the parts of it that have been completely processed. It allows minimal resource (CPU and memory) usage by building the tree only for the parts of the documents that need actual processing, through the use of the twig_roots and twig_print_outside_roots options.(as pointed by yum info)
\n\n
Let’s first search for the package \n$ yum search perl-XML-Twig \nperl-XML-Twig.noarch : A perl module for processing huge XML documents in tree
\n\n
Note that you must be the root/administrator to install the package. To install this package in Red Hat/Fedora Linux. \n$ yum install perl-XML-Twig.noarch
\n\n
You can check the details of this package perl-XML-Twig \n$ yum info perl-XML-Twig.noarch
\n\n
或者: \nperl -MCPAN -e 'install XML::Twig'
\n", "_id"=>396}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["nginx", "statistics", "upstream"], "comments_count"=>0, "category_id"=>9, "title"=>"NGINX upstream statistics", "body"=>"使用过nginx的应该都都晓得upstream,前面一篇文章说到《nginx upstream的5种配置方式》,例如如下是很常见的一段配置\r\n\r\n#create by ice 2011.12.22\r\nupstream unicon_v2_www {\r\n# This is the socket we configured in unicorn.rb\r\nserver unix:/var/www/v2/tmp/sockets/unicorn.sock backup;\r\nserver 192.168.0.1:5000 weight=9 max_fails=2 fail_timeout=30s;\r\nserver 192.168.0.2:5000 weight=3 max_fails=2 fail_timeout=30s;\r\n}\r\nserver {\r\nlisten 80;\r\nserver_name www.iceskysl.com;\r\nerror_log /opt/nginx/logs/error/error_v2_www.log;\r\naccess_log /opt/nginx/logs/access/access_v2_www.log main;\r\n\r\nroot /var/www/v2/public/;\r\nindex index.html index.htm;\r\n\r\nlocation / {\r\nproxy_redirect off;\r\nproxy_set_header X-Real-IP $remote_addr;\r\nproxy_set_header Host $host;\r\nproxy_set_header Content-Length $content_length;\r\nproxy_set_header X-Forwarded-For $remote_addr;\r\nclient_max_body_size 10m;\r\nclient_body_buffer_size 128k;\r\nproxy_connect_timeout 90;\r\nproxy_send_timeout 90;\r\nproxy_read_timeout 90;\r\nproxy_buffer_size 4k;\r\nproxy_buffers 4 32k;\r\nproxy_busy_buffers_size 64k;\r\nproxy_temp_file_write_size 64k;\r\nchunked_transfer_encoding off;\r\nproxy_pass http://unicon_v2_www/;\r\n}\r\n}\r\n\r\n其中upstream的这段配置:\r\nupstream unicon_v2_www {\r\n# This is the socket we configured in unicorn.rb\r\nserver unix:/var/www/v2/tmp/sockets/unicorn.sock backup;\r\nserver 192.168.0.1:5000 weight=9 max_fails=2 fail_timeout=30s;\r\nserver 192.168.0.2:5000 weight=3 max_fails=2 fail_timeout=30s;\r\n}\r\n\r\n我们了解到socket模式的这个是backup,其他两个机器分别weight=3和weight=9,于是我们想监控下upstream每个后端具体处理了多少请求,有没有问题等,这个好像就不好监控了,nginx自带的status模块只能监控总的请求数,无法区分每个upstream的具体情况。\r\n找到一个ustats(http://code.google.com/p/ustats/),其介绍是:NGINX basic upstream statistics module,具体的如下:\r\n
USTATS module provides basic statistics for each backend in nginx upstreams:\r\n\r\nNumber of requests\r\nHttp 499/500/503 errors count\r\nTcp errors\r\nHttp read/write timeouts\r\nFail timeout\r\nMax fails count\r\nLast failed access time\r\nTotal fails count\r\nBlacklisted backend highlighting\r\nDown backends highlighting\r\nThe module allows you to sort values in some columns for each separate upstream. The data can be retrieved as JSON by appending \"?json\" to the end of location on which the module was set to work on (see configuration instructions below).
我们了解到socket模式的这个是backup,其他两个机器分别weight=3和weight=9,于是我们想监控下upstream每个后端具体处理了多少请求,有没有问题等,这个好像就不好监控了,nginx自带的status模块只能监控总的请求数,无法区分每个upstream的具体情况。 \n找到一个ustats(http://code.google.com/p/ustats/),其介绍是:NGINX basic upstream statistics module,具体的如下:<!--more--> \nUSTATS module provides basic statistics for each backend in nginx upstreams:
\n\n
Number of requests \nHttp 499/500/503 errors count \nTcp errors \nHttp read/write timeouts \nFail timeout \nMax fails count \nLast failed access time \nTotal fails count \nBlacklisted backend highlighting \nDown backends highlighting \nThe module allows you to sort values in some columns for each separate upstream. The data can be retrieved as JSON by appending "?json" to the end of location on which the module was set to work on (see configuration instructions below). \n看上去正是我需要的,有时间试试看~(为啥nginx不学haproxy官方自带一个详细statistics的页面呢~haproxy那个statistics很详细很好用~) \n详细使用指南:http://code.google.com/p/ustats/
\r\nThe reason is simple. I installed an extension called SEO Site Tools which installs an icon on the right of the address bar. When you click the button, on the window displayed there is the option “Show no follo” which is an option for displaying links that have the value nofollow for the attribute rel of an HTML element.\r\n\r\nThis attribute instructs some search engines that a hyperlink should not influence the link target’s ranking in the search engine’s index. (Source: wikipedia.org)\r\n
\r\n\r\n修复的方法很简单,去掉“Show no follo”的勾选就好了~\r\n", "created_at"=>2012-01-28 01:48:36 UTC, "updated_at"=>2012-06-24 15:45:37 UTC, "body_html"=>"
经过检查(Library/Application Support/Google/Chrome/Default/User StyleSheets/Custom.css),发现不是本地的css配置,最后找到是一个叫“SEO Site Tools”导致的,具体原因是: \n \nThe reason is simple. I installed an extension called SEO Site Tools which installs an icon on the right of the address bar. When you click the button, on the window displayed there is the option “Show no follo” which is an option for displaying links that have the value nofollow for the attribute rel of an HTML element.
\n\n
This attribute instructs some search engines that a hyperlink should not influence the link target’s ranking in the search engine’s index. (Source: wikipedia.org)
\n\n
修复的方法很简单,去掉“Show no follo”的勾选就好了~
\n", "_id"=>399}])
+MONGODB iceylog_development['categories'].find({:_id=>10}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>10}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Html/css/js"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["ruby"], "comments_count"=>0, "category_id"=>2, "title"=>"Check for nil and initialize on a single line", "body"=>"点评:关于ROR中的一中“遇nil赋值”的写法,这个很早的时候在书上看到的是||=操作符,也一直这么用,今天发现作者的另外这个写法也挺好的。\n\nSometimes, you want to initialize a variable to some value only if that variable is equal to nil. If you like to write your methods as short, clean and readable as possible, you can do that task in a single line instead of taking the traditionnal 3 lines approach. You have two options :\n\n1) You can use the if modifier 1. x = get_some_object if x.nil?Very easy to read. This is my favorite.\n\n2) Or you can use the ||= operator 1. x ||= get_some_object This one is even shorter. The ||= operator is a little bit less verbose and might confuse a ruby newcomer… but I’m not saying that it should be a reason for not using it. This is more a matter of personal taste than anything else.Both of these methods are better than this :\n\n1. #eeww… we don’t like this one.\n\n2. if(x.nil?)\n\n3. x = get_some_object 4. end", "created_at"=>2007-05-19 01:23:10 UTC, "updated_at"=>2012-06-24 15:46:45 UTC, "body_html"=>"
Sometimes, you want to initialize a variable to some value only if that variable is equal to nil. If you like to write your methods as short, clean and readable as possible, you can do that task in a single line instead of taking the traditionnal 3 lines approach. You have two options :
\n\n
1) You can use the if modifier 1. x = get_some_object if x.nil?Very easy to read. This is my favorite.
\n\n
2) Or you can use the ||= operator 1. x ||= get_some_object This one is even shorter. The ||= operator is a little bit less verbose and might confuse a ruby newcomer… but I’m not saying that it should be a reason for not using it. This is more a matter of personal taste than anything else.Both of these methods are better than this :
$ uname -a\r\nLinux oj-web03 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux
\r\n
[iceskysl@oj-web03 logs]$ cat /proc/version\r\nLinux version 2.4.21-27.ELsmp (bhcompile@bugs.build.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47)) #1 SMP Wed Dec 1 21:59:02 EST 20045、内存信息$ cat /proc/meminfo\r\n$ free -M6、CPU信息$cat /proc/cpuinfo7、硬盘信息\r\n$df\r\n\r\n
(1)用客户端连接到数据库,执行select * from v$instance查看version项 \n(2)select * from product_component_version \n(3)或查询V$VERSION查看组件级信息
\n\n
4、内核 \n$ uname -a \nLinux oj-web03 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux \n[iceskysl@oj-web03 logs]$ cat /proc/version \nLinux version 2.4.21-27.ELsmp (bhcompile@bugs.build.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47)) #1 SMP Wed Dec 1 21:59:02 EST 20045、内存信息$ cat /proc/meminfo \n$ free -M6、CPU信息$cat /proc/cpuinfo7、硬盘信息 \n$df
\n\n", "_id"=>402}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Security"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["ruby", "安全", "漏洞"], "comments_count"=>0, "category_id"=>8, "title"=>"Ruby暴出大量严重漏洞!", "body"=>"Drew Yao at Apple uncovered a handful of nasty security vulnerabilities affecting all current versions of Ruby. The details are still under wraps because an attacker can DoS you or possibly execute arbitrary code—holy crap! Better upgrade sooner than later.\n\nAccording to the official Ruby security advisory, the vulnerable Rubies are:\n\n* 1.8.4 and earlier\n* 1.8.5-p230 and earlier\n* 1.8.6-p229 and earlier\n* 1.8.7-p21 and earlier\n\nThose of us running Ruby 1.8.4 or earlier must upgrade to 1.8.5 or later for a fix. Those on 1.8.5-7 can grab the latest patchlevel release for a fix.\n\n(Please note: Ruby 1.8.7 breaks backward compatibility and is only compatible with Rails 2.1 and later, so don’t go overboard!)\n虽然暂时还没看到具体的细节公布出来,也没看到0day放出来,但是从其描述上不难看出,这些bug是ruby一致以来都有的,或许还有更多的bug,ruby走向成熟,离不开这样的检验。", "created_at"=>2008-06-25 06:05:42 UTC, "updated_at"=>2012-06-24 15:46:46 UTC, "body_html"=>"
Drew Yao at Apple uncovered a handful of nasty security vulnerabilities affecting all current versions of Ruby. The details are still under wraps because an attacker can DoS you or possibly execute arbitrary code—holy crap! Better upgrade sooner than later.
\n\n
According to the official Ruby security advisory, the vulnerable Rubies are:
\n\n
\n
1.8.4 and earlier
\n
1.8.5-p230 and earlier
\n
1.8.6-p229 and earlier
\n
1.8.7-p21 and earlier
\n
\n\n
Those of us running Ruby 1.8.4 or earlier must upgrade to 1.8.5 or later for a fix. Those on 1.8.5-7 can grab the latest patchlevel release for a fix.
\n\n
(Please note: Ruby 1.8.7 breaks backward compatibility and is only compatible with Rails 2.1 and later, so don’t go overboard!) \n虽然暂时还没看到具体的细节公布出来,也没看到0day放出来,但是从其描述上不难看出,这些bug是ruby一致以来都有的,或许还有更多的bug,ruby走向成熟,离不开这样的检验。
\n", "_id"=>404}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["rsync"], "comments_count"=>0, "category_id"=>9, "title"=>"同步利器rsync", "body"=>"rsync is a program that copies file from one location to another, with it you can make backups of your files, synchronize data on different locations and computers. It is commonly used by unix users to keep a safe backup of their files and is often recommended as the simplest solution for backups and safety copys.\r\n\r\n参考资料:\r\n\r\n1.rsync的安装和使用\r\n\r\n2. rsync", "created_at"=>2008-06-25 19:58:32 UTC, "updated_at"=>2012-06-24 15:46:46 UTC, "body_html"=>"
rsync is a program that copies file from one location to another, with it you can make backups of your files, synchronize data on different locations and computers. It is commonly used by unix users to keep a safe backup of their files and is often recommended as the simplest solution for backups and safety copys.
A gravatar, or globally recognized avatar, is quite simply an avatar image that follows you from weblog to weblog appearing beside your name when you comment on gravatar enabled sites. Avatars help identify your posts on web forums, so why not on weblogs?
\r\n看明白了么,就是一个你输入自己的Email,然后上传自己的图片标识,然后在其他支持 Gravatars的网站(blog居多)中发表评论的时候输入自己的Email地址,就可以在Gravatars上找到其对应的图片来显示了。\r\n\r\n这确实是个不错的Idea,相当简单,但是也做得有声有色的,有点意思。\r\n\r\n使用也很方便,其在“How the URL is constructed”上介绍了其URL的组成,中可以这么使用(来源Gravatars on Rails):\r\n\r\n\r\n\r\n1、首先在````application_helper.rb中增加一个helper方法```\r\n
这个世界有意思,多大的idea都可以做成网站,以前看过缩址的网站,现在有看到一个省份标识的网站, Gravatars,看他的介绍: \nA gravatar, or globally recognized avatar, is quite simply an avatar image that follows you from weblog to weblog appearing beside your name when you comment on gravatar enabled sites. Avatars help identify your posts on web forums, so why not on weblogs? \n看明白了么,就是一个你输入自己的Email,然后上传自己的图片标识,然后在其他支持 Gravatars的网站(blog居多)中发表评论的时候输入自己的Email地址,就可以在Gravatars上找到其对应的图片来显示了。
\n\n
这确实是个不错的Idea,相当简单,但是也做得有声有色的,有点意思。
\n\n
使用也很方便,其在“How the URL is constructed”上介绍了其URL的组成,中可以这么使用(来源Gravatars on Rails):
晓得TDD,BDD,RSpec这些东西很久了,也看了不少的资料和教程,但总感觉还在门外徘徊,始终不得其要,真是怪异。应该是没在实际项目中实践过的缘故吧。 \n本文记录一些RSpec和BDD(Behaviour Driven Development )的资料和文档,给我自己也给各位路过者提供一些资料,感兴趣的仔细看看吧。 \n \n http://rspec.info/ \n Telling a good story - Rspec stories from the trenches \n Slides from RailsConf \n rspec plain text stories + webrat = chunky bacon! \n http://chinaonrails.com/topic/view/220.html \n Story Driven Development with Rails - Part I: Up and Running \n \n另外,http://rspec.info/documentation/rails/上的资料非常棒。有路过的,玩BDD的朋友还望多多指教,领我进门,多谢!
\n", "_id"=>416}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Html/css/js"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Android & Java"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Thin"], "comments_count"=>0, "category_id"=>6, "title"=>"Thin version 1.0.0 is out!", "body"=>"Thin version 1.0.0 (codename That's What She Said) is out!\r\n\r\nYes 1.0! That doesn't mean it's bug free or anything. But, it does\r\nmean that it's been running on a number of servers and no show stopper\r\nbugs have been found since a while.\r\n\r\nAlso see http://macournoyer.wordpress.com/2008/09/30/thin-10/\r\n\r\n== What's new?\r\n\r\n* Fixed vlad.rake to allow TCP or socket [hellekin]\r\n* Updated Mack adapter to handle both <0.8.0 and >0.8.0 [Mark Bates]\r\n* rails rack adapter uses File.readable_real? so it recognizes ACL\r\npermissions [Ricardo Chimal]\r\n* Log a warning if Rack application returns nil body [Michael S.\r\nKlishin]\r\n* Handle nil and Time header values correctly [#76 state:resolved]\r\n[tmm1]\r\n* Add Content-Length header to response automatically when possible\r\n[#74 state:resolved] [dkubb]\r\n* Runner now remembers -r, -D and -V parameters so that clustered\r\nservers inherit those and\r\nkeep your parameters.\r\n* Make Set-Cookie header, in Rails adapter, compatible with current\r\nRack spec [Pedro Belo]\r\n[#73, state:resolved]\r\n* Add --no-epoll option to disable epoll usage on Linux [#61\r\nstate:resolved]\r\n* Add --force (-f) option to force stopping of a daemonized server\r\n[#72 state:resolved]\r\n* Update halycon adapter loader [mtodd]\r\n\r\n== Get it!\r\n\r\nInstall Thin from RubyForge:\r\n\r\ngem install thin\r\n\r\nOr using my mirror:\r\n\r\ngem install thin --source http://code.macournoyer.com\r\n\r\n参考文档:\r\nhttp://groups.google.com/group/thin-ruby/browse_thread/thread/402d51a6d9f2651d", "created_at"=>2008-10-07 09:56:27 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
Thin version 1.0.0 (codename That's What She Said) is out!
\n\n
Yes 1.0! That doesn't mean it's bug free or anything. But, it does \nmean that it's been running on a number of servers and no show stopper \nbugs have been found since a while.
Search directory arguments recursively for files to convert.
\r\n\t
-d or --delete
\r\n\t
delete input files after successful conversion. May not be safe yet!!!
\r\n\t
-v or --verbose
\r\n\t
makes sneetchalizer more chatty.
\r\n\t
-s or --show-output
\r\n\t
shows output from conversion tool.
\r\n\t
-p or --pretend
\r\n\t
don't convert anything. sneetchalizer will go through the motions and print out the commands it would run. Useful for preview- ing a complex command line to ensure it does what you intend. You should interpret this option's output with a grain of salt. For example, if you include the '--sanitize' option, the files will not really be renamed when using --pretend, and as such the command's output will not reflect that the filenames would be changed during an actual run.
\r\n\t
-t or --terminate
\r\n\t
terminate sneetchalizer options. This is useful if you have to convert '--coolDir' or '-groovySong.mp3'. This is the only option whose order on the command line is significant.
\r\n\t
-D ARG or --out-directory=ARG
\r\n\t
write all outfiles to a directory argument. This is useful if you want to (re)encode files directly to a mounted portable device.
\r\n\t
--strict and --pedantic
\r\n\t
many errors that sneetchalizer may encounter are recoverable, such as specifying a directory as argument that contains no files to convert, or conversion failures in general. By default the script will print an error message and move on to the next file. If you use '--strict' then sneetchalizer will bail out at the first sign of trouble except for tag errors. With '--pedantic' the script will stop even on tag errors.
\r\n\t
--stasis
\r\n\t
Preserve timestamp (mtime) of original file.
\r\n\t
--threads [N]
\r\n\t
Experimental. Use threads to create concurrent jobs. This option takes an optional integer argument which represents the number of threads to launch. The default is two. Preliminary tests suggest there is little advantage (and even diminishing returns) when setting this number greater than the number of cores/CPUs you have. Due to the asychronous nature of threads the --verbose and --show-output flags will be silently disabled and most screen output is supressed.
\r\n\t
--sanitize
\r\n\t
Removes ,, ;, :, ', \", %, @, #, and ` from filenames and tags.
\r\n\t
-n [FORMAT] or --rename[=FORMAT]
\r\n\t
rename all outfiles (and temporary wavs) according to FORMAT. FORMAT is a string with special designators to be pulled from the file tags. The following options are available:
\r\n\t
\r\n\t
* %t Song title
\r\n\t
* %b Album title
\r\n\t
* %n Track number
\r\n\t
* %a Artist name
\r\n\t
* %y Year
\r\n\t
* %g Genre
\r\n\t
* %c Comment field
\r\n\t
\r\n\t
Directories may be created with this command, as in \"%b/%n - %t\". The default value of FORMAT is \"%n %t\".
\r\n\t
\r\n\t
Bitrate/Quality/Compression options:
\r\n\t
\r\n\t
-b or --bitrate
\r\n\t
mp3/ogg/m4a bitrate.
\r\n\t
-q or --quality
\r\n\t
mp3/ogg quality.
\r\n\t
\r\n\t
quality and bitrate are passed directly to lame or oggenc depending on mp3 or ogg output format respectively. Both tools can handle either a bitrate or quality argument, so it is important to understand what values are valid for the underlying tool in your specific use case. faac will accept a bitrate argument, but not a quality argument. These options will be silently ignored for any output formats other than mp3, ogg or m4a. Make sure you know what you are doing if you decide to use both in one run, and read each tools manpage for valid values. If these options are omitted the tools builtin defaults are used (-q3 for oggenc and -q5 for lame).
\r\n\t
\r\n\t
-c or --compression
\r\n\t
flac/mac compression level.
\r\n\t
\r\n\t
this option allows you to pass a compression argument to flac and mac. See 'flac --help' and/or 'mac --help' if you don't know what this means.
\r\n\t
\r\n\t
Format Options:
\r\n\t
\r\n\t
--out=format
\r\n\t
output format. Default is wav.
\r\n\t
--in=format[,format..]
\r\n\t
input format(s). Default is wav.
\r\n\t
\r\n\t
Valid output formats are: \"aac\", \"aif\", \"aifc\", \"aiff\", \"aiffc\", \"ape\", \"au\", \"cdr\", \"cdda\", \"copy\", \"flac\", \"m4a\", \"m4b\", \"mpc\", \"mp4\", \"mpp\", \"mp3\", \"mp2\", \"ofr\", \"ofs\", \"ogg\", \"snd\", \"spx\", \"tta\", \"wav\", \"wv\". Valid input formats are all of the above plus \"wma\". You can specify multiple input formats using a comma: 'mp3,m4a,wma'. Input format is only neccesary when passing directory arguments, as file arguments are handled by context (read: file extension). The \"copy\" output option copies files directly, bypassing decoding/encoding steps (useful in conjunction with --rename).
\r\n\t
\r\n\t
Tagging Options:
\r\n\t
\r\n\t
--tt or --title
\r\n\t
Set 'title' tag.
\r\n\t
--ta or --artist
\r\n\t
Set 'artist' tag.
\r\n\t
--tl or --album
\r\n\t
Set 'album' tag.
\r\n\t
--ty or --year
\r\n\t
Set 'year' tag.
\r\n\t
--tc or --comment
\r\n\t
Set 'comment' tag.
\r\n\t
--tg or --genre
\r\n\t
Set 'genre' tag.
\r\n\t
--tn or --trackn
\r\n\t
Set 'track number' tag.
\r\n\t
\r\n\t
The short and long versions are different in an important way: Using the long version will clobber any existing tags. The short version will only set the tag if the existing tag has no value. Note that these tags will be placed in _every_ outfile during the run.
\r\n\t
\r\n\t
Alternative Encoder/Decoder Options:
\r\n\t
\r\n\t
--gogo
\r\n\t
use gogo to encode mp3 files.
\r\n\t
--bladeenc
\r\n\t
use bladeenc to encode mp3 files.
\r\n\t
\r\n\t
The default is still 'lame'. If 'lame' is not found, the script will search for one of these two encoders regardless if these options are passed or not.
\r\n\t
\r\n\t
Special Options:
\r\n\t
\r\n\t
--in-optionhook=ARG
\r\n\t
add ARG to infile conversion command. Possibly dangerous!
\r\n\t
--out-optionhook=ARG
\r\n\t
add ARG to outfile conversion command. Possibly dangerous!
Using the same --in and --out format allows us to resample/encode the file at a different bitrate or quality. Note that this will overwrite the original file so only do this on a copy, or use '-D' to write files to another directory.
直接下载其gz包,sneetchalizer-0.9.0是现在的最新版本。下载解包后可以看到: \n \nManifest: \n \n README - You're reading it now. \n LICENSE - A copy of the GPL, under which sneetchalizer is released. \n CHANGES - sneetchalizer's cvs/svn commit log. \n sneetchalizer - The script itself. \n sneetchalizer.1 - The manpage for sneetchalizer. \n sneetchalizer.desktop - A KDE service menu for converting with Konqueror. \n install.rb - A quick and dirty script to install the sneetchalizer. \n \n \n如果有root权限,可以直接运行install.rb,其会将sneetchalizer拷贝到/usr/bin下,将sneetchalizer.1拷贝到/usr/share/man/man1下。
\n\n
2、参数解释
\n\n
不翻译了,都挺简单明了的,如下: \n \nXML/HTML代码 \n \n General options: \n \n -h or --help \n Print quick or full usage details respectively. \n -r or --recursive \n Search directory arguments recursively for files to convert. \n -d or --delete \n delete input files after successful conversion. May not be safe yet!!! \n -v or --verbose \n makes sneetchalizer more chatty. \n -s or --show-output \n shows output from conversion tool. \n -p or --pretend \n don't convert anything. sneetchalizer will go through the motions and print out the commands it would run. Useful for preview- ing a complex command line to ensure it does what you intend. You should interpret this option's output with a grain of salt. For example, if you include the '--sanitize' option, the files will not really be renamed when using --pretend, and as such the command's output will not reflect that the filenames would be changed during an actual run. \n -t or --terminate \n terminate sneetchalizer options. This is useful if you have to convert '--coolDir' or '-groovySong.mp3'. This is the only option whose order on the command line is significant. \n -D ARG or --out-directory=ARG \n write all outfiles to a directory argument. This is useful if you want to (re)encode files directly to a mounted portable device. \n --strict and --pedantic \n many errors that sneetchalizer may encounter are recoverable, such as specifying a directory as argument that contains no files to convert, or conversion failures in general. By default the script will print an error message and move on to the next file. If you use '--strict' then sneetchalizer will bail out at the first sign of trouble except for tag errors. With '--pedantic' the script will stop even on tag errors. \n --stasis \n Preserve timestamp (mtime) of original file. \n --threads [N] \n Experimental. Use threads to create concurrent jobs. This option takes an optional integer argument which represents the number of threads to launch. The default is two. Preliminary tests suggest there is little advantage (and even diminishing returns) when setting this number greater than the number of cores/CPUs you have. Due to the asychronous nature of threads the --verbose and --show-output flags will be silently disabled and most screen output is supressed. \n --sanitize \n Removes ,, ;, :, ', ", %, @, #, and ` from filenames and tags. \n -n [FORMAT] or --rename[=FORMAT] \n rename all outfiles (and temporary wavs) according to FORMAT. FORMAT is a string with special designators to be pulled from the file tags. The following options are available: \n \n * %t Song title \n * %b Album title \n * %n Track number \n * %a Artist name \n * %y Year \n * %g Genre \n * %c Comment field \n \n Directories may be created with this command, as in "%b/%n - %t". The default value of FORMAT is "%n %t". \n \n Bitrate/Quality/Compression options: \n \n -b or --bitrate \n mp3/ogg/m4a bitrate. \n -q or --quality \n mp3/ogg quality. \n \n quality and bitrate are passed directly to lame or oggenc depending on mp3 or ogg output format respectively. Both tools can handle either a bitrate or quality argument, so it is important to understand what values are valid for the underlying tool in your specific use case. faac will accept a bitrate argument, but not a quality argument. These options will be silently ignored for any output formats other than mp3, ogg or m4a. Make sure you know what you are doing if you decide to use both in one run, and read each tools manpage for valid values. If these options are omitted the tools builtin defaults are used (-q3 for oggenc and -q5 for lame). \n \n -c or --compression \n flac/mac compression level. \n \n this option allows you to pass a compression argument to flac and mac. See 'flac --help' and/or 'mac --help' if you don't know what this means. \n \n Format Options: \n \n --out=format \n output format. Default is wav. \n --in=format[,format..] \n input format(s). Default is wav. \n \n Valid output formats are: "aac", "aif", "aifc", "aiff", "aiffc", "ape", "au", "cdr", "cdda", "copy", "flac", "m4a", "m4b", "mpc", "mp4", "mpp", "mp3", "mp2", "ofr", "ofs", "ogg", "snd", "spx", "tta", "wav", "wv". Valid input formats are all of the above plus "wma". You can specify multiple input formats using a comma: 'mp3,m4a,wma'. Input format is only neccesary when passing directory arguments, as file arguments are handled by context (read: file extension). The "copy" output option copies files directly, bypassing decoding/encoding steps (useful in conjunction with --rename). \n \n Tagging Options: \n \n --tt or --title \n Set 'title' tag. \n --ta or --artist \n Set 'artist' tag. \n --tl or --album \n Set 'album' tag. \n --ty or --year \n Set 'year' tag. \n --tc or --comment \n Set 'comment' tag. \n --tg or --genre \n Set 'genre' tag. \n --tn or --trackn \n Set 'track number' tag. \n \n The short and long versions are different in an important way: Using the long version will clobber any existing tags. The short version will only set the tag if the existing tag has no value. Note that these tags will be placed in _every_ outfile during the run. \n \n Alternative Encoder/Decoder Options: \n \n --gogo \n use gogo to encode mp3 files. \n --bladeenc \n use bladeenc to encode mp3 files. \n \n The default is still 'lame'. If 'lame' is not found, the script will search for one of these two encoders regardless if these options are passed or not. \n \n Special Options: \n \n --in-optionhook=ARG \n add ARG to infile conversion command. Possibly dangerous! \n --out-optionhook=ARG \n add ARG to outfile conversion command. Possibly dangerous! \n \n \n另外,你可以运行sneetchalizer -h看到简要的使用说明,也可以使用sneetchalizer --help看到详细的使用信息。
\n\n
3、使用示例
\n\n
如下简要的写几个使用的示例: \n \n使用示例: \n \n $ sneetchalizer song.mp3 \n \n The most simple possible example, creates 'song.wav'. \n \n $ sneetchalizer --out=ogg --in=flac -q5 /some/music/dir \n \n This example converts every flac file in '/some/music/dir' to ogg format at quality 5. \n \n $ sneetchalizer -d --out=mp3 --in=ogg,m4a,wma -b 160 . \n \n Converts every ogg, m4a, and wma file in the current directory to a 160 kbps constant bitrate mp3 file. The original files are deleted. \n \n $ sneetchalizer --out=mp3 --out-optionhook="--preset extreme" /some/wavs \n \n Here we encode every wav in '/some/wavs' to mp3 format passing '--preset extreme' directly to lame. \n \n $ sneetchalizer --in=ogg --out=ogg --quality=1 norvegianWood.ogg /some/more/oggs \n \n Using the same --in and --out format allows us to resample/encode the file at a different bitrate or quality. Note that this will overwrite the original file so only do this on a copy, or use '-D' to write files to another directory. \n \n $ sneetchalizer --in=ogg --out=m4a -D /mnt/ipod/ /some/oggs \n \n Here we re-encode some ogg files to m4a format and write them to our mounted iPod. \n \n \n4、注意事项
\n\n
本脚本只是粘合剂,其他的tool还是需要另外安装的。
\n\n
其他信息请参考其主页说明,如果您有这个方面的问题或经验,欢迎和我讨论。
\n\n\n
\n", "_id"=>418}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["架构"], "comments_count"=>0, "category_id"=>9, "title"=>"网站架构文章列表(持续更新中)", "body"=>"互联网越来越开放,技术人员也越来越乐于分享,分析构架、演变和遇到的问题,虽然说没有真正经历过,很多体验可能会没那么深,但是有些东西提前了解会有诸多好处。在很多地方看到类似的构架分析、分享的文章,统一收集整理如下,遇到其他的,我会持续更新,如果经历允许,我还会写一些读后感或者点评;如果你看到其他的类似文章或者点评,欢迎留言让我知道。\n\n对dbanotes等表示感谢。\n\nWikiPedia 技术架构学习分享\nhttp://www.dbanotes.net/opensource/wikipedia_arch.html\n\nYouTube 的架构扩展\nhttp://www.dbanotes.net/opensource/youtube_web_arch.html\n\nLinkedIn 架构笔记\nhttp://www.dbanotes.net/arch/linkedin.html\n\nLinkedIn 架构与开发过程\nhttp://www.dbanotes.net/arch/linkedin_soa.html\n\nInternet Archive 的海量存储浅析\nhttp://www.dbanotes.net/database/internet_archive_storage.html\n\nTailrank 网站架构\nhttp://www.dbanotes.net/review/tailrank_arch.html\n\nTwitter 的架构扩展: 100 倍性能提升\nhttp://www.dbanotes.net/arch/twitter_arch.html\n\n财帮子(caibangzi.com)网站架构\nhttp://www.dbanotes.net/arch/caibangzi_web_arch.html\n\nYupoo! 的网站技术架构\nhttp://www.dbanotes.net/arch/yupoo_arch.html\n\n37Signals 架构\nhttp://www.dbanotes.net/arch/37signals_arch.html\n\nFlickr 的访问统计实现以及其他\nhttp://www.dbanotes.net/arch/flickr_stats_and_dathan.html\n\nPlentyOfFish 网站架构学习\nhttp://www.dbanotes.net/arch/plentyoffish_arch.html\n\nYahoo!社区架构\nhttp://www.dbanotes.net/arch/yahoo_arch.html\n\n有关 Alexa 与 AOL 部署集群文件系统\nhttp://www.dbanotes.net/arch/alexa_ibrix_san_file_system.html\n\neBay 的存储一瞥\nhttp://www.dbanotes.net/arch/ebay_storage.html\n\neBay 的数据量\nhttp://www.dbanotes.net/database/ebay_storage.html\n\neBay 的数据库分布扩展架构\nhttp://www.dbanotes.net/database/ebay_database_scale_out.html\n\neBay 的数据层扩展经验\nhttp://www.dbanotes.net/arch/ebay_db_scale_out.html\n\neBay 的应用服务器规模\nhttp://www.dbanotes.net/web/ebay_application_server.html\n\n性能扩展问题要趁早\nhttp://www.dbanotes.net/arch/scaling_an_early_stage_startup.html\n\nScaling an early stage startup\nhttp://www.scribd.com/doc/429986/Scaling-an-early-stage-startup\n\nFacebook 的 PHP 性能与扩展性\nhttp://www.dbanotes.net/arch/facebook_php.html\n\nSkype 用 PostgreSQL 支撑海量用户\nhttp://www.dbanotes.net/arch/skype_postgresql.html\n\n闲谈 Web 图片服务器\nhttp://www.dbanotes.net/web/web_image_server.html\n\n说说北京奥运购票系统瘫痪这事儿\nhttp://www.dbanotes.net/review/beijing_olympic_ticketes_system_crash.html\n\nArchitectures You’ve Always Wondered About\nhttp://qcon.infoq.com/london-2008/tracks/show_track.jsp?trackOID=82\n\neBay’s Architectural Principles\nhttp://www.eos1.dk/qcon-london-2008/slides/RandyShoup_eBaysArchitecturalPrinciples.pdf\n\nBuilding a large scale SaaS app\nhttp://www.eos1.dk/qcon-london-2008/slides/Dan_Hanley_Building_a_large_scale_SaaS_app.pdf\n\nScaling an early stage startup\nhttp://www.scribd.com/doc/429986/Scaling-an-early-stage-startup\n\n互联星空播客架构(原文在张宴blog上,但是后来文章撤下,很可惜.此为转载)\nhttp://www.flashmov.com/blog_1632.html\n\nQQ游戏百万人同时在线服务器架构实现\nhttp://www.libing.net.cn/read.php?41\n\n大型Web2.0站点构建技术初探\nhttp://blog.csdn.net/heiyeshuwu/archive/2007/11/18/1890793.aspx\n\nWeb站点数据库分布存储浅谈\nhttp://blog.csdn.net/heiyeshuwu/archive/2007/11/18/1891639.aspx\n\nQQ的架构讨论\nhttp://groups.google.com/group/dev4server/browse_thread/thread/0d72668d11c4886b/a6d202489cabf285#a6d202489cabf285\n\nNotes from Scaling MySQL - Up or Out\nhttp://venublog.com/2008/04/16/notes-from-scaling-mysql-up-or-out/\n\nYapache-Yahoo! Apache 的秘密\nhttp://www.dbanotes.net/web/yapache_yahoo_apache.html\n\nScalability Best Practices: Lessons from eBay\nhttp://www.infoq.com/articles/ebay-scalability-best-practices", "created_at"=>2008-10-09 06:51:05 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
Google的产品很多都深得我心,一直在使用,整理整合了一些Gmail的快捷方式,备忘。 \n \n \n \n快捷键 \n定义 \n作用 \n \n \nc \nCompose \n撰写新邮件。“Shift+C”打开新窗口撰写新邮件 \n \n \n<tab> then <Enter> \nSend message \n新邮件撰写完后,先<tab>后<Enter>可发送邮件。(在Windows中,使用IE和Firefox有效) \n \n \nk \nMove to newer conversation \n在收件箱中,向上移动光标,按<Enter>查看邮件;在查看邮件时,打开下一封新邮件 \n \n \nj \nMove to older conversation \n在收件箱中,向下移动光标,按<Enter>查看邮件;在查看邮件时,打开下一封旧邮件 \n \n \nn \nNext message \n查看邮件时,定位光标到 \n \n \np \nPrevious message \n移动光标到前一个消息。<Enter>展开或折叠消息。(只在“会话模式”(Conversation View)中有效) \n \n \no or <Enter> \nOpen \n打开会话。在“Conversation View”中,也可用于打开消息。 \n \n \nu \nReturn to conversation list \n刷新页面、返回收件箱或返回会话列表 \n \n \ny \nArchive* \nRemove from current view \n \n删除会话或消息。 \n在收件箱中,<Y>可“存档”选中的会话
\n\n
在“已加星标示”中,<Y>可取消选中会话的星号; \n 在查看有标签的邮件时,<Y>可取消标签。 \n 在“垃圾邮件”、“已发邮件”和“所有邮件”中,<Y>没有作用 \n \n \n \n \nx \nSelect conversation \n选中会话,配合其他快捷键可为会话存档、添加标签或从下拉菜单中选择其他命令 \n \n \ns \nStar a message or conversation \n为会话或消息加星标。 \n \n \n! \nReport spam \n将消息标记为垃圾邮件并从会话中删除 \n \n \nr \nReply \n回复邮件或会话。“shift+r”可在新窗口中回复消息(只在“会话模式”中有效) \n \n \na \nReply all \n回复所有收件人。“Shift+a”可打开新窗口中回复。(PConline注:如果邮件有抄送地址,<r>回复发件人,<a>则回复所有抄送地址) \n \n \nf \nForward \n转发消息。“Shift+f”可打开新窗口转发。(只在“查看消息模式”(“Conversation View”)中有效) \n \n \n<Esc> \nEscape from input field \nRemoves the cursor from your current input field.(PConline注:在中文版Gmail中暂未有效果) \n \n \ny then o \nArchive and next \n存档选中的会话并打开下一个 \n \n \ng then a \nGo to 'All Mail' \n转到“所有邮件” \n \n \ng then s \nGo to 'Starred' \n转到“已加星标” \n \n \ng then c \nGo to 'Contacts' \n转到“通讯录” \n \n \ng then d \nGo to 'Drafts' \n转到“草稿” \n \n \ng then i \nGo to 'Inbox' \n转到“收件箱” \n \n \n/ \nSearch \n将光标定位到搜索栏中的输入框中 \n \n \n \n
\n", "_id"=>420}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["analyzer"], "comments_count"=>0, "category_id"=>7, "title"=>"Request-log-analyzer: Rails&Merb的日志分析", "body"=>"生产环境下,需要对环境持续监控以尽快的发现问题,找到耗费资源较多的地方加以改进,比较常见的做法是使用moint或者God实时监控;另外,还可以定期分析日志找到特定的请求,虽然可以是shell来做这件事,但是何必再造轮子呢,因为我们已经有了Request log analyzer :\r\n``简介:This is a simple command line tool to analyze request log files of both Rails andMerb. Its purpose is to find what actions are best candidates for optimization.This tool will parse all requests in the logfile and aggregate theinformation. Once it is finished parsing the log file, it will show therequests that take op most server time. Different metrics are used (cumulativetime, average time, blockers, DB time, etc)\r\n\r\n安装:gem sources -a http://gems.github.comsudo gem install wvanbergen-request-log-analyzer\r\n\r\n使用:Usage: request-log-analyzer [FILE] [OPTION]Analyze the given log FILE with the given OPTIONExample: request-log-analyzer mongrel.log\r\n\r\n --fast, -t: Only use completed requests --guess-database-time, -g: Guesses the database duration of requests if they are not in the log --output, -o: Comma-separated list of reports to show --amount, -c: Displays the top <amount> elements in the reports --colorize, -z: Fancy bash coloring\r\n\r\n示例:Note that this example was shortened for your viewing pleasure.$ request-log-analyzer /var/log/my_app.log\r\n\r\nRequest log analyzer, by Willem van Bergen and Bart ten Brinke\r\n\r\nProcessing all log lines...========================================================================Successfully analyzed 58908 requests from log file\r\n\r\nTimestamp first request: 2008-07-13T06:25:58+00:00Timestamp last request: 2008-07-20T06:18:53+00:00Total time analyzed: 7 daysMethods: DELETE (1%), GET (50%), POST (22%), PUT (25%).\r\n\r\nTop 10 most requested actions========================================================================/overview/:date/ : 19359 requests/overview/day/:date/ : 6365 requests/overview/:date/set/ : 5589 requests/overview/ : 3985 requests/clients/:id/ : 1976 requests........\r\n\r\nTop 10 actions by time - cumulative========================================================================/overview/:date/ : 9044.582s [19359 requests]/overview/ : 8478.767s [3985 requests]/overview/:date/set/ : 3309.041s [5589 requests]/clients/:id/products/:id/ : 1479.911s [924 requests]/clients/:id/ : 750.080s [1976 requests]........\r\n\r\nTop 10 actions by time - per request mean========================================================================/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]/clients/:id/ : 0.380s [1976 requests]........\r\n\r\nTop 10 worst DB offenders - cumulative time========================================================================/overview/:date/ : 8773.993s [19359 requests]/overview/ : 8394.754s [3985 requests]/overview/:date/set/ : 3307.928s [5589 requests]/clients/:id/products/:id/ : 1425.220s [924 requests]/clients/:id/ : 535.229s [1976 requests]........\r\n\r\nTop 10 worst DB offenders - mean time========================================================================/overview/:id/:id/:id/print/ : 6.994s [448 requests]/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]........\r\n\r\nMongrel process blockers (> 1.0 seconds)========================================================================/overview/:date/ : 7494.233s [3144 requests]/overview/ : 8320.293s [1549 requests]/overview/:date/set/ : 1149.235s [803 requests]/overview/:id/:id/:id/print/new/ : 613.693s [341 requests]/clients/:id/products/:id/ : 1370.693s [313 requests]........\r\n\r\nRequests graph - per hour======================================================================== ........ 7:00 - 2731 : XXXXXXX 8:00 - 6139 : XXXXXXXXXXXXXXXX 9:00 - 7465 : XXXXXXXXXXXXXXXXXXXX 10:00 - 7118 : XXXXXXXXXXXXXXXXXXX 11:00 - 7409 : XXXXXXXXXXXXXXXXXXX 12:00 - 6450 : XXXXXXXXXXXXXXXXX 13:00 - 5377 : XXXXXXXXXXXXXX 14:00 - 6058 : XXXXXXXXXXXXXXXX 15:00 - 4156 : XXXXXXXXXXX 16:00 - 2767 : XXXXXXX 17:00 - 1598 : XXXX 18:00 - 792 : XX ........\r\n\r\nErrors========================================================================ArgumentError: [237 requests] -> invalid dateStaleObjectError: [28 requests] -> Attempted to update a stale objectRuntimeError: [3 requests] -> Cannot destroy rule before it was createdStatementError: [2 requests] -> Mysql::Error: Deadlock found when trying to get lock; try restarting transactionNoMethodError: [1 requests] -> undefined method `code' for nil:NilClass```", "created_at"=>2008-10-13 08:45:11 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
生产环境下,需要对环境持续监控以尽快的发现问题,找到耗费资源较多的地方加以改进,比较常见的做法是使用moint或者God实时监控;另外,还可以定期分析日志找到特定的请求,虽然可以是shell来做这件事,但是何必再造轮子呢,因为我们已经有了Request log analyzer : \n``简介:This is a simple command line tool to analyze request log files of both Rails andMerb. Its purpose is to find what actions are best candidates for optimization.This tool will parse all requests in the logfile and aggregate theinformation. Once it is finished parsing the log file, it will show therequests that take op most server time. Different metrics are used (cumulativetime, average time, blockers, DB time, etc)
\n\n
安装:gem sources -a http://gems.github.comsudo gem install wvanbergen-request-log-analyzer
\n\n
使用:Usage: request-log-analyzer [FILE] [OPTION]Analyze the given log FILE with the given OPTIONExample: request-log-analyzer mongrel.log
\n\n
--fast, -t: Only use completed requests --guess-database-time, -g: Guesses the database duration of requests if they are not in the log --output, -o: Comma-separated list of reports to show --amount, -c: Displays the top <amount> elements in the reports --colorize, -z: Fancy bash coloring
\n\n
示例:Note that this example was shortened for your viewing pleasure.$ request-log-analyzer /var/log/my_app.log
\n\n
Request log analyzer, by Willem van Bergen and Bart ten Brinke
\n\n
Processing all log lines...========================================================================Successfully analyzed 58908 requests from log file
\n\n
Timestamp first request: 2008-07-13T06:25:58+00:00Timestamp last request: 2008-07-20T06:18:53+00:00Total time analyzed: 7 daysMethods: DELETE (1%), GET (50%), POST (22%), PUT (25%).
\n\n
Top 10 most requested actions========================================================================/overview/:date/ : 19359 requests/overview/day/:date/ : 6365 requests/overview/:date/set/ : 5589 requests/overview/ : 3985 requests/clients/:id/ : 1976 requests........
\n\n
Top 10 actions by time - cumulative========================================================================/overview/:date/ : 9044.582s [19359 requests]/overview/ : 8478.767s [3985 requests]/overview/:date/set/ : 3309.041s [5589 requests]/clients/:id/products/:id/ : 1479.911s [924 requests]/clients/:id/ : 750.080s [1976 requests]........
\n\n
Top 10 actions by time - per request mean========================================================================/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]/clients/:id/ : 0.380s [1976 requests]........
Errors========================================================================ArgumentError: [237 requests] -> invalid dateStaleObjectError: [28 requests] -> Attempted to update a stale objectRuntimeError: [3 requests] -> Cannot destroy rule before it was createdStatementError: [2 requests] -> Mysql::Error: Deadlock found when trying to get lock; try restarting transactionNoMethodError: [1 requests] -> undefined method code' for nil:NilClass``
Nginx有个Log Rotation模块,nginx will re-open it's logs in response to the USR1 signal.参考如下脚本: \n`$ mv access.log access.log.0$ kill -USR1cat master.nginx.pid`$ sleep 1$ gzip access.log.0 # do something with access.log.0
\r\n``2、Hpricot```Pros: Cool name, created by _why, faster than REXML, also does HTML, creative APICons: Not as fast as libxml-ruby, more of an HTML parser linguistically (ie: uses innerHTML instead of text or content, etc.)```\r\n
\r\n
Ruby代码
\r\n\r\n\t
%w[benchmark pp rubygems].each { |x| require x }
\r\n\t
gem 'hpricot', '>= 0.6'
\r\n\t
require 'hpricot'
\r\n\t
\r\n\t
##################################
\r\n\t
# Parsing Delicious API Response #
\r\n\t
##################################
\r\n\t
xml = File.read('posts.xml')
\r\n\t
puts Benchmark.measure {
\r\n\t
doc, posts = Hpricot::XML(xml), []
\r\n\t
(doc/:post).eachdo |p|
\r\n\t
posts << p.attributes
\r\n\t
end
\r\n\t
# pp posts
\r\n\t
}
\r\n\t
\r\n\t
################################
\r\n\t
# Parsing Twitter API Response #
\r\n\t
################################
\r\n\t
xml = File.read('timeline.xml')
\r\n\t
puts Benchmark.measure {
\r\n\t
doc, statuses = Hpricot::XML(xml), []
\r\n\t
(doc/:status).eachdo |s|
\r\n\t
h = {:user => {}}
\r\n\t
%w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].eachdo |a|
\r\n\t
h[a.intern] = s.at(a).innerHTML
\r\n\t
end
\r\n\t
%w[id name screen_name location description profile_image_url url protected followers_count].eachdo |a|
\r\n\t
h[:user][a.intern] = s.at('user').at(a).innerHTML
\r\n\t
end
\r\n\t
statuses << h
\r\n\t
end
\r\n\t
# pp statuses
\r\n\t
}
\r\n\r\n
\r\n3、libxml-ruby \r\n\r\nPros: Blistering fast\r\nCons: Hpricot has cooler name, REXML and Hpricot both feel easier to use out of the box\r\n
Ruby可以很方便的解析XML格式的文档,目前用的比较多的lib主要有三个,分别是:REXML, Hpricot, libxml-ruby,如下选取两个XML文档,分别使用这三个lib解析,感受下各自的速度和易用性。 \n一、原料 \n \n posts.xml – Uses xml element for object (post) and xml attributes for object attributes \n timeline.xml – Uses xml element for object (status) and child xml elements for attributes \n \n二、解析过程 \n1、REXML
\n\n
Pros: In the standard library \nCons: Slow, I don’t like the name \n \nRuby代码 \n \n %w[benchmark pp rexml/document].each { |x| require x } \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n doc, posts = REXML::Document.new(xml), [] \n doc.elements.each('posts/post') do |p| \n posts << p.attributes \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n doc, statuses = REXML::Document.new(xml), [] \n doc.elements.each('statuses/status') do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.elements[a].text \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.elements['user'].elements[a].text \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n<code class="ruby"><strong>2、Hpricot</strong><strong>Pros:</strong> Cool name, created by _why, faster than <span class="caps">REXML</span>, also does <span class="caps">HTML</span>, creative <span class="caps">API</span><strong>Cons:</strong> Not as fast as libxml-ruby, more of an <span class="caps">HTML</span> parser linguistically (ie: uses innerHTML instead of text or content, etc.)`` \n \nRuby代码 \n \n %w[benchmark pp rubygems].each { |x| require x } \n gem 'hpricot', '>= 0.6' \n require 'hpricot' \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n doc, posts = Hpricot::XML(xml), [] \n (doc/:post).each do |p| \n posts << p.attributes \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n doc, statuses = Hpricot::XML(xml), [] \n (doc/:status).each do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.at(a).innerHTML \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.at('user').at(a).innerHTML \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n3、libxml-ruby
\n\n
Pros: Blistering fast \nCons: Hpricot has cooler name, REXML and Hpricot both feel easier to use out of the box \n \nRuby代码 \n \n %w[benchmark pp rubygems].each { |x| require x } \n gem 'libxml-ruby', '>= 0.8.3' \n require 'xml' \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n parser, parser.string = XML::Parser.new, xml \n doc, posts = parser.parse, [] \n doc.find('//posts/post').each do |p| \n posts << p.attributes.inject({}) { |h, a| h[a.name] = a.value; h } \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n parser, parser.string = XML::Parser.new, xml \n doc, statuses = parser.parse, [] \n doc.find('//statuses/status').each do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.find(a).first.content \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.find('user').first.find(a).first.content \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n<code class="ruby"><strong>三、结论</strong> \n<div class="codeText"> \n<div class="codeHead">结果如下:</div> \n<ol class="dp-xml" start="1"> \n <li class="alt"><span><span>=rexml </span></span></li> \n <li><span>delicious 0.020000 0.000000 0.020000 ( 0.021139) </span></li> \n <li class="alt"><span>twitter 0.940000 0.020000 0.960000 ( 0.988666) </span></li> \n <li><span> </span></li> \n <li class="alt"><span>=hpricot </span></li> \n <li><span>delicious 0.010000 0.000000 0.010000 ( 0.005548) </span></li> \n <li class="alt"><span>twitter 0.250000 0.010000 0.260000 ( 0.258320) </span></li> \n <li><span> </span></li> \n <li class="alt"><span>=libxml-ruby </span></li> \n <li><span>delicious 0.000000 0.000000 0.000000 ( 0.007829) </span></li> \n <li class="alt"><span>twitter 0.030000 0.010000 0.040000 ( 0.034040) </span></li> \n</ol> \n</div> \n``<code class="ruby">参考文档:http://railstips.org/2008/8/12/parsing-xml-with-ruby``
\n", "_id"=>424}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Tips"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["oauth"], "comments_count"=>0, "category_id"=>4, "title"=>"初识oauth: 为API访问授权提供一个开放的标准", "body"=>"最近在准备一些API设计开发工作,初步了解了下oauth,OAuth是由Blaine Cook、Chris Messina、Larry Halff 及David Recordon共同发起的,目的在于为API访问授权提供一个开放的标准。\r\noauth目前看来进展比较顺利,可以看到其有主流语言的lib(Java、C#、Objective-C、Perl、PHP及Ruby语言),目前支持oauth的API有twitter,douban等应用。\r\n\r\nOAuth is the great new standard allowing your users to use your application to talk to their accounts on other applications. I won’t go more into it here as it’s pretty well covered on the OAuth site.\r\n\r\nOAuth’s Goal\r\nWebsite X can access your protected data at API Y\r\n
\r\n\t
All without sharing your password off-site
\r\n\t
especially when there isn’t one like with OpenID
\r\n
\r\n其基本流程为:\r\n\r\n\t
Register your consumer application with the OAuth compliant service to receive your Consumer Credentials (This is only done once)
\r\n\t
You initiate the OAuth Token exchange process for a user by requesting a RequestToken from the Service
\r\n\t
You store the RequestToken in your database or in the users session object
\r\n\t
You redirect your user to the service providers authorize_url with the RequestToken’s key appended
\r\n\t
Your user is asked by the service provider to authorize your RequestToken
\r\n\t
Your user clicks yes and is redirected to your CallBack URL
OAuth is the great new standard allowing your users to use your application to talk to their accounts on other applications. I won’t go more into it here as it’s pretty well covered on the OAuth site. \n \nOAuth’s Goal \nWebsite X can access your protected data at API Y \n \n All without sharing your password off-site \n especially when there isn’t one like with OpenID \n \n其基本流程为: \n \n Register your consumer application with the OAuth compliant service to receive your Consumer Credentials (This is only done once) \n You initiate the OAuth Token exchange process for a user by requesting a RequestToken from the Service \n You store the RequestToken in your database or in the users session object \n You redirect your user to the service providers authorize_url with the RequestToken’s key appended \n Your user is asked by the service provider to authorize your RequestToken \n Your user clicks yes and is redirected to your CallBack URL \n Your callback action exchanges the RequestToken for an AccessToken \n Now you can access your users data by performing http requests signed by your consumer credentials and the AccessToken. \n ???? \n PROFIT!!! \n \n如果你想了解,请参考如下文档,如果你有经验,请分享,谢谢! \n \n参考文档: \n \n Developing OAuth clients in Ruby \n How to turn your rails site into an OAuth Provider \n OAuth不断获得动力 \n Rails plugin for OAuth \n OAuth implementation for Ruby \n 豆瓣 API 认证授权说明 \n The How of OAuth --这个PPT挺不错 \n
\n", "_id"=>432}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Ruby&Rails", "to_xml"], "comments_count"=>0, "category_id"=>11, "title"=>"Rails: Disabling XML character escaping for to_xml & xml builder", "body"=>"
In my case, I had to genarate the xml view for api render,but in rails, i got a &XXX format string for non englisg, it also appears to_xml will automatically escape any entities into their corresponding &XXX representation. There's a piece in the documentation that says "If $KCODE is set to u and encoding set to UTF8, then escaping will NOT be performed." \n \nUnfortunately, this doesn't appear to be the case. Even after following the docs and ensuring that default_charset is indeed UTF-8 (actually the default for Rails nowadays), we still get encoded characters in to_xml output. \n \nSince our client is UTF-8 aware, we need to pass thru the UTF-8 data intact. The only way we've found to do this is thru the following horrible monkey-patch:
\n
\n
Ruby代码
\n\n
module Builder
\n
class XmlBase
\n
def _escape(text)
\n
text
\n
end
\n
end
\n
end
\n\n
\n
\nWhat's the proper way to do this? \n \nPS: \nsomebody say that to "set $KCODE='UTF8' in config/environment.rb can solve this issue." but it's not for me. \n \nmore infos: \nhttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2c13ad7c0f8c0781
In my case, I had to genarate the xml view for api render,but in rails, i got a &XXX format string for non englisg, it also appears to_xml will automatically escape any entities into their corresponding &XXX representation. There's a piece in the documentation that says "If $KCODE is set to u and encoding set to UTF8, then escaping will NOT be performed." \n \nUnfortunately, this doesn't appear to be the case. Even after following the docs and ensuring that default_charset is indeed UTF-8 (actually the default for Rails nowadays), we still get encoded characters in to_xml output. \n \nSince our client is UTF-8 aware, we need to pass thru the UTF-8 data intact. The only way we've found to do this is thru the following horrible monkey-patch: \n \nRuby代码 \n \n module Builder \n class XmlBase \n def _escape(text) \n text \n end \n end \n end \n \n \n \nWhat's the proper way to do this? \n \nPS: \nsomebody say that to "set $KCODE='UTF8' in config/environment.rb can solve this issue." but it's not for me. \n \nmore infos: \nhttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2c13ad7c0f8c0781 \n
\n", "_id"=>433}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["random", "ruby"], "comments_count"=>0, "category_id"=>11, "title"=>"Generate a random string", "body"=>"Generates a random string of lowercase letters. Great for email verification codes or user password salt....\n
Some tips for mount&umount ,maybe give you some help..
\n
cdrom: \n# mount -t is09660 /dev/cdrom /mnt/cdrom \n# umount /mnt/cdrom \n \nfloppy: \n# mount /dev/fd0 /mnt/floppy \n#umount /mnt/floppy \n \nusb: \n1.use 'fdisk -l' to show the usb nums,something like '/dev/sda'; \n2.then use 'mkdir /mnt/usb' to create a dir for mount this usb; \n3.at last,use '# mount -t msdos /dev/sda1 /mnt/usb" to mount it. \n4.#umount /mnt/usb \n \nhda: \n1.use 'fdisk -l' to show the disk nums,like '/dev/hda1'; \n2.then use 'make /mnt/vfat' to create a mount point; \n3.at last,use '# mount -t vfat /dev/hda1 /mnt/vfat'to mount it.. \n4.#umount /mnt/vfat
Some tips for mount&umount ,maybe give you some help.. \ncdrom:
\n\n
mount -t is09660 /dev/cdrom /mnt/cdrom
\n\n
umount /mnt/cdrom
\n\n
floppy:
\n\n
mount /dev/fd0 /mnt/floppy
\n\n
umount /mnt/floppy
\n\n
usb: \n1.use 'fdisk -l' to show the usb nums,something like '/dev/sda'; \n2.then use 'mkdir /mnt/usb' to create a dir for mount this usb; \n3.at last,use '# mount -t msdos /dev/sda1 /mnt/usb" to mount it. \n4.#umount /mnt/usb \n \nhda: \n1.use 'fdisk -l' to show the disk nums,like '/dev/hda1'; \n2.then use 'make /mnt/vfat' to create a mount point; \n3.at last,use '# mount -t vfat /dev/hda1 /mnt/vfat'to mount it.. \n4.#umount /mnt/vfat \nand some usefull resource links and docs here: \nhttp://unix-cd.com/unixcd12/article_3967.html \nhttp://blog.oracle.com.cn/index.php/121320/viewspace-6733.html
In my case, I need do send big files to users, yes, you can do it with nginx,just like others static files,but i need some control for the request action,The delivery of a static file which depends on an application header is known as the X-Sendfile feature. \nLighttpd has this feature and there is a mod_xsendfile for Apache2. \nNginx also has this feature, but implemented a little bit differently. In Nginx this feature is called X-Accel-Redirect. \nThere are two main differences:
\n\n
The header must contain a URI
\n
The location should be defined as internal; to prevent the client going directly to the URI
\n\n
\n
\n
Ruby代码
\n\n
location /files {
\n
root /var/www;
\n
internal;
\n
}
\n\n
\n
\n
Ruby代码
\n\n
// Get requested file name
\n
path = @params["path"]
\n
\n
# ...
\n
# Perform any required security checks, validation
In my case, I need do send big files to users, yes, you can do it with nginx,just like others static files,but i need some control for the request action,The delivery of a static file which depends on an application header is known as the X-Sendfile feature. \nLighttpd has this feature and there is a mod_xsendfile for Apache2. \nNginx also has this feature, but implemented a little bit differently. In Nginx this feature is called X-Accel-Redirect. \nThere are two main differences: \n \n The header must contain a URI \n The location should be defined as internal; to prevent the client going directly to the URI \n \n \n \nRuby代码 \n \n location /files { \n root /var/www; \n internal; \n } \n \n \n \nRuby代码 \n \n // Get requested file name \n path = @params["path"] \n \n # ... \n # Perform any required security checks, validation \n # and/or stats accounting \n # ... \n \n # And redirect user to internal location \n response.headers['X-Accel-Redirect'] = "/files/" + path \n \n \n \nsome userfull link resource come here: \n \n http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/ \n http://wiki.codemongers.com/NginxXSendfile \n http://www.motionstandingstill.com/using-nginx-to-send-files-with-x-accel-redirect/2008-09-03/ \n \n
I store user sessions in memcache,and then i want do share theres sessions with sub domains,but i notice some strange things when i put session into memcached,there are: \n1. In my older website(rails 2.0),It genenrated sessions key for memcached as \#{namespace}-\#{RAILS_ENV}:"session:\#{id}"; \n2.In my newer website(reails 2.3),It generated seesions key for memcached just as "\#{namespace}:\#{id}"; \n \nso,i can not get the same seesion datas with diff session keys. i do have spend lots of time for sove this , i do have some userfull dis, \n \n1. In rails2.3 ,it's vendor memcache-client-1.5.0.5 in ruby\\lib\\ruby\\gems\\1.8\\gems\\activesupport-2.3.0\\lib\\active_support\\vendor; \n2. you can config namespace in you environment.rb file like " ActionController::Base.session_options[:namespace] = 'session'" \n3. In rails2.0,when you use memcached,you will use cached_fu and act_as_cache plugins,and you may have a config file in your config dir named memcached.yml, and in this file,you can config defaults,production,test and developer..with lots of filed,like namespace,servers etc.. \n4. you will notice it generate memcached key as mentioned above. \n \nI track it,and got this:
I store user sessions in memcache,and then i want do share theres sessions with sub domains,but i notice some strange things when i put session into memcached,there are: \n1. In my older website(rails 2.0),It genenrated sessions key for memcached as \#{namespace}-\#{RAILS_ENV}:"session:\#{id}"; \n2.In my newer website(reails 2.3),It generated seesions key for memcached just as "\#{namespace}:\#{id}"; \n \nso,i can not get the same seesion datas with diff session keys. i do have spend lots of time for sove this , i do have some userfull dis, \n \n1. In rails2.3 ,it's vendor memcache-client-1.5.0.5 in ruby\\lib\\ruby\\gems\\1.8\\gems\\activesupport-2.3.0\\lib\\active_support\\vendor; \n2. you can config namespace in you environment.rb file like " ActionController::Base.session_options[:namespace] = 'session'" \n3. In rails2.0,when you use memcached,you will use cached_fu and act_as_cache plugins,and you may have a config file in your config dir named memcached.yml, and in this file,you can config defaults,production,test and developer..with lots of filed,like namespace,servers etc.. \n4. you will notice it generate memcached key as mentioned above. \n \nI track it,and got this: \n \nRuby代码 \n \n def setup_memcache(config) \n config[:namespace] << "-\#{RAILS_ENV}" \n \n silence_warnings do \n Object.const_set :CACHE, memcache_klass.new(config) \n end \n \n CACHE.servers = Array(config.delete(:servers)) \n \n setup_session_store if config[:sessions] \n setup_fragment_store! if config[:fragments] \n setup_fast_hash! if config[:fast_hash] \n setup_fastest_hash! if config[:fastest_hash] \n \n CACHE \n end \n \n \nshit,it append RAILS_ENV to namespace with "-",that's it...I hate some hardcode config in plugin,blalal.... \nsome userfull link resources... \n \n http://errtheblog.com/posts/22-sessions-n-such \n http://www.raecoo.com/2008/10/25/rails-store-format-in-memcache/ \n http://www.scribd.com/doc/2203398/Scaling-Rails-with-memcached \n http://railscasts.com/episodes/115-caching-in-rails-2-1
In some case,you may want do get Uniquely Identifying for a 'real' android phone,and you can do it like this:
\n
In Android.Provider.Settings.System we have some interesting values that could be of use, one specifically is “Android_ID”. From the documentation it is the following;
\n
\n
String \tANDROID_ID \tThe Android ID (a unique 64-bit value) as a hex string. \t“android_id”
\nAlso, note that in an emulator this will return “null”, though a real device will return an actual value. The nice thing about this tid-bit of code is that you are not required any special permissions to call it, since it’s essentially a passive call to get information. No write access is (obviously) required.\n
Garry Tan, cofounder of Posterous, lists 12 lessons for scaling that apply to more than just Rails,and i mark some word below. \n \nUse cloud storage for static files. --S3,I do not care it 's fine in china. \nUse HTTP Cache Control to tell the browser what it can cache. --this is true,etag is great. \nUse Sphinx for text search. --sometimes,you do have others chose. \nUse InnoDB for more crash resistant and faster writes. --maybe it's right. \nDon't use textbook Rails ActiveRecord objects. Use New Relic to find exactly what is slow in your system. --yep \nUse memcache later so you find your database bottlenecks now. --this is very important. \nUse mongrel proctitle to find your slow queries. You are only as fast as your slowest queries. -maybe mongrel is not only chose,think about thin,ok? \nUse asynchronous job queuing to do work in parallel. --yes,but sometimes crontab is enough. \nUse monitoring so you'll know when your site went down and why. --that's it,just do it. \nLearn by reading the source code, fixing problems, and submitting them back to the community. --very userfull when you got some strange questions.. \nUse new plugins. Old plugins can't be trusted. --and check chang histroy carefully. \nUse new information. Old information can't be trusted. --and what's this? \n \ngo to http://axonflux.com/building-and-scaling-a-startup for more infos.
When it asks for driver location choose the unzipped folderand install the driver for it.
\n
You'll see sth like "HTC Dream Composite ADB Interface" on success
\n
(Re)Start Eclipse
\n
Your G1 should now be listed in the DDMS-Perspective under Devices
\n
Go to the AndroidManifest.xml of your App and modify it to containandroid:debuggable="true"in the <application ... >-Tag,look like this:<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
\n
Go Debug as usual. \n
\n\nps: I do not upload the zip file here,you can find it via the link above,but if you can not download it,you can mail me to fetch one.
I konw,you can dev app and test it on the simulator,but if you had a real driver,G1,you can do debug on it,very great,here is the tips for this: \n \n On your G1, go to Settings Applications Development [X] USB debugging \n Download this file: android_usb_windows.zip \n Unzip it to a folder \n Connect your G1 with your PC \n When it asks for driver location choose the unzipped folder and install the driver for it. \n You'll see sth like "HTC Dream Composite ADB Interface" on success \n (Re)Start Eclipse \n Your G1 should now be listed in the DDMS-Perspective under Devices \n Go to the AndroidManifest.xml of your App and modify it to contain android:debuggable="true" in the <application ... >-Tag ,look like this:<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> \n Go Debug as usual. \n \n \nps: I do not upload the zip file here,you can find it via the link above,but if you can not download it,you can mail me to fetch one. \nBtw: \nYou can now install (signed)APKs via USB: \nD:\\dev\\Android\\android-sdk-windows-1.0_r1\\tools>adb -d install D:\\Workspace\\keytools\\AndNav_signed.apk \n1305 KB/s (1975987 bytes in 1.478s) \npkg: /data/local/tmp/AndNav_signed.apk \nSuccess \n \n \nAnd uninstall them: \nD:\\dev\\Android\\android-sdk-windows-1.0_r1\\tools>adb uninstall org.andnav \nSuccess \n \n
In some case,you may want do get Uniquely Identifying for a 'real' android phone,such as IMEI code,SimOperator etc, and we all kown ,the IMEI like ID card,and you can use TelephonyManager to get it,some usefull codes like this :
Apr 1 01:47:49 garden kernel: Linux version 2.6.18-92.1.17.el5 (mockbuild@builder10.centos.org) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)) #1 SMP Tue Nov 4 13:43:30 EST 2008
\n
\n \nlooks like something wrong about "ip_conntrack",and i do some check like this: \n\n
Installing ri documentation for fastercsv-1.4.0...
\n
Installing RDoc documentation for fastercsv-1.4.0...
\n
iceskysl ~/webroot: cd ..
\n\n
\nand do not forget to add "require 'fastercsv'" in your class file.", "created_at"=>2009-04-22 17:12:15 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
some tips is here. \n \nRuby代码 \n \n def self.imp_init_owner_data \n fp = "\#{RAILS_ROOT}/datas/inumbers/ini_owner.csv" \n FasterCSV.open(fp, "w") do |csv| \n InumberCate.find_all_by_typee("owner").each do |owner| \n csv << [owner.name,owner.id] \n end \n end \n end \n \n \ninstall fastercsv gems like this.. \n \n \n \nRuby代码 \n \n iceskysl ~/webroot: gem install fastercsv \n Successfully installed fastercsv-1.4.0 \n 1 gem installed \n Installing ri documentation for fastercsv-1.4.0... \n Installing RDoc documentation for fastercsv-1.4.0... \n iceskysl ~/webroot: cd .. \n \n \nand do not forget to add "require 'fastercsv'" in your class file.
you can use apt-spy to update sources.list ,here is some step and tips. \n1.open /etc/apt/sources.list and add this \ndeb http://http.us.debian.org/debian/ stable main \n2.do "apt-get update" \n3.then "apt-get install apt-spy" \n4.then "apt-spy update" \n5.last,"apt-spy -d unstable -a asia -t 5" \n \nref: \nhttp://http.us.debian.org/debian/README.mirrors.txt
you can use apt-spy to update sources.list ,here is some step and tips. \n1.open /etc/apt/sources.list and add this \ndeb http://http.us.debian.org/debian/ stable main \n2.do "apt-get update" \n3.then "apt-get install apt-spy" \n4.then "apt-spy update" \n5.last,"apt-spy -d unstable -a asia -t 5" \n \nref: \nhttp://http.us.debian.org/debian/README.mirrors.txt
\n", "_id"=>448}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["iowait"], "comments_count"=>0, "category_id"=>11, "title"=>"How can I find out what is generating iowait on my server?", "body"=>"
A question I’m asked daily is “How can I find out what is generating iowait on my server?” Sure, you can dig through pages of lsof output, restart services, or run strace, but it can be a frustrating process. I saw a process on this blog post, and a guy changed the regexes to fit Red Hat and CentOS systems a bit better: \n
A question I’m asked daily is “How can I find out what is generating iowait on my server?” Sure, you can dig through pages of lsof output, restart services, or run strace, but it can be a frustrating process. I saw a process on this blog post, and a guy changed the regexes to fit Red Hat and CentOS systems a bit better: \n \nRuby代码 \n \n [root@5-3 ~]# /etc/init.d/syslog stop \n Shutting down kernel logger: [ OK ] \n Shutting down system logger: [ OK ] \n [root@5-3 ~]# echo 1 > /proc/sys/vm/block_dump \n [root@5-3 ~]# dmesg | egrep "READ|WRITE|dirtied" | egrep -o '([a-zA-Z]*)' | sort | uniq -c | sort -rn | head \n 202 kjournald \n 16 egrep \n 9 irqbalance \n 9 bash \n 2 java \n 1 sda \n 1 mailserver \n [root@5-3 ~]# echo 0 > /proc/sys/vm/block_dump \n [root@5-3 ~]# /etc/init.d/syslog start \n Starting system logger: [ OK ] \n Starting kernel logger: [ OK ] \n \n \nIn my specific situation, it looks like kjournald is the biggest abuser of my disk. \nDon’t forget to set things back to their normal state when you’re done! \n \nXML/HTML代码 \n \n # echo 0 > /proc/sys/vm/block_dump \n # /etc/init.d/syslog start \n \n \n \n \nref: \nhttp://rackerhacker.com/2008/03/11/hunting-down-elusive-sources-of-iowait/ \nhttp://blog.eikke.com/index.php/ikke/2007/03/22/who_s_abusing_my_sata_controller \nhttp://hi.baidu.com/dipsey/blog/item/900bbbaf3e46dcc97cd92aba.html \nhttp://www.ducea.com/2009/03/11/howto-install-iotop-on-debian-etch/ \n \nhttp://www.cppblog.com/go-benny/archive/2008/04/23/47908.html \n
--attach PID Quit god when the attached process dies
\n
--no-events Disable the event system
\n
--bleakhouse Enable bleakhouse profiling
\n
[iceskysl@ws_api]#
\n\n
\n1.DYNAMICALLY LOADING CONFIG FILES INTO AN ALREADY RUNNING GOD\n
\n
God allows you to load or reload configurations into an already running instance. There are a few things to consider when doing this:
\n
\n
Existng Watches with the samename```as the incoming Watches will be overidden by the new config.
\n
All paths must be either absolute or relative to the path from which god was started.
\n
\n
To load a config into a running god, issue the following command:
\n
$ sudo god load path/to/config.god # god load /data/www/api/config/config_thin_api.god```\n
Config files that are loaded dynamically can contain anything that a normal config file contains, however, global options such asGod.pid_file_directory```blocks will be ignored (and produce a warning in the logs).
\n
\n
2.show logs
\n
\n
\n
XML/HTML代码
\n\n
[iceskysl@ws_api]# god log thin-thin-7514
\n
I, [2009-04-28T08:24:16.705870 #23174] INFO -- : thin-thin-7514 moved 'up' to 'up'
\n
I, [2009-04-28T08:24:16.706346 #23174] INFO -- : thin-thin-7514 [trigger] process is not running (ProcessRunning)
\n
I, [2009-04-28T08:24:16.888477 #23174] INFO -- : thin-thin-7514 sent email to iceskysl@gmail.com (Email)
\n
I, [2009-04-28T08:24:16.888642 #23174] INFO -- : thin-thin-7514 move 'up' to 'start'
\n
I, [2009-04-28T08:24:16.888976 #23174] INFO -- : thin-thin-7514 before_start: no pid file to delete (CleanPidFile)
\n
I, [2009-04-28T08:24:16.889109 #23174] INFO -- : thin-thin-7514 start: thin start -C /data/www/web/current/config/thin.yml -o 7514
some days before,i posted a article 《God: 比Monit更好用的monitoring》,today,i will post more useful tips for God. \n \n \nRuby代码 \n \n [iceskysl@ws_api]# god --help \n Usage: \n Starting: \n god [-c <config file>] [-p <port> | -b] [-P <file>] [-l <file>] [-D] \n \n Querying: \n god <command> <argument> [-p <port>] \n god <command> [-p <port>] \n god -v \n god -V (must be run as root to be accurate on Linux) \n \n Commands: \n start <task or group name> start task or group \n restart <task or group name> restart task or group \n stop <task or group name> stop task or group \n monitor <task or group name> monitor task or group \n unmonitor <task or group name> unmonitor task or group \n remove <task or group name> remove task or group from god \n load <file> load a config into a running god \n log <task name> show realtime log for given task \n status show status of each task \n quit stop god \n terminate stop god and all tasks \n check run self diagnostic \n \n Options: \n -c, --config-file CONFIG Configuration file \n -p, --port PORT Communications port (default 17165) \n -b, --auto-bind Auto-bind to an unused port number \n -P, --pid FILE Where to write the PID file \n -l, --log FILE Where to write the log file \n -D, --no-daemonize Don't daemonize \n -v, --version Print the version number and exit \n -V Print extended version and build information \n --log-level LEVEL Log level [debug|info|warn|error|fatal] \n --no-syslog Disable output to syslog \n --attach PID Quit god when the attached process dies \n --no-events Disable the event system \n --bleakhouse Enable bleakhouse profiling \n [iceskysl@ws_api]# \n \n \n1.DYNAMICALLY LOADING CONFIG FILES INTO AN ALREADY RUNNING GOD \n \nGod allows you to load or reload configurations into an already running instance. There are a few things to consider when doing this: \n \n Existng Watches with the same name<span class="Apple-converted-space"> </span>as the incoming Watches will be overidden by the new config.</li> \n <li style="margin: 0px; font-size: 13px;">All paths must be either absolute or relative to the path from which god was started.</li> \n</ul> \n<p style="margin: 0px 0px 1em; font-size: 13px;">To load a config into a running god, issue the following command:</p> \n<pre style="border: 1px solid rgb(204, 204, 204); margin: 1em 0px; padding: 1em; font-size: 10px; line-height: 1.3; background-color: rgb(239, 239, 239);">$ sudo god load path/to/config.god<br /># god load /data/www/api/config/config_thin_api.god \nConfig files that are loaded dynamically can contain anything that a normal config file contains, however, global options such as God.pid_file_directory``` blocks will be ignored (and produce a warning in the logs). \n \n2.show logs \n \n \nXML/HTML代码 \n \n [iceskysl@ws_api]# god log thin-thin-7514 \n I, [2009-04-28T08:24:16.705870 #23174] INFO -- : thin-thin-7514 moved 'up' to 'up' \n I, [2009-04-28T08:24:16.706346 #23174] INFO -- : thin-thin-7514 [trigger] process is not running (ProcessRunning) \n I, [2009-04-28T08:24:16.888477 #23174] INFO -- : thin-thin-7514 sent email to iceskysl@gmail.com (Email) \n I, [2009-04-28T08:24:16.888642 #23174] INFO -- : thin-thin-7514 move 'up' to 'start' \n I, [2009-04-28T08:24:16.888976 #23174] INFO -- : thin-thin-7514 before_start: no pid file to delete (CleanPidFile) \n I, [2009-04-28T08:24:16.889109 #23174] INFO -- : thin-thin-7514 start: thin start -C /data/www/web/current/config/thin.yml -o 7514 \n \n \n \nresource links: \nhttp://god.rubyforge.org/ \n
If you have recently updated to Rails 2.2.2, you may encounter this error when you want to start your application: \n \n/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in \n`load_missing_constant': uninitialized constant Inflector (NameError) \n \nthe usage of Inflector class is changed a bit. You can see the difference when you compare the inflections.rb files. Path of the file is yourApp/config/initializers/inflections.rb \n \n
\n
inflections.rb (Rails 2.1.0)
\n\n
\n
\n
Inflector.inflections do |inflect|
\n
.
\n
.
\n
.
\n
end
\n\n
\n \n
\n
inflections.rb (Rails 2.2.2)
\n\n
ActiveSupport::Inflector.inflections do |inflect|
\n
.
\n
.
\n
.
\n
end
\n\n
\nthe situation changing Inflector to ActiveSupport::Inflector was enough to solve the problem.", "created_at"=>2009-05-05 13:37:01 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
If you have recently updated to Rails 2.2.2, you may encounter this error when you want to start your application: \n \n/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in \n`load_missing_constant': uninitialized constant Inflector (NameError) \n \nthe usage of Inflector class is changed a bit. You can see the difference when you compare the inflections.rb files. Path of the file is yourApp/config/initializers/inflections.rb \n \n \ninflections.rb (Rails 2.1.0) \n \n \n \n Inflector.inflections do |inflect| \n . \n . \n . \n end \n \n \n \n \ninflections.rb (Rails 2.2.2) \n \n ActiveSupport::Inflector.inflections do |inflect| \n . \n . \n . \n end \n \n \nthe situation changing Inflector to ActiveSupport::Inflector was enough to solve the problem.
\n", "_id"=>452}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["God", "ruby", "Ruby&Rails"], "comments_count"=>0, "category_id"=>11, "title"=>"Socket Errno::EAFNOSUPPORT with God in ruby", "body"=>"
when i start god.sh,then give some error msg like this:
\n
\n
\n
XML/HTML代码
\n\n
I [2009-05-16 21:25:41] INFO: Using pid file directory: /var/run/god
\n
/usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `initialize': Address family not supported by protocol - socket(2) (Errno::EAFNOSUPPORT)
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `open'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `open_server_inaddr_any'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:863:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:759:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in `each'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1340:in `initialize'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in `new'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in `start_service'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:78:in `start'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:43:in `initialize'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in `new'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in `start'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:633:in `at_exit'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:666
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/cli/run.rb:87
\n\n
\nok,then i find some userful messsage,like here:\n
Errno::EAFNOSUPPORT - the specifiedsockaddrisnot a valid address for the family of the callingsocket
\n
and here, i notice where is the problen,the god find hostname,name map it to ip address,then create some sockets on the ip,and the error point is here,so i nano my /etc/hosts file,and add map for hostname and 127.0.0.1,that's it! \n
when i start god.sh,then give some error msg like this: \n \n \nXML/HTML代码 \n \n I [2009-05-16 21:25:41] INFO: Using pid file directory: /var/run/god \n /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in initialize': Address family not supported by protocol - socket(2) (Errno::EAFNOSUPPORT) </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in open' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in open_server_inaddr_any' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:863:in open_server' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:759:in open_server' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in each' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in open_server' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1340:in initialize' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in new' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in start_service' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:78:in start' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:43:in initialize' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in new' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in start' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:633:in `at_exit' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:666 \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/cli/run.rb:87 \n \n \nok,then i find some userful messsage,like here: \nErrno::EAFNOSUPPORT - the specified sockaddr isnot a valid address for the family of the calling socket \nand here, i notice where is the problen,the god find hostname,name map it to ip address,then create some sockets on the ip,and the error point is here,so i nano my /etc/hosts file,and add map for hostname and 127.0.0.1,that's it!
\n", "_id"=>453}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["书"], "comments_count"=>0, "category_id"=>6, "title"=>"我写的书:《Google Android开发入门与实战》等即将上市.", "body"=>"这篇文章是非技术性的,所以使用中文写,免得写了大家看不懂,呵呵。\r\n\r\n写书不是第一次,出版却是第一本,至于原因,就不详述了,去年9月开始参与一些图书的翻译和撰写中,截至到目前,这段时间一共参与了三本书,按照参与的先后顺序,分别是《The Rails Way》,《Google API 编程.开发.实例》以及《Google Android开发入门与实战》。\r\n\r\n其中《The Rails Way》是做为译者参与,其他翻译者都是国内第一批Rails技术人员,分散在全国各地,还有一名译者在加拿大,我一共翻译了5章内容,分别是第2章“Working_with_Controllers”,第10章“ActionView”,第13章“Session__Session_Management”,第15章“XML_and_ActiveResource”和第16章“ActionMailer”,翻译很早前就结束了,目前好像还在审稿、校核工作,由YiTan在跟,至于何时出版,我还真不知道。\r\n\r\n《Google API 编程.开发.实例》我是从去年9月份介入,开始参与选题和策划,截至撰写相关内容,因为我自身是Google重度使用者,平时也比较多的使用和了解GoogleAPI,所以写起来得心应手,一共写了“Google Account Authentication”,“Google AJAX Language API”,“Google Chart API”,“Blogger Data API”,“Feedburner API”,“Google Code Search Data API”和“Google Book Search Book Viewability API”这些章节,前前后后也花了不少零碎的时间。其他作者大多都Google内部的同学,本书已经进入出版流程,由博文视点出版社策划出版,应该在6.5号Google开发者大会上可以看到,如下是本书第一版封面。\r\n\r\n\r\n\r\n本书特点:本书覆盖了Google绝大多数的API,其中针对每个API就其原理、用法做了详细说明,最后基本上都有实际的例子演示如何使用。\r\n\r\n《Google Android开发入门与实战》是08年11月份开始撰写的,和另外一个朋友一起,两个人陆续的差不多用了半年时间,在09年4月份差不多全部写完,后面主要是都在校核和审稿,由人民邮电出版社出版,5月底6月初即可上市,封面如下:\r\n\r\n\r\n\r\n \r\n
《Google API 编程.开发.实例》我是从去年9月份介入,开始参与选题和策划,截至撰写相关内容,因为我自身是Google重度使用者,平时也比较多的使用和了解GoogleAPI,所以写起来得心应手,一共写了“Google Account Authentication”,“Google AJAX Language API”,“Google Chart API”,“Blogger Data API”,“Feedburner API”,“Google Code Search Data API”和“Google Book Search Book Viewability API”这些章节,前前后后也花了不少零碎的时间。其他作者大多都Google内部的同学,本书已经进入出版流程,由博文视点出版社策划出版,应该在6.5号Google开发者大会上可以看到,如下是本书第一版封面。
and now,you can open a cmd shell,and input sqlite3 like this: \n
\n
C:\\Documents and Settings\\Administrator>sqlite3 \nSQLite version 3.5.9 \nEnter ".help" for instructions
\n
and some help infos is here:
\n
sqlite> .help \n.bail ON|OFF Stop after hitting an error. Default OFF \n.databases List names and files of attached databases \n.dump ?TABLE? ... Dump the database in an SQL text format \n.echo ON|OFF Turn command echo on or off \n.exit Exit this program \n.explain ON|OFF Turn output mode suitable for EXPLAIN on or off. \n.header(s) ON|OFF Turn display of headers on or off \n.help Show this message \n.import FILE TABLE Import data from FILE into TABLE \n.indices TABLE Show names of all indices on TABLE \n.load FILE ?ENTRY? Load an extension library \n.mode MODE ?TABLE? Set output mode where MODE is one of: \n csv Comma-separated values \n column Left-aligned columns. (See .width) \n html HTML <table> code \n insert SQL insert statements for TABLE \n line One value per line \n list Values delimited by .separator string \n tabs Tab-separated values \n tcl TCL list elements \n.nullvalue STRING Print STRING in place of NULL values \n.output FILENAME Send output to FILENAME \n.output stdout Send output to the screen \n.prompt MAIN CONTINUE Replace the standard prompts \n.quit Exit this program \n.read FILENAME Execute SQL in FILENAME \n.schema ?TABLE? Show the CREATE statements \n.separator STRING Change separator used by output mode and .import \n.show Show the current values for various settings \n.tables ?PATTERN? List names of tables matching a LIKE pattern \n.timeout MS Try opening locked tables for MS milliseconds \n.width NUM NUM ... Set column widths for "column" mode
Install SQLite3 for Windows by downloading the following 2 zip files and unzipping them into /WINDOWS/system32 \nhttp://www.sqlite.org/sqlite-3_6_14_1.zip \nhttp://www.sqlite.org/sqlitedll-3_6_14_1.zip \nIf those don't work try the official download site here \nand now,you can open a cmd shell,and input sqlite3 like this: \n \nC:\\Documents and Settings\\Administrator>sqlite3 \nSQLite version 3.5.9 \nEnter ".help" for instructions \nand some help infos is here: \nsqlite> .help \n.bail ON|OFF Stop after hitting an error. Default OFF \n.databases List names and files of attached databases \n.dump ?TABLE? ... Dump the database in an SQL text format \n.echo ON|OFF Turn command echo on or off \n.exit Exit this program \n.explain ON|OFF Turn output mode suitable for EXPLAIN on or off. \n.header(s) ON|OFF Turn display of headers on or off \n.help Show this message \n.import FILE TABLE Import data from FILE into TABLE \n.indices TABLE Show names of all indices on TABLE \n.load FILE ?ENTRY? Load an extension library \n.mode MODE ?TABLE? Set output mode where MODE is one of: \n csv Comma-separated values \n column Left-aligned columns. (See .width) \n html HTML <table> code \n insert SQL insert statements for TABLE \n line One value per line \n list Values delimited by .separator string \n tabs Tab-separated values \n tcl TCL list elements \n.nullvalue STRING Print STRING in place of NULL values \n.output FILENAME Send output to FILENAME \n.output stdout Send output to the screen \n.prompt MAIN CONTINUE Replace the standard prompts \n.quit Exit this program \n.read FILENAME Execute SQL in FILENAME \n.schema ?TABLE? Show the CREATE statements \n.separator STRING Change separator used by output mode and .import \n.show Show the current values for various settings \n.tables ?PATTERN? List names of tables matching a LIKE pattern \n.timeout MS Try opening locked tables for MS milliseconds \n.width NUM NUM ... Set column widths for "column" mode
add this line into /etc/lftp.conf \nset net:limit-rate 10240000,40960 \n \nthat's limit upload rate to 10M,and download to 40K \n \nsome useful resource:
\ncURL figures out which protocol to use from the URL you provide, and when \"http:\" is specified will, unless otherwise instructed (using -0), default to using HTTP 1.1. The first argument, -u, instructs cURL to use the next two parameters (separated by a colon) as the account name and password for basic authentication. The next argument, -d, specifies the data (maximum 140 characters) to be sent via a POST request.\n\nOf course what cURL expects is a response to the POST request so the result will be the requested page (update.xml) sent to stdout. This page will be encoded according to the file type used in the request, thus as we just requested update.xml we’ll get XML-formatted data. The alternatives are JSON (JavaScript Object Notation), RSS and Atom formats.\n\nfrom:\nhttp://www.networkworld.com/columnists/2008/052108-gearhead.html?page=2", "created_at"=>2009-09-27 18:26:17 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
curl -u email:passw -d status="text" http://twitter.com/statuses/update.xml \ncURL figures out which protocol to use from the URL you provide, and when "http:" is specified will, unless otherwise instructed (using -0), default to using HTTP 1.1. The first argument, -u, instructs cURL to use the next two parameters (separated by a colon) as the account name and password for basic authentication. The next argument, -d, specifies the data (maximum 140 characters) to be sent via a POST request.
\n\n
Of course what cURL expects is a response to the POST request so the result will be the requested page (update.xml) sent to stdout. This page will be encoded according to the file type used in the request, thus as we just requested update.xml we’ll get XML-formatted data. The alternatives are JSON (JavaScript Object Notation), RSS and Atom formats.
项目中使用nginx,上传一个大文件,出来错误提示,413 Request Entity Too Large! \n查了下资料,解决方法:打开nginx主配置文件nginx.conf,找到http{}段,添加
\n\n
client_max_body_size 20m;
\n\n
最好也调整下: \n keepalive_timeout 105; \n免得链接超时被关!
\n\n
该文件一般在/etc/nginx/nginx.conf
\n", "_id"=>463}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["rails", "rails-2.3.4"], "comments_count"=>0, "category_id"=>6, "title"=>"rails-2.3.4 发布了", "body"=>"Ruby on Rails 2.3.4, this release fixes bugs and introduces a few minor features. Due to the inclusion of two security fixes, all users of the 2.3 series are recommended to upgrade as soon as possible.\n\nC:\\Documents and Settings\\Administrator>gem install rails\nSuccessfully installed activesupport-2.3.4\nSuccessfully installed activerecord-2.3.4\nSuccessfully installed actionpack-2.3.4\nSuccessfully installed actionmailer-2.3.4\nSuccessfully installed activeresource-2.3.4\nSuccessfully installed rails-2.3.4\n6 gems installed\nInstalling ri documentation for activesupport-2.3.4...\nInstalling ri documentation for activerecord-2.3.4...\nInstalling ri documentation for actionpack-2.3.4...\nInstalling ri documentation for actionmailer-2.3.4...\nInstalling ri documentation for activeresource-2.3.4...\nInstalling RDoc documentation for activesupport-2.3.4...\nInstalling RDoc documentation for activerecord-2.3.4...\nInstalling RDoc documentation for actionpack-2.3.4...\nInstalling RDoc documentation for actionmailer-2.3.4...\nInstalling RDoc documentation for activeresource-2.3.4...\n\n详细信息:\n\nhttp://weblog.rubyonrails.org/2009/9/4/ruby-on-rails-2-3-4", "created_at"=>2009-10-14 07:47:04 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
Ruby on Rails 2.3.4, this release fixes bugs and introduces a few minor features. Due to the inclusion of two security fixes, all users of the 2.3 series are recommended to upgrade as soon as possible.
\n\n
C:\\Documents and Settings\\Administrator>gem install rails \nSuccessfully installed activesupport-2.3.4 \nSuccessfully installed activerecord-2.3.4 \nSuccessfully installed actionpack-2.3.4 \nSuccessfully installed actionmailer-2.3.4 \nSuccessfully installed activeresource-2.3.4 \nSuccessfully installed rails-2.3.4 \n6 gems installed \nInstalling ri documentation for activesupport-2.3.4... \nInstalling ri documentation for activerecord-2.3.4... \nInstalling ri documentation for actionpack-2.3.4... \nInstalling ri documentation for actionmailer-2.3.4... \nInstalling ri documentation for activeresource-2.3.4... \nInstalling RDoc documentation for activesupport-2.3.4... \nInstalling RDoc documentation for activerecord-2.3.4... \nInstalling RDoc documentation for actionpack-2.3.4... \nInstalling RDoc documentation for actionmailer-2.3.4... \nInstalling RDoc documentation for activeresource-2.3.4...
\n", "_id"=>465}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["package", "ubuntu", "uninstall"], "comments_count"=>0, "category_id"=>7, "title"=>"Uninstall / Delete / Remove Package", "body"=>"Just use the following syntax:\n\nsudo apt-get remove {package-name}\n\nFor example remove package called mplayer, enter:\n$ sudo apt-get remove mplayer\n\nRemove package called lighttpd along with all configuration files, enter:\n$ sudo apt-get --purge remove lighttpd\n\nTo list all installed package, enter:\\\ndpkg --list\ndpkg --list | less\ndpkg --list | grep -i 'http'", "created_at"=>2009-11-22 18:48:23 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
Just use the following syntax:
\n\n
sudo apt-get remove {package-name}
\n\n
For example remove package called mplayer, enter: \n$ sudo apt-get remove mplayer
\n\n
Remove package called lighttpd along with all configuration files, enter: \n$ sudo apt-get --purge remove lighttpd
\n\n
To list all installed package, enter:\\ \ndpkg --list \ndpkg --list | less \ndpkg --list | grep -i 'http'
\n", "_id"=>466}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["delegate", "ImageMagick"], "comments_count"=>0, "category_id"=>7, "title"=>"ImageMagick够折腾得,no decode delegate", "body"=>"估计RP出问题了,以前安装和今天在mac上安装都很顺利,但是在服务器上装得时候,出现一大堆得问题,极度诡异,最后查了N多资料,改了N多东西,也不晓得最后是哪个生效了,终于折腾好了.\n记录下我参考过得资料:\nhttp://www.imagemagick.org/script/command-line-processing.php\nhttp://wanguan2000.blog.ubuntu.org.cn/2009/01/04/ubuntu-下rmagick的安装/\nhttp://infrastacks.com/?p=57\nhttp://hi.baidu.com/yttxuehui/blog/item/9f1a21978d6fa96a55fb96d5.html\nhttp://www.blogjava.net/fl1429/archive/2009/06/17/282895.html\nhttp://hi.baidu.com/countryroadtao/blog/item/225c72dad2adc16cd0164e97.html\nhttp://www.cnscn.org/htm_data/602/0705/8717.html\nhttp://stackoverflow.com/questions/1483968/imagemagick-convert-error-wrong-jpeg-library-version-library-is-62-caller-expe\n我读最后一个问题印象深刻\n\"Looks like it is reading the wrong jpeg ibrary, but I have jpeg 7 installed. How do i tell ImageMagick to look up the right JPEG library version(I don't care 62 or 70 as long as it works).\"\nroot@li84-64:/data/soft/ImageMagick-6.5.7-9# convert -list format | grep JPEG\n see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS),\n and supplement 61 which adds JPEG-2000 encoding.\n JNG* PNG rw- JPEG Network Graphics\n JP2* JP2 rw- JPEG-2000 File Format Syntax\n JPC* JPC rw- JPEG-2000 Code Stream Syntax\n JPEG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n JPG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n JPX* JPX rw- JPEG-2000 File Format Syntax\n PGX* PGX r-- JPEG-2000 VM Format\n PJPEG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n\n看到其需要得JPEG得lib是70,但是我装得是\n\nroot@li84-64:/data/soft/ImageMagick-6.5.7-9# dpkg --list | grep \"magick\"\nrc imagemagick 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation programs\nii libmagick++10 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library\nii libmagick++9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library - develop\nii libmagick10 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library\nii libmagick9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library - development fil\nii libmagickcore1 7:6.4.5.4.dfsg1-1ubuntu3.1 low-level image manipulation library\nii libmagickwand1 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation library\nii librmagick-ruby 1.15.11-1ubuntu1 ImageMagick API for Ruby\nii librmagick-ruby1.8 1.15.11-1ubuntu1 ImageMagick API for Ruby", "created_at"=>2009-11-22 20:30:32 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
root@li84-64:/data/soft/ImageMagick-6.5.7-9# dpkg --list | grep "magick" \nrc imagemagick 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation programs \nii libmagick++10 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library \nii libmagick++9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library - develop \nii libmagick10 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library \nii libmagick9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library - development fil \nii libmagickcore1 7:6.4.5.4.dfsg1-1ubuntu3.1 low-level image manipulation library \nii libmagickwand1 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation library \nii librmagick-ruby 1.15.11-1ubuntu1 ImageMagick API for Ruby \nii librmagick-ruby1.8 1.15.11-1ubuntu1 ImageMagick API for Ruby
\n", "_id"=>467}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["find", "inject", "rails", "ruby", "select"], "comments_count"=>0, "category_id"=>5, "title"=>"用Ruby在已知数组中找到和目标最匹配得元素", "body"=>"有个需求,给定一个数组,然后给出一个变量,需要在这个数组中找到和这个变量得值最接近得那个元素,开始用find或者select都不是很合适,最后找到inject,很好得解决了这个需求,现在记录下:\n首先看下inject这个函数\n````\nenum.inject(initial) {| memo, obj | block } => obj\nenum.inject {| memo, obj | block } => obj\nCombines the elements of enum by applying the block to an accumulator value (memo) and each element in turn. At each step, memo is set to the value returned by the block. The first form lets you supply an initial value for memo. The second form uses the first element of the collection as a the initial value (and skips that element while iterating).\n\n # Sum some numbers\n (5..10).inject {|sum, n| sum + n } #=> 45\n # Multiply some numbers\n (5..10).inject(1) {|product, n| product * n } #=> 151200\n\n # find the longest word\n longest = %w{ cat sheep bear }.inject do |memo,word|\n memo.length > word.length ? memo : word\n end\n longest #=> \"sheep\"\n\n # find the length of the longest word\n longest = %w{ cat sheep bear }.inject(0) do |memo,word|\n memo >= word.length ? memo : word.length\n end\n longest #=> 5\n```\n\n然后根据我得需求,写出一个函数如下:\n````\n # find the min abs size\n def self.select_h(h)\n if ALL_FORMATS.include?(h)\n return h\n else\n ok_size = ALL_FORMATS.inject do |i,j|\n (i-h).abs < (j-h).abs ? i : j\n end\n return ok_size\n end\n end\n```\n首先看是否包含这个变量,如果又,直接返回,如果没有就inject来取一个最合适得。", "created_at"=>2009-11-24 08:06:13 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
有个需求,给定一个数组,然后给出一个变量,需要在这个数组中找到和这个变量得值最接近得那个元素,开始用find或者select都不是很合适,最后找到inject,很好得解决了这个需求,现在记录下: \n首先看下inject这个函数 \n```` \nenum.inject(initial) {| memo, obj | block } => obj \nenum.inject {| memo, obj | block } => obj \nCombines the elements of enum by applying the block to an accumulator value (memo) and each element in turn. At each step, memo is set to the value returned by the block. The first form lets you supply an initial value for memo. The second form uses the first element of the collection as a the initial value (and skips that element while iterating).
\n\n
# Sum some numbers \n (5..10).inject {|sum, n| sum + n } #=> 45 \n # Multiply some numbers \n (5..10).inject(1) {|product, n| product * n } #=> 151200
\n\n
# find the longest word \n longest = %w{ cat sheep bear }.inject do |memo,word| \n memo.length > word.length ? memo : word \n end \n longest #=> "sheep"
\n\n
# find the length of the longest word \n longest = %w{ cat sheep bear }.inject(0) do |memo,word| \n memo >= word.length ? memo : word.length \n end \n longest #=> 5 \n```
\n\n
然后根据我得需求,写出一个函数如下: \n` \n # find the min abs size \n def self.select_h(h) \n if ALL_FORMATS.include?(h) \n return h \n else \n ok_size = ALL_FORMATS.inject do |i,j| \n (i-h).abs < (j-h).abs ? i : j \n end \n return ok_size \n end \n end \n \n首先看是否包含这个变量,如果又,直接返回,如果没有就inject来取一个最合适得。
\n", "_id"=>470}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["GD", "php", "ubuntu"], "comments_count"=>0, "category_id"=>7, "title"=>"Install GD Support for PHP in Ubuntu", "body"=>"I am in the process of building my blog using wordpress ,then i install SI CAPTCHA Anti-Spam ,but it's say i didn’t have GD support for PHP5 installed on my server. so i need to do:\n\nOpen terminal and type in the following command:\n
\n\nThere you go, you now have GD Support for PHP5 in Ubuntu. Get your Drupal on!", "created_at"=>2010-01-13 02:25:36 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
I am in the process of building my blog using wordpress ,then i install SI CAPTCHA Anti-Spam ,but it's say i didn’t have GD support for PHP5 installed on my server. so i need to do:
\n\n
Open terminal and type in the following command: \n$ sudo apt-get install php5-gd
\n\n
Now restart Apache \n# sudo /etc/init.d/apache2 restart
\n\n
or restart spawn-fcgi \n/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9100 -u www-data -g www-data -f /usr/bin/php-cgi -C 10
\n\n
There you go, you now have GD Support for PHP5 in Ubuntu. Get your Drupal on!
\n", "_id"=>471}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["centOS", "Swap"], "comments_count"=>0, "category_id"=>7, "title"=>"Swap Space in centOS", "body"=>"Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.\n\nSwap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.\n\nSwap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.\n\nSo, if:\n\nM = Amount of RAM in GB, and S = Amount of swap in GB, then\n
If M < 2\n\tS = M *2\nElse\n\tS = M + 2
\nUsing this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.\n\nFor systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).\n\nsource:http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-swapspace.html", "created_at"=>2010-01-21 02:01:34 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.
\n\n
Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
\n\n
Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.
\n\n
So, if:
\n\n
M = Amount of RAM in GB, and S = Amount of swap in GB, then \nIf M < 2 \n S = M *2 \nElse \n S = M + 2 \nUsing this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.
\n\n
For systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).
\n", "_id"=>472}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["劫持", "电信"], "comments_count"=>0, "category_id"=>5, "title"=>"深圳电信耍流氓,劫持浏览器", "body"=>"今天无意发现在浏览器的左下角经常出现一个页面无法打开的提示,如下\nThe webpage at http://121.15.207.133:4022/logo.jpg?p=undefined|778|1276|24|800|1280might be temporarily down or it may have moved permanently to a new web address.\n\n看其样式是请求了一个121.15.207.133上的一个logo图片,然后传入了几个参数,但是这个图片的服务器貌似除了电问题,导致请求不到。\n无缘无故的,咋会去请求这个玩意呢,查了吓这个IP归属,属于:\n
\n", "_id"=>473}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["C", "ruby", "RubyInline"], "comments_count"=>0, "category_id"=>2, "title"=>"RubyInline, Making Making Things Faster Easier", "body"=>"发现一篇好文,讲的是如何使用RubyInline,在Ruby中直接嵌入C并运行,相比之前些lib,要方便的多,由于这个文章在墙外,就转了一份过来,可以翻墙的可以去看原文\nhttp://on-ruby.blogspot.com/2006/07/rubyinline-making-making-things-faster.html\n\nToday on ruby-talk, I caught a thread called \"For Performance, Write it in C\". I'd like to present a slight amendment to that thesis. Let me explain.\n\nIt all started with an email at work. Someone was passing around a bunch of prime number printers in various languages (C, Java, C#, Perl, and Python). They all used the same (ugly) algorithm, and were supposed to show just how 'performant the languages were. Since I'm the local Ruby evangelist, I was asked to write a Ruby version. Here's what I came up with (warning, ugly algorithm ahead):\n\n#!/usr/bin/ruby\n\nfor num in 1..10_000 do\nis_prime = 1\nfor x in 2..(num - 1) do\nif (num % x == 0)\nis_prime = x\nbreak\nend\nend\nif is_prime == 1\nputs \"\#{num} is a prime number\"\nelse\nputs \"\#{num} equals \#{is_prime} * \#{num/is_prime}\"\nend\nend\nHow fast is it? Well, time says:\n\n$ time ./primes.rb > /dev/null\n\nreal 0m2.905s\nuser 0m2.716s\nsys 0m0.004s\n$\n\nCertainly, nothing to write home about, but not too far from Perl or Python either.\nWanting to improve it, and not being able to touch the algorithm (we want to be comparing apples to quinces after all, not apples to oranges). I know my only hope is to find the bottleneck(s) and rewrite it (them?) in C. My first step is to grab Ruby's profiler and see what it says (oh, by the way, I reduced the value of num to 100 so that this would complete in my lifetime ... the profiler is slow).\n\n$ ruby -rprofile primes.rb > /dev/null\n% cumulative self self total\ntime seconds seconds calls ms/call ms/call name\n63.64 0.14 0.14 101 1.39 3.56 Range#each\n13.64 0.17 0.03 1133 0.03 0.03 Fixnum#%\n9.09 0.19 0.02 1233 0.02 0.02 Fixnum#==\n4.55 0.20 0.01 100 0.10 0.20 Kernel.puts\n4.55 0.21 0.01 200 0.05 0.05 IO#write\n4.55 0.22 0.01 248 0.04 0.04 Fixnum#to_s\n0.00 0.22 0.00 74 0.00 0.00 Fixnum#/\n0.00 0.22 0.00 100 0.00 0.00 Fixnum#-\n0.00 0.22 0.00 1 0.00 220.00 #toplevel\n$\n\nWhich tells me that most of my time is spent in each (well, it's actually spent in the block I sent to each. It's taking a whopping 1.39 msec per call, compared to .0X msec for everything else. What would happen if I rewrote just that block?\nEnter RubyInline (A great tool written by zenspider and Eric Hodel). I'm not a C wiz by any stretch of the imagination, but this stuff is pretty easy to bang out. My new code looks like this:\n\n#!/usr/bin/ruby\n\nrequire \"rubygems\"\nrequire \"inline\"\n\nclass Primes\ninline do |builder|\nbuilder.c '\nint prime(int num) {\nint x;\nfor (x = 2; x < (num - 1) ; x++) { if (num == 2) { return 1; } if (num % x == 0) { return x; } } return 1; }' end end p = Primes.new for num in 2..10_000 do is_prime = p.prime(num) if is_prime == 1 puts \"\#{num} is a prime number\" else puts \"\#{num} equals \#{is_prime} * \#{num/is_prime}\" end end Not too ugly. At least I can still see what's happening. The main loop being in Ruby helps a lot too (especially if this were a much bigger program). How much of a difference does it make? time says: $ time ./cprimes.rb > /dev/null\n\nreal 0m0.328s\nuser 0m0.288s\nsys 0m0.020s\n\nAn order of magnitude improvement. Not too shabby.\nWhat's the lesson here? Optimize what you need to (and only what you need to), profile find out what that is (it may be slow, but profiling is your friend), and use the right tools (rewriting a bit of code with RubyInline is way better than rewriting the whole app in C).", "created_at"=>2010-01-24 10:51:47 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
Today on ruby-talk, I caught a thread called "For Performance, Write it in C". I'd like to present a slight amendment to that thesis. Let me explain.
\n\n
It all started with an email at work. Someone was passing around a bunch of prime number printers in various languages (C, Java, C#, Perl, and Python). They all used the same (ugly) algorithm, and were supposed to show just how 'performant the languages were. Since I'm the local Ruby evangelist, I was asked to write a Ruby version. Here's what I came up with (warning, ugly algorithm ahead):
\n\n
!/usr/bin/ruby
\n\n
for num in 1..10_000 do \nis_prime = 1 \nfor x in 2..(num - 1) do \nif (num % x == 0) \nis_prime = x \nbreak \nend \nend \nif is_prime == 1 \nputs "\#{num} is a prime number" \nelse \nputs "\#{num} equals \#{is_prime} * \#{num/is_prime}" \nend \nend \nHow fast is it? Well, time says:
\n\n
$ time ./primes.rb > /dev/null
\n\n
real 0m2.905s \nuser 0m2.716s \nsys 0m0.004s \n$
\n\n
Certainly, nothing to write home about, but not too far from Perl or Python either. \nWanting to improve it, and not being able to touch the algorithm (we want to be comparing apples to quinces after all, not apples to oranges). I know my only hope is to find the bottleneck(s) and rewrite it (them?) in C. My first step is to grab Ruby's profiler and see what it says (oh, by the way, I reduced the value of num to 100 so that this would complete in my lifetime ... the profiler is slow).
Which tells me that most of my time is spent in each (well, it's actually spent in the block I sent to each. It's taking a whopping 1.39 msec per call, compared to .0X msec for everything else. What would happen if I rewrote just that block? \nEnter RubyInline (A great tool written by zenspider and Eric Hodel). I'm not a C wiz by any stretch of the imagination, but this stuff is pretty easy to bang out. My new code looks like this:
\n\n
!/usr/bin/ruby
\n\n
require "rubygems" \nrequire "inline"
\n\n
class Primes \ninline do |builder| \nbuilder.c ' \nint prime(int num) { \nint x; \nfor (x = 2; x < (num - 1) ; x++) { if (num == 2) { return 1; } if (num % x == 0) { return x; } } return 1; }' end end p = Primes.new for num in 2..10_000 do is_prime = p.prime(num) if is_prime == 1 puts "\#{num} is a prime number" else puts "\#{num} equals \#{is_prime} * \#{num/is_prime}" end end Not too ugly. At least I can still see what's happening. The main loop being in Ruby helps a lot too (especially if this were a much bigger program). How much of a difference does it make? time says: $ time ./cprimes.rb > /dev/null
\n\n
real 0m0.328s \nuser 0m0.288s \nsys 0m0.020s
\n\n
An order of magnitude improvement. Not too shabby. \nWhat's the lesson here? Optimize what you need to (and only what you need to), profile find out what that is (it may be slow, but profiling is your friend), and use the right tools (rewriting a bit of code with RubyInline is way better than rewriting the whole app in C).
\n# Example MySQL config file for large systems.\n#\n# This is for a large system with memory = 512M where the system runs mainly\n# MySQL.\n#\n# You can copy this file to\n# /etc/my.cnf to set global options,\n# mysql-data-dir/my.cnf to set server-specific options (in this\n# installation this directory is /var/lib/mysql) or\n# ~/.my.cnf to set user-specific options.\n#\n# In this file, you can use all long options that a program supports.\n# If you want to know which options a program supports, run the program\n# with the \"--help\" option.\n\n# The following options will be passed to all MySQL clients\n[client]\nport = 3306\nsocket = /var/lib/mysql/mysql.sock\n\n# Here follows entries for some specific programs\n\n# The MySQL server\n[mysqld]\ndatadir=/var/lib/mysql\nsocket=/var/lib/mysql/mysql.sock\nuser=mysql\nskip-locking\n\n# By default, the wait_timeout value is 28800. Unless you want MySQL to keep waiting for 28800 seconds (480 minutes or 8 hours),\n# please decrease its value according to your application needs.\nwait_timeout=60\n# Increase connect_timeout from 5 to 10\nconnect_timeout=10\n# Decrease interactive_timeout from 28800 to 100\ninteractive_timeout=120\n# Increase join_buffer_size from 131072 to 1M\njoin_buffer_size=1M\n# Increase query_cache_size from 0 to 128M\nquery_cache_size=32M\n# Increase query cache limit from 1048576 to 2M\nquery_cache_limit=2M\n# Increase max allowed packet size from 1M to 16M\nmax_allowed_packet=2M\n# Increase table cache cache from 256 to 1024\ntable_cache=1024\n# Increase sort buffer size from 1M\nsort_buffer_size=2M\n# Increase read buffer size from 1M\nread_buffer_size=2M\n# Increase read_rnd_buffer_size to 4M\nread_rnd_buffer_size=4M\n\n#Other settings\nsort_buffer_size=8M\nkey_buffer = 256M\nkey_buffer_size=64M\nmyisam_sort_buffer_size = 64M\nthread_cache_size = 8\n# Try number of CPU's*2 for thread_concurrency\nthread_concurrency = 2\n\n\n# Don't listen on a TCP/IP port at all. This can be a security enhancement,\n# if all processes that need to connect to mysqld run on the same host.\n# All interaction with mysqld must be made via Unix sockets or named pipes.\n# Note that using this option without enabling named pipes on Windows\n# (via the \"enable-named-pipe\" option) will render mysqld useless!\n#\n#skip-networking\n\n# Disable Federated by default\nskip-federated\n\nold_passwords=1\n\n#for slow queries\nlog-slow-queries = /var/log/mysql-slow.log\nlong_query_time = 3\n\n[mysqldump]\nquick\nmax_allowed_packet = 16M\n\n[mysql]\nno-auto-rehash\n# Remove the next comment character if you are not familiar with SQL\n#safe-updates\n\n[isamchk]\nkey_buffer = 128M\nsort_buffer_size = 128M\nread_buffer = 2M\nwrite_buffer = 2M\n\n[myisamchk]\nkey_buffer = 128M\nsort_buffer_size = 128M\nread_buffer = 2M\nwrite_buffer = 2M\n\n[mysqlhotcopy]\ninteractive-timeout\n\n[mysqld_safe]\nlog-error=/var/log/mysqld.log\npid-file=/var/run/mysqld/mysqld.pid\n
mysql> SHOW VARIABLES like \"%sort%\";\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| max_length_for_sort_data | 1024 |\n| max_sort_length | 1024 |\n| myisam_max_sort_file_size | 2146435072 |\n| myisam_sort_buffer_size | 67108864 |\n| sort_buffer_size | 8388608 |\n+---------------------------+------------+\n5 rows in set (0.00 sec)
\n\n不晓得是做啥用的,查了下资料:\n
http://forge.mysql.com/wiki/MySQL_Internals_Algorithms\n\nUsing the modified filesort algorithm, the tuples are longer than the pairs used in the original method, and fewer of them fit in the sort buffer (the size of which is given by sort_buffer_size). As a result, it is possible for the extra I/O to make the modified approach slower, not faster. To avoid a slowdown, the optimization is used only if the total size of the extra columns in the sort tuple does not exceed the value of the max_length_for_sort_data system variable. (A symptom of setting the value of this variable too high is that you should see high disk activity and low CPU activity.)
Using the modified filesort algorithm, the tuples are longer than the pairs used in the original method, and fewer of them fit in the sort buffer (the size of which is given by sort_buffer_size). As a result, it is possible for the extra I/O to make the modified approach slower, not faster. To avoid a slowdown, the optimization is used only if the total size of the extra columns in the sort tuple does not exceed the value of the max_length_for_sort_data system variable. (A symptom of setting the value of this variable too high is that you should see high disk activity and low CPU activity.)
\n", "_id"=>479}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "filesort"], "comments_count"=>0, "category_id"=>11, "title"=>"What does Using filesort mean in MySQL?", "body"=>"一直以来,只要我看到explain出来的结果有“Using filesort ”,我就要想方设法的优化和改善,因为我以前以为这个的意思就是使用文件系统来排序(那该多慢呀!),其实不是这样的。\n在mysqlperformanceblog上看到一篇文章《What does Using filesort mean in MySQL?》其中作者说自己每次面世的时候都会问“what does Using filesort mean in EXPLAIN,” 结果没有一个人回答的是对的,结果让其比较郁闷,就写了这个文章说明:\n
The usual answer is something like “rows are being placed into a temporary table which is too big to fit in memory, so it gets sorted on disk.” Unfortunately, this is not the same thing. First of all, this is Using temporary. Secondly, temporary tables may go to disk if they are too big, but EXPLAIN doesn’t show that. (If I interview you, I might ask you what “too big” means, or I might ask you the other reason temporary tables go to disk!)
The truth is, filesort is badly named. Anytime a sort can’t be performed from an index, it’s a filesort. It has nothing to do with files. Filesort should be called “sort.” It is quicksort at heart.
\n正解是,filesort这个名字有问题,容易给人误解,在mysql中,任何不能通过index进行的sort都称之为filesort,这里的filesort和文件没有任何关系,应该称之为“sort”而不是“filesort”,它的内部实现就是快速排序。\n\n参考资料:\nWhat does Using filesort mean in MySQL?\nhttp://www.mysqlperformanceblog.com/2009/03/05/what-does-using-filesort-mean-in-mysql/\n\nHow MySQL executes ORDER BY\nhttp://s.petrunia.net/blog/?p=24", "created_at"=>2010-02-03 03:51:36 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
一直以来,只要我看到explain出来的结果有“Using filesort ”,我就要想方设法的优化和改善,因为我以前以为这个的意思就是使用文件系统来排序(那该多慢呀!),其实不是这样的。 \n在mysqlperformanceblog上看到一篇文章《What does Using filesort mean in MySQL?》其中作者说自己每次面世的时候都会问“what does Using filesort mean in EXPLAIN,” 结果没有一个人回答的是对的,结果让其比较郁闷,就写了这个文章说明: \nThe usual answer is something like “rows are being placed into a temporary table which is too big to fit in memory, so it gets sorted on disk.” Unfortunately, this is not the same thing. First of all, this is Using temporary. Secondly, temporary tables may go to disk if they are too big, but EXPLAIN doesn’t show that. (If I interview you, I might ask you what “too big” means, or I might ask you the other reason temporary tables go to disk!) \n通常的解释是:选择出来的记录太多了,需要排序时内存中放不下了,所以会存储在磁盘中,并通过操作磁盘的文件的方式来排序。但是呢,这是不对的。
\n\n
The truth is, filesort is badly named. Anytime a sort can’t be performed from an index, it’s a filesort. It has nothing to do with files. Filesort should be called “sort.” It is quicksort at heart. \n正解是,filesort这个名字有问题,容易给人误解,在mysql中,任何不能通过index进行的sort都称之为filesort,这里的filesort和文件没有任何关系,应该称之为“sort”而不是“filesort”,它的内部实现就是快速排序。
\n", "_id"=>480}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "variables"], "comments_count"=>0, "category_id"=>11, "title"=>"Mysql动态修改参数", "body"=>"mysql数据库也像ORACLE数据库一样,可以动态的修改参数,可以修改会话级变量只对当前会话产生影响;也可以修改全局变量,对所有新连接的会话都产生影响。\n\n修改会话级变量\n用show variables 命令查看当前参数的值,like 'pattern'用于模式匹配,查找指定的参数\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n用set SESSION命令设置会话级变量的新值\n\nmysql> set SESSION sort_buffer_size=7000000;\nQuery OK, 0 rows affected (0.00 sec)\n\n--修改会话级变量对当前会话来说立刻生效\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 7000000 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\nmysql> exit\nBye\n退出重新连接后,此参数恢复原值\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 40 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n修改全局变量\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 40 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n用set GLOBAL 命令设置全局变量\n\nmysql> set GLOBAL sort_buffer_size = 7000000;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n当前此参数的值并不发生变化,先退出,然后重新连进去\nmysql> exit\nBye\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 41 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 7000000 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n新的参数值生效", "created_at"=>2010-02-03 04:00:12 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
--修改会话级变量对当前会话来说立刻生效 \nmysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 7000000 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
mysql> exit \nBye \n退出重新连接后,此参数恢复原值 \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 40 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
修改全局变量 \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 40 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
用set GLOBAL 命令设置全局变量
\n\n
mysql> set GLOBAL sort_buffer_size = 7000000; \nQuery OK, 0 rows affected (0.00 sec)
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec) \n当前此参数的值并不发生变化,先退出,然后重新连进去 \nmysql> exit \nBye \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 41 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 7000000 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec) \n新的参数值生效
\n", "_id"=>482}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Tips"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Textmate", "theme"], "comments_count"=>0, "category_id"=>4, "title"=>"Installing a New Textmate Theme", "body"=>"To install a new theme, select one of the .tmTheme links listed below, download it to your desktop and double-click on the file. This will place it in ~/Library/Application Support/TextMate/Themes, at which point the new theme will appear in the list found in Preferences → Fonts & Colors. This will also set it as the active theme. (Once the theme is installed, you may remove the .tmTheme from your desktop.)\n\nRails Envy TextMate Theme\n http://railsenvy.com/2008/9/18/rails-envy-textmate-theme\n\nUser Submitted Themes\n http://wiki.macromates.com/Themes/UserSubmittedThemes", "created_at"=>2010-02-04 18:24:02 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
To install a new theme, select one of the .tmTheme links listed below, download it to your desktop and double-click on the file. This will place it in ~/Library/Application Support/TextMate/Themes, at which point the new theme will appear in the list found in Preferences → Fonts & Colors. This will also set it as the active theme. (Once the theme is installed, you may remove the .tmTheme from your desktop.)
\n\nrestart teatmate and it's done!\n\nIn the TextMate preferences, advanced tab, shell variables, set the TM_GIT variable to point to your installation of git (ie /usr/local/bin/git)\nMany shortcuts are available from the Git-shortcut (Ctrl-Shift-G). Subversion commands are Command-Option-g. Less frequent commands are accessed via the menu.\nUpdate your bundle by running the “Update Git Bundle” command.", "created_at"=>2010-02-04 23:39:24 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
In the TextMate preferences, advanced tab, shell variables, set the TM_GIT variable to point to your installation of git (ie /usr/local/bin/git) \nMany shortcuts are available from the Git-shortcut (Ctrl-Shift-G). Subversion commands are Command-Option-g. Less frequent commands are accessed via the menu. \nUpdate your bundle by running the “Update Git Bundle” command.
SIMBL (SIMple Bundle Loader) - pronounced like \"symbol\" or \"cymbal\" - enables hacks and plugins. For instance, SIMBL enables PithHelmet to enhance Safari.
Install SIMBL and make sure you have latest SIMBL 0.9.x\nPlace Visor.bundle into ~/Library/Application Support/SIMBL/Plugins (create this directory if it does not exist)\nRelaunch Terminal.app - You should now see the Visor Status Menu Item\nConfigure your keyboard trigger by selecting the Visor Status Menu Item -> Visor Preferences ... and edit your keyboard hot-key\nYou can now trigger Visor with your hot-key from any application to get an instant terminal session.\n\nTo hide Visor, you can either:\nre-trigger with your key-combo\noptionally you can click off of the Visor window
如果你和我一样经常使用终端程序,这个小程序一定可以帮到你。他能将终端窗口变成类似雷神或CS那样的下拉窗口,非常酷。 \n可以从这里下载 http://visor.binaryage.com/ \n这个软件需要SIMBL ,如果你没有安装,要先安装这个。 \nhttp://www.culater.net/software/SIMBL/SIMBL.php \nSIMBL (SIMple Bundle Loader) - pronounced like "symbol" or "cymbal" - enables hacks and plugins. For instance, SIMBL enables PithHelmet to enhance Safari. \n之后将下载下来的文件解压,将解压后的文件拷贝至/Library/Application Support/SIMBL/Plugins,之后再重新启动你的终端你就可以看到效果了。 默认的快捷启动键是Ctrl+` \nvisor: http://visor.binaryage.com/
\n\n
Installation
\n\n
Install SIMBL and make sure you have latest SIMBL 0.9.x \nPlace Visor.bundle into ~/Library/Application Support/SIMBL/Plugins (create this directory if it does not exist) \nRelaunch Terminal.app - You should now see the Visor Status Menu Item \nConfigure your keyboard trigger by selecting the Visor Status Menu Item -> Visor Preferences ... and edit your keyboard hot-key \nYou can now trigger Visor with your hot-key from any application to get an instant terminal session.
\n\n
To hide Visor, you can either: \nre-trigger with your key-combo \noptionally you can click off of the Visor window
前段时间写了一篇《实例优化mysql配置文件my.cnf》,这几天看到效果非常明显,别的不说,单mysql cache_hits就很不错(之前竟然没注意到这个参数) \n# Increase query_cache_size from 0 to 128M \nquery_cache_size=128M
Rails 3 in Action by Yehuda Katz and Mike Gunderloy. Currently available is their Early Access Edition, which gives you access to chapters as they are written.
\n\t
Beginning Rails 3 by Jeffrey Allan Hardy , Cloves Carneiro Jr. & Rida Al Barazi
这次升级需要新装很多的gem,如下: \ngem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n \ngem install rails --pre \n期间遇到一个错误: \nDue to a rubygems bug, you must uninstall all older versions of bundler for 0.9 to work \n然后这边有N多关于Rails3的资料供参考:
\n\n
Rails 3 Tutorials & Blog Posts
\n\n
Edging your way towards Ruby 1.9.1 and Rails 3.0pre \n Unobtrusive JavaScript in Rails 3 by Zach Carter \n A Fresh Cup: Seed Data in Rails 3 tutorial – feature summary + code example by Mike Gunderloy. \n Rails3: Stepping off of the golden path slides by Matt Aimonetti \n Rails Magazine – RailsConf 2009 Edition page 5 has a section called The Unofficial Guide to What’s New in Rails 3 by Rupak Ganguly \n Jason Ting’s RailsConf 2009 Notes includes some basic notes about Rails 3 \n Noel Rappin: Railsconf 09 – After the RailsConfening article \n Yehuda Katz: Railsconf Wrapup blog – contains links to jQuery talk by Katz at RailsConf 09 \n How to Begin Playing With Rails 3 by Oscar Del Ben \n My Five Favorite Things About Rails 3 by Yehuda Katz \n Rails 3: The Great Decoupling by Yehuda Katz \n Rails Edge Architecture by Yehuda Katz \n How to Build Sinatra on Rails 3 by Yehuda Katz
\n\n
Rails 3 Presentations & Conference Talks
\n\n
Yehuda: What to Expect in Rails 3.0 webcast recording \n Scotland on Rails: Yehuda on Rails & Merb Merge video. For more Scotland on Rails videos, check out this Ruby Inside post. \n Yehuda Katz on Rails 3 and beyond interview by Mark Coleman \n RailsConf: Yehuda – The Russian Doll Pattern video \n RailsConf 09: DHH Keynote video – DHH previews unobtrusive javascript, default escaping & more.
\n\n
Rails 3 Books
\n\n
Rails 3 in Action by Yehuda Katz and Mike Gunderloy. Currently available is their Early Access Edition, which gives you access to chapters as they are written. \n Beginning Rails 3 by Jeffrey Allan Hardy , Cloves Carneiro Jr. & Rida Al Barazi
\n\n
Rails 3 Commentary
\n\n
Internet News: Rails 3 Gets Supersized With Merb \n eWeek: Rubyists Unite Ruby on Rails and Merb to Merge in Rails 3 \n CIO: Rails 3 to add security enhancement \n Yehuda Katz: Rails and Merb Merge \n RubyOnRails.org: Rails + Merb Merge Announcement
\n", "_id"=>487}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"02. 产品设计 | PM"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Axure", "Balsamiq Mockups", "原型设计"], "comments_count"=>0, "category_id"=>13, "title"=>"Balsamiq Mockups,理想的原型设计工具", "body"=>"由于经常要讨论产品,包括web和手机(\bAandroid,Iphone)的产品原型设计,尝试过很多的原型设计工具,例如Axure等,后来换了mac book,就一直找不到合适的原型设计工具,就一直在Google Doc中直接draw,其做了很多无用功。\n比较偶然的机会看到Balsamiq Mockups这个软件,和Pixelmator一样,是个人开发者(意大利人Peldi)开发的产品,其地址为http://www.balsamiq.com/ ,在其提供的demo页面上试了下http://www.balsamiq.com/demos/mockups/Mockups.html,效果很好,符合我的预期。\n虽然是由个人设计的,但功能却一点不弱于其他大牌的原型设计工具:\n操作方面,拖拽,控件分组,甚至元素之间的对齐都做得很贴心;\n预制了很多界面元素,从简单的输入框,下拉框,浏览器主要元素,到经常用得到的导航条,日历,表格,到复杂的Tag Cloud,Cover Flow, 地图,WYSWYG的格式工具栏等,有了这些不用从头画起,往往比用白板都快;\n界面元素的修改很简单,比如导航条的几个标签页的label,就是用逗号分隔的文字,下拉框的选项就是分行的文字;\n使用xml语言来记录和保存界面元素和布局,\n这使得每个设计都能被很好得放进SVN,Git,和CVS等工具中进行管理和跟踪;\n可以设计复杂的界面元素,保存后,以后可以重复使用(包括修改);\n可以将设计导出成PNG格式的图片;\n可以用命令行进行导出操作,这样就能让我写个脚本,从svn里checkout某个目录下的所有设计文件后,导出图片,打包后用邮件发到项目经理,工程师甚至客户那;\n跨平台,Balsamiq Mokups是用Flex和Air实现的,所以在Mac OS, Linux和Windows下都能使用;\n不仅仅有桌面版本,还有能集成在Confluence,JIRA,和XWiki中的版本,使得异地在线协作更方便有效。\n\n以下是关于Balsamiq Mockups的一些特点:\n易操作:从 Balsamiq Mockups 自带的元素里可以很方便地拖拽,效果图轻易形成;元素对齐很贴心;\n可偷懒:根据 Balsamiq Mockups 提供的 Wiki 风格的代码规则,画图时可以「偷懒」,输入文本符号则能生成图标。因此相比其它繁琐的软件操作,Balsamiq Mockups 也能更快地完成画图任务。\n控件足:Balsamiq Mockups 软件包括 50 多个控件, 70 多个图标。基本自带了所有常用的小控件,并在导航处进行分类;图标设计赏心悦目。要是 Balsamiq Mockups 允许用户导入自定义的控件就更好了,当然现有的也足够了 -\n新风格:让人眼前一亮的涂鸦风格,很能还原手绘效果;\n可中文:在菜单栏 View 里将 Use System Fonts 勾上,就能完美支持中文输入(注:非 Balsamiq Mockups 中文版);\n其它点:Balsamiq Mockups 使用 xml 记录,方便移植、二次利用;可导出为 png 格式图片。\n\n另外还有跨平台与多版本两个优点:\n跨平台:Balsamiq Mockups 基于 Air ,因此能同时在 Windows、Mac OS 及 Linux 下使用;\n多版本:包括桌面版本,以及集成于 Confluence、JIRA、XWiki、FogBugz 中的版本\n\n软件可以从其网站上下载,其中桌面版本售价是$79。但作者非常厚道,提供了几种免费使用的方式:http://www.balsamiq.com/products/mockups/desktop\n\nYou can download Mockups for Desktop for free. Some of the features of the app, like saving and loading multiple mockups or linking mockups together can only get unlocked using a license key.\n", "created_at"=>2010-02-21 18:39:26 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
You can download Mockups for Desktop for free. Some of the features of the app, like saving and loading multiple mockups or linking mockups together can only get unlocked using a license key.
\n", "_id"=>488}])
+MONGODB iceylog_development['categories'].find({:_id=>13}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>13}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "socket"], "comments_count"=>0, "category_id"=>3, "title"=>"Can’t connect to local MySQL server through socket 解决办法", "body"=>"Rails启动后报错,ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/temp/mysql.sock’ (2)\n\n1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.\n另外看看是不是权限问题.\n\n2、确定你的mysql.sock是不是在那个位置,\nmysql -u 你的mysql用户名 -p -S /var/lib/mysql/mysql.sock\n\n3、试试:service mysqld start\n\n4、如果是权限问题,则先改变权限 #chown -R mysql:mysql /var/lib/mysql\n\n[root@localhost ~]# /etc/init.d/mysqld start\n启动 MySQL: [ 确定 ]\n[root@localhost ~]# mysql -uroot -p", "created_at"=>2010-02-23 21:24:14 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
Rails启动后报错,ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/temp/mysql.sock’ (2)
\n\n
1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动. \n另外看看是不是权限问题.
\n", "_id"=>489}])
+MONGODB iceylog_development['categories'].find({:_id=>3}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>3}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Passenger", "REE"], "comments_count"=>0, "category_id"=>2, "title"=>"Download Ruby Enterprise Edition(REE)", "body"=>"前段时间用上了Passenger ,尔后就看到很多的人推荐使用Ruby Enterprise Edition(REE),今天得闲,试了一把。\nStep 1: Download\nSource code: version 1.8.7-2010.01\nStep 2: Install\nExtract it:\ntar xzvf ruby-enterprise-X.X.X.tar.gz\nRun the installer (completely safe, none of your system files will be touched!):\n./ruby-enterprise-X.X.X/installer\n
Welcome to the Ruby Enterprise Edition installer
\n
This installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.
\n
Don't worry, none of your system files will be touched if you don't want them
\n
to, so there is no risk that things will screw up.
\n
You can expect this from the installation process:
\n
1. Ruby Enterprise Edition will be compiled and optimized for speed for this
\n
system.
\n
2. Ruby on Rails will be installed for Ruby Enterprise Edition.
\n
3. You will learn how to tell Phusion Passenger to use Ruby Enterprise
\n
Edition instead of regular Ruby.
\n
Press Enter to continue, or Ctrl-C to abort.
\n
Welcome to the Ruby Enterprise Edition installerThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.Don't worry, none of your system files will be touched if you don't want themto, so there is no risk that things will screw up.\nYou can expect this from the installation process:\n1. Ruby Enterprise Edition will be compiled and optimized for speed for this system.\n\n2. Ruby on Rails will be installed for Ruby Enterprise Edition.\n\n3. You will learn how to tell Phusion Passenger to use Ruby Enterprise Edition instead of regular Ruby.\nPress Enter to continue, or Ctrl-C to abort.
\nStep 3: Make Phusion Passenger use Ruby Enterprise Edition instead of regular Ruby\nFollow the instructions that the Ruby Enterprise Edition installer gave you.", "created_at"=>2010-03-03 16:53:29 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
前段时间用上了Passenger ,尔后就看到很多的人推荐使用Ruby Enterprise Edition(REE),今天得闲,试了一把。 \nStep 1: Download \nSource code: version 1.8.7-2010.01 \nStep 2: Install \nExtract it: \ntar xzvf ruby-enterprise-X.X.X.tar.gz \nRun the installer (completely safe, none of your system files will be touched!): \n./ruby-enterprise-X.X.X/installer \nWelcome to the Ruby Enterprise Edition installer \nThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01. \nDon't worry, none of your system files will be touched if you don't want them \nto, so there is no risk that things will screw up. \nYou can expect this from the installation process: \n1. Ruby Enterprise Edition will be compiled and optimized for speed for this \nsystem. \n2. Ruby on Rails will be installed for Ruby Enterprise Edition. \n3. You will learn how to tell Phusion Passenger to use Ruby Enterprise \nEdition instead of regular Ruby. \nPress Enter to continue, or Ctrl-C to abort. \nWelcome to the Ruby Enterprise Edition installerThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.Don't worry, none of your system files will be touched if you don't want themto, so there is no risk that things will screw up. \nYou can expect this from the installation process: \n1. Ruby Enterprise Edition will be compiled and optimized for speed for this system.
\n\n\n
Ruby on Rails will be installed for Ruby Enterprise Edition.
\n
You will learn how to tell Phusion Passenger to use Ruby Enterprise Edition instead of regular Ruby. \nPress Enter to continue, or Ctrl-C to abort. \nStep 3: Make Phusion Passenger use Ruby Enterprise Edition instead of regular Ruby \nFollow the instructions that the Ruby Enterprise Edition installer gave you.
\n\n", "_id"=>490}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"02. 产品设计 | PM"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Border-radius", "css3"], "comments_count"=>0, "category_id"=>13, "title"=>"Border-radius: create rounded corners with CSS!", "body"=>"W3C has offered some new options for borders in CSS3, of which one is border-radius. Both Mozila/Firefox and Safari 3 have implemented this function, which allows you to create round corners on box-items. This is an example:\n\nMozilla/Firefox and Safari 3 users should see a nicely rounded box, with a nicely rounded border.\nThe code for this example above is actually quite simple:\n\nThese different corners can also each be handled on their own, Mozilla has other names for the feature than the spec says it should have though, as it has f.i. -moz-border-radius-topright as opposed to -webkit-border-top-right-radius:\n\nMozilla/Firefox and Safari 3 users should see a box with a rounded left upper corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded right upper corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded left lower corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded right lower corner.\nThese are handled by / should be handled by:\n\n````-moz-border-radius-topleft / -webkit-border-top-left-radius\n-moz-border-radius-topright / -webkit-border-top-right-radius\n-moz-border-radius-bottomleft / -webkit-border-bottom-left-radius\n-moz-border-radius-bottomright / -webkit-border-bottom-right-radius```", "created_at"=>2010-03-05 10:38:13 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
W3C has offered some new options for borders in CSS3, of which one is border-radius. Both Mozila/Firefox and Safari 3 have implemented this function, which allows you to create round corners on box-items. This is an example:
\n\n
Mozilla/Firefox and Safari 3 users should see a nicely rounded box, with a nicely rounded border. \nThe code for this example above is actually quite simple: \n \nThese different corners can also each be handled on their own, Mozilla has other names for the feature than the spec says it should have though, as it has f.i. -moz-border-radius-topright as opposed to -webkit-border-top-right-radius:
\n\n
Mozilla/Firefox and Safari 3 users should see a box with a rounded left upper corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded right upper corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded left lower corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded right lower corner. \nThese are handled by / should be handled by:
\n", "_id"=>493}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["action_mailer_optional_tls", "Gmail", "Redmine"], "comments_count"=>0, "category_id"=>2, "title"=>"Setup Redmine to send email using GMail", "body"=>"Redmine是用Rails写的一套很不错的项目管理系统,其提供了诸多很方便实用的功能,诸如里程碑管理,BUG跟踪,代码库变更管理等等。\n搭建以后在管理面板中测试邮件不通,主要原因是由于采用的Gmail的邮箱,于是找到一些解决方案,如下:\n1. Install the action_mailer_optional_tls plugin\nThe action_mailer_optional_tls_plugin adds a TLS option to Redmine's emailing library, ActionMailer. TLS is a version of SSL which is required by GMail in order to send email.\n\nTo install this plugin, use the script/plugin command in your Redmine directory:\n ./script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git\n\n2. Configure your email.yml\n# File: config/email.yml\nproduction:\n delivery_method: :smtp\n smtp_settings:\n tls: true\n address: \"smtp.gmail.com\"\n port: 587\n domain: \"www.YOURDOAMIN.com\" # 'your.domain.com' for GoogleApps\n authentication: :plain\n user_name: \"username@youdomain.com\"\n password: \"password\"\n\n3. Start up Redmine and test your Email\nNext it's time to start up Redmine and to send a test email. Make sure that you start Redmine in the same mode as you configured above (e.g. production). To send a test email:\nLogin as an administrator\nGo to the Administration panel\nGo into the Settings and select the \"Email notifications\" tab\nIn the bottom right, click the link to \"Send a test email\"", "created_at"=>2010-03-14 18:31:57 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
Redmine是用Rails写的一套很不错的项目管理系统,其提供了诸多很方便实用的功能,诸如里程碑管理,BUG跟踪,代码库变更管理等等。 \n搭建以后在管理面板中测试邮件不通,主要原因是由于采用的Gmail的邮箱,于是找到一些解决方案,如下: \n1. Install the action_mailer_optional_tls plugin \nThe action_mailer_optional_tls_plugin adds a TLS option to Redmine's emailing library, ActionMailer. TLS is a version of SSL which is required by GMail in order to send email.
\n\n
To install this plugin, use the script/plugin command in your Redmine directory: \n ./script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git
3. Start up Redmine and test your Email \nNext it's time to start up Redmine and to send a test email. Make sure that you start Redmine in the same mode as you configured above (e.g. production). To send a test email: \nLogin as an administrator \nGo to the Administration panel \nGo into the Settings and select the "Email notifications" tab \nIn the bottom right, click the link to "Send a test email"
\n", "_id"=>495}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["concat", "Database"], "comments_count"=>0, "category_id"=>3, "title"=>"MySQL CONCAT", "body"=>"MySQL CONCAT function is used to concatenate two strings to form a single string. Try out following example:\nmysql> SELECT CONCAT('FIRST ', 'SECOND');\n+----------------------------+\n| CONCAT('FIRST ', 'SECOND') |\n+----------------------------+\n| FIRST SECOND |\n+----------------------------+\n1 row in set (0.00 sec)\n\nie.\nmysql -u eoewallpapers -p123456123 wallpapers -e 'set names 'utf8'; select CONCAT(base_url,\"400\",title) from photos where state > 10 ' > photos_400.txt", "created_at"=>2010-03-19 20:34:34 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
MySQL CONCAT function is used to concatenate two strings to form a single string. Try out following example: \nmysql> SELECT CONCAT('FIRST ', 'SECOND'); \n+----------------------------+ \n| CONCAT('FIRST ', 'SECOND') | \n+----------------------------+ \n| FIRST SECOND | \n+----------------------------+ \n1 row in set (0.00 sec)
\n\n
ie. \nmysql -u eoewallpapers -p123456123 wallpapers -e 'set names 'utf8'; select CONCAT(base_url,"400",title) from photos where state > 10 ' > photos_400.txt
alias ls=”ls -G”是给”ls -G”起了一个别名,当执行ls时,就相当于执行了ls -G。
\n\n
CLICOLOR是用来设置是否进行颜色的显示。CLI是Command Line Interface的缩写。 \nLSCOLORS是用来设置当CLICOLOR被启用后,各种文件类型的颜色。LSCOLORS的值中每两个字母为一组,分别设置某个文件类型的文字颜色和背景颜色。LSCOLORS中一共11组颜色设置,按照先后顺序,分别对以下的文件类型进行设置:
\n\n
directory \nsymbolic link \nsocket \npipe \nexecutable \nblock special \ncharacter special \nexecutable with setuid bit set \nexecutable with setgid bit set \ndirectory writable to others, with sticky bit \ndirectory writable to others, without sticky bit \nLSCOLORS中,字母代表的颜色如下:
\n", "_id"=>501}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["10.6.3", "rails3", "railties"], "comments_count"=>0, "category_id"=>7, "title"=>"解决升级mac OS 10.6.3后rails3无法启动的问题", "body"=>"昨晚看hero的时候顺带update到mac OS 10.6.3,早上重启机器安装成功,发现rails3无法启动,报:\n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception)\nfrom /usr/bin/rails:19\n\n这个错误我之前安装rails3的时候遇到过,解决如下:\n1.先尝试下重新安装rails\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install rails --pre\nPassword:\nSuccessfully installed treetop-1.4.5\n1 gem installed\nInstalling ri documentation for treetop-1.4.5...\nInstalling RDoc documentation for treetop-1.4.5..\n发现多了个treetop的gem,查查是啥:\n
Treetop is a language for describing languages. Combining the elegance of Ruby with cutting-edge parsing expression grammars, it helps you analyze syntax with revolutionarily ease.
\n\n再次执行rails,发现\n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception)\n from /usr/bin/rails:19\n\n还是不行,那就是railties的问题了,重新装下\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install railties --pre\nSuccessfully installed railties-3.0.0.beta\n1 gem installed\nInstalling ri documentation for railties-3.0.0.beta...\nInstalling RDoc documentation for railties-3.0.0.beta...\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ rails -v\nRails 3.0.0.beta\n\nOK,可以了~", "created_at"=>2010-03-31 22:01:38 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
昨晚看hero的时候顺带update到mac OS 10.6.3,早上重启机器安装成功,发现rails3无法启动,报: \n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception) \nfrom /usr/bin/rails:19
\n\n
这个错误我之前安装rails3的时候遇到过,解决如下: \n1.先尝试下重新安装rails \nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install rails --pre \nPassword: \nSuccessfully installed treetop-1.4.5 \n1 gem installed \nInstalling ri documentation for treetop-1.4.5... \nInstalling RDoc documentation for treetop-1.4.5.. \n发现多了个treetop的gem,查查是啥: \nTreetop is a language for describing languages. Combining the elegance of Ruby with cutting-edge parsing expression grammars, it helps you analyze syntax with revolutionarily ease.
\n\n
再次执行rails,发现 \n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception) \n from /usr/bin/rails:19
做移动互联网的过程中,有这样一些词是必须知道的,如MO,MT,GSM,LINKID \n上行(MO)上行的意思就是短信发送到服务器端 MO又称 Mobile Original \n下行(MT)下行的意思就是短信从服务器端发回到手机上,MT又称Mobile Terminated \n简单的说,从手机发起一个的过程叫上行(MO),到手机结束的过程叫下行(MT),比如,平时给你的朋友发送一条短信,对你来说就是上行(MO),而对你的朋友来说,就是下行(MT)。在企业、行业应用中,从系统给手机发送信息的过程叫下行(MT),而手机发送信息给系统的过程叫上行(MO)。
\n", "_id"=>511}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["log", "rails3", "slice_before"], "comments_count"=>0, "category_id"=>2, "title"=>"Parse Rails 3 log file using Enumerable#slice_before", "body"=>"``def parse_rails_log_file(file)\n # Remove all empty lines\n lines = file.each_line.map(&:strip).reject(&:empty?)\n\n # Use +Enumerable#slice_before+ to slice log file into sections for each request\n lines.slice_before(/Started (GET|POST|PUT|DELETE)/).each_with_object({}) do |request_log, totals|\n # Only include successfully finished actions in report\n if duration = request_log.last[/Completed 200 OK in (?<duration>\\d+)ms/, :duration]\n action_name = request_log.first[/Started (GET|POST|PUT|DELETE) \"(?<action>.+?)\" for/, :action]\n totals[action_name] ||= 0\n totals[action_name] += duration.to_i\n end\n end\nend\n\nif __FILE__ == $PROGRAM_NAME\n require \"pp\"\n puts \"Parsing Rails 3 log file (extracting cumulative running time per request path):\"\n puts \"=================\"\n\n log_file = <<-LOG_FILE\n Started GET \"/index\" for 192.168.74.1 at 2010-03-09 11:37:40\n Processing by UpdatesController#index as HTML\n Update Load (0.5ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (16.7ms)\n Completed 200 OK in 71ms (Views: 44.3ms | ActiveRecord: 0.5ms)\n\n Started POST \"/updates\" for 192.168.74.1 at 2010-03-09 11:37:43\n Processing by UpdatesController#create as HTML\n Parameters: {\"commit\"=>\"Save changes\"}\n Update Load (0.4ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (1.3ms)\n Completed 200 OK in 60ms (Views: 32.1ms | ActiveRecord: 0.4ms)\n\n Started GET \"/updates\" for 192.168.74.1 at 2010-03-09 11:45:51\n Processing by UpdatesController#index as HTML\n\n TypeError (exception class/object expected):\n app/controllers/updates_controller.rb:3:in `raise'\n app/controllers/updates_controller.rb:3:in `index'\n\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.6ms)\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.9ms)\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb (23.9ms)\n\n Started GET \"/updates\" for 192.168.74.1 at 2010-03-09 11:45:58\n Processing by UpdatesController#index as HTML\n Update Load (0.3ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (1.1ms)\n Completed 200 OK in 100ms (Views: 29.3ms | ActiveRecord: 0.3ms)\n LOG_FILE\n\n pp parse_rails_log_file(log_file) # => {\"/index\"=>71, \"/updates\"=>160}\nend```", "created_at"=>2010-07-26 21:42:33 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
# Use +Enumerable#slice_before+ to slice log file into sections for each request \n lines.slice_before(/Started (GET|POST|PUT|DELETE)/).each_with_object({}) do |request_log, totals| \n # Only include successfully finished actions in report \n if duration = request_log.last[/Completed 200 OK in (?<duration>\\d+)ms/, :duration] \n action_name = request_log.first[/Started (GET|POST|PUT|DELETE) "(?<action>.+?)" for/, :action] \n totals[action_name] ||= 0 \n totals[action_name] += duration.to_i \n end \n end \nend
\n\n
if FILE == $PROGRAM_NAME \n require "pp" \n puts "Parsing Rails 3 log file (extracting cumulative running time per request path):" \n puts "================="
\n\n
log_file = <<-LOG_FILE \n Started GET "/index" for 192.168.74.1 at 2010-03-09 11:37:40 \n Processing by UpdatesController#index as HTML \n Update Load (0.5ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (16.7ms) \n Completed 200 OK in 71ms (Views: 44.3ms | ActiveRecord: 0.5ms)
\n\n
Started POST "/updates" for 192.168.74.1 at 2010-03-09 11:37:43 \n Processing by UpdatesController#create as HTML \n Parameters: {"commit"=>"Save changes"} \n Update Load (0.4ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (1.3ms) \n Completed 200 OK in 60ms (Views: 32.1ms | ActiveRecord: 0.4ms)
\n\n
Started GET "/updates" for 192.168.74.1 at 2010-03-09 11:45:51 \n Processing by UpdatesController#index as HTML
Started GET "/updates" for 192.168.74.1 at 2010-03-09 11:45:58 \n Processing by UpdatesController#index as HTML \n Update Load (0.3ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (1.1ms) \n Completed 200 OK in 100ms (Views: 29.3ms | ActiveRecord: 0.3ms) \n LOG_FILE
\n写完申明后,去看消息出处看到其竟然做了修改,我早料到其会做相关的行为,所有早些时候截了屏幕如下:\n\n\n\n而现在的文章被修改为:\n\n\n\n看我用鼠标标识的地方,对关键信息进行了修改,感兴趣的人可以去 http://mobile.venturebeat.com/2010/07/28/android-wallpaper-app-that-steals-your-data-was-downloaded-by-millions/ 查看原文,对于这种标题党用子虚乌有的事情炒作,等消息传播后再修改自己的内容算什么行为!而对国内部分媒体在传播时不但不对真实性进行验证,还添油加醋,歪曲意思的报道,我非常无奈(看到有人还说可以获取信用卡信息,还加密传输,我实在无语)。\n\n按照我个人的感觉,他们应该紧接着要开始拿这个事件来炒作自己的产品了,我个人懒得去关注,如果有人发现有人借此炒作自己的产品,请帮忙分析分析,看看到底是什么人用这样手法。\n\n再次update!!!\n\n通过email和mylookout的人取得联系,说明我取得诸如设备号,手机屏幕大小是为了更智能的给设备适配图片,而获取部分的sim卡号是后来用户反馈说自己换了手机还想使用之前的收藏记录才使用的,这些信息只在该应用中使用,并没提供给任何第三方!\n\n同时让其确认venturebeat上文章中说到的获取浏览器历史,短信息,密码等高敏感性信息是否是他们说的还是写文章的人自己写的(Lots of my users send me the email ask me why I collect their text message and voicemail passward, I just want to make sure whether you and your ceo said that I collected browsing history,text message ,voicemail passward during the meeting.)。\n\n其cto给我回复说他们没有说过我的应用获取过诸如text messages or browsing history这些信息( We never stated that the wallpaper applications gathered users text messages or browsing history.),是媒体在撰写和传播的时候错误报道了(A member of the press misreported our research and he has since corrected it. )。\n\n我非常无语~\n\n2010年8月4日第二次次update!\n\n多谢这些天很多朋友的关心,我很好,谢谢!这些天和google android组,lookout公司和venturebeat的作者,以及国内外很多媒体,博客们,记者们都有很多的接触。\n\n1. google就前段时间将应用暂停和我一起分析了这个应用,今天发来调查的结果:\n\nOur investigation has concluded that there's no obvious malicious code in your apps, though the implementation accesses data that it doesn't need to. We've restored your apps (and they'll be available on Market again once you publish them), and are looking forward to seeing them updated to use ANDROID_ID. We are likely to make a statement about this issue this week--I'll let you know.\n\n我早就说过,我配合调查,我把代码提供给他们,google也做出了公正的评判,另外也给我提了一些建议(ANDROID_ID)。\n\n2. 当时写这篇报道的venturebeat记者Dean Takahashi发来了mail,为自己犯的错误道歉,并道歉该事带来的恶劣影响,会再写一篇文章澄清这个事情以消除影响。\n\n3. 那个安全公司lookout的人写邮件来要于我一起“ We wanted to coordinate with you to prevent further misunderstandings. ”。\n\n4.好几个不认识的国外记者很负责任,发邮件和gt和我交流询问事情的真相,并帮我喊冤,谢谢这些有职业精神的记者们。\n\n这个事情到这差不多就结束了,其中看到很多假丑恶,也看到很多真善美!谢谢所有帮助过我的人(很多很多,就不一一列举)。", "created_at"=>2010-07-29 08:41:39 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
同时让其确认venturebeat上文章中说到的获取浏览器历史,短信息,密码等高敏感性信息是否是他们说的还是写文章的人自己写的(Lots of my users send me the email ask me why I collect their text message and voicemail passward, I just want to make sure whether you and your ceo said that I collected browsing history,text message ,voicemail passward during the meeting.)。
\n\n
其cto给我回复说他们没有说过我的应用获取过诸如text messages or browsing history这些信息( We never stated that the wallpaper applications gathered users text messages or browsing history.),是媒体在撰写和传播的时候错误报道了(A member of the press misreported our research and he has since corrected it. )。
Our investigation has concluded that there's no obvious malicious code in your apps, though the implementation accesses data that it doesn't need to. We've restored your apps (and they'll be available on Market again once you publish them), and are looking forward to seeing them updated to use ANDROID_ID. We are likely to make a statement about this issue this week--I'll let you know.
\n", "_id"=>513}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Munin", "netstat", "passive"], "comments_count"=>0, "category_id"=>7, "title"=>"Fix the passive netstat connections in Munin", "body"=>"\n\nIf your running Munin in WHM they you may have noticed the passive netstat connections have been rising steadily over the last couple of weeks. This isn't a problem with your server, its a Munin bug that can be easily fixed.\n\n\n\n\n\nApparently the problem stemms from Munin counting the passive connections rejected. You can fix this problem quite easily by following the instructions below\n\nEdit the following file:\n/usr/share/munin/plugins/netstat\n\nand change the line\n
If your running Munin in WHM they you may have noticed the passive netstat connections have been rising steadily over the last couple of weeks. This isn't a problem with your server, its a Munin bug that can be easily fixed.
\n\n\n\n
Apparently the problem stemms from Munin counting the passive connections rejected. You can fix this problem quite easily by following the instructions below
\n\n
Edit the following file: \n/usr/share/munin/plugins/netstat
\n", "_id"=>514}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Charts", "Highcharts", "rails"], "comments_count"=>0, "category_id"=>2, "title"=>"ChartsOnRails", "body"=>"这几天需要找到漂亮的Charts类库,找了几个,发现一个很不粗的,mark下待使用,介绍如下:\n\nHighcharts is a charting library written in pure JavaScript, offering an easy way of adding interactive charts to your web site or web application. Highcharts currently supports line, spline, area, areaspline, column, bar, pie and scatter chart types.\n\n有兴趣的可以参考如下连接去看看:\n\nhttp://highcharts.com/\n\nhttp://railscasts.com/episodes/223-charts\n\nhttp://www.spritle.com/blogs/?p=859", "created_at"=>2010-08-20 21:48:59 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
这几天需要找到漂亮的Charts类库,找了几个,发现一个很不粗的,mark下待使用,介绍如下:
\n\n
Highcharts is a charting library written in pure JavaScript, offering an easy way of adding interactive charts to your web site or web application. Highcharts currently supports line, spline, area, areaspline, column, bar, pie and scatter chart types.
Delete your debug certificate under ~/.android/debug.keystore (on Linux and Mac OS X); the directory is something like %USERHOME%/.androidon Windows.
\n\n
The Eclipse plugin should then generate a new certificate when you next try to build a debug package.
\n", "_id"=>520}])
+MONGODB iceylog_development['categories'].find({:_id=>12}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>12}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["brew"], "comments_count"=>0, "category_id"=>7, "title"=>"Installs Homebrew to /usr/local so you don't need sudo to `brew install`", "body"=>"$ curl https://raw.github.com/gist/323731/install_homebrew.rb -o /tmp/install_homebrew.rb\n % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n100 4569 100 4569 0 0 1605 0 0:00:02 0:00:02 --:--:-- 2346\n\n $ ruby /tmp/install_homebrew.rb\n==> This script will install:\n/usr/local/bin/brew\n/usr/local/Library/Formula/...\n/usr/local/Library/Homebrew/...\n==> The following directories will be made group writable:\n/usr/local/.\n/usr/local/bin\n==> The following directories will have their group set to admin:\n/usr/local/.\n/usr/local/bin\n\nPress enter to continue\n==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin\n==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin\n==> Downloading and Installing Homebrew...\nWarning: The following *evil* dylibs exist in /usr/local/lib\nThey may break builds or worse. You should consider deleting them:\n/usr/local/lib/libevent-1.4.2.1.3.dylib\n/usr/local/lib/libevent_core-1.4.2.1.3.dylib\n/usr/local/lib/libevent_extra-1.4.2.1.3.dylib\n/usr/local/lib/libkyotocabinet.4.8.0.dylib\n/usr/local/lib/libprotobuf-lite.6.dylib\n/usr/local/lib/libprotobuf.6.dylib\n/usr/local/lib/libprotoc.6.dylib\n==> Installation successful!\nNow type: brew help\n\n参考:https://gist.github.com/323731", "created_at"=>2011-09-03 08:29:42 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
$ curl https://raw.github.com/gist/323731/install_homebrew.rb -o /tmp/install_homebrew.rb \n % Total % Received % Xferd Average Speed Time Time Time Current \n Dload Upload Total Spent Left Speed \n100 4569 100 4569 0 0 1605 0 0:00:02 0:00:02 --:--:-- 2346
\n\n
$ ruby /tmp/install_homebrew.rb \n==> This script will install: \n/usr/local/bin/brew \n/usr/local/Library/Formula/... \n/usr/local/Library/Homebrew/... \n==> The following directories will be made group writable: \n/usr/local/. \n/usr/local/bin \n==> The following directories will have their group set to admin: \n/usr/local/. \n/usr/local/bin
\n\n
Press enter to continue \n==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin \n==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin \n==> Downloading and Installing Homebrew... \nWarning: The following evil dylibs exist in /usr/local/lib \nThey may break builds or worse. You should consider deleting them: \n/usr/local/lib/libevent-1.4.2.1.3.dylib \n/usr/local/lib/libevent_core-1.4.2.1.3.dylib \n/usr/local/lib/libevent_extra-1.4.2.1.3.dylib \n/usr/local/lib/libkyotocabinet.4.8.0.dylib \n/usr/local/lib/libprotobuf-lite.6.dylib \n/usr/local/lib/libprotobuf.6.dylib \n/usr/local/lib/libprotoc.6.dylib \n==> Installation successful! \nNow type: brew help
\n", "_id"=>521}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["perl", "Twig", "xml"], "comments_count"=>0, "category_id"=>7, "title"=>"install perl module for XML-Twig in RHEL-Red Hat/Fedora Linux?", "body"=>"This module provides a way to process XML documents. It is build on top of XML::Parser. XML::Twig offers a tree interface to the document, while allowing you to output the parts of it that have been completely processed. It allows minimal resource (CPU and memory) usage by building the tree only for the parts of the documents that need actual processing, through the use of the twig_roots and twig_print_outside_roots options.(as pointed by yum info)\r\n\r\nLet’s first search for the package\r\n$ yum search perl-XML-Twig\r\nperl-XML-Twig.noarch : A perl module for processing huge XML documents in tree\r\n\r\nNote that you must be the root/administrator to install the package. To install this package in Red Hat/Fedora Linux.\r\n$ yum install perl-XML-Twig.noarch\r\n\r\nYou can check the details of this package perl-XML-Twig\r\n$ yum info perl-XML-Twig.noarch\r\n\r\n或者:\r\nperl -MCPAN -e 'install XML::Twig'", "created_at"=>2011-12-10 10:53:02 UTC, "updated_at"=>2012-06-24 15:46:47 UTC, "body_html"=>"
This module provides a way to process XML documents. It is build on top of XML::Parser. XML::Twig offers a tree interface to the document, while allowing you to output the parts of it that have been completely processed. It allows minimal resource (CPU and memory) usage by building the tree only for the parts of the documents that need actual processing, through the use of the twig_roots and twig_print_outside_roots options.(as pointed by yum info)
\n\n
Let’s first search for the package \n$ yum search perl-XML-Twig \nperl-XML-Twig.noarch : A perl module for processing huge XML documents in tree
\n\n
Note that you must be the root/administrator to install the package. To install this package in Red Hat/Fedora Linux. \n$ yum install perl-XML-Twig.noarch
\n\n
You can check the details of this package perl-XML-Twig \n$ yum info perl-XML-Twig.noarch
\n\n
或者: \nperl -MCPAN -e 'install XML::Twig'
\n", "_id"=>522}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["nginx", "statistics", "upstream"], "comments_count"=>0, "category_id"=>9, "title"=>"NGINX upstream statistics", "body"=>"使用过nginx的应该都都晓得upstream,前面一篇文章说到《nginx upstream的5种配置方式》,例如如下是很常见的一段配置\r\n\r\n#create by ice 2011.12.22\r\nupstream unicon_v2_www {\r\n# This is the socket we configured in unicorn.rb\r\nserver unix:/var/www/v2/tmp/sockets/unicorn.sock backup;\r\nserver 192.168.0.1:5000 weight=9 max_fails=2 fail_timeout=30s;\r\nserver 192.168.0.2:5000 weight=3 max_fails=2 fail_timeout=30s;\r\n}\r\nserver {\r\nlisten 80;\r\nserver_name www.iceskysl.com;\r\nerror_log /opt/nginx/logs/error/error_v2_www.log;\r\naccess_log /opt/nginx/logs/access/access_v2_www.log main;\r\n\r\nroot /var/www/v2/public/;\r\nindex index.html index.htm;\r\n\r\nlocation / {\r\nproxy_redirect off;\r\nproxy_set_header X-Real-IP $remote_addr;\r\nproxy_set_header Host $host;\r\nproxy_set_header Content-Length $content_length;\r\nproxy_set_header X-Forwarded-For $remote_addr;\r\nclient_max_body_size 10m;\r\nclient_body_buffer_size 128k;\r\nproxy_connect_timeout 90;\r\nproxy_send_timeout 90;\r\nproxy_read_timeout 90;\r\nproxy_buffer_size 4k;\r\nproxy_buffers 4 32k;\r\nproxy_busy_buffers_size 64k;\r\nproxy_temp_file_write_size 64k;\r\nchunked_transfer_encoding off;\r\nproxy_pass http://unicon_v2_www/;\r\n}\r\n}\r\n\r\n其中upstream的这段配置:\r\nupstream unicon_v2_www {\r\n# This is the socket we configured in unicorn.rb\r\nserver unix:/var/www/v2/tmp/sockets/unicorn.sock backup;\r\nserver 192.168.0.1:5000 weight=9 max_fails=2 fail_timeout=30s;\r\nserver 192.168.0.2:5000 weight=3 max_fails=2 fail_timeout=30s;\r\n}\r\n\r\n我们了解到socket模式的这个是backup,其他两个机器分别weight=3和weight=9,于是我们想监控下upstream每个后端具体处理了多少请求,有没有问题等,这个好像就不好监控了,nginx自带的status模块只能监控总的请求数,无法区分每个upstream的具体情况。\r\n找到一个ustats(http://code.google.com/p/ustats/),其介绍是:NGINX basic upstream statistics module,具体的如下:\r\n
USTATS module provides basic statistics for each backend in nginx upstreams:\r\n\r\nNumber of requests\r\nHttp 499/500/503 errors count\r\nTcp errors\r\nHttp read/write timeouts\r\nFail timeout\r\nMax fails count\r\nLast failed access time\r\nTotal fails count\r\nBlacklisted backend highlighting\r\nDown backends highlighting\r\nThe module allows you to sort values in some columns for each separate upstream. The data can be retrieved as JSON by appending \"?json\" to the end of location on which the module was set to work on (see configuration instructions below).
我们了解到socket模式的这个是backup,其他两个机器分别weight=3和weight=9,于是我们想监控下upstream每个后端具体处理了多少请求,有没有问题等,这个好像就不好监控了,nginx自带的status模块只能监控总的请求数,无法区分每个upstream的具体情况。 \n找到一个ustats(http://code.google.com/p/ustats/),其介绍是:NGINX basic upstream statistics module,具体的如下:<!--more--> \nUSTATS module provides basic statistics for each backend in nginx upstreams:
\n\n
Number of requests \nHttp 499/500/503 errors count \nTcp errors \nHttp read/write timeouts \nFail timeout \nMax fails count \nLast failed access time \nTotal fails count \nBlacklisted backend highlighting \nDown backends highlighting \nThe module allows you to sort values in some columns for each separate upstream. The data can be retrieved as JSON by appending "?json" to the end of location on which the module was set to work on (see configuration instructions below). \n看上去正是我需要的,有时间试试看~(为啥nginx不学haproxy官方自带一个详细statistics的页面呢~haproxy那个statistics很详细很好用~) \n详细使用指南:http://code.google.com/p/ustats/
\r\nThe reason is simple. I installed an extension called SEO Site Tools which installs an icon on the right of the address bar. When you click the button, on the window displayed there is the option “Show no follo” which is an option for displaying links that have the value nofollow for the attribute rel of an HTML element.\r\n\r\nThis attribute instructs some search engines that a hyperlink should not influence the link target’s ranking in the search engine’s index. (Source: wikipedia.org)\r\n
\r\n\r\n修复的方法很简单,去掉“Show no follo”的勾选就好了~\r\n", "created_at"=>2012-01-28 01:48:36 UTC, "updated_at"=>2012-06-24 15:46:48 UTC, "body_html"=>"
经过检查(Library/Application Support/Google/Chrome/Default/User StyleSheets/Custom.css),发现不是本地的css配置,最后找到是一个叫“SEO Site Tools”导致的,具体原因是: \n \nThe reason is simple. I installed an extension called SEO Site Tools which installs an icon on the right of the address bar. When you click the button, on the window displayed there is the option “Show no follo” which is an option for displaying links that have the value nofollow for the attribute rel of an HTML element.
\n\n
This attribute instructs some search engines that a hyperlink should not influence the link target’s ranking in the search engine’s index. (Source: wikipedia.org)
\n\n
修复的方法很简单,去掉“Show no follo”的勾选就好了~
\n", "_id"=>525}])
+MONGODB iceylog_development['categories'].find({:_id=>10}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>10}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Html/css/js"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["CoffeeScript", "Connect", "Express", "jade", "JavaScript", "Node.js", "npm"], "comments_count"=>0, "category_id"=>10, "title"=>"CoffeeScript解决JavaScript不美,Node.js潜力巨大", "body"=>"如果你对JavaScript感兴趣,但是不喜欢写一大堆一大堆的JavaScript代码,那真的不是你的错,因为很多人都说JavaScript不美,究其原因,可以归纳为:JavaScript的诞生是个悲剧. 它是函数式+动态语言的优秀内核, 却硬被绑上了C/Java的语法。\r\n\r\n如果你真的喜欢JavaScript,那么你可以尝试了解更多~比如CoffeeScript,再比如Node.js,再比如Connect,再比如Express,再再比如jade,再再再比如npm等等,于是我们从安装npm(a package manager for node)开始~\r\n\r\n#装npm\r\nice@mac:~ > curl http://npmjs.org/install.sh | sh\r\n % Total % Received % Xferd Average Speed Time Time Time Current\r\n Dload Upload Total Spent Left Speed\r\n100 7881 100 7881 0 0 3664 0 0:00:02 0:00:02 --:--:-- 8584\r\ntar=/usr/bin/tar\r\nversion:\r\nbsdtar 2.8.3 - libarchive 2.8.3\r\ninstall npm@1.1\r\nfetching: http://registry.npmjs.org/npm/-/npm-1.1.0-3.tgz\r\n0.6.2\r\n1.1.0-3\r\ncleanup prefix=/usr/local\r\n\r\nAll clean!\r\n/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js\r\nnpm@1.1.0-3 /usr/local/lib/node_modules/npm\r\nIt worked\r\n\r\n#看看怎么用\r\nice@mac:~ > npm help\r\n\r\nUsage: npm \r\n\r\nwhere is one of:\r\n adduser, apihelp, author, bin, bugs, c, cache, completion,\r\n config, deprecate, docs, edit, explore, faq, find, get,\r\n help, help-search, home, i, info, init, install, la, link,\r\n list, ll, ln, login, ls, outdated, owner, pack, prefix,\r\n prune, publish, r, rb, rebuild, remove, restart, rm, root,\r\n run-script, s, se, search, set, show, star, start, stop,\r\n submodule, tag, test, un, uninstall, unlink, unpublish,\r\n unstar, up, update, version, view, whoami\r\n\r\nnpm -h quick help on \r\nnpm -l display full usage info\r\nnpm faq commonly asked questions\r\nnpm help search for help on \r\nnpm help npm involved overview\r\n\r\nSpecify configs in the ini-formatted file:\r\n /Users/ice/.npmrc\r\nor on the command line via: npm --key value\r\nConfig info can be viewed via: npm help config\r\n\r\nnpm@1.1.0-3 /usr/local/lib/node_modules/npm\r\n\r\n#用npm装connect\r\nice@mac:~ > npm install connect\r\nnpm http GET https://registry.npmjs.org/connect\r\nnpm http 200 https://registry.npmjs.org/connect\r\nnpm http GET https://registry.npmjs.org/connect/-/connect-1.8.5.tgz\r\nnpm http 200 https://registry.npmjs.org/connect/-/connect-1.8.5.tgz\r\nnpm http GET https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/mime\r\nnpm http GET https://registry.npmjs.org/formidable\r\nnpm http 200 https://registry.npmjs.org/formidable\r\nnpm http 200 https://registry.npmjs.org/mime\r\nnpm http 200 https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/formidable/-/formidable-1.0.8.tgz\r\nnpm http GET https://registry.npmjs.org/mime/-/mime-1.2.4.tgz\r\nnpm http GET https://registry.npmjs.org/qs/-/qs-0.4.1.tgz\r\nnpm http 200 https://registry.npmjs.org/mime/-/mime-1.2.4.tgz\r\nnpm http 200 https://registry.npmjs.org/formidable/-/formidable-1.0.8.tgz\r\nnpm http 200 https://registry.npmjs.org/qs/-/qs-0.4.1.tgz\r\nconnect@1.8.5 ./node_modules/connect \r\n├── mime@1.2.4\r\n├── qs@0.4.1\r\n└── formidable@1.0.8\r\n\r\n#用npm装express\r\nice@mac:~ > npm install express\r\nnpm http GET https://registry.npmjs.org/express\r\nnpm http 200 https://registry.npmjs.org/express\r\nnpm http GET https://registry.npmjs.org/express/-/express-2.5.6.tgz\r\nnpm http 200 https://registry.npmjs.org/express/-/express-2.5.6.tgz\r\nnpm http GET https://registry.npmjs.org/mime\r\nnpm http GET https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/mkdirp/0.0.7\r\nnpm http 304 https://registry.npmjs.org/qs\r\nnpm http 304 https://registry.npmjs.org/mime\r\nnpm http 200 https://registry.npmjs.org/mkdirp/0.0.7\r\nnpm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.0.7.tgz\r\nnpm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.0.7.tgz\r\nexpress@2.5.6 ./node_modules/express \r\n├── mkdirp@0.0.7\r\n├── mime@1.2.4\r\n└── qs@0.4.1\r\n\r\n#用npm装jade\r\nice@mac:~ > npm install jade\r\nnpm http GET https://registry.npmjs.org/jade\r\nnpm http 200 https://registry.npmjs.org/jade\r\nnpm http GET https://registry.npmjs.org/jade/-/jade-0.20.0.tgz\r\nnpm http 200 https://registry.npmjs.org/jade/-/jade-0.20.0.tgz\r\nnpm http GET https://registry.npmjs.org/commander\r\nnpm http GET https://registry.npmjs.org/mkdirp\r\nnpm http 200 https://registry.npmjs.org/mkdirp\r\nnpm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz\r\nnpm http 200 https://registry.npmjs.org/commander\r\nnpm http GET https://registry.npmjs.org/commander/-/commander-0.2.1.tgz\r\nnpm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz\r\nnpm http 200 https://registry.npmjs.org/commander/-/commander-0.2.1.tgz\r\njade@0.20.0 ./node_modules/jade \r\n├── commander@0.2.1\r\n└── mkdirp@0.3.0\r\n\r\n好了,你入门了,更多资料,请自行查看如下链接的资料吧~\r\n\r\n相关资料\r\n\r\nCoffeeScript: CoffeeScript is a little language that compiles into JavaScript\r\nhttp://coffeescript.org/\r\n\r\n为什么CoffeeScript这么美?\r\nhttp://cnodejs.org/blog/?p=1584\r\n\r\nCoffeeScript: The beautiful way to write JavaScript\r\nhttp://amix.dk/blog/post/19612\r\n\r\n10个让朋友对你刮目相看的CoffeeScript单行代码绝技\r\nhttp://heikezhi.com/2011/06/08/10-coffeescript-one-liners-to-impress-your-friends/\r\n\r\nnpm: a package manager for node\r\nhttps://github.com/isaacs/npm\r\n\r\nExpress:http://expressjs.com/\r\nHigh performance, high class web development for Node.js\r\n\r\nConnect: Connect is a middleware layer for Node.js\r\nhttp://www.senchalabs.org/connect/\r\n\r\njade: http://jade-lang.com/\r\nNode Template Engine\r\n\r\ncoffee-box: Blog engine for fashionable developers. Built upon Node.js, Express, MongoDB and CoffeeScript.\r\nhttps://github.com/qiao/coffee-box", "created_at"=>2012-01-28 14:57:06 UTC, "updated_at"=>2012-06-24 15:46:48 UTC, "body_html"=>"
如果你真的喜欢JavaScript,那么你可以尝试了解更多~比如CoffeeScript,再比如Node.js,再比如Connect,再比如Express,再再比如jade,再再再比如npm等等,于是我们从安装npm(a package manager for node)开始~
\n\n
#装npm \nice@mac:~ > curl http://npmjs.org/install.sh | sh \n % Total % Received % Xferd Average Speed Time Time Time Current \n Dload Upload Total Spent Left Speed \n100 7881 100 7881 0 0 3664 0 0:00:02 0:00:02 --:--:-- 8584 \ntar=/usr/bin/tar \nversion: \nbsdtar 2.8.3 - libarchive 2.8.3 \ninstall npm@1.1 \nfetching: http://registry.npmjs.org/npm/-/npm-1.1.0-3.tgz \n0.6.2 \n1.1.0-3 \ncleanup prefix=/usr/local
\n\n
All clean! \n/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js \nnpm@1.1.0-3 /usr/local/lib/node_modules/npm \nIt worked \n<!--more-->
npm -h quick help on \nnpm -l display full usage info \nnpm faq commonly asked questions \nnpm help search for help on \nnpm help npm involved overview
\n\n
Specify configs in the ini-formatted file: \n /Users/ice/.npmrc \nor on the command line via: npm --key value \nConfig info can be viewed via: npm help config
首先安装Graphviz \n% brew install cairo pango graphviz # Homebrew on Mac OS X \n% sudo port install graphviz # Macports on Mac OS X \n% sudo aptitude install graphviz # Debian and Ubuntu
更多信息参考:http://rails-erd.rubyforge.org/ \n<!--more--> \n附:常见错误处理: \nCould not find gem 'choice (~> 0.1.4) ruby', which is required by gem 'rails-erd (>= 0) ruby', in any of the sources.
\n\n
原因是rails-erd依赖choice这个gem,装下 \nice@mac:/www/trunk > sudo gem install choice \nPassword: \nSuccessfully installed choice-0.1.4 \n1 gem installed \nInstalling ri documentation for choice-0.1.4... \nInstalling RDoc documentation for choice-0.1.4...
\n", "_id"=>535}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['system.namespaces'].find({})
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['system.namespaces'].find({})
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Making rhtml better", "body"=>"It’s even easier like this:in app/views/layouts/application.rhtml:<%= xhtml_doctype :strict %><%= html_tag :lang => Globalize::Locale.active.language.iso_639_1 %><%= @content_for_layout %><%= end_html_tag %>and in app/helpers/application_helper.rb:module ApplicationHelper # Renders an xhtml doctype declaration for the document's prolog. Defaults to xhtml transitional. # <tt>xhtml_doctype :strict</tt> def xhtml_doctype( doctype=:transitional ) doctype = :transitional unless [:transitional, :strict, :frameset].include? doctype case doctype when :transitional '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' when :strict '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' when :frameset '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">' end end # Displays an html tag, complete with xhtml namespace and language. Accepts language as an option, but defaults to English. # <tt>html_tag :lang => 'de'</tt> def html_tag( options={} ) options[:lang] ||= 'en' lang = options.delete( :lang ) "<html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"\#{lang}\\" xml:lang=\\"\#{lang}\\" \#{options.map { |k,v| "\#{k}=\\"\#{v}\\"" }.join( ' ' )}>" end # End html tag. def end_html_tag; "</html>" endend", "created_at"=>2007-05-19 01:37:13 UTC, "updated_at"=>2012-06-24 15:47:00 UTC, "body_html"=>"
It’s even easier like this:in app/views/layouts/application.rhtml:<%= xhtml_doctype :strict %><%= html_tag :lang => Globalize::Locale.active.language.iso_639_1 %><%= @content_for_layout %><%= end_html_tag %>and in app/helpers/application_helper.rb:module ApplicationHelper # Renders an xhtml doctype declaration for the document's prolog. Defaults to xhtml transitional. # <tt>xhtml_doctype :strict</tt> def xhtml_doctype( doctype=:transitional ) doctype = :transitional unless [:transitional, :strict, :frameset].include? doctype case doctype when :transitional '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' when :strict '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' when :frameset '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">' end end # Displays an html tag, complete with xhtml namespace and language. Accepts language as an option, but defaults to English. # <tt>html_tag :lang => 'de'</tt> def html_tag( options={} ) options[:lang] ||= 'en' lang = options.delete( :lang ) "<html xmlns="http://www.w3.org/1999/xhtml\\" lang="\#{lang}" xml:lang="\#{lang}" \#{options.map { |k,v| "\#{k}="\#{v}"" }.join( ' ' )}>" end # End html tag. def end_html_tag; "</html>" endend
\n", "_id"=>536}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Quick add slashes filter for Rails", "body"=>"读后:有的时候,需要在提交的URL后面自动加上"/",这个方法实现这样一个需求,你还可以扩展下去,比如在域名前加"http:\\\\"这样的字符。def add_slash unless %r{/$}.match(@request.path) redirect_to @request.path << '/' endendThis ensures you always have the trailing slash at the end of your URLs. Maybe it could be done better, but for now it works. Django has some stock middleware that does just this, as well as ensuring the first part of the hostname is ‘www’. The point is that your resource can be accessed with one and only one URL, rather than with potentially 4 combinations of / and www. I have no hard evidence, but this is supposedly good for teh Google, and some people find it elegant.I am thinking about maybe whipping up a module of such utilities that you could include in your ApplicationController and never think about again.", "created_at"=>2007-05-19 01:34:51 UTC, "updated_at"=>2012-06-24 15:47:00 UTC, "body_html"=>"
读后:有的时候,需要在提交的URL后面自动加上"/",这个方法实现这样一个需求,你还可以扩展下去,比如在域名前加"http:\\"这样的字符。def add_slash unless %r{/$}.match(@request.path) redirect_to @request.path << '/' endendThis ensures you always have the trailing slash at the end of your URLs. Maybe it could be done better, but for now it works. Django has some stock middleware that does just this, as well as ensuring the first part of the hostname is ‘www’. The point is that your resource can be accessed with one and only one URL, rather than with potentially 4 combinations of / and www. I have no hard evidence, but this is supposedly good for teh Google, and some people find it elegant.I am thinking about maybe whipping up a module of such utilities that you could include in your ApplicationController and never think about again.
\n", "_id"=>537}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Introducing the AJAX Feed API FeedControl", "body"=>"Google放出来的AJAX feed API我老早就关注到了,也试用了一些,感觉还真的不错,现在又添加了一些东西,如下:其API都很简单,详细的可以看这个页面上的介绍:http://code.google.com/apis/ajaxfeeds/documentation/reference.html#FeedControl只有一个构造器:FeedControl四个函数:1.addFeed(url, label) //添加需要显示的FEED的URL2.addFeed(element, opt_options?);//这个其实就是draw方法,指定显示的方式,例如:feedControl.draw( document.getElementById("feedControl"), { drawMode : google.feeds.FeedControl.DRAW_MODE_TABBED });feedControl这个是页面的DOM的ID名称,google.feeds.FeedControl.DRAW_MODE_TABBED 就是指定的显示方式,默认值是:google.feeds.FeedControl.DRAW_MODE_LINEAR.3.setNumEntries(num); //设定显示的条数(貌似只能统一指定,不能为各个FEED单独指定)4.setLinkTarget(linkTarget) //设定链接的打开方式,其值分别如下: * google.feeds.LINK_TARGET_BLANK - links will open in a new window * google.feeds.LINK_TARGET_SELF - links will open in the current window * google.feeds.LINK_TARGET_TOP - links will open in the topmost frame * google.feeds.LINK_TARGET_PARENT - links will open in either the topmost frame, or replace the current frame. * anything-else - the value of target in the resulting anchor element is set to linkTarget附录其网站上的说明:---------------This morning we added a new class to the Google AJAX Feed API designed to allow you to more easily add a collection of feeds to your pages. The FeedControl is pretty simple:var feedControl = new google.feeds.FeedControl();feedControl.addFeed("http://www.digg.com/rss/index.xml", "Digg");feedControl.addFeed("http://feeds.feedburner.com/Techcrunch", "TechCrunch");feedControl.draw(document.getElementById("feedControl"));In addition to the formal documentation, we have put together a few samples to help you quickly come up to speed. * Basic FeedControl - feedcontrol.html * Tabbed FeedControl - tabbed.html * Sidebar Style FeedControl - sidebar.html * AJAX Feed API Playground Blog", "created_at"=>2007-05-19 01:32:26 UTC, "updated_at"=>2012-06-24 15:47:00 UTC, "body_html"=>"
Google放出来的AJAX feed API我老早就关注到了,也试用了一些,感觉还真的不错,现在又添加了一些东西,如下:其API都很简单,详细的可以看这个页面上的介绍:http://code.google.com/apis/ajaxfeeds/documentation/reference.html#FeedControl只有一个构造器:FeedControl四个函数:1.addFeed(url, label) //添加需要显示的FEED的URL2.addFeed(element, opt_options?);//这个其实就是draw方法,指定显示的方式,例如:feedControl.draw( document.getElementById("feedControl"), { drawMode : google.feeds.FeedControl.DRAW_MODE_TABBED });feedControl这个是页面的DOM的ID名称,google.feeds.FeedControl.DRAW_MODE_TABBED 就是指定的显示方式,默认值是:google.feeds.FeedControl.DRAW_MODE_LINEAR.3.setNumEntries(num); //设定显示的条数(貌似只能统一指定,不能为各个FEED单独指定)4.setLinkTarget(linkTarget) //设定链接的打开方式,其值分别如下: * google.feeds.LINK_TARGET_BLANK - links will open in a new window * google.feeds.LINK_TARGET_SELF - links will open in the current window * google.feeds.LINK_TARGET_TOP - links will open in the topmost frame * google.feeds.LINK_TARGET_PARENT - links will open in either the topmost frame, or replace the current frame. * anything-else - the value of target in the resulting anchor element is set to linkTarget附录其网站上的说明:---------------This morning we added a new class to the Google AJAX Feed API designed to allow you to more easily add a collection of feeds to your pages. The FeedControl is pretty simple:var feedControl = new google.feeds.FeedControl();feedControl.addFeed("http://www.digg.com/rss/index.xml", "Digg");feedControl.addFeed("http://feeds.feedburner.com/Techcrunch", "TechCrunch");feedControl.draw(document.getElementById("feedControl"));In addition to the formal documentation, we have put together a few samples to help you quickly come up to speed. * Basic FeedControl - feedcontrol.html * Tabbed FeedControl - tabbed.html * Sidebar Style FeedControl - sidebar.html * AJAX Feed API Playground Blog
\n", "_id"=>538}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>3, "title"=>"Counting Distinct Records In Rails", "body"=>"If you ever need to count your Rails records based on a distinct column, here is a simple solution:Gift.count_by_sql("select count(distinct url) from gifts")In this example, I am counting the number of distinct gift urls from my gifts table.", "created_at"=>2007-05-19 01:30:32 UTC, "updated_at"=>2012-06-24 15:47:00 UTC, "body_html"=>"
If you ever need to count your Rails records based on a distinct column, here is a simple solution:Gift.count_by_sql("select count(distinct url) from gifts")In this example, I am counting the number of distinct gift urls from my gifts table.
\n", "_id"=>539}])
+MONGODB iceylog_development['categories'].find({:_id=>3}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>3}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Appending to a string(ROR中的+=和<<操作符的比较)", "body"=>"If you come from another language, you might be tempted to use the += operator when appending to a string. 1. my_str = "Marco " 2. my_str += "Polo"It works… but there is a better way to do it : the << method. 1. my_str = "Marco " 2. my_str << "Polo"#UPDATEI have removed my initial claim about operator precedence as it isn’t really accurate. There is a much better reason to use << instead of += when appending to a string... something I didn't even realize (Thanks to Gregory). += will create a new String instance and will assign it to your left object. On the other hand, << will append the new string directly into your already existing left object. One could argue that += is only different than << and not better, but to me << is what you'll want to use 99% of the time (if not 100%) when appending to a String. I have yet to see a real case where one would want to "lose" it's existing String instance just to get a new one containing the exact same value.You can also use the << method with arrays : 1. [1,2,3] << 4 #gives [1,2,3,4]、 Be careful however when using << with Fixnum/Bignum instances. With these objects, the << method will shift the bits of your integer to the left. If you want to do a summation (append style that is), you will have to use +=", "created_at"=>2007-05-19 01:29:16 UTC, "updated_at"=>2012-06-24 15:47:00 UTC, "body_html"=>"
If you come from another language, you might be tempted to use the += operator when appending to a string. 1. my_str = "Marco " 2. my_str += "Polo"It works… but there is a better way to do it : the << method. 1. my_str = "Marco " 2. my_str << "Polo"#UPDATEI have removed my initial claim about operator precedence as it isn’t really accurate. There is a much better reason to use << instead of += when appending to a string... something I didn't even realize (Thanks to Gregory). += will create a new String instance and will assign it to your left object. On the other hand, << will append the new string directly into your already existing left object. One could argue that += is only different than << and not better, but to me << is what you'll want to use 99% of the time (if not 100%) when appending to a String. I have yet to see a real case where one would want to "lose" it's existing String instance just to get a new one containing the exact same value.You can also use the << method with arrays : 1. [1,2,3] << 4 #gives [1,2,3,4]、 Be careful however when using << with Fixnum/Bignum instances. With these objects, the << method will shift the bits of your integer to the left. If you want to do a summation (append style that is), you will have to use +=
\n", "_id"=>540}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["ruby"], "comments_count"=>0, "category_id"=>2, "title"=>"Check for nil and initialize on a single line", "body"=>"点评:关于ROR中的一中“遇nil赋值”的写法,这个很早的时候在书上看到的是||=操作符,也一直这么用,今天发现作者的另外这个写法也挺好的。\n\nSometimes, you want to initialize a variable to some value only if that variable is equal to nil. If you like to write your methods as short, clean and readable as possible, you can do that task in a single line instead of taking the traditionnal 3 lines approach. You have two options :\n\n1) You can use the if modifier 1. x = get_some_object if x.nil?Very easy to read. This is my favorite.\n\n2) Or you can use the ||= operator 1. x ||= get_some_object This one is even shorter. The ||= operator is a little bit less verbose and might confuse a ruby newcomer… but I’m not saying that it should be a reason for not using it. This is more a matter of personal taste than anything else.Both of these methods are better than this :\n\n1. #eeww… we don’t like this one.\n\n2. if(x.nil?)\n\n3. x = get_some_object 4. end", "created_at"=>2007-05-19 01:23:10 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
Sometimes, you want to initialize a variable to some value only if that variable is equal to nil. If you like to write your methods as short, clean and readable as possible, you can do that task in a single line instead of taking the traditionnal 3 lines approach. You have two options :
\n\n
1) You can use the if modifier 1. x = get_some_object if x.nil?Very easy to read. This is my favorite.
\n\n
2) Or you can use the ||= operator 1. x ||= get_some_object This one is even shorter. The ||= operator is a little bit less verbose and might confuse a ruby newcomer… but I’m not saying that it should be a reason for not using it. This is more a matter of personal taste than anything else.Both of these methods are better than this :
\n", "_id"=>542}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>6, "title"=>"CodeGear公司准备发布Ruby", "body"=>"CodeGear公司本周宣布他们将在2007年下半年发布针对rails的开发者Ruby集成开发环境(IDE)…… 隶属Borland软件公司的开发工具业务公司CodeGear公布了即将发布的被称为“Ruby IDE”的部分信息,其主要特征包括: * A full set of development and deployment modules including Ruby, Rails, Gems and Database. * 全面支持Ruby和Rails,具有代码完成、重构、类型浏览和导航等开发特性。 * 创新性的管理器集成了命令行的功能和IDE、向导与代码浏览器的易用性,提高了生产率。 * 可视化和导航依赖可以无缝的利用各种资源进行工作,不管它们的关系、位置或格式。 * 完整的开发和部署模块包括Ruby、Rails、 Gems和数据库。 Ruby IDE所包含的技术将有利于推动开源技术发展。CodeGear已经表示他们将为Ruby提供补丁及分发代码以支持Eclipse动态语言工具包的支持。 CodeGear生产战略事务副总裁Michael Swindell 在该公司发布的一次讲话中说到:“Ruby on Rails已经成为一个重要的Web应用程序开发平台,因为它使得利用最少的代码开发丰富、数据驱动Web2.0应用更快更简单。然而,生产力背后的“魔法”对开发人员“现实世界”生产力水平上Web应用的构建,开发和维护带来了新的挑战。” Swindell说到:“我们新的Ruby on Rails 技术通过不再是仅仅编辑和调试Ruby脚本解决了这些挑战。它提供了一个综合的以Rails为中心的开发环境,该集成环境即适用于新手也适用于流线开发专家。同时,基于CodeGear IDE 的创新性,这是我们开发的第一个可同时吸引命令行开发者,IDE开发者和可视化开发者的工具。”来源:IT专家网", "created_at"=>2007-05-19 23:05:07 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
CodeGear公司本周宣布他们将在2007年下半年发布针对rails的开发者Ruby集成开发环境(IDE)…… 隶属Borland软件公司的开发工具业务公司CodeGear公布了即将发布的被称为“Ruby IDE”的部分信息,其主要特征包括: * A full set of development and deployment modules including Ruby, Rails, Gems and Database. * 全面支持Ruby和Rails,具有代码完成、重构、类型浏览和导航等开发特性。 * 创新性的管理器集成了命令行的功能和IDE、向导与代码浏览器的易用性,提高了生产率。 * 可视化和导航依赖可以无缝的利用各种资源进行工作,不管它们的关系、位置或格式。 * 完整的开发和部署模块包括Ruby、Rails、 Gems和数据库。 Ruby IDE所包含的技术将有利于推动开源技术发展。CodeGear已经表示他们将为Ruby提供补丁及分发代码以支持Eclipse动态语言工具包的支持。 CodeGear生产战略事务副总裁Michael Swindell 在该公司发布的一次讲话中说到:“Ruby on Rails已经成为一个重要的Web应用程序开发平台,因为它使得利用最少的代码开发丰富、数据驱动Web2.0应用更快更简单。然而,生产力背后的“魔法”对开发人员“现实世界”生产力水平上Web应用的构建,开发和维护带来了新的挑战。” Swindell说到:“我们新的Ruby on Rails 技术通过不再是仅仅编辑和调试Ruby脚本解决了这些挑战。它提供了一个综合的以Rails为中心的开发环境,该集成环境即适用于新手也适用于流线开发专家。同时,基于CodeGear IDE 的创新性,这是我们开发的第一个可同时吸引命令行开发者,IDE开发者和可视化开发者的工具。”来源:IT专家网
\n", "_id"=>548}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Tips"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>4, "title"=>"去掉CSS中的链接图片的外边框", "body"=>"在ROR的实际开发中,遇到这么一个情况:例如凡是有图片的地方,在图片外面显示了一个边框,很不好看,找了下资料,可以这样修复:1.如果是直接用image_tag来实现的 ,则加上:border => 0,结果如下:<%= link_to(image_tag("/images/btn_home.png", :border => 0), {:controller => "code"}) %>2.如果这个图片使用的是CSS中的DIV格式,则需要添加:border: 0就可以了.归结为:when images are used in links they put a border around them.To disable this globally (as most people do) add "img {border: 0}" to your css.", "created_at"=>2007-05-19 22:21:02 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
在ROR的实际开发中,遇到这么一个情况:例如凡是有图片的地方,在图片外面显示了一个边框,很不好看,找了下资料,可以这样修复:1.如果是直接用image_tag来实现的 ,则加上:border => 0,结果如下:<%= link_to(image_tag("/images/btn_home.png", :border => 0), {:controller => "code"}) %>2.如果这个图片使用的是CSS中的DIV格式,则需要添加:border: 0就可以了.归结为:when images are used in links they put a border around them.To disable this globally (as most people do) add "img {border: 0}" to your css.
\n", "_id"=>550}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"ruby操作时间对象", "body"=>"在开发过程中,难免需要对时间对象进行一系列操作,比如统计新发的文章,统计在线会员等,如下是对时间对象的操作方法:distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)Reports the approximate distance in time between two Time or Date objects or integers as seconds. Set include_seconds to true if you want more detailed approximations when distance < 1 min, 29 secs Distances are reported base on the following table:0 <-> 29 secs # => less than a minute 30 secs <-> 1 min, 29 secs # => 1 minute 1 min, 30 secs <-> 44 mins, 29 secs # => [2..44] minutes 44 mins, 30 secs <-> 89 mins, 29 secs # => about 1 hour 89 mins, 29 secs <-> 23 hrs, 59 mins, 29 secs # => about [2..24] hours 23 hrs, 59 mins, 29 secs <-> 47 hrs, 59 mins, 29 secs # => 1 day 47 hrs, 59 mins, 29 secs <-> 29 days, 23 hrs, 59 mins, 29 secs # => [2..29] days 29 days, 23 hrs, 59 mins, 30 secs <-> 59 days, 23 hrs, 59 mins, 29 secs # => about 1 month 59 days, 23 hrs, 59 mins, 30 secs <-> 1 yr minus 31 secs # => [2..12] months 1 yr minus 30 secs <-> 2 yrs minus 31 secs # => about 1 year 2 yrs minus 30 secs <-> max time or date # => over [2..X] yearsWith include_seconds = true and the difference < 1 minute 29 seconds 0-4 secs # => less than 5 seconds 5-9 secs # => less than 10 seconds 10-19 secs # => less than 20 seconds 20-39 secs # => half a minute 40-59 secs # => less than a minute 60-89 secs # => 1 minuteExamples: from_time = Time.now distance_of_time_in_words(from_time, from_time + 50.minutes) # => about 1 hour distance_of_time_in_words(from_time, from_time + 15.seconds) # => less than a minute distance_of_time_in_words(from_time, from_time + 15.seconds, true) # => less than 20 secondsNote: Rails calculates one year as 365.25 days.[ show source ] # File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 4848: def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)49: from_time = from_time.to_time if from_time.respond_to?(:to_time)50: to_time = to_time.to_time if to_time.respond_to?(:to_time)51: distance_in_minutes = (((to_time - from_time).abs)/60).round52: distance_in_seconds = ((to_time - from_time).abs).round53: 54: case distance_in_minutes55: when 0..156: return (distance_in_minutes == 0) ? 'less than a minute' : '1 minute' unless include_seconds57: case distance_in_seconds58: when 0..4 then 'less than 5 seconds'59: when 5..9 then 'less than 10 seconds'60: when 10..19 then 'less than 20 seconds'61: when 20..39 then 'half a minute'62: when 40..59 then 'less than a minute'63: else '1 minute'64: end65: 66: when 2..44 then "\#{distance_in_minutes} minutes"67: when 45..89 then 'about 1 hour'68: when 90..1439 then "about \#{(distance_in_minutes.to_f / 60.0).round} hours"69: when 1440..2879 then '1 day'70: when 2880..43199 then "\#{(distance_in_minutes / 1440).round} days"71: when 43200..86399 then 'about 1 month'72: when 86400..525959 then "\#{(distance_in_minutes / 43200).round} months"73: when 525960..1051919 then 'about 1 year'74: else "over \#{(distance_in_minutes / 525960).round} years"75: end76: enddistance_of_time_in_words_to_now(from_time, include_seconds = false)Alias for time_ago_in_words", "created_at"=>2007-05-19 22:18:11 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
在开发过程中,难免需要对时间对象进行一系列操作,比如统计新发的文章,统计在线会员等,如下是对时间对象的操作方法:distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)Reports the approximate distance in time between two Time or Date objects or integers as seconds. Set include_seconds to true if you want more detailed approximations when distance < 1 min, 29 secs Distances are reported base on the following table:0 <-> 29 secs # => less than a minute 30 secs <-> 1 min, 29 secs # => 1 minute 1 min, 30 secs <-> 44 mins, 29 secs # => [2..44] minutes 44 mins, 30 secs <-> 89 mins, 29 secs # => about 1 hour 89 mins, 29 secs <-> 23 hrs, 59 mins, 29 secs # => about [2..24] hours 23 hrs, 59 mins, 29 secs <-> 47 hrs, 59 mins, 29 secs # => 1 day 47 hrs, 59 mins, 29 secs <-> 29 days, 23 hrs, 59 mins, 29 secs # => [2..29] days 29 days, 23 hrs, 59 mins, 30 secs <-> 59 days, 23 hrs, 59 mins, 29 secs # => about 1 month 59 days, 23 hrs, 59 mins, 30 secs <-> 1 yr minus 31 secs # => [2..12] months 1 yr minus 30 secs <-> 2 yrs minus 31 secs # => about 1 year 2 yrs minus 30 secs <-> max time or date # => over [2..X] yearsWith include_seconds = true and the difference < 1 minute 29 seconds 0-4 secs # => less than 5 seconds 5-9 secs # => less than 10 seconds 10-19 secs # => less than 20 seconds 20-39 secs # => half a minute 40-59 secs # => less than a minute 60-89 secs # => 1 minuteExamples: from_time = Time.now distance_of_time_in_words(from_time, from_time + 50.minutes) # => about 1 hour distance_of_time_in_words(from_time, from_time + 15.seconds) # => less than a minute distance_of_time_in_words(from_time, from_time + 15.seconds, true) # => less than 20 secondsNote: Rails calculates one year as 365.25 days.[ show source ] # File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 4848: def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)49: from_time = from_time.to_time if from_time.respond_to?(:to_time)50: to_time = to_time.to_time if to_time.respond_to?(:to_time)51: distance_in_minutes = (((to_time - from_time).abs)/60).round52: distance_in_seconds = ((to_time - from_time).abs).round53: 54: case distance_in_minutes55: when 0..156: return (distance_in_minutes == 0) ? 'less than a minute' : '1 minute' unless include_seconds57: case distance_in_seconds58: when 0..4 then 'less than 5 seconds'59: when 5..9 then 'less than 10 seconds'60: when 10..19 then 'less than 20 seconds'61: when 20..39 then 'half a minute'62: when 40..59 then 'less than a minute'63: else '1 minute'64: end65: 66: when 2..44 then "\#{distance_in_minutes} minutes"67: when 45..89 then 'about 1 hour'68: when 90..1439 then "about \#{(distance_in_minutes.to_f / 60.0).round} hours"69: when 1440..2879 then '1 day'70: when 2880..43199 then "\#{(distance_in_minutes / 1440).round} days"71: when 43200..86399 then 'about 1 month'72: when 86400..525959 then "\#{(distance_in_minutes / 43200).round} months"73: when 525960..1051919 then 'about 1 year'74: else "over \#{(distance_in_minutes / 525960).round} years"75: end76: enddistance_of_time_in_words_to_now(from_time, include_seconds = false)Alias for time_ago_in_words
\n", "_id"=>558}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"find out the current url / uri in *.rhtml file", "body"=>"// find out the current url / uri in *.rhtml file// is quite simple with the request object<% page = request.request_uri %>page: <%= page %>// but then different urls mean the same page// (../admin = ../admin/ = ../admin/index = ..admin/index/)// and maybe the id is unwanted too (../admin/show/8)// so below is an alternative with control on which parameter is used<% page = "/" + request.path_parameters['controller'] + "/" + request.path_parameters['action'] %>page: <%= page %>", "created_at"=>2007-05-19 21:58:09 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
// find out the current url / uri in *.rhtml file// is quite simple with the request object<% page = request.request_uri %>page: <%= page %>// but then different urls mean the same page// (../admin = ../admin/ = ../admin/index = ..admin/index/)// and maybe the id is unwanted too (../admin/show/8)// so below is an alternative with control on which parameter is used<% page = "/" + request.path_parameters['controller'] + "/" + request.path_parameters['action'] %>page: <%= page %>
\n", "_id"=>559}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"image_tag with popup for alt attribute", "body"=>"Firefox doesn't display a popup for the alt attribute for images. While this is according to spec, it's slightly annoying to put the same text in both the alt and the title. Put the following in your ApplicationHelper to copy the alt to the title for every image. Please don't tell me how wrong this is. I don't care.module ApplicationHelper def image_tag(location, options) options[:title] ||= options[:alt] super(location, options) endend", "created_at"=>2007-05-19 21:56:35 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
Firefox doesn't display a popup for the alt attribute for images. While this is according to spec, it's slightly annoying to put the same text in both the alt and the title. Put the following in your ApplicationHelper to copy the alt to the title for every image. Please don't tell me how wrong this is. I don't care.module ApplicationHelper def image_tag(location, options) options[:title] ||= options[:alt] super(location, options) endend
\n", "_id"=>564}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Introduction to ActiveMessaging for Rails", "body"=>"ActiveMessaging是个感觉很不错的一个插件,通过它你可以发送、接收MO,总得来说很有诱惑力,还没有看完,下面这篇文章对这个东西做了详细的介绍,感兴趣的可以自己去看看,我就不翻译了,等我自己试用后,可以再些些心得什么的。*introduction*Rails has already planted its flag firmly in the ground of database driven web applications. *ActiveMessaging*is a Rails plugin framework that extends the borders of Rails territory by adding simplified messaging integration. With ActiveMessaging and Rails now you can loosely integrate with systems as disparate as mainframes sending MQ messages or J2EE webapps, offload processing long-running tasks, or create applications with event or message-driven architectures. As others have put it, ActiveMessaging is trying to do for messaging what ActiveRecord does for databases. This article will introduce you to ActiveMessaging and related technologies, and get you started using it in your Rails applications now.http://www.infoq.com/articles/intro-active-messaging-rails", "created_at"=>2007-05-30 21:12:54 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
ActiveMessaging是个感觉很不错的一个插件,通过它你可以发送、接收MO,总得来说很有诱惑力,还没有看完,下面这篇文章对这个东西做了详细的介绍,感兴趣的可以自己去看看,我就不翻译了,等我自己试用后,可以再些些心得什么的。*introduction*Rails has already planted its flag firmly in the ground of database driven web applications. *ActiveMessaging*is a Rails plugin framework that extends the borders of Rails territory by adding simplified messaging integration. With ActiveMessaging and Rails now you can loosely integrate with systems as disparate as mainframes sending MQ messages or J2EE webapps, offload processing long-running tasks, or create applications with event or message-driven architectures. As others have put it, ActiveMessaging is trying to do for messaging what ActiveRecord does for databases. This article will introduce you to ActiveMessaging and related technologies, and get you started using it in your Rails applications now.http://www.infoq.com/articles/intro-active-messaging-rails
\n", "_id"=>565}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"清除HTML标签中的危险字符", "body"=>"很多时候,我们需要处理用户输入,为了适合WEB2的特性,做为开发者我们也会设计很对个途径让用户参与进去,但是“盖茨”大叔说得很对:*凡是用户的输入都是有害的!*一点不假,有时候用户可能是无意的或者一些不怀好意的用户会输入一些我们并不想让他们输入的东西,以防止破坏页面结构或者造成其他的危害(比如SQL注射和XSS攻击),所以我们需要对用户的输入认真的检验和过滤。在页面上显示的时候,我们可以选择+h()+或者+sanitize+或者+strip_tags+等等rails提供的方法进行过滤,但是这些危险的字符还适度会存在数据库,或许有一天就会引爆了呢,所以呢,最好的办法是在存入数据库的时候就做一些过滤或转换,一下一点点代码段只是一个小例子,真实世界中需要过滤和清除的危险字符是很多的,大家注意主机收集和完善,也希望大家一起来实现这个功能,做一个通用的 helper方法。<code> def stripped_html(html) # this is a copynpaste of the routine in article.rb # so the one in article.rb can change w/o breaking this. self.html.gsub(/<[^>]*>/,'').to_url end</code>对于HTML标签的过滤和清除,你有什么好的方法么?欢迎分享!", "created_at"=>2007-05-29 21:24:57 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
很多时候,我们需要处理用户输入,为了适合WEB2的特性,做为开发者我们也会设计很对个途径让用户参与进去,但是“盖茨”大叔说得很对:凡是用户的输入都是有害的!*一点不假,有时候用户可能是无意的或者一些不怀好意的用户会输入一些我们并不想让他们输入的东西,以防止破坏页面结构或者造成其他的危害(比如SQL注射和XSS攻击),所以我们需要对用户的输入认真的检验和过滤。在页面上显示的时候,我们可以选择+h()+或者+sanitize+或者+strip_tags+等等rails提供的方法进行过滤,但是这些危险的字符还适度会存在数据库,或许有一天就会引爆了呢,所以呢,最好的办法是在存入数据库的时候就做一些过滤或转换,一下一点点代码段只是一个小例子,真实世界中需要过滤和清除的危险字符是很多的,大家注意主机收集和完善,也希望大家一起来实现这个功能,做一个通用的 helper方法。<code> def stripped_html(html) # this is a copynpaste of the routine in article.rb # so the one in article.rb can change w/o breaking this. self.html.gsub(/<[^>]>/,'').to_url end</code>对于HTML标签的过滤和清除,你有什么好的方法么?欢迎分享!
\n", "_id"=>567}])
+MONGODB iceylog_development['categories'].find({:_id=>9}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>9}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"日期上的迭代问题", "body"=>"给定一个时间点,希望得到其他时间点的解决方案如下,Ruby 的所有时间对象都可像数字一样用在值域中。Date和DateTime对象按天递增,而Time对象按秒递增:*例子*require 'date'(Date.new(1976, 7, 2)..Date.new(1976, 7, 4)).each { |x| puts x }1976-07-021976-07-031976-07-04span = DateTime.new(1776, 7, 2, 1, 30, 15)..DateTime.new(1776, 7, 4, 7, 0,0)span.each { |x| puts x } 1776-07-02T01:30:15Z 1776-07-03T01:30:15Z 1776-07-04T01:30:15Z(Time.at(100)..Time.at(102)).each { |x| puts x } Wed Dec 31 19:01:40 EST 1969 Wed Dec 31 19:01:41 EST 1969 Wed Dec 31 19:01:42 EST 1969Ruby 的Date类定义了*step*和*upto*两种方便的由数字使用的迭代器:the_first = Date.new(2004, 1, 1)the_fifth = Date.new(2004, 1, 5)the_first.upto(the_fifth) { |x| puts x } 2004-01-01 2004-01-02 2004-01-03 2004-01-04 2004-01-05*讨论*Ruby的日期对象在内部被存储为数字,并且一定范围的这种对象可被视为一定范围的数字。对于Date和DateTime对象而言,内部表示是儒略历日期:每次在一定范围的这种对象上累加一天。对于Time对象而言,内部表示是自Unix 纪元以来的秒数:每次在一定范围的Time对象上累加一秒。*Time*没有定义step和upto方法,但添加它们也很简单:class Timebq. def step(other_time, increment) raise ArgumentError, "step can't be 0" if increment == 0 increasing = self < other_time if (increasing && increment < 0) || (!increasing && increment > 0) yield self return end d = self begin yield d d += increment end while (increasing ? d <= other_time : d >= other_time) enddef upto(other_time) step(other_time, 1) { |x| yield x } endendthe_first = Time.local(2004, 1, 1)the_second = Time.local(2004, 1, 2)the_first.step(the_second, 60 * 60 * 6) { |x| puts x } Thu Jan 01 00:00:00 EST 2004 Thu Jan 01 06:00:00 EST 2004 Thu Jan 01 12:00:00 EST 2004 Thu Jan 01 18:00:00 EST 2004 Fri Jan 02 00:00:00 EST 2004the_first.upto(the_first) { |x| puts x } Thu Jan 01 00:00:00 EST 2004", "created_at"=>2007-05-27 05:09:33 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
给定一个时间点,希望得到其他时间点的解决方案如下,Ruby 的所有时间对象都可像数字一样用在值域中。Date和DateTime对象按天递增,而Time对象按秒递增:*例子*require 'date'(Date.new(1976, 7, 2)..Date.new(1976, 7, 4)).each { |x| puts x }1976-07-021976-07-031976-07-04span = DateTime.new(1776, 7, 2, 1, 30, 15)..DateTime.new(1776, 7, 4, 7, 0,0)span.each { |x| puts x } 1776-07-02T01:30:15Z 1776-07-03T01:30:15Z 1776-07-04T01:30:15Z(Time.at(100)..Time.at(102)).each { |x| puts x } Wed Dec 31 19:01:40 EST 1969 Wed Dec 31 19:01:41 EST 1969 Wed Dec 31 19:01:42 EST 1969Ruby 的Date类定义了*step*和*upto*两种方便的由数字使用的迭代器:the_first = Date.new(2004, 1, 1)the_fifth = Date.new(2004, 1, 5)the_first.upto(the_fifth) { |x| puts x } 2004-01-01 2004-01-02 2004-01-03 2004-01-04 2004-01-05*讨论*Ruby的日期对象在内部被存储为数字,并且一定范围的这种对象可被视为一定范围的数字。对于Date和DateTime对象而言,内部表示是儒略历日期:每次在一定范围的这种对象上累加一天。对于Time对象而言,内部表示是自Unix 纪元以来的秒数:每次在一定范围的Time对象上累加一秒。*Time*没有定义step和upto方法,但添加它们也很简单:class Timebq. def step(other_time, increment) raise ArgumentError, "step can't be 0" if increment == 0 increasing = self < other_time if (increasing && increment < 0) || (!increasing && increment > 0) yield self return end d = self begin yield d d += increment end while (increasing ? d <= other_time : d >= other_time) enddef upto(other_time) step(other_time, 1) { |x| yield x } endendthe_first = Time.local(2004, 1, 1)the_second = Time.local(2004, 1, 2)the_first.step(the_second, 60 * 60 * 6) { |x| puts x } Thu Jan 01 00:00:00 EST 2004 Thu Jan 01 06:00:00 EST 2004 Thu Jan 01 12:00:00 EST 2004 Thu Jan 01 18:00:00 EST 2004 Fri Jan 02 00:00:00 EST 2004the_first.upto(the_first) { |x| puts x } Thu Jan 01 00:00:00 EST 2004
\n", "_id"=>568}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Textile Editor Helper", "body"=>"*Textile*是一种语言标记格式,目前在ROR领域用的相当多,本着简洁好用的原则,这套规则就像PHP领域内的BBCODE一样流行,但是一直一来,都是靠手工去写这些标识符号,很不方便,也曾萌发了写一套可视化的东西来,可惜一直没有时间和精力,今天看到slate blog的blog上有关于这个的东西,感觉就是自己想实现的那个,看了下视频(http://www.youtube.com/watch?v=wQYedmbsJf4)和DEMO(http://slateinfo.blogs.wvu.edu/plugins/textile_editor_helper/demo),果然是的,试用了下,很方便,效果很好,再各种浏览器下都表现不错,推荐给大家。可以先看下它的功能:安装也挺方便的:+script/plugin install http://svn.webtest.wvu.edu/repos/rails/plugins/textile_editor_helper/+使用:bq. # 1. run rake textile_editor_helper:install 2. for the textarea(s) that you want to add the TEH toolbar to replace the text area tag(s) with: <%= textile_editor 'object', 'field' -%> just like writing a text area tag, same options 3. at the end of your form put in the following code: <%= textile_editor_initialize -%> Important! 4. save your view and check it out*注意*:To use Textile, you must install the RedCloth gem first.", "created_at"=>2007-05-24 21:08:58 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
*Textile*是一种语言标记格式,目前在ROR领域用的相当多,本着简洁好用的原则,这套规则就像PHP领域内的BBCODE一样流行,但是一直一来,都是靠手工去写这些标识符号,很不方便,也曾萌发了写一套可视化的东西来,可惜一直没有时间和精力,今天看到slate blog的blog上有关于这个的东西,感觉就是自己想实现的那个,看了下视频(http://www.youtube.com/watch?v=wQYedmbsJf4)和DEMO(http://slateinfo.blogs.wvu.edu/plugins/textile_editor_helper/demo),果然是的,试用了下,很方便,效果很好,再各种浏览器下都表现不错,推荐给大家。可以先看下它的功能:安装也挺方便的:+script/plugin install http://svn.webtest.wvu.edu/repos/rails/plugins/textile_editor_helper/+bq使用:. # 1. run rake textile_editor_helper:install 2. for the textarea(s) that you want to add the TEH toolbar to replace the text area tag(s) with: <%= textile_editor 'object', 'field' -%> just like writing a text area tag, same options 3. at the end of your form put in the following code: <%= textile_editor_initialize -%> Important! 4. save your view and check it out*注意*:To use Textile, you must install the RedCloth gem first.
\n", "_id"=>569}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>7, "title"=>"安装mongrel服务器", "body"=>"需要安装这个的很简单,下面就是我在自己机子上安装的时候的过程演示,比起Apache等的配置,这个东西好多了。D:\\>gem install mongrelSelect which gem to install for your platform (i386-mswin32) 1. mongrel 1.0.1 (mswin32) 2. mongrel 1.0.1 (ruby) 3. mongrel 1.0 (mswin32) 4. mongrel 1.0 (ruby) 5. Skip this gem 6. Cancel installation> 1Install required dependency gem_plugin? [Yn] yInstall required dependency cgi_multipart_eof_fix? [Yn] ySuccessfully installed mongrel-1.0.1-mswin32Successfully installed gem_plugin-0.2.2Successfully installed cgi_multipart_eof_fix-2.1Installing ri documentation for mongrel-1.0.1-mswin32...Installing ri documentation for gem_plugin-0.2.2...Installing ri documentation for cgi_multipart_eof_fix-2.1...Installing RDoc documentation for mongrel-1.0.1-mswin32...Installing RDoc documentation for gem_plugin-0.2.2...Installing RDoc documentation for cgi_multipart_eof_fix-2.1...D:\\>", "created_at"=>2007-05-23 22:27:14 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
需要安装这个的很简单,下面就是我在自己机子上安装的时候的过程演示,比起Apache等的配置,这个东西好多了。D:>gem install mongrelSelect which gem to install for your platform (i386-mswin32) 1. mongrel 1.0.1 (mswin32) 2. mongrel 1.0.1 (ruby) 3. mongrel 1.0 (mswin32) 4. mongrel 1.0 (ruby) 5. Skip this gem 6. Cancel installation> 1Install required dependency gem_plugin? [Yn] yInstall required dependency cgi_multipart_eof_fix? [Yn] ySuccessfully installed mongrel-1.0.1-mswin32Successfully installed gem_plugin-0.2.2Successfully installed cgi_multipart_eof_fix-2.1Installing ri documentation for mongrel-1.0.1-mswin32...Installing ri documentation for gem_plugin-0.2.2...Installing ri documentation for cgi_multipart_eof_fix-2.1...Installing RDoc documentation for mongrel-1.0.1-mswin32...Installing RDoc documentation for gem_plugin-0.2.2...Installing RDoc documentation for cgi_multipart_eof_fix-2.1...D:>
有的时候,虚拟主机提供商并不能按照每个用户的需求安装全部的gem,这个时候,我们就需要自己动手了,如下是我在一家虚拟主机上的安装builder的过程,主要就是先FTP把gem包放上去,然后本地安装的时候使用一个--install-dir来指定安装到的目录。<code>[1ster@1ster.cn@bee-00 gemdir]$ gem install builder-2.1.1.gem --install-dir /var///1ster.cn/gemdirSuccessfully installed builder, version 2.1.1Installing ri documentation for builder-2.1.1...Installing RDoc documentation for builder-2.1.1...</code>
我们使用创建表的时候,是不想想初始化一些数据呢,比如一个默认的分类什么的,可以使用migration按照下面这个来实现: <code> def self.up create_table :words do |t| t.column :eng, :string t.column :pl, :string end Word.new(:eng=>'yes', :pl=>'tak').save Word.new(:eng=>'no', :pl=>'nie').save Word.new(:eng=>'everything', :pl=>'wszystko').save end def self.down drop_table :words end</code>
\n", "_id"=>572}])
+MONGODB iceylog_development['categories'].find({:_id=>3}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>3}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"15步创建一个测试驱动(TDD)的Rails应用~", "body"=>"题外话:这个文章展示了一种测试驱动(TDD)的开发模式,针对Rails的基本步骤,原文很清楚,我就随便翻译下关键的部分,见下:原文地址:http://andrzejonsoftware.blogspot.com/2007/05/15-tdd-steps-to-create-rails.html15 TDD steps to create a Rails applicationIntroductionSeveral times recently, I have been asked how to develop a Rails application using the Test Driven Development approach. I'm not an expert here, but I've put together some notes on how to start working on a Rails application whilst being test-driven all the time.As an example I will use a word-learning web application. The simplest use case is to display a random word object (with its polish translation) from the database.Every time we refresh we want to see a different word.1. Create a new Rails applicationsrails my_appcd my_appRun tests with 'rake test'. It fails due to missing database configuration.2. Set up the databases - config/database.ymlThe code below assumes sqlite3 databases. development: adapter: sqlite3 database: db/my_app_development.sqlite test: adapter: sqlite3 database: db/my_app_test.sqlite'rake test' now runs fine.3. Create a Word class with a corresponding unit testscript/generate model Word4. Write a unit test for the Word class. Edit the test/unit/word_test.rb. def test_word_is_english_and_polish word = Word.new :eng=>'never', :pl=>'nigdy' assert_equal 'never', word.eng assert_equal 'nigdy', word.pl end'rake test' now fails due to missing words table.5. Edit db/migrate/001_create_words.rbWe are using a migration here in order to create a table. It's a recommended way of dealing with database changes. def self.up create_table :words do |t| t.column :eng, :string t.column :pl, :string end Word.new(:eng=>'yes', :pl=>'tak').save Word.new(:eng=>'no', :pl=>'nie').save Word.new(:eng=>'everything', :pl=>'wszystko').save end def self.down drop_table :words endThe sample words that we are adding use Word.new .. lines, will be added to the development database. It's important to distinguish the 'test' and 'development' database. The first one is only used during tests. The latter is used by default when you start the application.Apply the migration with 'rake db:migrate'.'rake test' now succeeds with the following:'1 tests, 2 assertions, 0 failures, 0 errors'6. Fixtures and test for word.random. Edit word_test again.It's not easy to test a method which behaves randomly. Let's assume that it's enough to test that if we have only two words in our database then one of them should be called at least once per 10 calls.fixtures :wordsdef test_random results = [] 10.times {results << Word.random.eng} assert results.include?("yes")endNote the 'fixtures :words' line. Edit the 'words.yml' file.yes: id: 1 pl: 'tak' eng: 'yes'no: id: 2 pl: 'nie' eng: 'no'This will be loaded to the test database before every run of tests.7. Implement the Word.random method def self.random all = Word.find :all all[rand(all.size)] endWarning: The code above could be slow for many words in a database (we retrieve all words only for selecting a random element). It's good enough for our needs.8. Generate the Words controller with a 'learn' actionscript/generate controller Words learn9. Write a test for the learn methodJust as there is a one-to-one ratio between unit tests and models, so there is between functional tests and controllers. The Controller's responsibility is to retrieve objects from the Model layer and pass them to the View. Let's test the View part first. We use the 'assigns' collection which contains all the objects passed to the View.def test_learn_passes_a_random_word get 'learn' assert_kind_of Word, assigns('word')end10. Make the Test Passdef learn @word = Word.newend11. Write more tests in the words_controller_testHow can we test that controller uses the Word.random method? We don't want to duplicate the tests for the Word.random method.Mocks to the rescue! We will only test that the controller calls the Word.random method. The returned value will be faked with a prepared word.Let's install the mocha framework:gem install mochaNow we can use 'expects' and 'returns' methods.'expects' is used for setting an expectation on an object or a class. In this case we expect that the 'random' method will be called. We also set a return value by using 'returns' method. Setting a return value means faking (stubbing) the real method. The real Word.random won't be called. If an expectation isn't met the test fails.require 'mocha'def test_learn_passes_a_random_word random_word = Word.new Word.expects(:random).returns(random_word) get 'learn' assert_equal random_word, assigns('word')end'rake test' now fails. The Word.method wasn't called.12. Rewrite the implementationdef learn @word = Word.randomend'rake test' now passes.13. Test that a word is displayed:Extend the existing test with assert_tag calls.def test_learn_passes_a_random_word random_word = Word.new(:pl=>'czesc', :eng=>'hello') Word.expects(:random).returns(random_word) get 'learn' assert_equal random_word, assigns('word') assert_tag :tag=>'div', :child => /czesc/ assert_tag :tag=>'div', :child => /hello/end14. Implement the view - learn.rhtml <div> <%= word.eng %> <%= word.pl %> </div>15. Manual testingscript/serverGo to 'http://localhost:3000/words/learn'.Refresh several times.If you want to read more about testing in Rails go to the Guide To Testing The Rails.", "created_at"=>2007-05-22 21:30:02 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
题外话:这个文章展示了一种测试驱动(TDD)的开发模式,针对Rails的基本步骤,原文很清楚,我就随便翻译下关键的部分,见下:原文地址:http://andrzejonsoftware.blogspot.com/2007/05/15-tdd-steps-to-create-rails.html15 TDD steps to create a Rails applicationIntroductionSeveral times recently, I have been asked how to develop a Rails application using the Test Driven Development approach. I'm not an expert here, but I've put together some notes on how to start working on a Rails application whilst being test-driven all the time.As an example I will use a word-learning web application. The simplest use case is to display a random word object (with its polish translation) from the database.Every time we refresh we want to see a different word.1. Create a new Rails applicationsrails my_appcd my_appRun tests with 'rake test'. It fails due to missing database configuration.2. Set up the databases - config/database.ymlThe code below assumes sqlite3 databases. development: adapter: sqlite3 database: db/my_app_development.sqlite test: adapter: sqlite3 database: db/my_app_test.sqlite'rake test' now runs fine.3. Create a Word class with a corresponding unit testscript/generate model Word4. Write a unit test for the Word class. Edit the test/unit/word_test.rb. def test_word_is_english_and_polish word = Word.new :eng=>'never', :pl=>'nigdy' assert_equal 'never', word.eng assert_equal 'nigdy', word.pl end'rake test' now fails due to missing words table.5. Edit db/migrate/001_create_words.rbWe are using a migration here in order to create a table. It's a recommended way of dealing with database changes. def self.up create_table :words do |t| t.column :eng, :string t.column :pl, :string end Word.new(:eng=>'yes', :pl=>'tak').save Word.new(:eng=>'no', :pl=>'nie').save Word.new(:eng=>'everything', :pl=>'wszystko').save end def self.down drop_table :words endThe sample words that we are adding use Word.new .. lines, will be added to the development database. It's important to distinguish the 'test' and 'development' database. The first one is only used during tests. The latter is used by default when you start the application.Apply the migration with 'rake db:migrate'.'rake test' now succeeds with the following:'1 tests, 2 assertions, 0 failures, 0 errors'6. Fixtures and test for word.random. Edit word_test again.It's not easy to test a method which behaves randomly. Let's assume that it's enough to test that if we have only two words in our database then one of them should be called at least once per 10 calls.fixtures :wordsdef test_random results = [] 10.times {results << Word.random.eng} assert results.include?("yes")endNote the 'fixtures :words' line. Edit the 'words.yml' file.yes: id: 1 pl: 'tak' eng: 'yes'no: id: 2 pl: 'nie' eng: 'no'This will be loaded to the test database before every run of tests.7. Implement the Word.random method def self.random all = Word.find :all all[rand(all.size)] endWarning: The code above could be slow for many words in a database (we retrieve all words only for selecting a random element). It's good enough for our needs.8. Generate the Words controller with a 'learn' actionscript/generate controller Words learn9. Write a test for the learn methodJust as there is a one-to-one ratio between unit tests and models, so there is between functional tests and controllers. The Controller's responsibility is to retrieve objects from the Model layer and pass them to the View. Let's test the View part first. We use the 'assigns' collection which contains all the objects passed to the View.def test_learn_passes_a_random_word get 'learn' assert_kind_of Word, assigns('word')end10. Make the Test Passdef learn @word = Word.newend11. Write more tests in the words_controller_testHow can we test that controller uses the Word.random method? We don't want to duplicate the tests for the Word.random method.Mocks to the rescue! We will only test that the controller calls the Word.random method. The returned value will be faked with a prepared word.Let's install the mocha framework:gem install mochaNow we can use 'expects' and 'returns' methods.'expects' is used for setting an expectation on an object or a class. In this case we expect that the 'random' method will be called. We also set a return value by using 'returns' method. Setting a return value means faking (stubbing) the real method. The real Word.random won't be called. If an expectation isn't met the test fails.require 'mocha'def test_learn_passes_a_random_word random_word = Word.new Word.expects(:random).returns(random_word) get 'learn' assert_equal random_word, assigns('word')end'rake test' now fails. The Word.method wasn't called.12. Rewrite the implementationdef learn @word = Word.randomend'rake test' now passes.13. Test that a word is displayed:Extend the existing test with assert_tag calls.def test_learn_passes_a_random_word random_word = Word.new(:pl=>'czesc', :eng=>'hello') Word.expects(:random).returns(random_word) get 'learn' assert_equal random_word, assigns('word') assert_tag :tag=>'div', :child => /czesc/ assert_tag :tag=>'div', :child => /hello/end14. Implement the view - learn.rhtml <div> <%= word.eng %> <%= word.pl %> </div>15. Manual testingscript/serverGo to 'http://localhost:3000/words/learn'.Refresh several times.If you want to read more about testing in Rails go to the Guide To Testing The Rails.
\n", "_id"=>576}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Get XML or YAML output of your data quickly", "body"=>"It's not necessary to create a Builder .rxml template to export data as XML. ActiveRecord has a to_xml method that will output the object or result set in XML format. It works with simple objects, to complete tables with includes. Examples:User.find(:all).to_xmlPost.find(:all, :include => [:comments]).to_xmlYAML is also supported, by using to_yaml instead.", "created_at"=>2007-05-21 07:27:24 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
It's not necessary to create a Builder .rxml template to export data as XML. ActiveRecord has a to_xml method that will output the object or result set in XML format. It works with simple objects, to complete tables with includes. Examples:User.find(:all).to_xmlPost.find(:all, :include => [:comments]).to_xmlYAML is also supported, by using to_yaml instead.
什么是Trackback呢?简单说来,Trackback是网站与网站之间互相通告的一种方法。它能让甲对乙说:“这篇文章可能是你感兴趣的”,要实现这一动作,甲向乙发送一个 Trackback Ping(引用通告)即可。在这种情况下,一个ping就是一条从一个web服务器发送到另一个服务器的短消息(a small message)。Trackback Ping是由Moveable Type发明的规范,他们说Trackback是:<blockquote>"a framework for peer-to-peer communication and notifications between web sites"。</blockquote>这里是他们的Trackback技术规范文档:http://www.movabletype.org/docs/mttrackback.html举个例子来说明一下。比如B在A的Blog中看了一篇我感兴趣的文章,对这篇文章B自己有一些看法,如果按照传统BBS的做法,B需要在A这篇文章下发表自己的评论,但这样做的话B的文字只能存在于A的网站上,B无法再维护自己的这篇评论。另一个情况是B在自己的Blog中也在写一篇相类似的文章,B希望A也能来看一看B的这篇,传统BBS的习惯还是得到A的文章下发一篇回复,把B的URL贴过去。但有了Trackback Ping,我们的Blog不再需要这样做。Blog 跟BBS有点重要的不同,Blog是一种个人创作,用Blog来发表自己的东西,保存自己的东西,即使是对他人Blog文章的评论也要在自己的Blog中永久保留下来。通过Trackbak,我就可以在自己的Blog中发表文章,同时把自己这篇文章的URL地址Ping到A的那篇文章上去。这样,所有阅读A文章的人也能通过Trackback顺藤摸瓜地来我的Blog看我的文章。所以,当我们的Blog有了Trackback Ping功能,那么谁都可以通过Trackback Ping来发表意见和评论了。这样,多家Blog网站就通过相关话题而联接起来。各种评论在Internet上相互连接而织成一张大网。因此,可以说, Trackback创造出了Blog与BBS、Diary完全不同的文化,Blog的世界通过Trackback而变成真正的无限互连。作为Blogger,让我们习惯于这样讨论问题和做评论吧:把内容写在自己的Blog里面,Trackback Ping到别人的Blog。这个概念是论坛模式里从来没有的,称为Remote Commenting。如何在Blog中实现Trackback?在有Trackback功能的Blog系统中,每篇Blog文章都有两个URL,一个是要访问这篇文章所使用的URL,另一个就是Trackback Ping URL(引用通告地址),它是用来接受来自其他Blog网站Trackback Ping的程序。当我发表文章的时候,想要通知鱼头的话,只需要把鱼头那篇文章的Trackback Ping URL贴到我这边文章中来,我提交文章时,系统就会按照这个URL发送一个Ping给A的那篇文章。而鱼头则将在自己的文章下看到类似这样的一个引用通告:标题: 1ster的文章来自: 1ster的Blog摘要: 1ster的文章内容摘要...地址: http://1ster的文章地址这个Trackback Ping是通过标准的HTTP协议从我的Blog发送到鱼头的Blog的,我的Blog发送一个POST格式的HTTP请求到A那篇文章的 Trackback Ping URL。这个请求的content type是application/x-www-form-URLencoded,它大概是这个样子的:POST http://A文章的TrackbackPingURLContent-Type: application/x-www-form-URLencodedtitle=1ster的文章&url=http://1ster的文章地址&excerpt=1ster的文章摘要&blog_name=1ster的Blog早期版本的Trackback规范中,Ping是GET方式的HTTP请求,现在不再支持GET方式,只能用POST方式。参数包括: * title - 文章的标题 * excerpt - 文章的摘要。在Movable Type系统中,如果摘录信息超过255个字符将会被截断为252个字符,并在后面增加...三个字符 * url - 文章的永久连接。象其它永久连接一样,这个连接应可能准确地在页面中定位文章的入口,因有疑问时这个链接会用到 * blog_name - 发表文章的blog的名称在上述的参数中只有url是必须的。如果title没有提供,url的值将被用作标题。当我的Blog发出这个Trackback Ping后,将接收一个简单的XML格式应答,如果Ping成功,那么应答的格式如下:<blockquote><?xml version="1.0" encoding="iso-8859-1"?><response><error>0</error></response></blockquote>而失败应答的格式为:<blockquote><?xml version="1.0" encoding="iso-8859-1"?><response><error>1</error><message>The error message</message></response></blockquote>
\n", "_id"=>579}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"witter发布Gem包提供witter主要功能", "body"=>"witter越来越火了,这个提供IM服务的应用,越来越受到大家的关注,越来越多的人加入其中,昨天台湾的一个朋友还说对witter的这个IM功能很感兴趣,想了解是怎么实现的,呵呵~witter通过网络或者SMS(短消息)使得你和自己的朋友取得及时沟通。你有没有考虑过给自己的WebApp加上这样的功能呢,现在借助witter发布的Gem包,可以很方便的实现这个功能了,更多说明请到http://www.rubyinside.com/twitter-gem-twitterize-your-ruby-application-498.html查看,我这里稍微说下用法,如下:# to post an update to twitter$ twitter post "posting from the twitter gem"# to see you and your friends timeline$ twitter timeline命令行接口很简单,支持YAML配置,也支持Ruby的API:twit.update('me got dizzy this time')# Show your friends' statustwit.timeline(:friends).each do |s| puts s.text, s.user.nameendUse RubyGems as usual to install it:gem install twitter --include-dependenciesps:One note, the gem uses hpricot to parse the xml and there is an annoying bug that reared it's head in the 0.5+ versions (it doesn't like xml elements named text). That said, be sure to sudo gem install hpricot --source http://code.whytheluckystiff.net -v 0.4.86 and uninstall any hpricot versions 0.5+.", "created_at"=>2007-05-20 21:17:49 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
witter越来越火了,这个提供IM服务的应用,越来越受到大家的关注,越来越多的人加入其中,昨天台湾的一个朋友还说对witter的这个IM功能很感兴趣,想了解是怎么实现的,呵呵~witter通过网络或者SMS(短消息)使得你和自己的朋友取得及时沟通。你有没有考虑过给自己的WebApp加上这样的功能呢,现在借助witter发布的Gem包,可以很方便的实现这个功能了,更多说明请到http://www.rubyinside.com/twitter-gem-twitterize-your-ruby-application-498.html#查看,我这里稍微说下用法,如下: to post an update to twitter$ twitter post "posting from the twitter gem"# to see you and your friends timeline$ twitter timeline命令行接口很简单,支持YAML配置,也支持Ruby的API:twit.update('me got dizzy this time')# Show your friends' statustwit.timeline(:friends).each do |s| puts s.text, s.user.nameendUse RubyGems as usual to install it:gem install twitter --include-dependenciesps:One note, the gem uses hpricot to parse the xml and there is an annoying bug that reared it's head in the 0.5+ versions (it doesn't like xml elements named text). That said, be sure to sudo gem install hpricot --source http://code.whytheluckystiff.net -v 0.4.86 and uninstall any hpricot versions 0.5+.
\n", "_id"=>598}])
+MONGODB iceylog_development['categories'].find({:_id=>3}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>3}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"在windows上安装RMagick", "body"=>"看到网上很多人说再WIN下安装RMagick的方法都是这样的,gem install ImageMagick-6.3.0-7-Q8-windows-dll.exe,这样我感觉谁有问题的,至少我这样安装的时候是有错误的,如:D:\\gem\\RMagick-1.14.1_IM-6.3.0-7-Q8>gem install ImageMagick-6.3.0-7-Q8-windows-dll.exeERROR: Error installing gem ImageMagick-6.3.0-7-Q8-windows-dll.exe[.gem]: string contains null byte所以正确的应该是用gem包来安装,如下:D:\\gem\\RMagick-1.14.1_IM-6.3.0-7-Q8>gem install rmagick-1.14.1-win32.gemSuccessfully installed rmagick, version 1.14.1看看是不是安装上了:D:\\gem\\RMagick-1.14.1_IM-6.3.0-7-Q8>gem listrmagick (1.14.1) RMagick is an interface between the Ruby programming language and the ImageMagick and GraphicsMagick image processing libraries.", "created_at"=>2007-06-04 22:06:54 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
看到网上很多人说再WIN下安装RMagick的方法都是这样的,gem install ImageMagick-6.3.0-7-Q8-windows-dll.exe,这样我感觉谁有问题的,至少我这样安装的时候是有错误的,如:D:\\gem\\RMagick-1.14.1_IM-6.3.0-7-Q8>gem install ImageMagick-6.3.0-7-Q8-windows-dll.exeERROR: Error installing gem ImageMagick-6.3.0-7-Q8-windows-dll.exe[.gem]: string contains null byte所以正确的应该是用gem包来安装,如下:D:\\gem\\RMagick-1.14.1_IM-6.3.0-7-Q8>gem install rmagick-1.14.1-win32.gemSuccessfully installed rmagick, version 1.14.1看看是不是安装上了:D:\\gem\\RMagick-1.14.1_IM-6.3.0-7-Q8>gem listrmagick (1.14.1) RMagick is an interface between the Ruby programming language and the ImageMagick and GraphicsMagick image processing libraries.
\n", "_id"=>599}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>6, "title"=>"mini_magick 1.2.2 Released", "body"=>"*mini_magick* version 1.2.2 has been released!RMagick是大家用的最多的图片处理类库,但是它台复杂了,消耗太多的内存,比如下面这段最简单的代码都会吃掉100M的内存:<code>Magick::read("image.jpg") do |f|f.write("manipulated.jpg")end</code>*mini_magick*是把ImageMagick进行的一次封装,使得可以很方便的使用MiniMagick的commandline,可以在http://www.imagemagick.org/script/mogrify.php 查看可耕多的ImageMagick has 信息。*mini_magick*1.2.2包含如下更新:# 1.) all image commands return the image object (The output of the last command is saved in @output)# 2.) identify doesn't trip over strangley named files# 3.) TempFile uses file extention now (Thanks http://marsorange.com/archives/of-mogrify-ruby-tempfile-dynamic-class-definitions)# 4.) identify commands escape output path correctly", "created_at"=>2007-06-03 00:01:12 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
mini_magick version 1.2.2 has been released!RMagick是大家用的最多的图片处理类库,但是它台复杂了,消耗太多的内存,比如下面这段最简单的代码都会吃掉100M的内存:<code>Magick::read("image.jpg") do |f|f.write("manipulated.jpg")end</code>*mini_magick*是把ImageMagick进行的一次封装,使得可以很方便的使用MiniMagick的commandline,可以在http://www.imagemagick.org/script/mogrify.php 查看可耕多的ImageMagick has 信息。*mini_magick*1.2.2包含如下更新:# 1.) all image commands return the image object (The output of the last command is saved in @output)# 2.) identify doesn't trip over strangley named files# 3.) TempFile uses file extention now (Thanks http://marsorange.com/archives/of-mogrify-ruby-tempfile-dynamic-class-definitions#) 4.) identify commands escape output path correctly
\n", "_id"=>600}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"days_in_month函数介绍", "body"=>"days_in_month这个函数返回给定的年月的月的天数,对于写阴历什么的很有帮助,下面是英文的介绍。Descriptiondays_in_month(month, year=nil)Return the number of days in the given month. If a year is given, February will return the correct number of days for leap years. Otherwise, this method will always report February as having 28 days.<code> 1. >> Time.days_in_month(4) => 30 2. >> Time.days_in_month(4,2006) => 30 3. >> Time.days_in_month(2,2006) => 28 4. >> Time.days_in_month(2) => 28 5. >> Time.days_in_month(2,2008) => 29</code>", "created_at"=>2007-06-02 00:29:03 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
days_in_month这个函数返回给定的年月的月的天数,对于写阴历什么的很有帮助,下面是英文的介绍。Descriptiondays_in_month(month, year=nil)Return the number of days in the given month. If a year is given, February will return the correct number of days for leap years. Otherwise, this method will always report February as having 28 days.<code> 1. >> Time.days_in_month(4) => 30 2. >> Time.days_in_month(4,2006) => 30 3. >> Time.days_in_month(2,2006) => 28 4. >> Time.days_in_month(2) => 28 5. >> Time.days_in_month(2,2008) => 29</code>
由于一个系统需要对外提供数据,自然使用widget来实现,JS中自然是对json支持最好,也是就可以吧数据组装成json格式的,再用JS解析显示,于是就有了这个需求:在rails中生成JSON,尽管rails1.1版本就增加了对json的支持,但要想更加灵活,自然使用插件来实现了,而Jsonifier 正是我们需要的。 \n看看Jsonifier的自我介绍: \nJsonifier is a Rails plugin that adds options to the ActiveRecord#to_json method similar to ActiveRecord#to_xml. It's time to treat the JSON encoding of AR objects with more respect ;)The :only, :except, :methods, and :include options are supported. Check out the examples below. \n \n*安装:* \n很简单,script/plugin install svn://svn.codefront.net/jsonifier/trunk \n \n*使用:*
\n", "_id"=>607}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"在rails中实现跟踪记录每个用户的最近十条记录", "body"=>"有的时候,你可能想显示给每个用户他最近浏览的页面,这个时候的一个很自然的想法就是使用数据库来存放,但是这样如果你的用户足够的多,而且页面的读取数据库又很频繁的话,就会对性能造成很大的影响,换个思路,我们可以在session里面存取,示范代码如下:<code>class ApplicationController < ActionController::Base\tbefore_filter :add_to_history\tbefore_filter :page_title\t###def add_to_history session[:history] ||= []## if File.exists?("\#{RAILS_ROOT}/app/views/\#{self.controller_name}/\#{self.action_name}.rhtml") && session[:history].empty? || session[:history].first['uri'] != @request.request_uri session[:history].unshift({ 'uri' => @request.request_uri, 'name' => page_title }) session[:history].pop while session[:history].length > 11 endend######## This bit came from Peter Cooper's snippets source and was moved into the application controller:###\tdef page_title\t\tcase self.controller_name\t\t\twhen 'tag' \t\t\t\ttitle = "Tags » " + @params[:tags].join(" > ")\t\t\twhen 'user'\t\t\t\ttitle = "Users » \#{@params[:user]}"\t \t\t\twhen 'features'\t\t\t\t\tcase self.action_name\t\t\t\t\t\twhen 'show' then title = "Feature » \#{Feature.find(@params[:id]).title}"\t\t\t\t\t\telse title = APP_CONFIG["default_title"]\t\t\t\t\tend\t\t\telse \t\t\t\ttitle = APP_CONFIG["default_title"] + self.controller_name + ":" + self.action_name\t\tend\tend\thelper_method :page_title###...end</code>然后在页面上就可以这样显示了:<code><h4>User History</h4><% for cur in session[:history][0..9] -%> <p><a href="<%= cur["url"] %>"><%= cur["name"] %></a></p><% end -%></code>", "created_at"=>2007-07-03 16:47:31 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
有的时候,你可能想显示给每个用户他最近浏览的页面,这个时候的一个很自然的想法就是使用数据库来存放,但是这样如果你的用户足够的多,而且页面的读取数据库又很频繁的话,就会对性能造成很大的影响,换个思路,我们可以在session里面存取,示范代码如下:<code>class ApplicationController < ActionController::Base before_filter :add_to_history before_filter :page_title ###def add_to_history session[:history] ||= []## if File.exists?("\#{RAILS_ROOT}/app/views/\#{self.controller_name}/\#{self.action_name}.rhtml") && session[:history].empty? || session[:history].first['uri'] != @request.request_uri session[:history].unshift({ 'uri' => @request.request_uri, 'name' => page_title }) session[:history].pop while session[:history].length > 11 endend######## This bit came from Peter Cooper's snippets source and was moved into the application controller:### def page_title case self.controller_name when 'tag' title = "Tags » " + @params[:tags].join(" > ") when 'user' title = "Users » \#{@params[:user]}" when 'features' case self.action_name when 'show' then title = "Feature » \#{Feature.find(@params[:id]).title}" else title = APP_CONFIG["default_title"] end else title = APP_CONFIG["default_title"] + self.controller_name + ":" + self.action_name end end helper_method :page_title###...end</code>然后在页面上就可以这样显示了:<code><h4>User History</h4><% for cur in session[:history][0..9] -%> <p><a href="<%= cur["url"] %>"><%= cur["name"] %></a></p><% end -%></code>
returnfalse, "You made the most idiot error in history. Way to go…"
\n
elsereturntrue, "You made no error, you are still an idiot"
\n
end
\n
end
\n
\n
success, msg = a_method_to_insult_innocent_people
\n
do_something_with_success(success)
\n
destroy_hateful_words!(msg) \n
\n\n
\n
但是这段代码还是只能返回一个结果,如何实现返回多个值呢,很简单,使用数组来实现,只要把上面这段代码中的- return false, "you made a stupid error"- 修改为 *return [false, "you made a stupid error"]*就可以了。记录记录以备不时之需。
大家知道,在一般的编程实现中,一个method只能返回一个结果,如果想实现返回多个结果,java中可以使用VO来实现,但是ruby借助其灵活的语法,我们可以一次返回多个结果,我记得前些时候还不晓得这么做,问了几个人貌似也没有提到,今天五一看到了这个实现,分享给大家:首先,按照这个需求,你可能会写出类似下面的这段代码来检验,如下: \n \nRuby代码 \n \n def a_method_to_insult_innocent_people \n error = compute_error \n if error == :stupid \n return false, "You made a stupid error" \n elsif error == :ridiculous \n return false, "You made a ridiculous error" \n elsif error == :worst_of_all_time \n return false, "You made the most idiot error in history. Way to go…" \n else return true, "You made no error, you are still an idiot" \n end \n end \n \n success, msg = a_method_to_insult_innocent_people \n do_something_with_success(success) \n destroy_hateful_words!(msg) \n \n \n \n但是这段代码还是只能返回一个结果,如何实现返回多个值呢,很简单,使用数组来实现,只要把上面这段代码中的- return false, "you made a stupid error"- 修改为 *return [false, "you made a stupid error"]*就可以了。记录记录以备不时之需。
\n", "_id"=>620}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"关于rails启动报500错误的可能问题点", "body"=>"当你启动rails的时候可能会遇到500错误“500- Premature end of script.”或者类似的错误,使得程序跑不起来~问题可能出在两个地方: 1、 The file permissions are not set to allow the dispatch.cgi to execute properly. Chmod the dispatch.cgi to +0755+. 2、The path to Ruby is is incorrect in the dispatch.cgi file. The first line of the file is called the shebang-- it sets the location of the intrepretor (in this case ruby). Change the shebang to the correct path to Ruby (/usr/bin/ruby). The first line of the dispatch.cgi file should look like this: #!/usr/bin/ruby", "created_at"=>2007-06-19 19:24:55 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
当你启动rails的时候可能会遇到500错误“500- Premature end of script.”或者类似的错误,使得程序跑不起来~问题可能出在两个地方: 1、 The file permissions are not set to allow the dispatch.cgi to execute properly. Chmod the dispatch.cgi to +0755+. 2、The path to Ruby is is incorrect in the dispatch.cgi file. The first line of the file is called the shebang-- it sets the location of the intrepretor (in this case ruby). Change the shebang to the correct path to Ruby (/usr/bin/ruby). The first line of the dispatch.cgi file should look like this: #!/usr/bin/ruby
记不得时候在本地机子上安装了mongrel,今天把1stlog用mongrel运行时,报告:-e:3:in `load': no such file to load -- mongrel_rails (LoadError) from -e:3看错误提示貌似mongrel_rails 这个加载不到,那么应该就是配置的问题了,问题解决如下:找到RadRails的 preferences > Rails > configuration ,在这里指定mongrel_rails的路径就可以了(注意不是bat也不是cmd,而是那个没有后缀的)ok,解决了,如果有谁遇到这个问题,也算帮忙了。呵呵。。。
\n", "_id"=>637}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"警惕rails中的保留字带来的问题~", "body"=>"这个问题还真一直没有关注过,只是晓得rails和ruby中有些关键字、保留字,也没太注意,昨天开始遇到一个很奇怪的问题,我建立了一个用来存放友情链接的表links,里面有title,desc,*type*,created_at等字段,然后在controller中取记录的时候类似如下语句: @friend_links = Link.find(:all, :conditions => { :type => 1, :visible => 1 })貌似一切都很平常,却发生如下的错误:compile errorD:/soft/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1358: syntax errorObject::1一切都很平常呀,试着换个find的写法,还是一样出问题,真是够邪门的~!然后今天问了几个朋友,也说奇怪,没有遇到过,还好google还是找到了这个问题的根源:保留字。请注意,这里我使用了一个保留字*type*做为字段名,导致这个错误的发生,就像一个朋友这样解释的一样:Its because *type *is a reserved word, so you'll have to change that column's name (perhaps to kind or something). Otherwise you're code looks fine wink.大家以后一定要注意,这个小问题浪费了不少时间~", "created_at"=>2007-07-12 05:10:19 UTC, "updated_at"=>2012-06-24 15:47:01 UTC, "body_html"=>"
这个问题还真一直没有关注过,只是晓得rails和ruby中有些关键字、保留字,也没太注意,昨天开始遇到一个很奇怪的问题,我建立了一个用来存放友情链接的表links,里面有title,desc,*type*,created_at等字段,然后在controller中取记录的时候类似如下语句: @friend_links = Link.find(:all, :conditions => { :type => 1, :visible => 1 })貌似一切都很平常,却发生如下的错误:compile errorD:/soft/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1358: syntax errorObject::1一切都很平常呀,试着换个find的写法,还是一样出问题,真是够邪门的~!然后今天问了几个朋友,也说奇怪,没有遇到过,还好google还是找到了这个问题的根源:保留字。请注意,这里我使用了一个保留字*type*做为字段名,导致这个错误的发生,就像一个朋友这样解释的一样:Its because *type *is a reserved word, so you'll have to change that column's name (perhaps to kind or something). Otherwise you're code looks fine wink.大家以后一定要注意,这个小问题浪费了不少时间~
The easiest and fastest way to install Ruby gems is to install them in your local directory, you will need shell access. To install your own gems use the following steps: \n \n1) Using File Manager in your cPanel make a copy of the .bashrc file in your root directory, name it .bashrc.bak. \n2) Now edit the .bashrc file and add the following to the end of the file:
3) Using your favorite SSH client connect to your site. \n \n4) at the prompt type: \n \ncp /usr/lib/ruby/gems/1.8/cache/sources-0.0.1.gem ./ \ngem install sources-0.0.1.gem \ngem update -y \n \nThis will update rails to the latest version and install it to your local gem directory. \n \n5) When using a rails application, make sure you add the following to your ./config/environment.rb: \n \nENV['GEM_PATH'] = '/path/to/your/home/.gems:/usr/lib/ruby/gems/1.8' \n \n这里还有一个帖子,可以参考下: \nhttp://www.bluehostforum.com/showthread.php?t=1064
BH 上缺少了一些我需要的gem,于是需要自己安装,BH允许把Gems安装到自己的目录下,于是找了些资料,操作步骤如下: \nThe easiest and fastest way to install Ruby gems is to install them in your local directory, you will need shell access. To install your own gems use the following steps: \n \n1) Using File Manager in your cPanel make a copy of the .bashrc file in your root directory, name it .bashrc.bak. \n2) Now edit the .bashrc file and add the following to the end of the file: \n \nlunix代码 \n \n export PATH="$PATH:$HOME/packages/bin:$HOME/.gems/bin" \n export GEM_HOME="$HOME/.gems" \n export GEM_PATH="$GEM_HOME:/usr/lib/ruby/gems/1.8" \n \n export GEM_CACHE=”$GEM_HOME/cache” \n \n \n \n3) Using your favorite SSH client connect to your site. \n \n4) at the prompt type: \n \ncp /usr/lib/ruby/gems/1.8/cache/sources-0.0.1.gem ./ \ngem install sources-0.0.1.gem \ngem update -y \n \nThis will update rails to the latest version and install it to your local gem directory. \n \n5) When using a rails application, make sure you add the following to your ./config/environment.rb: \n \nENV['GEM_PATH'] = '/path/to/your/home/.gems:/usr/lib/ruby/gems/1.8' \n \n这里还有一个帖子,可以参考下: \nhttp://www.bluehostforum.com/showthread.php?t=1064 \n \n另外:还可以把在本地安装好gem后把其copy到Vendor目录下,但是这个方法我不喜欢,不晓得能不能直接把gem包copy到Vendor目录下?试过的告诉下下,多谢!
Ruby on Rails does a decent job in handling security concerns in the background. You will have to configure your application to avoid few security attacks while plugins would be required for many security concerns which are not at all or poorly managed by rails.
\n
In this article I have described the security issues related to a ruby on rails web application. I have followed DRY by linking to articles with good explanation and solutions to security concerns wherever required. This guide can also be used as a quick security check for your current web application.
\n好久没去ROR官方站点了,今天google到他上面的一个wiki,看完后随手到其blog里面看看,看到一篇好文章,是介绍Rails中安全控制的,于是跟着那个链接过去,看了一部分,没时间看完,特转回来记录着有时间再看~ \nRuby on Rails does a decent job in handling security concerns in the background. You will have to configure your application to avoid few security attacks while plugins would be required for many security concerns which are not at all or poorly managed by rails. \nIn this article I have described the security issues related to a ruby on rails web application. I have followed DRY by linking to articles with good explanation and solutions to security concerns wherever required. This guide can also be used as a quick security check for your current web application. \n原文地址:http://www.quarkruby.com/2007/9/20/ruby-on-rails-security-guide
content_for这个方法竟然一直没看到过,今天也是无意中看到的,看到对此介绍为: \nIf you want to change something in the layout on a per-template basis, content_for is your answer! This allows templates to specify view code that can be placed anywhere in a layout. \n也就是说,如果你想动态的改变你原来layout中的东西,你可以使用content_for这个方法,结合代码就很好理解了,如下:
\nThe parameters as following: \n * q = quality level ( 30-70% ) \n * h = output height \n * w = output width \n * sdx = crop area horizontally \n * sdy = crop area vertically \n \nIf you omit the sdx & sdy values, the whole page gets snapped. \nDon't forget to add a backlink to www.artviper.net or www.artviper.de ( textlink is enough ) but please place the link good visible. \nhttp://www.artviper.net/screenshots/screener.php?&url=http://www.itechtag.com&q=70&h=180&w=360\n
\n", "_id"=>673}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Html/css/js"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>10, "title"=>"Introducing the AJAX Feed API FeedControl", "body"=>" 这篇文章是我很早前写的,放在原来的blog上的,无奈那个blog坏掉了,幸好还有”百度快照 “(http://cache.baidu.com/c?word=feedcontrol&url=http%3A//weblog% 2E1ster%2Ecn/%3Faction%3Dshow%26id%3D112&p=98769a45dcd011a05be7d3284c0096& user=baidu),找回来了,呵呵。以下是原文。\r\n\r\nGoogle放出来的AJAX feed API我老早就关注到了,也试用了一些,感觉还真的不错,现在又添加了一些东西,如下:\r\n其API都很简单,详细的可以看这个页面上的介绍:\r\nhttp://code.google.com/apis/ajaxfeeds/documentation/reference.html#FeedControl\r\n只有一个构造器:FeedControl\r\n四个函数:\r\n1.addFeed(url, label) //添加需要显示的FEED的URL\r\n2.addFeed(element, opt_options?);//这个其实就是draw方法,指定显示的方式,例如:\r\n\r\nfeedControl.draw(\r\ndocument.getElementById(\"feedControl\"),\r\n{\r\ndrawMode : google.feeds.FeedControl.DRAW_MODE_TABBED\r\n});\r\n\r\nfeedControl这个是页面的DOM的ID名称,google.feeds.FeedControl.DRAW_MODE_TABBED 就是指定的显示方式,默认值是:google.feeds.FeedControl.DRAW_MODE_LINEAR.\r\n\r\n3.setNumEntries(num); //设定显示的条数(貌似只能统一指定,不能为各个FEED单独指定)\r\n4.setLinkTarget(linkTarget) //设定链接的打开方式,其值分别如下:\r\n\r\n* google.feeds.LINK_TARGET_BLANK - links will open in a new window\r\n* google.feeds.LINK_TARGET_SELF - links will open in the current window\r\n* google.feeds.LINK_TARGET_TOP - links will open in the topmost frame\r\n* google.feeds.LINK_TARGET_PARENT - links will open in either the topmost frame, or replace the current frame.\r\n* anything-else - the value of target in the resulting anchor element is set to linkTarget\r\n\r\n附录其网站上的说明:\r\n---------------\r\nThis morning we added a new class to the Google AJAX Feed API designed to allow you to more easily add a collection of feeds to your pages. The FeedControl is pretty simple:\r\n\r\nvar feedControl = new google.feeds.FeedControl();\r\nfeedControl.addFeed(\"http://www.digg.com/rss/index.xml\", \"Digg\");\r\nfeedControl.addFeed(\"http://feeds.feedburner.com/Techcrunch\", \"TechCrunch\");\r\nfeedControl.draw(document.getElementById(\"feedControl\"));\r\n\r\nIn addition to the formal documentation, we have put together a few samples to help you quickly come up to speed.\r\n
google.feeds.LINK_TARGET_BLANK - links will open in a new window
\n
google.feeds.LINK_TARGET_SELF - links will open in the current window
\n
google.feeds.LINK_TARGET_TOP - links will open in the topmost frame
\n
google.feeds.LINK_TARGET_PARENT - links will open in either the topmost frame, or replace the current frame.
\n
anything-else - the value of target in the resulting anchor element is set to linkTarget
\n
\n\n
附录其网站上的说明:
\n\n
This morning we added a new class to the Google AJAX Feed API designed to allow you to more easily add a collection of feeds to your pages. The FeedControl is pretty simple:
This release closes a JSON XSS vulnerability, fixes a couple of minor regressions introduced in 1.2.4, and backports a handful of features and fixes from the 2.0 preview release.
\n
All users of Rails 1.2.4 or earlier are advised to upgrade to 1.2.5, though it isn’t strictly necessary if you aren’t working with JSON. For more information the JSON vulnerability, see CVE-2007-3227.
\n
Summary of changes:
\n
\n
acts_as_list: fixed an edge case where removing an item from the list then destroying the item leads to incorrect item positioning
\n
deprecated calling .create on has_many associations with an unsaved owner (like post = Post.new; post.comments.create)
\n
backport array and hash query parameters
\n
fix in place editor’s setter action with non-string fields
\n
updated config/boot.rb to correctly recognize RAILS_GEM_VERSION
\n
\n
To upgrade, `gem install rails`, set RAILS_GEM_VERSION to ‘1.2.5’ in config/environment.rb, and `rake rails:update:configs`.
This release closes a JSON XSS vulnerability, fixes a couple of minor regressions introduced in 1.2.4, and backports a handful of features and fixes from the 2.0 preview release. \nAll users of Rails 1.2.4 or earlier are advised to upgrade to 1.2.5, though it isn’t strictly necessary if you aren’t working with JSON. For more information the JSON vulnerability, see CVE-2007-3227. \nSummary of changes: \n \n acts_as_list: fixed an edge case where removing an item from the list then destroying the item leads to incorrect item positioning \n deprecated calling .create on has_many associations with an unsaved owner (like post = Post.new; post.comments.create) \n backport array and hash query parameters \n fix in place editor’s setter action with non-string fields \n updated config/boot.rb to correctly recognize RAILS_GEM_VERSION \n \nTo upgrade, gem install rails, set RAILS_GEM_VERSION to ‘1.2.5’ in config/environment.rb, and rake rails:update:configs.
从上看到的,随手记录如下,可能需要用到。 \n \nRails URL Validation \n \n validates_each :href, :on => :create do |record, attr, value| \n begin \n uri = URI.parse(value) \n if uri.class != URI::HTTP \n record.errors.add(attr, 'Only HTTP protocol addresses can be used') \n end \n rescue URI::InvalidURIError \n record.errors.add(attr, 'The format of the url is not valid.') \n end \n end \n \n \n以前我判断的时候都是按照是不是http://开头等做的判断,感觉好傻,这样的判断才更加专业和准确。
\n", "_id"=>677}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"image_tag with popup for alt attribute", "body"=>"
"Freezing Rails is recommended if you are using a Rails application for a business site or another production environment where stability is the most important concern (if you don't freeze your application, there is a small possibility that your application might stop working due to compatibility problems when a new version of Rails is installed on our servers)."
早上起了一个大早,打开电脑,打开技能云,寒~出错了,信息如下: \nRails application failed to start properly"RewriteCond %{HTTP_REFERER} !^http://1stimes.liquidchinaware.com/.*$ [NC] \n看来有点问题,赶紧打开log看看,没有任何错误,看来还没到这步,奇怪,感觉应该是.htaccess的问题,但是我没改过呀,copy一个好的过去,还是不行,郁闷! \n赶紧./script/server 试试,提示找不到1.2.3版本的rails,接着rails -v 看下,我靠,咋成1.2.5了,看来是Bl自己升级了,也不通知下,囧~ \n找到问题就好办了,修改配置文件environment.rb,把rails版本改成1.2.5即可! \n引出另外一个话题,需要freeze你的Rails么?答案是肯定的,转另外一个老外写的一段话,如下: \n"Freezing Rails is recommended if you are using a Rails application for a business site or another production environment where stability is the most important concern (if you don't freeze your application, there is a small possibility that your application might stop working due to compatibility problems when a new version of Rails is installed on our servers)." \n方法很简单:rake rails:freeze:gems等几个命令就ok,会把rails单独拷贝到你的 vender下,而rails启动的时候先看这个目录,如果有就加载,没有的话再加载系统的。 \n至于为什么这么做,你可以参考他写的文章:http://support.tigertech.net/freeze-rails \n参考命令: \n<a name="freezing-to-a-different">rake rails:freeze:gems<br />rake rails:freeze:edge<br /></a><a name="freezing-to-a-different">rake rails:freeze:edge TAG=rel_1-1-6<br /></a><a name="unfreezing-thawing-rails">rake rails:unfreeze</a>` \n
It can be run with 2 optional parameters: “atime”, which defines the time in minutes that will be compared against the last access time of a session file and “ctime” which defines the time in minutes that will be compared against the creation time of a session file. The default values are: ctime = 120 (minutes) and atime = 20 (miuntes) which means that the session files not accessed in the last 20 minutes and created earlier than 2 hours ago will be removed when the script runs.
Here's a cron-only one liner which, every 30 min, removes all session files that haven't been accessed in 4 hours. 10,40 * * * * /usr/bin/find /u/apps/*/current/tmp/sessions -name "ruby_sess*" -amin +240 -exec rm {} \\;
早上6点半起床,打开电脑,打开技能云,一切正常,开始写Gtalk的发送消息的ruby代码,很顺利,全部搞定,准备关机的时候,刷新了下技能云,显示启动错误! \n晕,哪里出问题了呢?我刚才没有更新代码上去呀,看来是系统的问题,SSH上去,看日志没有任何有用的信息,调试一把,可以启动,难道是 sessions的问题(我的session还是保存在文件系统里面的),转到tmp/sessions下wc -l 了一下,寒,7W多个文件,恐怖,貌似我忘记清理了,直接rm * (保存密码的人别骂我哈),显示参数过长,郁闷,看来文件数太多了,文件貌似也没有什么规律,总不能一个一个删吧(傻瓜才这个干),于是寻找解决办法。 \nGoogle到这段代码,试了下可以正常工作,共享给大家: \n \nRuby代码 \n \n require 'find' \n namespace :tmp do \n namespace :sessions do \n desc 'Clear expired sessions' \n task :clear_expired => :environment do \n ctime = (ENV['ctime'] || 120).to_i \n atime = (ENV['atime'] || 20).to_i \n Find.find(RAILS_ROOT + "/tmp/sessions/") do |path| \n if FileTest.directory?(path) \n if File.basename(path)[0] == ?. \n Find.prune \n else \n next \n end \n else \n File.delete(path) if File.ctime(path) < ctime.minutes.ago or File.atime(path) < atime.minutes.ago \n end \n end \n end \n end \n end \n \n \n按照作者给出的用法,如下: \nIt can be run with 2 optional parameters: “atime”, which defines the time in minutes that will be compared against the last access time of a session file and “ctime” which defines the time in minutes that will be compared against the creation time of a session file. The default values are: ctime = 120 (minutes) and atime = 20 (miuntes) which means that the session files not accessed in the last 20 minutes and created earlier than 2 hours ago will be removed when the script runs. \n保存到你的lib/tasks目录下,然后用rake -T就可以看到这个rake命令,可以接受两个参数,举个例子,如下: \n \n \nRuby代码 \n \n rake tmp:sessions:clear_expired atime=15 ctime=60 \n \n \n另外,还google到一段直接配置的脚本,如下: \nHere's a cron-only one liner which, every 30 min, removes all session files that haven't been accessed in 4 hours. 10,40 * * * * /usr/bin/find /u/apps//current/tmp/sessions -name "ruby_sess" -amin +240 -exec rm {} \\; \n如果你有更优雅的方法,请分享给我,谢谢~ \n参考地址: \nhttp://www.taknado.com/2007/7/25/rake-task-to-clear-expired-session-files
来源:http://errtheblog.com/post/8 \nGiven a piece of XML:
\n
\n
XML/HTML代码
\n\n
<Export>
\n
<Product>
\n
<SKU>403276</SKU>
\n
<ItemName>Trivet</ItemName>
\n
<CollectionNo>0</CollectionNo>
\n
<Pages>0</Pages>
\n
</Product>
\n
</Export>
\n\n
\n
One might assume that REXML is the way to parse it, but we all know how slow it is. \n \nEnter _why’s HTML parser, Hpricot. It’s written in C and since XHTML is a subset of XML, there’s no reason it shouldn’t be able to parse my file. \n \nTurns out it does, it’s really fast, and the code is dead simple.
来源:http://errtheblog.com/post/8 \nGiven a piece of XML: \n \nXML/HTML代码 \n \n <Export> \n <Product> \n <SKU>403276</SKU> \n <ItemName>Trivet</ItemName> \n <CollectionNo>0</CollectionNo> \n <Pages>0</Pages> \n </Product> \n </Export> \n \n \nOne might assume that REXML is the way to parse it, but we all know how slow it is. \n \nEnter _why’s HTML parser, Hpricot. It’s written in C and since XHTML is a subset of XML, there’s no reason it shouldn’t be able to parse my file. \n \nTurns out it does, it’s really fast, and the code is dead simple. \n \nRuby代码 \n \n FIELDS = %w[SKU ItemName CollectionNo Pages] \n \n doc = Hpricot.parse(File.read("my.xml")) \n (doc/:product).each do |xml_product| \n product = Product.new \n for field in FIELDS \n product[field] = (xml_product/field.intern).first.innerHTML \n end \n product.save \n end \n \n \nUpdate: Slight refactoring of the code above. Chris figured out last night that you can use innerHTML which eliminated the only ugly part of the code.
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\Folder\\shell\\DeleteSVN\\command]@=”cmd.exe /c \\”TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \\”%1\\” %%f IN (.svn) DO RD /s /q \\”%%f\\” \\”“```\n
FeedTools is a simple Ruby library for handling rss, atom, and cdf parsing, generation, and translation as well as caching. It attempts to adhere to Postel’s law—i.e. a liberal parsing and conservative generation policy.
由于需要抽时间重新1st的站点,按照我设想的模式,会抓取指定的RSS功能,以前都是自己写的,前些日志看到ruby有个gem,可以找时间试试, \nFeedTools is a simple Ruby library for handling rss, atom, and cdf parsing, generation, and translation as well as caching. It attempts to adhere to Postel’s law—i.e. a liberal parsing and conservative generation policy. \n参考如下2篇文章: \nhttp://sporkmonger.com/projects/feedtools/ \nhttp://sporkmonger.com/2005/08/11/tutorial
“Just when I thought it was safe to upgrade, another version appears!
\n
I’m going to start upgrading our servers to Rails 2.0.2. This involves packaging, testing, and then slowly rolling it out. The jump is to a 2.x version from 1.2.6, so I’m going to take my time with this one to make sure nothing goes horribly wrong, so it might be right after the new year when it’s all done, just to be safe.
\n
For your new year’s resolution, you will freeze your rails! Login via shell, and in your rails directory, run “rake freeze_gems” - that should do the trick!
\n
Please contact support if you have any questions or concerns.”
早上看RSS订阅的时候,发现DH有一则公告,仔细看了下,原来其准备升级到Rails2.0.2版本了,看来Rails2的时代以及来临了,引起原话如下: \n \n \n \n“Just when I thought it was safe to upgrade, another version appears! \nI’m going to start upgrading our servers to Rails 2.0.2. This involves packaging, testing, and then slowly rolling it out. The jump is to a 2.x version from 1.2.6, so I’m going to take my time with this one to make sure nothing goes horribly wrong, so it might be right after the new year when it’s all done, just to be safe. \nFor your new year’s resolution, you will freeze your rails! Login via shell, and in your rails directory, run “rake freeze_gems” - that should do the trick! \nPlease contact support if you have any questions or concerns.” \n \n \n \n
Application configuration shouldn't be spread throughout your code base. Instead a much better place to put it is an external YAML file. See how to do that in this episode.
其实很早前我就用过这个,貌似还是在读书的时候吧,现在技能云上我突然感觉这个相当不错的一个功能,可惜的是,在其站上发现,已经不在提供了,看到其公告如下: \n“ \nf December 5, 2006, we are no longer issuing new API keys for the SOAP Search API. Developers with existing SOAP Search API keys will not be affected. \n
\n
Depending on your application, the AJAX Search API may be a better choice for you instead. It tends to be better suited for search-based web applications and supports additional features like Video, News, Maps, and Blog search results.
\n
For developers who are already using the SOAP Search API, we've kept the documentation live on this site.
\n
”
\n
唉,按照其意思是推荐大家使用更强大的AJAX Search API,但是我不觉得其好用,也不符合我的需要,可惜了哦。 \n还是贴一段代码吧,如下: \nrequire 'soap/wsdlDriver' \n$KCODE = "UTF8" \nkey = 'LVJnAm5QFHblahblahblah your key here' \n \n#create driver \nwsdl = "http://api.google.com/GoogleSearch.wsdl" \ndriver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver \nquery = "your query string here" \nstart = 0 \nmax = 10 \n \n# see http://dev.ctor.org/soap4r/browser/trunk/sample/wsdl/googleSearch/wsdlDriver.rb \n@results = driver.doGoogleSearch( key, query, start, max, true, "", true, 'lang_en', '','') \nsnippets = @results.resultElements.collect { |r| r.snippet } # you can get all kinds'a' info here \nself.update_attribute(:html, snippets.join("\\n")) # or whatever \n \n=================================== \ndef search \n require 'soap/wsdlDriver' \n @title = 'Search Results' \n key = 'YOUR GOOGLE API KEY HERE' \n yoursite = 'YOUR SITE ADDRESS HERE' \n driver = SOAP::WSDLDriverFactory.new("http://api.google.com/GoogleSearch.wsdl").createDriver \n @results = driver.doGoogleSearch(key, @params['term']+" site:\#{yoursite}", 0, 10, true, " ", false, " ", " ", " ") \nend \n \n \n<% for result in @results.resultElements %> \n <h2><%= result.title %></h2> \n <p><%= result.snippet %></p> \n <p><a href="<%= result.URL %>"><%= result.URL %></a></p> \n<% end %>
其实很早前我就用过这个,貌似还是在读书的时候吧,现在技能云上我突然感觉这个相当不错的一个功能,可惜的是,在其站上发现,已经不在提供了,看到其公告如下: \n“ \nf December 5, 2006, we are no longer issuing new API keys for the SOAP Search API. Developers with existing SOAP Search API keys will not be affected. \n \nDepending on your application, the AJAX Search API may be a better choice for you instead. It tends to be better suited for search-based web applications and supports additional features like Video, News, Maps, and Blog search results. \nFor developers who are already using the SOAP Search API, we've kept the documentation live on this site. \n” \n唉,按照其意思是推荐大家使用更强大的AJAX Search API,但是我不觉得其好用,也不符合我的需要,可惜了哦。 \n还是贴一段代码吧,如下: \nrequire 'soap/wsdlDriver' \n$KCODE = "UTF8" \nkey = 'LVJnAm5QFHblahblahblah your key here'
I found the following lines of code on Wikipedia today. It’s a very succinct description of one important difference between a lambda and a Proc. Try printing the return value of f.call for more insight.
\n
\n
摘录部分内容如下:
\n`` def foo f = Proc.new{ return "return from foo from inside proc"} f.call# control leaves foo here return "return from foo" end
def bar f = lambda { return "return from lambda"} f.call# control does not leave bar here return "return from bar" end
puts foo # prints "return from foo from inside proc" puts bar # prints "return from bar"
一直都不是很能把ruby的Proc运用自由,今天看一个gem的时候,又发现另外一个比较让我迷惑的东西Lambda ,好读书不求甚解,先找到一篇相关的文章,如下: \nhttp://samdanielson.com/2007/3/19/proc-new-vs-lambda-in-ruby \n原作者是这么说的: \n \nI found the following lines of code on Wikipedia today. It’s a very succinct description of one important difference between a lambda and a Proc. Try printing the return value of f.call for more insight. \n \n摘录部分内容如下: \n<code class="ruby"><br /><span class="keywords">def</span> foo<br /> f = <span class="constants">Proc</span><span class="method">.new</span> <span class="brackets">{</span> return <span class="string">"return from foo from inside proc"</span> <span class="brackets">}</span><br /> f<span class="method">.call</span> <span class="comment"># control leaves foo here</span><br /> return <span class="string">"return from foo"</span> <br /><span class="keywords">end</span><br /><br /><span class="keywords">def</span> bar<br /> f = lambda <span class="brackets">{</span> return <span class="string">"return from lambda"</span> <span class="brackets">}</span><br /> f<span class="method">.call</span> <span class="comment"># control does not leave bar here</span><br /> return <span class="string">"return from bar"</span> <br /><span class="keywords">end</span><br /><br />puts foo <span class="comment"># prints "return from foo from inside proc" </span><br />puts bar <span class="comment"># prints "return from bar" </span><br /><br />在wiki上也有,地址如下:http://en.wikipedia.org/wiki/Closure_(computer_science)````
Fast, simple, designed to mirror the style of memcached. Rails plugin available, or usable with a simple Ruby-based API. Server written in C, but is very easy to install. Memory only…jobs are not persistent. New, so the internal protocol may change. Workers may be difficult to manage.
开始的时候,有人说Rails没有队列机制,无法达到企业级的需求,时间没多久,现在再来看看Rails有没有队列机制吧。 \n \n别看一组可行的列表,如下: \nbeanstalkd \nFast, simple, designed to mirror the style of memcached. Rails plugin available, or usable with a simple Ruby-based API. Server written in C, but is very easy to install. Memory only…jobs are not persistent. New, so the internal protocol may change. Workers may be difficult to manage. \nbj \nRails plugin. Self-spawning. Can only send shell commands. Jobs start a full copy of your Rails app on every execution. \nBackgroundRB \nRuby-based. Can be polled for incremental feedback on the progress of a job. Recently rewritten. \nAmazon SQS \nRuns on Amazon’s cluster, so it can handle a ton of traffic. Operated by Amazon, so it doesn’t run locally. Not open source. \nApache ActiveMQ \nWell-known. Persistent. Requires several installation steps and database tables. \nActiveMessaging \nRails plugin. Works with ActiveMQ and others. Requires external job server. \nBBQ \nNothing to install…involves only a single line of code! Doesn’t work on Windows NT4. \n如下是几篇介绍的文章: \nhttp://www.thewebfellas.com/blog/2008/1/17/queues \nhttp://nubyonrails.com/articles/about-this-blog-beanstalk-messaging-queue
I ported the php code for open flash chart to ruby and so far it has worked quite well with Rails. Just ported the latest 1.9.6 version – see the many graph examples below. To install and use the open flash chart plugin for Rails do the following:
/config/../log/sql/production_2008-01-24.log.20080124' already exists.):” \n看上去感觉是在1.25号凌晨的时候,将原来的日志改名为production_2008-01-24.log.20080124,而此时已经存在名字为“production_2008-01-24.log.20080124”的文件,导致改名失败的。 \n但是这个“production_2008-01-24.log.20080124”是哪里来的呢?backgroundrb应该是没有进行改名操作的。 \n \n于是乎开始google,找到有类似问题的文章如下: \n1、Rails application not working, no error displayed, just error code 500 \n错误基本上是一样的,但是这个文章没有仔细说是什么原因,只说了: \n
And the problem was almost solved - problem with log rotation. \nSo, if you face the same problem, try to perform few operations in your rails console... and if you are lucky, you will find the bug. \n
\n``ActionView::TemplateError (undefined method `[]' for nil:NilClass) on line #57 of companies/_cannot_edit_item.rhtml: 而这行却是没有代码的,真的奇怪的很。翻遍这个文件也没有发现什么可疑的地方,最后 没有办法就挨个的测试,发现有的公司展示页面是可以的,进数据库比较不同,发现有些 字段是没有值的,难道这个问题,于是挨个的加上值,测试,果然通过,后来再仔细看看 错误信息:
Do you get annoyed when you have a SSH session open, visit your browser for a while, and then return only to find you were disconnected? Most home NAT routers are the cause of this. If your router doesn’t offer an option to not shut off idle connections, you are probably better off by setting a keep-alive setting.
\n
To do this, just open /etc/ssh/ssh_config on your home (client) computer. Add the following line:
\n
\n
\n
配置代码
\n\n
ServerAliveInterval 180
\n\n
\nThere you have it! Just remember now, if you leave SSH open accidentally, anyone else can get on it. Remember to close your session when finished.PS:If you’re using AbsoluteTelnet (for Windows), you can do this from the Options->Properties->Connection page. There is an option there to enable keepalives and you can specify the duration between them.
不管我是使用linux的的SSH还是windows下的putty、SecureCRT还是AbsoluteTelnet,当我连接到服务器端 后,离开一会或者做点其他的事情,再回到SSH的时候,常常发现客户端自动掉出来了;有的时候甚至跑一个需要时间比较长的JOB的时候,还没跑完就掉出来 了,导致JOB跑了一半,等等。。 \n所以一直在找解决这个问题的办法,今天在googleReader上找到了一个解决办法,如下: \n \nDo you get annoyed when you have a SSH session open, visit your browser for a while, and then return only to find you were disconnected? Most home NAT routers are the cause of this. If your router doesn’t offer an option to not shut off idle connections, you are probably better off by setting a keep-alive setting. \nTo do this, just open /etc/ssh/ssh_config on your home (client) computer. Add the following line: \n \n \n配置代码 \n \n ServerAliveInterval 180 \n \n \nThere you have it! Just remember now, if you leave SSH open accidentally, anyone else can get on it. Remember to close your session when finished.PS:If you’re using AbsoluteTelnet (for Windows), you can do this from the Options->Properties->Connection page. There is an option there to enable keepalives and you can specify the duration between them.
今天无意在Google订阅里面看到了人评价说“itechtag 纯粹靠自我声明或者相互吹捧的是没有办法 建立creditibility(可信度) 如果像ohloh.net那种有真凭实据的还差不多”。 \n哦,有人这样评价技能云,还提到了ohloh.net,这个是什么网站呢?赶紧瞧瞧去。 \nOhloh is an open source network that connects people through the software they create and use. \n \nwowo,和我们的技能云的定位有些神似呀,有时间好好研究下:( \n
AviScreen - As the name would imply, this capture program records the video into AVI files, but can also do BMP photos. It’s Windows only and does not record audio.
\n
CamStudio.org - An open source program for capturing your on-screen video and audio as AVI files. Windows only, and absolutely free.
\n
Copernicus - A free program for Macs that focuses heavily on making quick and speedy films by recording the video to your RAM for quicker access. Does not include any support for audio.
\n
JingProject.com - Beyond recording video, Jing allows you to take a picture of any portion fo your desktop, draw on it, add a message, and immediately upload your media to a free hosting account. You are then given a small URL that you can give to whomever needs to see the image or video. Works with Macs and Windows machines.
\n
Screencast-O-Matic.com - A Java-based screencasting tool that requires no downloads and will allow you to automatically upload to hosting. According to their site it works well with Macs and Windows machines, but does have some issues with Linux.
\n
Wink - Screencasting software that focuses on making tutorials with audio and text annotation abilities. Outputs to Flash, PDF, HTML, EXE files and more. \n \n以及在ubuntu下的xvidcap。
经常看一些视频教程,觉得视频教程简单易懂,相当不错,如下两个文章列了一些制作视频教程的工具,被点名的有: \nAviScreen - As the name would imply, this capture program records the video into AVI files, but can also do BMP photos. It’s Windows only and does not record audio. \nCamStudio.org - An open source program for capturing your on-screen video and audio as AVI files. Windows only, and absolutely free. \nCopernicus - A free program for Macs that focuses heavily on making quick and speedy films by recording the video to your RAM for quicker access. Does not include any support for audio. \nJingProject.com - Beyond recording video, Jing allows you to take a picture of any portion fo your desktop, draw on it, add a message, and immediately upload your media to a free hosting account. You are then given a small URL that you can give to whomever needs to see the image or video. Works with Macs and Windows machines. \nScreencast-O-Matic.com - A Java-based screencasting tool that requires no downloads and will allow you to automatically upload to hosting. According to their site it works well with Macs and Windows machines, but does have some issues with Linux. \nWink - Screencasting software that focuses on making tutorials with audio and text annotation abilities. Outputs to Flash, PDF, HTML, EXE files and more. \n \n以及在ubuntu下的xvidcap。 \n【1】http://www.freecharity.org.uk/2007/04/12/the-secret-to-screencasting-with-ubuntu-and-free-software/ \n【2】http://mashable.com/2008/02/21/screencasting-video-tutorials/
\n", "_id"=>754}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"50 Questions to Evaluate the Quality of Your Website", "body"=>"
If the answer to every question that follows below was answered with yes, you can be very pleased with yourself and consider yourself the top of the crop, because most websites have flaws for a number of different reasons, mostly related to the limitation of resources and sacrifices that must be made as a direct result of the shortage.
\n
These questions are divided into following main categories: Accessibility, Navigation, Design, Content, Security, Other Technical Considerations, Other Marketing Considerations and Legal Stuff/Re-Assurance/Legitimization.
作为一个互联网人,你对自己的网站有多少理解和把握,对其前途是否能看好,能否认识到目前的现况和不足,都是十分重要的。 \nCarstenCumbrowski from SearchEngineJournal has come up with a great and pretty detailed list of 50 questions that a website owner should asked himself about his own website. \nIf the answer to every question that follows below was answered with yes, you can be very pleased with yourself and consider yourself the top of the crop, because most websites have flaws for a number of different reasons, mostly related to the limitation of resources and sacrifices that must be made as a direct result of the shortage. \nThese questions are divided into following main categories: Accessibility, Navigation, Design, Content, Security, Other Technical Considerations, Other Marketing Considerations and Legal Stuff/Re-Assurance/Legitimization. \n【1】http://www.searchenginejournal.com/50-questions-to-evaluate-the-quality-of-your-website/6400/
虽然我使用Ubuntu工作已经很长一段时间,虽然我也使用过Kubuntu、Xubuntu,虽然我也对ubuntu的前途比较看好,虽然。。 \nN多的虽然,但当我第一次看到Ubuntu Mobile Edition的时候,还是不免呢喃了一句“世界太疯狂了!”难道不是么。 \n \n自从iphone的成功,到Google的潜力修行,加上nokia的大半市场和windowmobile的无可奈何,现在又多了Ubuntu Mobile Edition。
\n
\n
“Ubuntu Mobile Edition 是 Ubuntu 家族的又一新成员。与 Kubuntu、Xubuntu、Edubuntu 这些版本相同的是,Ubuntu Mobile 一样基于 Ubuntu;不同的是,Ubuntu Mobile 是专门为 MID (Mobile Internet Devices,移动互联网设备) 而设计的。”
\n
“Ubuntu Mobile 不仅包含丰富的应用软件,而且集成了流行的 Web 2.0 服务,如 Facebook、MySpace、YouTube 等。使用者通过 Ubuntu Mobile 能够执行诸如网络浏览、收发邮件、分享视频/音乐/照片、即时通讯、撰写博客、玩游戏等常见操作。”
虽然我使用Ubuntu工作已经很长一段时间,虽然我也使用过Kubuntu、Xubuntu,虽然我也对ubuntu的前途比较看好,虽然。。 \nN多的虽然,但当我第一次看到Ubuntu Mobile Edition的时候,还是不免呢喃了一句“世界太疯狂了!”难道不是么。 \n \n自从iphone的成功,到Google的潜力修行,加上nokia的大半市场和windowmobile的无可奈何,现在又多了Ubuntu Mobile Edition。 \n \n“Ubuntu Mobile Edition 是 Ubuntu 家族的又一新成员。与 Kubuntu、Xubuntu、Edubuntu 这些版本相同的是,Ubuntu Mobile 一样基于 Ubuntu;不同的是,Ubuntu Mobile 是专门为 MID (Mobile Internet Devices,移动互联网设备) 而设计的。” \n“Ubuntu Mobile 不仅包含丰富的应用软件,而且集成了流行的 Web 2.0 服务,如 Facebook、MySpace、YouTube 等。使用者通过 Ubuntu Mobile 能够执行诸如网络浏览、收发邮件、分享视频/音乐/照片、即时通讯、撰写博客、玩游戏等常见操作。” \n \n其他的介绍: \nhttp://linuxtoy.org/archives/ubuntu-mobile-edition.html \nhttp://moblin.org/
先来看这篇文章“How To Manage Your Online Reputation”,文章中说到:You've spent a lot of time building up your reputation and image both online and off, so it's important to make sure that someone isn't out there dragging it through the mud. The latest tool for reputation management is Trackur, but its bottom-level price is $88/month, so the question on my mind, is: "Is it worth it?" There are already many different ways to monitor your online reputation as it is. Let's see how they stack up.
Did you know that 52% of individuals put their trust in what others have to say about you? \n \nDid you know that 87% of consumers look at the reputation of your CEO, when judging your company's reputation? \n \nDid you know that 59% of hiring managers are influenced by your online reputation? \n \nDid you know that Trackur will monitor the web 24/7 and alert you whenever your reputation is being discussed?( 这条是宣传自己网站的)
个人在线声望真的越来越被看重了,我一直在做的“技能云”的目的就是建立良好的个人声望,虽然目前国内的很多人还没有意识到这点,但毋庸置疑的是,真的越来越重要了,前段时间MR.6就写过一篇文章,几天又发现了一个文章专门说这个问题的,我也顺着这个思路说说看。 \n先来看这篇文章“How To Manage Your Online Reputation”,文章中说到:You've spent a lot of time building up your reputation and image both online and off, so it's important to make sure that someone isn't out there dragging it through the mud. The latest tool for reputation management is Trackur, but its bottom-level price is $88/month, so the question on my mind, is: "Is it worth it?" There are already many different ways to monitor your online reputation as it is. Let's see how they stack up. \n而后列举了几个可以使用的工具(网站)来管理自己的在线声望,其中提到了一个网站http://www.trackur.com/竟然是收费的,而且还不便宜,最便宜的还88美刀/月,另外还有像google通知等。详细的可以去看这篇文章:http://www.readwriteweb.com/archives/how_to_manage_your_online_reputation.php \n接着看上面说到的这个收费的网站,真的是个监视、管理个人在线声望的网站,价格也真不便宜,呵呵,看看他是怎么说个人声望的: \nDid you know that 52% of individuals put their trust in what others have to say about you? \n \nDid you know that 87% of consumers look at the reputation of your CEO, when judging your company's reputation? \n \nDid you know that 59% of hiring managers are influenced by your online reputation? \n \nDid you know that Trackur will monitor the web 24/7 and alert you whenever your reputation is being discussed?( 这条是宣传自己网站的) \n看看上面列举的几个数据,怎么来的,我们无法得知,但是其在一定程度上说明了个人声望是如何的重要,可能国外会更普及一点;但是对于国内来说,其他行业我不了解,至少和互联网沾边的,不如软件开发行业等,会比较看重的。 \n都说国内什么都要落后老外们几年时间,但是值得我们高兴的事,我们这次我们的意识并没有晚,我们与2007年中开始做的”技能云“正是在这个方面的体现,我们希望的是通过用户的努力,创建良好的个人声望,并勇敢的把自己的声望show出去;此外,我们还将创建公司和项目的声望。 \n虽然我们才刚刚起步,虽然很多人还不能意识到这点的重要性,但是我们相信,随着时间的推移,随着个人不断的体会和经历,加上技能云平台的不断完善,我们肯定会让所有的对自己声望在意的朋友建立起自己的”技能云“。
最近比较清闲,就到处转悠,然后写些自己的感受,今天要说的是FriendFeed,FriendFeed enables you to keep up-to-date on the web pages, photos, videos and music that your friends and family are sharing. It offers a unique way to discover and discuss information among friends.
最近比较清闲,就到处转悠,然后写些自己的感受,今天要说的是FriendFeed,FriendFeed enables you to keep up-to-date on the web pages, photos, videos and music that your friends and family are sharing. It offers a unique way to discover and discuss information among friends. \n注册试用了下,感觉比以前试用的那几个好点,比如facebook我一进去就晕,校内也差不多的模式,其他的什么占座之类的就看几眼就再不会去了。而FriendFeed有点点不一样,可能是由于其”亲缘“关系的缘故(大多数人都死来自Google成员)做事风格也和Google比较类似,简洁明了。其主要的抓取功能还是挺强大的,速度相当的快。 \n应该是在Google中积累的经验,使得这个项目在Google排名等都表现相当不错,在改进”技能云“的时候可以学习下他的表现形式,再琢磨下Google的一些规则。 \n我向来不是很喜欢这类SNS的东西,不过这个FriendFeed倒让我觉得可以忍受。 \n慢慢的,我也学会了冷静的观察~
(Sends the file by streaming it 4096 bytes at a time. This way the whole \nfile doesn‘t need to be read into memory at once. This makes it \nfeasible to send even large files.) \n
有个需求是需要在程序里生成压缩文件,并通过浏览器下载,在rails中发送文件的方式有2中,分别是send_data和send_file,两者还是有些区别的,详细的可以参考Rails的API文档(http://api.rubyonrails.com/classes/ActionController/Streaming.html2个方式,如下:),这里简单的记录 \n<strong>send_file '/path/to.zip'</strong> \n<blockquote>(Sends the file by streaming it <strong>4096 </strong>bytes at a time. This way the whole<br /> \nfile doesn‘t need to be read into memory at once. This makes it<br /> \nfeasible to send even large files.)<br /> \n</blockquote> \n恩,我的需求差不多也是这样的,需要发送的文件比较大,大概在10M左右的大小,按照上<br />面的这个说明,15M的文件差不多需要下载一分钟(理论速度,和实际的网速还是有关系的);<br />挺方便了。<br />参考:<br />http://api.rubyonrails.com/classes/ActionController/Streaming.html<br />http://www.javaeye.com/post/219997``
請不要管它是真還是假,試一下! 如下文章的意思是:(水平有限,可能翻譯得不是很正確,班門弄斧了!) \nDear Friends, \nPlease do not take this for a junk letter. Bill Gates is sharing his fortune. If you ignore this you will repent later. Microsoft and AOL are now the largest Internet companies and in an effort to make sure that Internet Explorer remains the most widely used program, Microsoft and AOL are running an e-mail beta test. \n親愛的朋友們, \n請不要把此郵件當作是垃圾郵件。比爾.蓋茨正在施捨他的財富。如果你無視此封郵件稍後你將會追悔莫及.Microsoft and AOL 是現今最大的因特網公司並致力於確保因特網Windows資源管理器依然是使用最廣的程序,Microsoft and AOL 正在進行E-mail第二個階段的測試。 \n \nWhen you forward this e-mail to friends, Microsoft can and will track it (if you are a Microsoft Windows user) for a two week time period. \n噹你把此e-mail轉送給你的朋友時,微軟將跟在兩周內蹤它(如果你是Microsoft Windows 的使用者)。 \nFor every person that you forward this e-mail to, Microsoft will pay you $245.00, for every person that you sent it to that forwards it on, Microsoft will pay you $243.00 and for every third person that receives it, you will be paid $241.00. Within two week! s, Microsoft will contact you for your address and then send you a cheque. \n對於每一個轉發此mail給朋友的人,微軟將會付給你$245。對於每一個你轉發了的人,別人又繼續轉發的人,微軟將付給你$243並且每三個人收到此mail,你將會得及$241的付款。在兩周內,微軟將會聯繫你的地址並給你一張支票! \nDon’t Know True Or False, Just Have a Try \n \nDear Friends, \nPlease do not take this for a junk letter. Bill Gates is sharing his fortune. If you ignore this you will repent later. Microsoft and AOL are now the largest Internet companies and in an effort to make sure that Internet Explorer remains the most widely used program, Microsoft and AOL are running an e-mail beta test. \n \nWhen you forward this e-mail to friends, Microsoft can and will track it (if you are a Microsoft Windows user) for a two week time period. \n \nFor every person that you forward this e-mail to, Microsoft will pay you $245.00, for every person that you sent it to that forwards it on, Microsoft will pay you $243.00 and for every third person that receives it, you will be paid $241.00. Within two week! s, Microsoft will contact you for your address and then send you a cheque. \n
最近,老是收到一封名字为“spam轉寄^_^”的邮件,内容相当老套,和以往的思路差不多,这次是鼓吹“比尔盖茨”多NB,说起在施舍自己的财富啥的,只要转发那个邮件就可以自动汇入多少多少美金。。 \n对于这类的馅饼,偶从来就不放心上的,搞过计算机安全,偶也懂得一点的”社会工程学“的,利用社会学的例子,在不知不觉中,有些人就得到了其需要的东西而不会被人发觉。这就是社工的魅力和内涵。 \n来看下这个邮件,其诱惑点有如下几个: \n1、有英文及其对应的翻译(繁体字),让人觉得有那么点可信; \n2、开始有几个炒作的,都说收到钱了,等等,让人稍微动心了; \n3、反正不费事,于是很多人就开始抱着试试看的心情大量转发咯; \n那么这样会给开始策划的人带来什么好处呢? \n具体的我不知道,有可能是测试中国人的心里;有可能是闹着玩等等,但是偶认为其还可以收集大家的工作邮箱,想想这么多人的真实、活跃邮箱,这可是比较珍贵的东西呀。 \n抑或在某些版本的邮件接收中有类似跨站,取cookie、溢出下载等等的漏洞,这样就可以有更多的用处了。 \n哎,对于这类”馅饼“,大家还是小心为妙,不要为了”馅饼“调到”陷阱“里啦。 \n附:原文: \n請不要管它是真還是假,試一下! 如下文章的意思是:(水平有限,可能翻譯得不是很正確,班門弄斧了!) \nDear Friends, \nPlease do not take this for a junk letter. Bill Gates is sharing his fortune. If you ignore this you will repent later. Microsoft and AOL are now the largest Internet companies and in an effort to make sure that Internet Explorer remains the most widely used program, Microsoft and AOL are running an e-mail beta test. \n親愛的朋友們, \n請不要把此郵件當作是垃圾郵件。比爾.蓋茨正在施捨他的財富。如果你無視此封郵件稍後你將會追悔莫及.Microsoft and AOL 是現今最大的因特網公司並致力於確保因特網Windows資源管理器依然是使用最廣的程序,Microsoft and AOL 正在進行E-mail第二個階段的測試。 \n \nWhen you forward this e-mail to friends, Microsoft can and will track it (if you are a Microsoft Windows user) for a two week time period. \n噹你把此e-mail轉送給你的朋友時,微軟將跟在兩周內蹤它(如果你是Microsoft Windows 的使用者)。 \nFor every person that you forward this e-mail to, Microsoft will pay you $245.00, for every person that you sent it to that forwards it on, Microsoft will pay you $243.00 and for every third person that receives it, you will be paid $241.00. Within two week! s, Microsoft will contact you for your address and then send you a cheque. \n對於每一個轉發此mail給朋友的人,微軟將會付給你$245。對於每一個你轉發了的人,別人又繼續轉發的人,微軟將付給你$243並且每三個人收到此mail,你將會得及$241的付款。在兩周內,微軟將會聯繫你的地址並給你一張支票! \nDon’t Know True Or False, Just Have a Try \n \nDear Friends, \nPlease do not take this for a junk letter. Bill Gates is sharing his fortune. If you ignore this you will repent later. Microsoft and AOL are now the largest Internet companies and in an effort to make sure that Internet Explorer remains the most widely used program, Microsoft and AOL are running an e-mail beta test. \n \nWhen you forward this e-mail to friends, Microsoft can and will track it (if you are a Microsoft Windows user) for a two week time period. \n \nFor every person that you forward this e-mail to, Microsoft will pay you $245.00, for every person that you sent it to that forwards it on, Microsoft will pay you $243.00 and for every third person that receives it, you will be paid $241.00. Within two week! s, Microsoft will contact you for your address and then send you a cheque.
Scout是Highgroove Studios写的一个很有趣的应用,他提供了一个大的框架,使得其他人可以以插件(集成)的方式实现他的方法(run),进而按照他预定的格式,将采集到的数据发送到其中央服务器,进而可以存储,并以报表的形式展示出来。 \n我大概了看了下起实现方式,和插件的编写方式,其实也挺简单的,其原理也就是在*unix上可以采用crob之类的做定时调度,采集数据(可以使用系统的一些命令,比如ps,top)等等,再把数据组合成他预定义的格式就可以了。 \n看个插件的代码以及我的注释,就很清楚了: \n \n \nRuby代码 \n \n # TODO: use alternate process open to catch STDOUT, STDERR for those \n # processes that use \n #分析: IceskYsl@1sters!(http://iceskysl.1sters.com) \n #这个插件实现的是,定时监控指定的进程,需要的时候重启,并生成报告 \n class KeepProcessRunning < Scout::Plugin \n \n def run \n #预定义返回的数据格式 \n report = {:report => {}, :alerts => [], :memory => {}} \n #取需要监控的进程的名字和重启进程的命令 \n process_to_monitor = @options[:process_name] || "" \n restart_action = @options[:restart_action] || process_to_monitor \n \n # Search all running processes for the process (do not match the grep \n # process nor the locally running scout client). \n #这就是调用系统的ps命令,并grep,看是否有指定的进程存在 \n ps_output = ps auxww | grep <span class="string">"\#{process_to_monitor}"</span><span> | grep -v </span><span class="string">"grep"</span><span> | grep -v </span><span class="string">"scout"</span><span> \n #如果不存在,则根据上面给的重启命令来重启 \n unless process_match = ps_output.to_a.first # process not found \n # attempt to restart the process \n restart_output = <span class="comment">\#{restart_action} \n report[:alerts] << {:subject => "\#{process_to_monitor} is not running. Restart reported: \#{restart_output}"} \n else # process is running \n # if we wanted to parse fields we could: \n # fields = process_match.downcase.split \n report[:report][process_to_monitor] = 1 \n end \n #返回报告 \n return report \n rescue Exception \n { :error => { :subject => "Could not keep the process running.", \n :body => "An exception was thrown: \#{$!.message}" } } \n end \n end \n \n \n \n他采取的“Client Key”来做唯一性校验,也就是说,你必须获得这个“Client Key”,而这个将来可以成为其卖点(可行的方法是分级售卖,比如多少钱的帐号可以监控几个服务器之类的)。 \n仔细一想,这个Idea还真不赖,呵呵~ \n其他的参考资料: \n1、Scout主页:http://scoutapp.com/ \n2、插件编写手册:http://scoutapp.com/plugin_urls/static/creating_a_plugin \n3、rubyinside的报道:http://www.rubyinside.com/scout-a-ruby-powered-web-monitoring-and-reporting-service-825.html
Last week brought some exciting, highly requested new Amazon EC2 features to the community - Elastic IP Addresses, Availability Zones, and User Selectable Kernels.
Elastic IP addresses are static IP addresses designed for dynamic cloud computing. An Elastic IP address is associated with your account, not a particular instance, and you control that address until you choose to explicitly release it. Unlike traditional static IP addresses, however, Elastic IP addresses allow you to mask instance or availability zone failures by programmatically remapping your public IP addresses to any instance associated with your account. Rather than waiting on a data technician to reconfigure or replace your host, or waiting for DNS to propagate to all of your customers, Amazon EC2 enables you to engineer around problems with your instance or software by programmatically remapping your Elastic IP address to a replacement instance.
晚上写完手上的代码,正准备睡觉的时候,收到Amazon的一封mail,以为是S3或EC2的账单呢,打开一看,原来是EC2的好消息. \nGreetings AWS Developers, \n Last week brought some exciting, highly requested new Amazon EC2 features to the community - Elastic IP Addresses, Availability Zones, and User Selectable Kernels. \nwowo,真是个好东西,EC2一直以来都被人诟病之一的就是其IP地址的动态的,也就是当你重启您"镜像"后,你的IP地址会变化,也就是说,你的域名需要才信修改IP指向,或者采用一个老外写的一个插件(忘记脚啥名字了)来动态解析,比较不爽的很.现在EC2终于推出了"静态IP"功能,我粗略的看了下,其和账户是绑定的,也就是你重启自己的"镜像"后,并不失效. \n好东西,EC2会越来越好的... \n \n还是直接看英语的吧,呵呵: \nElastic IP addresses are static IP addresses designed for dynamic cloud computing. An Elastic IP address is associated with your account, not a particular instance, and you control that address until you choose to explicitly release it. Unlike traditional static IP addresses, however, Elastic IP addresses allow you to mask instance or availability zone failures by programmatically remapping your public IP addresses to any instance associated with your account. Rather than waiting on a data technician to reconfigure or replace your host, or waiting for DNS to propagate to all of your customers, Amazon EC2 enables you to engineer around problems with your instance or software by programmatically remapping your Elastic IP address to a replacement instance. \n详细情况请参考:http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1346
2.How to catch Timeout::ERROR ? : http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/170394
\n
3.Ruby's Thread#raise, Thread#kill, timeout.rb, and net/protocol.rb libraries are broken: http://headius.blogspot.com/2008/02/rubys-threadraise-threadkill-timeoutrb.html
\n
4.How to change the Timeout::Error threshold for open_uri : http://www.ruby-forum.com/topic/146676
1sters@IceskYsl:~/sources$ uname -a \nLinux taojer 2.6.18-xen #1 SMP Fri Nov 2 06:14:54 UTC 2007 x86_64 GNU/Linux
\n
然后使用“sudo apt-get install rar”,却发现出错,如下:
\n
\n
1sters@IceskYsl:~/sources$ sudo apt-get install rar \nPassword: \nReading package lists... Done \nBuilding dependency tree... Done \nPackage rar is not available, but is referred to by another package. \nThis may mean that the package is missing, has been obsoleted, or \nis only available from another source \nE: Package rar has no installation candidate
早在我开始使用Ubuntu的时候(7.04)就安装了linux下的rar,这几天在一台新的服务器上上安装的时候,竟然花了这么大的牛劲,呵呵。 \n 先看下版本,如下: \n1sters@IceskYsl:~/sources$ uname -a \nLinux taojer 2.6.18-xen #1 SMP Fri Nov 2 06:14:54 UTC 2007 x86_64 GNU/Linux \n然后使用“sudo apt-get install rar”,却发现出错,如下: \n \n1sters@IceskYsl:~/sources$ sudo apt-get install rar \nPassword: \nReading package lists... Done \nBuilding dependency tree... Done \nPackage rar is not available, but is referred to by another package. \nThis may mean that the package is missing, has been obsoleted, or \nis only available from another source \nE: Package rar has no installation candidate \n \n找不到相应的包,哦,因该是源的问题,查了下Google,很多人说是源的问题,于是乎,胡乱加了一大堆的源,试了下,貌似不好使,再查,找到相应的源,如下: \n \n \nShell代码 \n \n deb http://archive.ubuntu.com/ubuntu dapper universe multiverse; \n deb-src http://archive.ubuntu.com/ubuntu dapper universe multiverse; \n \n \n再使用: \n \nShell代码 \n \n sudo aptitude upgrade \n sudo aptitude install rar unrar \n \n \n \n然后就差不多OK了。 \n参考资料: \n1、http://ubuntuforums.org/showthread.php?t=571440
关于在RUby中调用系统的shell,大家可以参考如下文章( 6 Ways to Run Shell Commands in Ruby: http://pasadenarb.com/2007/03/ruby-shell-commands.html#comment-1886),我就不多废话了.直接看我的相关代码,如下:
\n
\n
\n
Ruby代码
\n\n
local_dir_name=1207667932_2
\n
logger.info("rar a \#{local_dir_name} \#{local_dir_name}")
\n
oo= %x{rar a \#{local_dir_name} \#{local_dir_name}}
尽管Google说会支持其他很多环境,但是现在还只支持python,毫无疑问,Google内部对python的喜爱已经毋庸置疑的。当然,我期待着哪天其可以支持ruby(rails框架或者其他);或者我该抽点时间去学学python了,呵呵。 \n看看他自己的说明: \nRun your web applications on Google's infrastructure. \nGoogle App Engine enables you to build web applications on the same scalable systems that power Google applications. \nNo assembly required. \nGoogle App Engine provides a fully-integrated application environment. \nIt's easy to scale. \nGoogle App Engine makes it easy to build scalable applications that grow from one user to millions of users without infrastructure headaches. \nIt's free to get started. \nEvery Google App Engine application can use up to 500MB of persistent storage and enough bandwidth and CPU for 5 million monthly page views.
早在几天前,就在Gseek上看到关于GoogleAppEngine的介绍,可惜当时去晚了,没有申请到试用帐号,只大略的看了下,发现其实好东西,今天在infoQ上再次看到这个东西的就介绍,再跑过去看看,下载了SDK并看了下他的guider,和演示代码,发现其真的很有前途,是个很有诱惑力的东西。 \n尽管Google说会支持其他很多环境,但是现在还只支持python,毫无疑问,Google内部对python的喜爱已经毋庸置疑的。当然,我期待着哪天其可以支持ruby(rails框架或者其他);或者我该抽点时间去学学python了,呵呵。 \n看看他自己的说明: \nRun your web applications on Google's infrastructure. \nGoogle App Engine enables you to build web applications on the same scalable systems that power Google applications. \nNo assembly required. \nGoogle App Engine provides a fully-integrated application environment. \nIt's easy to scale. \nGoogle App Engine makes it easy to build scalable applications that grow from one user to millions of users without infrastructure headaches. \nIt's free to get started. \nEvery Google App Engine application can use up to 500MB of persistent storage and enough bandwidth and CPU for 5 million monthly page views. \n毫无疑问,如果能大规模的推广开,将会带来很大的web开发热浪,同时Google将在这个里面得到更多的东西,不仅仅限于卖这个服务的费用,还会给google自己的其他份额应用更好的支撑。 \n同时,不可否认,会给亚马逊的S3,EC2,SQS等带来一些竞争,当然,这会使得这个领域更加合理和更多的选择。
"Last night Amazon announced persistent storage on EC2. Now you can create disks in S3 and attach them to EC2 instances. You want a terabyte of storage for your machine, just create it in S3 and mount it."
PS:这次公告中还提及一个新功能: \nAnother feature rolled out last night is snapshots. Need backup or the ability to rollback? Snapshot the instance and it’s on S3, ready to use. You can create new volumes from any particular snapshot. \n \nThese two features make Amazon’s grid computing platform a very nice place for startups to experiment, develop, and build out. All with little or no capital cost.
"Last night Amazon announced persistent storage on EC2. Now you can create disks in S3 and attach them to EC2 instances. You want a terabyte of storage for your machine, just create it in S3 and mount it." \n很多人应该记得,EC2才宣布支持静态IP没几天,今天就看到消息称EC2支持Persistent Storage了,大家应该还记得,EC2发布以来,虽然带给大家无数的方便和快捷,但是其中两个诟病一直被人提及,那就是“不支持固定IP地址”和“没有”Persistent Storage“,这两个诟病使得: \n1、一旦你重启了EC2,你的IP地址就会变化,这就意味着你花了几个小时才解析生效的DNS又无法解析。 \n2、一旦你的EC2重启,你必须及时的备份数据库和数据文件到S3上,以防止重启或者down机丢失数据。 \n而这两个问题,到现在为止,已经全部完善了,EC2基本上很成熟了,剩下一个让国内开发者认为不爽的是,在国内,访问的速度实在不咋地。希望亚马逊有改善的计划,到时,就不用自己买服务器,托管啥的啦,甚至VPS都得靠边站,呵呵,就像我以前说的《RubyOnRails + S3 + EC2 = ? 》,依然好戏。 \n或许是受到Google发布的Google App Engine的刺激,亚马逊才会在最近做这么大的动作,因为Google App Engine号称是亚马逊的EC2,S3,SQS以及SimpleDB的整体方案。对亚马逊有直接的竞争关系。 \n前面一篇文章《Google App Engine,前途无量,充满乐趣 》就说了,这样的竞争,会带来更多的好处,好戏还会有,下一个改进会是什么呢? \nPS:这次公告中还提及一个新功能: \nAnother feature rolled out last night is snapshots. Need backup or the ability to rollback? Snapshot the instance and it’s on S3, ready to use. You can create new volumes from any particular snapshot. \n \nThese two features make Amazon’s grid computing platform a very nice place for startups to experiment, develop, and build out. All with little or no capital cost.
A rails plugin to push things towards component-oriented architecture. Controller logic and views are encapsulated in lightweight cells and can be rendered like render_component.
由于打算将我的第一个开源项目1stlog重构和完善,看了下以前的实现方式,除了用到了很对rails2不支持的方法和插件外(正在着手修改),还用到了Rails中的component的。而这正是被很多railser们告诫要小心的地方,甚至有人说component是evil的,新版1stlog发布在即,我得好好了解下component为什么evil。 \n一、为什么当时选择component \n选择component是根据当时的设计需求来的,1stlog设计的时候是作为一个只有基本blog功能的大框架,而其他的一些个性化功能,需要由其他开发人员或者爱好者来按照一定的规范开发和编写,当时认为,使用component时自简单有效的策略,您可以参考我当时编写”1stlog插件开发指南“。 \n二、为什么说component是邪恶的 \n有人说Rails中的component是邪恶的,千万不要使用,原因呢,还真不清楚,看到有人这么写: \n \nUsing Components \n \n \n \n Components don’t belong in Rails. Don’t use them. They weren’t an \n \n extraction. They weren’t well planned. When you want to use a \n \n component it is probably because you misunderstand them or \n \n really want a partial. Rethink what you’re doing. \n \n The rest of the Rails world has written off components for a \n \n reason and they’ll probably be deprecated by 2.0. Resist. \n \n \n \n也有人拿typo中使用component导致响应很迟钝的数据说明,可以参考“Components may not be evil, but they sure can be slow”,再看看Rails的DHH咋说的呢?哦,他说”Why engines and components are not evil but distracting“ \n这么看来,component并不邪恶了,只是慢一点,有些小问题罢了。 \n三、还用不用? \n竟然大家都持谨慎态度,那么我们还用不用呢?用!但是或许得换个方式用。此话怎么讲?因为有一个既可以实现component功能,又不evil的东西出现了,那就是Cells,何谓Cells?还是看他的自白好了: \n \n \nA rails plugin to push things towards component-oriented architecture. Controller logic and views are encapsulated in lightweight cells and can be rendered like render_component. \n \n哦,看来是个好东西,还想多了解点,看看这些文章吧,"Cells: Bringing Components Back Into Rails 3"或者中文简要版本”插件Cells:把模块化带入Rails 应用中,组件导向轻量级的开发“,还可以看看道喜的简介”Rails框架:组件理念是否重返Rails框架“,或者看看中文的一个简单那的例子”有人用过cell么?“,如果想更深入的了解,可以看看”Ruby Component Web Frameworks“ \n四、还有更好的? \n我是不知道了,您要是知道的话,还请告诉我。 \n参考资料: \n1、http://glu.ttono.us/articles/2006/08/30/guide-things-you-shouldnt-be-doing-in-rails \n2、http://usurffx-gmail-com.javaeye.com/blog/176186 \n3、https://groups.google.com/group/ruby-component-web-frameworks \n4、http://chinaonrails.com/topic/view/1318/1.html \n5、http://www.lycom.de/past/2008/2/14/component-2008-02-14/#comments \n6、http://railsexpress.de/blog/articles/2005/11/18/components-may-not-be-evil-but-they-sure-can-be-slow \n7、http://weblog.rubyonrails.org/2005/11/11/why-engines-and-components-are-not-evil-but-distracting/ \n8、http://rubyforge.org/projects/cells/
\n", "_id"=>794}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"TibetIsXiZang,Tell this to all over the world,Tibet就是西藏!", "body"=>"
Amazon Simple Queue Service (Amazon SQS) offers a reliable, highly scalable, hosted queue for storing messages as they travel between computers. By using Amazon SQS, developers can simply move data between distributed components of their applications that perform different tasks, without losing messages or requiring each component to be always available.
Overview: What is Google Docs Offline? \n \nGoogle Docs now allows you to view and edit your documents offline, without an internet connection. To do all of this, Google Docs uses Google Gears, an open source browser extension that adds offline functionality directly to the browser. Google Docs can be accessed offline by typing http://docs.google.com into your browser or by clicking on the desktop shortcut that is downloaded during the installation process.
早就在Gseek看到GoogleDocs可以离线的消息,但是我的帐户里面一直还没有发现,好歹我也算Dcos的重度使用者,咋一直没看到这个功能呢? \n今天猛然发现,OK了,我等到了,呵呵。 \nOverview: What is Google Docs Offline? \n \nGoogle Docs now allows you to view and edit your documents offline, without an internet connection. To do all of this, Google Docs uses Google Gears, an open source browser extension that adds offline functionality directly to the browser. Google Docs can be accessed offline by typing http://docs.google.com into your browser or by clicking on the desktop shortcut that is downloaded during the installation process. \n挺好的,可以彻底不用Word和OpenOffice咯。三者比较下,我还是喜欢GoogleDocs的这个简洁和方便,不过不得不说几句,上次的改变,把那结果H1 H2 H3几个放到下拉菜单,不是好的用户体验,每次都多点一下,囧~ \n有了离线后,以后带着本本就不怕没网络咯,Good~
We've often told you that one of our goals is to drive down costs continuously and to pass those savings on to you. We have been able to reduce our costs for data transfer, so we're pleased to announce that we're lowering our pricing for data transfer, effective May 1, 2008. You'll notice below that we've reduced price at every existing usage tier of transfer out, as well as added an additional tier for the heaviest users.
\n
Current data transfer price (through April 30, 2008) \n$0.100 per GB - data transfer in \n$0.180 per GB - first 10 TB / month data transfer out \n$0.160 per GB - next 40 TB / month data transfer out \n$0.130 per GB - data transfer out / month over 50 TB
\n
Data transfer "in" and "out" refers to transfer into and out of the Amazon service. Data transferred between Amazon EC2 and Amazon S3-US, Amazon SimpleDB and Amazon SQS is free of charge (i.e., $0.00 per GB). Data transferred between Amazon EC2 and Amazon S3-Europe will be charged at regular rates.
\n
New data transfer price (effective May 1, 2008) \n$0.100 per GB - data transfer in \n$0.170 per GB - first 10 TB / month data transfer out \n$0.130 per GB - next 40 TB / month data transfer out \n$0.110 per GB - next 100 TB / month data transfer out \n$0.100 per GB - data transfer out / month over 150 TB
\n
Data transfer "in" and "out" refers to transfer into and out of the Amazon service. Data transferred between Amazon EC2 and Amazon S3-US, Amazon SimpleDB and Amazon SQS is free of charge (i.e., $0.00 per GB). Data transferred between Amazon EC2 and Amazon S3-Europe will be charged at regular rates.
\n
The result of this pricing change is that all customers will see a reduction in the price of transfer out. For example, a customer transferring 50TB a month will save 16% and a customer transferring 500TB a month will save 26% on transfer with the new pricing. Please see http://aws.amazon.com for full pricing information for each service.
晚上收到Amazon的AWS的邮件,说降价了,哈,真是好消息,前台在写<Google App Engine,前途无量,充满乐趣>的时候,还说到"同时,不可否认,会给亚马逊的S3,EC2,SQS等带来一些竞争,当然,这会使得这个领域更加合理和更多的选择。",不想到,这么快,Amazon就有动作了,真是好消息,直接看原文吧,总觉得用中文把E文再重复一遍挺浪费的,也比较别扭,总感觉有些外文不好使用中文表述出来,呵呵. \n=====================start=================== \n \nDear Amazon Web Services developers, \nWe've often told you that one of our goals is to drive down costs continuously and to pass those savings on to you. We have been able to reduce our costs for data transfer, so we're pleased to announce that we're lowering our pricing for data transfer, effective May 1, 2008. You'll notice below that we've reduced price at every existing usage tier of transfer out, as well as added an additional tier for the heaviest users. \nCurrent data transfer price (through April 30, 2008) \n$0.100 per GB - data transfer in \n$0.180 per GB - first 10 TB / month data transfer out \n$0.160 per GB - next 40 TB / month data transfer out \n$0.130 per GB - data transfer out / month over 50 TB \nData transfer "in" and "out" refers to transfer into and out of the Amazon service. Data transferred between Amazon EC2 and Amazon S3-US, Amazon SimpleDB and Amazon SQS is free of charge (i.e., $0.00 per GB). Data transferred between Amazon EC2 and Amazon S3-Europe will be charged at regular rates. \nNew data transfer price (effective May 1, 2008) \n$0.100 per GB - data transfer in \n$0.170 per GB - first 10 TB / month data transfer out \n$0.130 per GB - next 40 TB / month data transfer out \n$0.110 per GB - next 100 TB / month data transfer out \n$0.100 per GB - data transfer out / month over 150 TB \nData transfer "in" and "out" refers to transfer into and out of the Amazon service. Data transferred between Amazon EC2 and Amazon S3-US, Amazon SimpleDB and Amazon SQS is free of charge (i.e., $0.00 per GB). Data transferred between Amazon EC2 and Amazon S3-Europe will be charged at regular rates. \nThe result of this pricing change is that all customers will see a reduction in the price of transfer out. For example, a customer transferring 50TB a month will save 16% and a customer transferring 500TB a month will save 26% on transfer with the new pricing. Please see http://aws.amazon.com for full pricing information for each service. \nSincerely, \nThe Amazon Web Services Team \n================end-================== \n当然了,你也可以到Amazon官方网站上看到这个消息,"Announcement: Lower Data Transfer Costs" \nAWS越来越成熟,在继支持静态IP和固定存储后,这又是一个大的变化,如果啥时能使得国内的访问速度提上去的话,对国内的WEB人员将是最大的幸福了.继续期待... \n
在U盘价格卖到“白菜”一样的时候,你拿U盘来做什么,又可以做什么,你有想过把一个linux装到U盘里,打造一个随身携带的“生产环节”呢。 \n设想下这么个场景,你是公司业务人员,受客户邀请和上司器重,去一个你并不熟悉的客户环境中讲解客户需要的产品,当你兴致勃勃的到达客户处时,却发现无法联上演示离不开的互联网来连到您的DEMO服务器,或者网路相当糟糕,让你不得不点一个按钮就停下里尴尬的等待,或者其他等等等情况。 \n如果我告诉你,可以把Puppy Linux 4.00打造成这套演示环境(小生产环境)随手带在U盘里,随时随地的演示,你会不会心动? \nOk,先看看“随身系统——Puppy Linux 4.00 初体验”,如何,挺不错吧,想自己做一个么,看“将 Puppy Linux 4.00 安装在U盘里 打造随身系统”,还想了解更多,看“E-PUP Linux 中文项目(Puppy Linux 中文版)您高效实用的小型Linux发行版”和"Puppy Linux Discussion Forum“。 \n恩,差不多了,我想要的是一个带有Linux、Mysql,Ruby,Rails,gems,mogrels,nginx的小生产环境即可。至于开发环境下的JAVA,Netbeans等就无所谓了。有人能已经实践过了么,共享 :)
虽然在ubuntu上的rails里面使用过很多次的RMagick,但是却一直没有在单独的ruby \nscript中使用过,这次需要单独使用来画一些图片,于是写了一段代码,但是却跑不起来,老是报"LoadError: no such file to load -- RMagick "错误,查了些资料,搞清楚原因,记录如下: \n1.注意大小写敏感度 \n在windows或者mac上,不敏感大小写,可以:require 'rmagick'```</p> \n<p>但是在linux上,却不行,需要写:require 'RMagick'```</p> \n<p>````否则您可能得到如下错误:```</p> \n<p>```` MissingSourceFile: no such file to load -- rmagick```</p> \n<p><strong>2.单独ruby中需要引用````rubygems```</strong></p> \n<p>````require 'rubygems'<br /> \nrequire 'RMagick'```</p> \n<p>````如果不引用rubygems,可能会看到如下错误:</p> \n<p>require': no such file to load -- rmagick (LoadError)</p> \n<p>或者<br /> \n</p> \n<p>`require': no such file to load -- RMagick (LoadError)` \n参考文档: \n \n 在Ubuntu上安装RMagic:http://www.hhtong.com/blog1/articles/2006/11/11/ubuntu20061111-install-rmagic \n Ruby on Rails RMagic:http://www.mysmallventures.com/ruby-on-rails-rmagick-linux-issues/
看到http://chinaonrails.com/topic/view/1620.html上说DH已经采用了mod_rails(Passenger ),但是没看到效果,按照其介绍文章"Introducing Passenger for Ruby on Rails",登录我的DH帐户后,果然发现已经支持了,见我抓的图片。
Cross Site Reference Forgery works by including malicious code or a link in a page that accesses a web application that the user is believed to have authenticated. If the session for that web application has not timed out, an attacker may execute unauthorized commands. \n
This plugin works by extending all forms created with #form_tag (including #form_for, #form_remote_tag, and #remote_form_for) by adding a token unique to each session id. It also adds a filter that checks all non-GET requests for the existence of this token. This should ensure that all non-GET actions have been correctly submitted from a form on your site.```", "created_at"=>2008-05-22 13:28:39 UTC, "updated_at"=>2012-06-24 15:47:02 UTC, "body_html"=>"
前面一篇文章《CSRF: 不要低估了我的危害和攻击能力》说到了CSRF是相当恐怖的,前面也说了,在Rails2中可以设置安全码来进一步的防止,另外,今天给大家分享一个插件,是csrf_killer,详细的介绍请参考README。 \n<strong>CsrfKiller</strong><br />==========<br /><br />This plugin helps protect against possible CSRF attacks. If you don't know what a Cross Site Request Forgery attack is, check these links:<br /><br />* http://isc.sans.org/diary.html?storyid=1750<br />* http://en.wikipedia.org/wiki/Cross-site_request_forgery<br /><br />This plugin works by extending all forms created with #form_tag (including #form_for, #form_remote_tag, and #remote_form_for) by adding<br />a token unique to each session id. It also adds a filter that checks all non-GET requests for the existence of this token. This should<br />ensure that all non-GET actions have been correctly submitted from a form on your site.`
For use appcfg.pyto upload you app datas behind an HTTP proxy in Google App Engine \n,or use with gems, cpan,etc. Inside cmd.exe, typed: \n \nset HTTP_proxy=http://my.proxy.server:8000
For use appcfg.py to upload you app datas behind an HTTP proxy in Google App Engine \n,or use with gems, cpan,etc. Inside cmd.exe, typed: \n \nset HTTP_proxy=http://my.proxy.server:8000
WWW::Mechanize:The Mechanize library is used for automating interaction with websites. Mechanize automatically stores and sends cookies, follows redirects, can follow links, and submit forms. Form fields can be populated and submitted. Mechanize also keeps track of the sites that you have visited as a history.
有的时候需要去一个URL上取一些文字或者简介啥的下来,或者取一些自己需要的内容下来,这个时候虽然可以直接使用http-net连到URL上,取回内容,然后自己解析等,但是这在一定程度上算是网络爬虫的范畴。 \nWWW::Mechanize:The Mechanize library is used for automating interaction with websites. Mechanize automatically stores and sends cookies, follows redirects, can follow links, and submit forms. Form fields can be populated and submitted. Mechanize also keeps track of the sites that you have visited as a history. \n啊哈,貌似不错,在这个上面构建自己的爬虫应该简单的多了,可以使用它模拟浏览器的行为,但是需要注意的一点是,他模拟浏览器的时候会按照浏览器一样记住“历史”,如果你不设定历史条数,wowo,请留意你的内存吧,详细的请查看“ashchan”的文章”Mechanize的内存问题“。 \n再看段例子吧,真的很简单,他里面使用的是hpricot,大家都比较熟悉了,呵呵,看段代码,如下: \n \n \nGoogle \n \n require 'rubygems' \n require 'mechanize' \n \n agent = WWW::Mechanize.new \n agent.user_agent_alias = 'Mac Safari' \n page = agent.get("http://www.google.com/") \n search_form = page.forms.with.name("f").first \n search_form.q = "Hello" \n search_results = agent.submit(search_form) \n puts search_results.body \n \n \n简单吧,其他的请参考他的“EXAMPLES.txt”,其他信息请到其“Documentation”页面上查看吧。
恩,挺直接的,就是: \nALTER TABLE table_name ADD column_name ,貌似没啥问题,看来是MySQL的问题,和Rails无关,Google下资料,发现“change index or add column in a very big table”和我遇到的问题基本一致,但是其回复中并没有说道如何解决或者如何提升性能。 \n继续Google,找到“Why MySQL could be slow with large tables ?”这篇文章,谈到了为什么说MySQL在大表的时候会很慢,其观点是和表的结构设计有关。其有人回复说“I have a table with 35 mil records. When I wanted to add a column (alter table) I would take about 2 days.”,和我的问题一致,这个文章很好,建议各位有时间的仔细看看。 \n但是我的这个数据表结构并不复杂,如何能提升其速度呢,还在研究中,有了思路会再更新上来。 \n
项目使用Rails开发,DB采用的是MySQL,有一个不算复杂的表A,记录数差不多50W条数据,现在想增加一个列属性,于是很自然的想到Rails中的add_column,然后rake迁移数据,但是等了很久未见执行完毕,诡异。 \n初步判断是由于表里的记录太多了,查下add_column是怎杨的,如下: \n \nRuby代码 \n \n # File activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 121 \n 121: def add_column(table_name, column_name, type, options = {}) \n 122: add_column_sql = "ALTER TABLE \#{table_name} ADD \#{quote_column_name(column_name)} \#{type_to_sql(type, options[:limit], options[:precision], options[:scale])}" \n 123: add_column_options!(add_column_sql, options) \n 124: execute(add_column_sql) \n 125: end \n \n \n恩,挺直接的,就是: \nALTER TABLE table_name ADD column_name ,貌似没啥问题,看来是MySQL的问题,和Rails无关,Google下资料,发现“change index or add column in a very big table”和我遇到的问题基本一致,但是其回复中并没有说道如何解决或者如何提升性能。 \n继续Google,找到“Why MySQL could be slow with large tables ?”这篇文章,谈到了为什么说MySQL在大表的时候会很慢,其观点是和表的结构设计有关。其有人回复说“I have a table with 35 mil records. When I wanted to add a column (alter table) I would take about 2 days.”,和我的问题一致,这个文章很好,建议各位有时间的仔细看看。 \n但是我的这个数据表结构并不复杂,如何能提升其速度呢,还在研究中,有了思路会再更新上来。
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mys
\n\n
\n
ERROR: While executing gem ... (RuntimeError) ERROR: Failed to build gem native extension. Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mys```\n
解决方案 \n1.先运行
\n
\n\n
$ sudo apt-get install libmysqlclient15-dev
\n\n
\n
$ sudo apt-get install libmysqlclient15-dev```\n
注意上面安装的库名为libmysqlclient15-dev而非libmysqlclient5-dev \n \n2.再运行 \nsudo gem install mysql
昨天看到caiwangqin在CoR上发了一篇帖子说“RubyOnRails 2.1 what's new”这本书原文是葡萄牙的,由Brazilian社区翻译为英文,希望能有人组织翻译成中文版。 \n我向来希望把自己了解的东西写下里,记录成Doc文档分享给其他的人,如果你经常关注我的blog,应该了解;于是花了中午午休的时候,按照以往的经验做了一份协作约定文档《协作翻译: Ruby On Raisl 2.1新特性(第二版)》,然后翻译了索引篇《Ruby On Raisl 2.1新特性介绍》和第一章《第1章: 概述(Introduction)》,发布给其他成员。 \n紧接着我有挑选了几篇感兴趣的翻译,其他成员积极性相当高,仅仅一下午,所有14章全部领取完毕,晚上看GoogleDoc发现大家都在辛苦工作,实在感动,谢谢各位。 \n再次感受到社区的力量,很多朋友一般是不怎么联系的,但是这事情一发动就得到大家的积极响应,人多力量果然很大。 \n相信,这本书很快就可以和大家见面了,:) \n这是个不错的模式,希望以后还能有机会找到好资料,大家协作完成。
\n", "_id"=>848}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"install and configuration vsftpd ftp service on Ubuntu Linux", "body"=>"
Q. How do I install Ubuntu ftp service or server?
\n
A. Ubuntu Linux comes with various ftp servers to setup FTP service such as: \n=> proftpd - Versatile, virtual-hosting FTP daemon
\n
=> vsftpd - The Very Secure FTP Daemon
\n
=> ftpd - FTP server
\n
=> wu-ftpd - powerful and widely used FTP server
\n
=> wzdftpd - A portable, modular, small and efficient ftp server
\n
=> pure-ftpd - Pure-FTPd FTP server
\n
其中vsftpd相当优秀,其配置简单方便,且非常安全,如下是其主页上的说明:
\n
vsftpd is the Very Secure File Transfer Protocol Daemon. The server can be launched via a super-server such as inetd or xinetd. Alternatively, vsftpd can be launched in standalone mode, in which case vsftpd itself will listen on the network.
Type apt-get command to install vsftpd \n````$ sudo apt-get install vsftpd``` \nOutput:
\n
\n``Password: Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: vsftpd 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 121kB of archives. After unpacking 438kB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com edgy/main vsftpd 2.0.4-0ubuntu5 [121kB] Fetched 121kB in 0s (246kB/s) Selecting previously deselected package vsftpd. (Reading database ... 31396 files and directories currently installed.) Unpacking vsftpd (from .../vsftpd_2.0.4-0ubuntu5_amd64.deb) ... Setting up vsftpd (2.0.4-0ubuntu5) ... Adding system user `ftp' with uid 106... Adding new user `ftp' (106) with group `nogroup'. Not creating home directory `/home/ftp'. * Starting FTP server: vsftpd```\n
\n### Step # 2: Configure /etc/vsftpd.conf\n
The default vsftpd configuration file is /etc/vsftpd.conf. You need to edit this file using text editor such as vi: \n````$ sudo vi /etc/vsftpd.conf```
\n
Add the following line (uncomment line) to the vsftpd configuration file: \n````local_enable=YES``` \nAbove config directive will allow local users to log in via ftp
\n
If you would like to allow users to upload file, add the following to the file: \n````write_enable=YES```
\n
For security you may restrict local users to their home directories. Add the following to the file: \n````chroot_local_user=YES```
\n
Save and close the file.
\n### Step # 3: Restart vsftpd\n
To restart vsftpd type the command : \n````$ sudo /etc/init.d/vsftpd restart``` \nOutput:
\n``* Stopping FTP server: vsftpd [ ok ] * Starting FTP server: vsftpd [ ok ]
add following rules to your iptables script. Assuming that default incoming policy is drop. If protocol is TCP and destination port is 21 (ftp):
There are a large number of other configuration options available for vsftpd that can be used to fine tune ftp server. Read vsftpd.conf man page by typing following command: \n````$ man vsftpd.conf```
Q. How do I install Ubuntu ftp service or server? \nA. Ubuntu Linux comes with various ftp servers to setup FTP service such as: \n=> proftpd - Versatile, virtual-hosting FTP daemon \n=> vsftpd - The Very Secure FTP Daemon \n=> ftpd - FTP server \n=> wu-ftpd - powerful and widely used FTP server \n=> wzdftpd - A portable, modular, small and efficient ftp server \n=> pure-ftpd - Pure-FTPd FTP server \n其中vsftpd相当优秀,其配置简单方便,且非常安全,如下是其主页上的说明: \nvsftpd is the Very Secure File Transfer Protocol Daemon. The server can be launched via a super-server such as inetd or xinetd. Alternatively, vsftpd can be launched in standalone mode, in which case vsftpd itself will listen on the network. \n=> Default ftp port : 21 \n=> Default configuration file : /etc/vsftpd.conf \nQ:如何安装vsftpd \n很简单,即可搞,如下:
\n\n
Step # 1: Install vsftpd
\n\n
Type apt-get command to install vsftpd \n`$ sudo apt-get install vsftpd \nOutput: \n \nPassword:<br />Reading package lists... Done<br />Building dependency tree<br />Reading state information... Done<br />The following NEW packages will be installed:<br /> vsftpd<br />0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.<br />Need to get 121kB of archives.<br />After unpacking 438kB of additional disk space will be used.<br />Get:1 http://us.archive.ubuntu.com edgy/main vsftpd 2.0.4-0ubuntu5 [121kB]<br />Fetched 121kB in 0s (246kB/s)<br />Selecting previously deselected package vsftpd.<br />(Reading database ... 31396 files and directories currently installed.)<br />Unpacking vsftpd (from .../vsftpd_2.0.4-0ubuntu5_amd64.deb) ...<br />Setting up vsftpd (2.0.4-0ubuntu5) ...<br />Adding system user `ftp' with uid 106...<br />Adding new user `ftp' (106) with group `nogroup'.<br />Not creating home directory `/home/ftp'.<br /> * Starting FTP server: vsftpd`
\n\n
Step # 2: Configure /etc/vsftpd.conf
\n\n
The default vsftpd configuration file is /etc/vsftpd.conf. You need to edit this file using text editor such as vi: \n$ sudo vi /etc/vsftpd.conf```</strong></p> \n<p>Add the following line (uncomment line) to the vsftpd configuration file:<br /> \n<strong>local_enable=YES</strong><br /> \nAbove config directive will allow local users to log in via ftp</p> \n<p>If you would like to allow users to upload file, add the following to the file:<br /> \n<strong>write_enable=YES</strong></p> \n<p>For security you may restrict local users to their home directories. Add the following to the file:<br /> \n<strong>chroot_local_user=YES` \nSave and close the file.
\n\n
Step # 3: Restart vsftpd
\n\n
To restart vsftpd type the command : \n$ sudo /etc/init.d/vsftpd restart```</strong><br /> \nOutput:</p> \n``* Stopping FTP server: vsftpd [ ok ]<br /> * Starting FTP server: vsftpd [ ok ]<br /><br />add following rules to your iptables script. Assuming that default<br />incoming policy is drop. If protocol is TCP and destination port is 21<br />(ftp):<br /><br /><em>iptables -A INPUT -p tcp -m tcp --dport 21 -j ACCEPT</em><br /><br />See - <a href="http://www.cyberciti.biz/faq/iptables-open-ftp-port-21/">How do I open open ftp port 21 using iptables</a> for more information. \nThere are a large number of other configuration options available for vsftpd that can be used to fine tune ftp server. Read vsftpd.conf man page by typing following command: \n`$ man vsftpd.conf \n参考文档:<br />1、http://www.cyberciti.biz/faq/ubuntu-vsftpd-ftp-service-server/<br />2、http://school.cfan.com.cn/system/unix/2008-06-16/1213603744d188509.shtml`
有人问,如何在Rails的控制器中取得URL中的锚点的值,这个需求比较奇特,以前没搞过,于是google了一把,在“Getting the # value”这个帖子看到有人有类似的问题,他说出了在controller中直接取不到的原因是“For normal links/urls the #anchor is a client side feature and is often not even sent to the server as part of a request.”,恩,确实直接取不到,只能使用类似JS的方法来取了,因为其没有将URL全部提交到服务端,所以是无法取值的。
有人问,如何在Rails的控制器中取得URL中的锚点的值,这个需求比较奇特,以前没搞过,于是google了一把,在“Getting the # value”这个帖子看到有人有类似的问题,他说出了在controller中直接取不到的原因是“For normal links/urls the #anchor is a client side feature and is often not even sent to the server as part of a request.”,恩,确实直接取不到,只能使用类似JS的方法来取了,因为其没有将URL全部提交到服务端,所以是无法取值的。 \n另外,看了下Rails中生成anchor的方法比较简单,如下: \n \n \nRuby代码 \n \n <%= url_for(:action => 'play', :anchor => 'player') %> \n # => /messages/play/#player \n \n <%= url_for(:action => 'checkout', :anchor => 'tax&ship') %> \n # => /testing/jump/#tax&ship \n \n <%= url_for(:action => 'checkout', :anchor => 'tax&ship', :escape => false) %> \n # => /testing/jump/#tax&ship \n \n \n详细的请参考API:ActionView::Helpers::UrlHelper
\n", "_id"=>852}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["linux"], "comments_count"=>0, "category_id"=>7, "title"=>"linux下相关信息查看", "body"=>"有的时候需要对服务器信息做比较详细的了解,需要查看一些信息,整理如下:\r\n\r\n1、Java版本(JDK)\r\n\r\n$ java -version\r\njava version \"1.4.2_11\"\r\nJava(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_11-b06)\r\nJava HotSpot(TM) Client VM (build 1.4.2_11-b06, mixed mode)\r\n\r\n2、weblogic版本\r\n\r\n查看weblogic的版本信息,可以在bea\\logs目录下的log.txt中查到版本信息,如下:\r\n\r\n$ cat log.txt\r\n2004-10-20 15:00:58 -- install \"WebLogic Platform\" 8.1.3.0 at /opt/bea/weblogic81\r\nrelease 8.1.3.0 [Added]\r\n\r\n3、Oracle版本\r\n\r\n(1)用客户端连接到数据库,执行select * from v$instance查看version项\r\n(2)select * from product_component_version\r\n(3)或查询V$VERSION查看组件级信息\r\n\r\n4、内核\r\n
$ uname -a\r\nLinux oj-web03 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux
\r\n
[iceskysl@oj-web03 logs]$ cat /proc/version\r\nLinux version 2.4.21-27.ELsmp (bhcompile@bugs.build.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47)) #1 SMP Wed Dec 1 21:59:02 EST 20045、内存信息$ cat /proc/meminfo\r\n$ free -M6、CPU信息$cat /proc/cpuinfo7、硬盘信息\r\n$df\r\n\r\n
(1)用客户端连接到数据库,执行select * from v$instance查看version项 \n(2)select * from product_component_version \n(3)或查询V$VERSION查看组件级信息
\n\n
4、内核 \n$ uname -a \nLinux oj-web03 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux \n[iceskysl@oj-web03 logs]$ cat /proc/version \nLinux version 2.4.21-27.ELsmp (bhcompile@bugs.build.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47)) #1 SMP Wed Dec 1 21:59:02 EST 20045、内存信息$ cat /proc/meminfo \n$ free -M6、CPU信息$cat /proc/cpuinfo7、硬盘信息 \n$df
\n\n", "_id"=>853}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Security"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["ruby", "安全", "漏洞"], "comments_count"=>0, "category_id"=>8, "title"=>"Ruby暴出大量严重漏洞!", "body"=>"Drew Yao at Apple uncovered a handful of nasty security vulnerabilities affecting all current versions of Ruby. The details are still under wraps because an attacker can DoS you or possibly execute arbitrary code—holy crap! Better upgrade sooner than later.\n\nAccording to the official Ruby security advisory, the vulnerable Rubies are:\n\n* 1.8.4 and earlier\n* 1.8.5-p230 and earlier\n* 1.8.6-p229 and earlier\n* 1.8.7-p21 and earlier\n\nThose of us running Ruby 1.8.4 or earlier must upgrade to 1.8.5 or later for a fix. Those on 1.8.5-7 can grab the latest patchlevel release for a fix.\n\n(Please note: Ruby 1.8.7 breaks backward compatibility and is only compatible with Rails 2.1 and later, so don’t go overboard!)\n虽然暂时还没看到具体的细节公布出来,也没看到0day放出来,但是从其描述上不难看出,这些bug是ruby一致以来都有的,或许还有更多的bug,ruby走向成熟,离不开这样的检验。", "created_at"=>2008-06-25 06:05:42 UTC, "updated_at"=>2012-06-24 15:47:02 UTC, "body_html"=>"
Drew Yao at Apple uncovered a handful of nasty security vulnerabilities affecting all current versions of Ruby. The details are still under wraps because an attacker can DoS you or possibly execute arbitrary code—holy crap! Better upgrade sooner than later.
\n\n
According to the official Ruby security advisory, the vulnerable Rubies are:
\n\n
\n
1.8.4 and earlier
\n
1.8.5-p230 and earlier
\n
1.8.6-p229 and earlier
\n
1.8.7-p21 and earlier
\n
\n\n
Those of us running Ruby 1.8.4 or earlier must upgrade to 1.8.5 or later for a fix. Those on 1.8.5-7 can grab the latest patchlevel release for a fix.
\n\n
(Please note: Ruby 1.8.7 breaks backward compatibility and is only compatible with Rails 2.1 and later, so don’t go overboard!) \n虽然暂时还没看到具体的细节公布出来,也没看到0day放出来,但是从其描述上不难看出,这些bug是ruby一致以来都有的,或许还有更多的bug,ruby走向成熟,离不开这样的检验。
\n", "_id"=>855}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["rsync"], "comments_count"=>0, "category_id"=>9, "title"=>"同步利器rsync", "body"=>"rsync is a program that copies file from one location to another, with it you can make backups of your files, synchronize data on different locations and computers. It is commonly used by unix users to keep a safe backup of their files and is often recommended as the simplest solution for backups and safety copys.\r\n\r\n参考资料:\r\n\r\n1.rsync的安装和使用\r\n\r\n2. rsync", "created_at"=>2008-06-25 19:58:32 UTC, "updated_at"=>2012-06-24 15:47:02 UTC, "body_html"=>"
rsync is a program that copies file from one location to another, with it you can make backups of your files, synchronize data on different locations and computers. It is commonly used by unix users to keep a safe backup of their files and is often recommended as the simplest solution for backups and safety copys.
A gravatar, or globally recognized avatar, is quite simply an avatar image that follows you from weblog to weblog appearing beside your name when you comment on gravatar enabled sites. Avatars help identify your posts on web forums, so why not on weblogs?
\r\n看明白了么,就是一个你输入自己的Email,然后上传自己的图片标识,然后在其他支持 Gravatars的网站(blog居多)中发表评论的时候输入自己的Email地址,就可以在Gravatars上找到其对应的图片来显示了。\r\n\r\n这确实是个不错的Idea,相当简单,但是也做得有声有色的,有点意思。\r\n\r\n使用也很方便,其在“How the URL is constructed”上介绍了其URL的组成,中可以这么使用(来源Gravatars on Rails):\r\n\r\n\r\n\r\n1、首先在````application_helper.rb中增加一个helper方法```\r\n
这个世界有意思,多大的idea都可以做成网站,以前看过缩址的网站,现在有看到一个省份标识的网站, Gravatars,看他的介绍: \nA gravatar, or globally recognized avatar, is quite simply an avatar image that follows you from weblog to weblog appearing beside your name when you comment on gravatar enabled sites. Avatars help identify your posts on web forums, so why not on weblogs? \n看明白了么,就是一个你输入自己的Email,然后上传自己的图片标识,然后在其他支持 Gravatars的网站(blog居多)中发表评论的时候输入自己的Email地址,就可以在Gravatars上找到其对应的图片来显示了。
\n\n
这确实是个不错的Idea,相当简单,但是也做得有声有色的,有点意思。
\n\n
使用也很方便,其在“How the URL is constructed”上介绍了其URL的组成,中可以这么使用(来源Gravatars on Rails):
\n", "_id"=>865}])
+MONGODB iceylog_development['categories'].find({:_id=>3}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>3}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Rails: How to use helper inside a controller & model", "body"=>"前几天一个朋友问我如何在Controller中使用helper,我当时说helper是view层的东西,C层没法使用,当时有点忙,虽然知道这个说法也过得去,但是一棍子打死的说法肯定不对。\r\n\r\n今天另外一个朋友问我如何在Model里面使用helper,我开始也说没法使用,并说以前我都是直接在model里面在copy一遍helper的东西。然后还是觉得应该是可以使用的,于是google到一篇tips,但是其访问不了了,还好使用google caceh还是看到了其内容,现在记录如下:\r\n\r\nThis is an easy to use any helpers that rails provides in any other place besides views and view helpers\r\n
\r\n
Ruby代码
\r\n\r\n\t
# create a new file inside lib/ and call it helpers.rb
\r\n\t
# paste the following:
\r\n\t
\r\n\t
def help
\r\n\t
Helper.instance
\r\n\t
end
\r\n\t
\r\n\t
class Helper
\r\n\t
include Singleton
\r\n\t
# look inside ActionView::Helpers to include any other helpers that you might need
if Donkey.find_fit_donkeys.size == APP_SETTINGS['max_fit_donkeys']
\r\n\t
flash_error \"The maximum of \#{help.pluralize(APP_SETTINGS['max_fit_donkeys'], 'donkey')} has been reached.\"
\r\n\t
redirect_to_index
\r\n\t
end
\r\n\t
end
\r\n\r\n
\r\nPS:Don't use the method name \"helper\" because Rails already uses that. Just \"help\" works fine.", "created_at"=>2008-07-10 08:33:29 UTC, "updated_at"=>2012-06-24 15:47:02 UTC, "body_html"=>"
This is an easy to use any helpers that rails provides in any other place besides views and view helpers \n \nRuby代码 \n \n # create a new file inside lib/ and call it helpers.rb \n # paste the following: \n \n def help \n Helper.instance \n end \n \n class Helper \n include Singleton \n # look inside ActionView::Helpers to include any other helpers that you might need \n include ActionView::Helpers::DateHelper \n include ActionView::Helpers::TextHelper \n end \n \n # then in any model or controller: \n require 'lib/helpers' \n \n # to use: \n # help.name_of_helper \n # EX: help.pluralize 10, "person" \n \n \n然后又找到一篇类似的文档:http://snippets.dzone.com/posts/show/1799,摘个方法如下: \n \nRuby代码 \n \n def check_for_max_donkeys \n if Donkey.find_fit_donkeys.size == APP_SETTINGS['max_fit_donkeys'] \n flash_error "The maximum of \#{help.pluralize(APP_SETTINGS['max_fit_donkeys'], 'donkey')} has been reached." \n redirect_to_index \n end \n end \n \n \nPS:Don't use the method name "helper" because Rails already uses that. Just "help" works fine.
puts \"I am fun2 from Mixin1. I’ll call a member function of the class which includes me\"
\r\n\t
mem_fun
\r\n\t
end
\r\n\t
\r\n\t
def fun3
\r\n\t
puts \"I am fun3 from Mixin1. I’ll puts out a member variable of the class which includes me\"
\r\n\t
puts @mem_var
\r\n\t
end
\r\n\t
end
\r\n\t
\r\n\t
class A
\r\n\t
include Mixin1
\r\n\t
def mem_fun
\r\n\t
puts \"I am a member fun of class A\"
\r\n\t
end
\r\n\t
\r\n\t
def initialize
\r\n\t
@mem_var =\"I am a member varaible of class A\"
\r\n\t
end
\r\n\t
end
\r\n\r\n
\r\n调用一下试试看:\r\n
\r\n
Ruby代码
\r\n\r\n\t
a = A.new
\r\n\t
a.fun1
\r\n\t
a.fun2
\r\n\t
a.fun3
\r\n\r\n
\r\n结果如下:\r\nI am fun1 from Mixin1\r\nI am fun2 from Mixin1. I’ll call a member function of the class which includes me\r\nI am a member fun of class A\r\nI am fun3 from Mixin1. I’ll puts out a member variable of the class which includes me\r\nI am a member varaible of class A\r\n\r\n很明显了,不赘述。\r\n\r\n参考文档:\r\nhttp://thinkinginruby.javaeye.com/blog/148967\r\nhttp://my.donews.com/idlecat/2006/10/21/UDDxaYBkNCABNXNVgmIMuMwuKJMHiRXduBBu/\r\nhttp://www.juixe.com/techknow/index.php/2006/06/15/mixins-in-ruby/", "created_at"=>2008-07-10 10:01:42 UTC, "updated_at"=>2012-06-24 15:47:02 UTC, "body_html"=>"
在Ruby中,我们可以把一个模块混入(Mixin)到对象中,从而达到类似多重继承的效果。看几个例子: \n \nRuby代码 \n \n module Mixin1 \n def fun1 \n puts "I am fun1 from Mixin1" \n end \n \n def fun2 \n puts "I am fun2 from Mixin1. I’ll call a member function of the class which includes me" \n mem_fun \n end \n \n def fun3 \n puts "I am fun3 from Mixin1. I’ll puts out a member variable of the class which includes me" \n puts @mem_var \n end \n end \n \n class A \n include Mixin1 \n def mem_fun \n puts "I am a member fun of class A" \n end \n \n def initialize \n @mem_var ="I am a member varaible of class A" \n end \n end \n \n \n调用一下试试看: \n \nRuby代码 \n \n a = A.new \n a.fun1 \n a.fun2 \n a.fun3 \n \n \n结果如下: \nI am fun1 from Mixin1 \nI am fun2 from Mixin1. I’ll call a member function of the class which includes me \nI am a member fun of class A \nI am fun3 from Mixin1. I’ll puts out a member variable of the class which includes me \nI am a member varaible of class A
\n", "_id"=>868}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>9, "title"=>"Protocol Buffers:更简洁有效的数据交换格式!", "body"=>"“Protocol Buffers are a way of encoding structured data in an efficient yet extensible format. Google uses Protocol Buffers for almost all of its internal RPC protocols and file formats.”\r\n\r\nGoogle公司与本月初宣布其内部数据交换格式Protocol Buffers正式开源,基于Apache软件证书2.0发布,相关文档、实例和代码已经可以从Google Code上 访问到。\r\n\r\nProtocol Buffers被定义为一种数据描述语言(Data Description Language,DDL),广泛的应用于Google内部,用于结构化数据的描述、传输和存储。尽管其功能和用途与XML基本相似,但是 Protocol Buffers更为轻便。Google宣称其效率对于XML有很大提升,文本比XML要小3-10倍,而解析效率却提升至20-100倍。\r\n\r\n这真是和好消息,XML慢的诟病相比大家都非常清楚,JSON格式的又无法取代XML的强大地位,虽然Ruby中有Hpricot这样的XML解析利器,但是在大批量的解析中还是会有瓶颈出现,而Google此次放出的Protocol Buffers比XML小,且解析速度很快,足够引起广泛的关注了。\r\n\r\nInfoQ上有篇报道“Google开源数据交换格式Protocol Buffers”比较详细,你也可以在\"Protocol Buffers\"上查看。\r\n\r\n目前已经看到C++,Java,Python格式的API,但是没看到基于Ruby的API,何时会出现 ,应该很快就有了。", "created_at"=>2008-07-15 03:20:15 UTC, "updated_at"=>2012-06-24 15:47:02 UTC, "body_html"=>"
“Protocol Buffers are a way of encoding structured data in an efficient yet extensible format. Google uses Protocol Buffers for almost all of its internal RPC protocols and file formats.”
\n", "_id"=>873}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Starling: 消息队列服务器", "body"=>"Starling is a light-weight persistent queue server that speaks the MemCache protocol. It was built to drive Twitter's backend, and is in production across Twitter's cluster.\r\n\r\n参考文章:\r\n1、http://rubyforge.org/projects/starling/\r\n2、The complete guide to setting up Starling:http://rubypond.com/articles/2008/07/17/the-complete-guide-to-setting-up-starling/\r\n3、http://github.com/IceskYsl/starling/tree/master\r\n4、http://myspacesurfer.hee-ro.net/index.php?q=uggc%3A%2F%2Fjjj.eholvafvqr.pbz%2Ffgneyvat-naq-ehqrd-crefvfgrag-ehol-dhrhrf-958.ugzy", "created_at"=>2008-07-22 02:24:50 UTC, "updated_at"=>2012-06-24 15:47:02 UTC, "body_html"=>"
Starling is a light-weight persistent queue server that speaks the MemCache protocol. It was built to drive Twitter's backend, and is in production across Twitter's cluster.
\n", "_id"=>875}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Fleximage:Rails图片处理新选择", "body"=>"Fleximage is a Rails plugin that tries to make image uploading and rendering super easy.\r\nThere are 2 pieces involved in making Rails image handling easy.\r\n1. Image Uploads\r\n2. Image Rendering\r\n其使用的是Magick\r\n\r\n参考文档:\r\n1.让rails处理图片再简单一点\r\n2.fleximage", "created_at"=>2008-07-29 02:54:14 UTC, "updated_at"=>2012-06-24 15:47:02 UTC, "body_html"=>"
Fleximage is a Rails plugin that tries to make image uploading and rendering super easy. \nThere are 2 pieces involved in making Rails image handling easy. \n1. Image Uploads \n2. Image Rendering \n其使用的是Magick
在中国,电信,网通,联通等南北分化问题相当突出,电线的线路网通的访问可能会慢的无法忍受,解决这个问题的办法中,CDN比较靠谱,但是价格不是一般的贵,一般人玩不起,呵呵。一般会搞双线或者在每个网络中部署一套以提高用户体验。 \n而在页面上,一般来说,AJAX用的JS库表会比较大,这个时候就可以考虑直接使用Google或者Yahoo的JS库,Google的“AJAX Libraries API ”库包含了常见的jQuery, prototype, script.aculo.us, MooTools, and dojo.等等。 \n这样一来可以省去不少的网络流量,也提高了各地的速度。而且是免费的,何乐而不为呢? \n还有类似YUI的UI库,也可以这样考虑。可以提高不少性能。
\n", "_id"=>881}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Security"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>8, "title"=>"Apache Tomcat Directory Traversal Vulnerability", "body"=>"``Title: Apache Tomcat Directory Traversal VulnerabilityAuthor: Simon Ryeo(bar4mi (at) gmail.com, barami (at) ahnlab.com)Severity: HighImpact: Remote File DisclosureVulnerable Version: prior to 6.0.18Solution: - Best Choice: Upgrade to 6.0.18 (http://tomcat.apache.org) - Hot fix: Disable allowLinking or do not set URIencoding to utf8 in order to avoid this vulnerability. - Tomcat 5.5.x and 4.1.x Users: The fix will be included in the next releases. Please apply the hot fix until next release.References: - http://tomcat.apache.org/security.html - http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-2938History: - 07.17.2008: Initiate notify (To Apache Security Team) - 08.02.2008: Responsed this problem fixed and released new version - 08.05.2008: Notify disclosure (To Apache Tomcat Security Team) - 08.10.2008: Responsed with some suggestions.\r\n\r\nDescriptionAs Apache Security Team, this problem occurs because of JAVA side.If your context.xml or server.xml allows 'allowLinking'and 'URIencoding' as'UTF-8', an attacker can obtain your important system files.(e.g. /etc/passwd)\r\n\r\nExploitIf your webroot directory has three depth(e.g /usr/local/wwwroot), Anattacker can access arbitrary files as below. (Proof-of-concept)\r\n\r\nhttp://www.target.com/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/foo/bar\r\n\r\n# milw0rm.com [2008-08-11]```", "created_at"=>2008-08-11 09:51:56 UTC, "updated_at"=>2012-06-24 15:47:02 UTC, "body_html"=>"
``Title: Apache Tomcat Directory Traversal VulnerabilityAuthor: Simon Ryeo(bar4mi (at) gmail.com, barami (at) ahnlab.com)Severity: HighImpact: Remote File DisclosureVulnerable Version: prior to 6.0.18Solution: - Best Choice: Upgrade to 6.0.18 (http://tomcat.apache.org) - Hot fix: Disable allowLinking or do not set URIencoding to utf8 in order to avoid this vulnerability. - Tomcat 5.5.x and 4.1.x Users: The fix will be included in the next releases. Please apply the hot fix until next release.References: - http://tomcat.apache.org/security.html - http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-2938History: - 07.17.2008: Initiate notify (To Apache Security Team) - 08.02.2008: Responsed this problem fixed and released new version - 08.05.2008: Notify disclosure (To Apache Tomcat Security Team) - 08.10.2008: Responsed with some suggestions.
\n\n
DescriptionAs Apache Security Team, this problem occurs because of JAVA side.If your context.xml or server.xml allows 'allowLinking'and 'URIencoding' as'UTF-8', an attacker can obtain your important system files.(e.g. /etc/passwd)
\n\n
ExploitIf your webroot directory has three depth(e.g /usr/local/wwwroot), Anattacker can access arbitrary files as below. (Proof-of-concept)
有时间的看看其他人对中国网民的调查、分析、报告还是有好处的,至少可以让自己在一个宏观和趋势是了解中国网民在做什么和喜欢做什么,在08年1月的时候,在一篇《What Do Chinese Internet Users Do Online?》文章中看到《中国互联网络发展状况统计报告》,比较详细的说明了中国网民的构成,分布等等,非常不错。
\n\n
时隔半年,《TrendsSpotting Handbook Of Online China》这篇文章中又看到一个《Handbook of Online China》的PPT,该PPT分析了中国互联网用户的行为特征,从应用、搜索、web2等方面分析、比较了中国当下比较大的应用。
\n\n
在该报告中,我们可以看到,互联网应用中网络音乐,IM和在线视频,在线游戏都是热门,详细的可以进一步的查看该PPT。 \nHandbook of Online China \nView SlideShare presentation (tags: web trend trends powerpoint olympics) \n
The music API gives developers access to Yahoo!’s “catalog of artists, albums, tracks, videos, ratings and more,” according to the company. It allows developers to interface with Yahoo! Music’s database via “charts, search, similarities, genres, artists, and user recommendations and ratings.”\r\n\r\nThe REST-based API returns data in XML, JSON, and RSS and uses BBAuth to allow user authentication for Yahoo! Music users to access their personal data via external apps. Use of the API is currently limited to 5k queries per day.
\r\n采用REST格式的API,使用Ruby来调用非常简单,看一段代码:\r\n
\r\n
Ruby代码
\r\n\r\n\t
require 'yahoo-music'
\r\n\t
include Yahoo::Music
\r\n\t
Yahoo::Music.app_id = \"...\"# Put Your App ID Here
\r\n\t
artist = Artist.new(\"Beirut\") # Searches by name and uses first result
\r\n\t
album = artist.releases.detect{|r| r.title == \"Flying Club Cup\"}
在Last.fm宣布其开放API后,Yahoo! Music也宣布其开放API。直接看一段英文描述,不废话了,大家都看得懂,如下: \nThe music API gives developers access to Yahoo!’s “catalog of artists, albums, tracks, videos, ratings and more,” according to the company. It allows developers to interface with Yahoo! Music’s database via “charts, search, similarities, genres, artists, and user recommendations and ratings.”
\n\n
The REST-based API returns data in XML, JSON, and RSS and uses BBAuth to allow user authentication for Yahoo! Music users to access their personal data via external apps. Use of the API is currently limited to 5k queries per day. \n采用REST格式的API,使用Ruby来调用非常简单,看一段代码: \n \nRuby代码 \n \n require 'yahoo-music' \n include Yahoo::Music \n Yahoo::Music.app_id = "..." # Put Your App ID Here \n artist = Artist.new("Beirut") # Searches by name and uses first result \n album = artist.releases.detect{|r| r.title == "Flying Club Cup"} \n puts album.title \n puts album.artist \n puts "Release Date:" + album.released_on.strftime("%m/%d/%Y") \n puts \n puts "Tracks" \n artist.tracks.each_with_index do |track, i| \n puts "\\t%d %s \\t%2d:%2d" % [i, track.title, track.duration / 60, track.duration % 60] \n end \n \n \n详细资料,请参考:
正确的做法,应该是修改/etc/security/limits.conf \n里面有很详细的注释,比如 \n* soft nofile 2048 \n* hard nofile 32768
\n\n
检查: \n \nRuby代码 \n \n #check file descriptor \n \n echo \n echo "-----------------------------------------------" \n echo "Begin to check the file descriptor limit" \n fd=ulimit -n \n if [ $fd -lt 8192 ]; \n then \n echo "Fatal Error!" \n echo "The file descriptor limit is only '"$fd"'!" \n echo "Please make it more than 8192!" \n exit \n fi \n echo "OK, the file descriptor limit is" $fd \n echo "-----------------------------------------------" \n echo \n echo \n \n \n \n参考文章: \nhttp://blog.chinaunix.net/u2/64804/showart_1019246.html \nhttp://hi.baidu.com/leshy/blog/item/f57f4a903fb0898ea877a452.html
\n", "_id"=>888}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>3, "title"=>"查看MYSQL表占用空间状态", "body"=>"比如需要查询库占用的空间和索引占用的空间:\r\n\r\n查整个库的状态:\r\nselect concat(truncate(sum(data_length)/1024/1024,2),'MB') as data_size,\r\nconcat(truncate(sum(max_data_length)/1024/1024,2),'MB') as max_data_size,\r\nconcat(truncate(sum(data_free)/1024/1024,2),'MB') as data_free,\r\nconcat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size\r\nfrom information_schema.tables where TABLE_SCHEMA = 'databasename';\r\n\r\n查单表:\r\nselect concat(truncate(sum(data_length)/1024/1024,2),'MB') as data_size,\r\nconcat(truncate(sum(max_data_length)/1024/1024,2),'MB') as max_data_size,\r\nconcat(truncate(sum(data_free)/1024/1024,2),'MB') as data_free,\r\nconcat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size\r\nfrom information_schema.tables where TABLE_NAME = 'tablename';", "created_at"=>2008-08-19 09:08:34 UTC, "updated_at"=>2012-06-24 15:47:02 UTC, "body_html"=>"
比如需要查询库占用的空间和索引占用的空间:
\n\n
查整个库的状态: \nselect concat(truncate(sum(data_length)/1024/1024,2),'MB') as data_size, \nconcat(truncate(sum(max_data_length)/1024/1024,2),'MB') as max_data_size, \nconcat(truncate(sum(data_free)/1024/1024,2),'MB') as data_free, \nconcat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size \nfrom information_schema.tables where TABLE_SCHEMA = 'databasename';
\n\n
查单表: \nselect concat(truncate(sum(data_length)/1024/1024,2),'MB') as data_size, \nconcat(truncate(sum(max_data_length)/1024/1024,2),'MB') as max_data_size, \nconcat(truncate(sum(data_free)/1024/1024,2),'MB') as data_free, \nconcat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size \nfrom information_schema.tables where TABLE_NAME = 'tablename';
Prawn::Document.generate(\"utf8_text_flow.pdf\") do
\r\n\t
font \"\#{Prawn::BASEDIR}/data/fonts/simfang.ttf\"
\r\n\t
text \"我是中文,还有数字+yingwen+898\"* 2
\r\n\t
text \"This is a english text, and i will be here ...\"
\r\n\t
text \"This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,\"
\r\n\t
\r\n\t
font_size!(16)
\r\n\t
text \"At size 16\"
\r\n\t
\r\n\t
font_size!(16)
\r\n\t
text \"\\nIceskYsl@1sters!\"
\r\n\t
font_size!(10)
\r\n\t
text \"不考虑安全的开发过程就是不完整的过程,而我只是个懂点安全对于互联网充满期待的程序员…\"
\r\n\t
font_size!(12)
\r\n\t
text \"更可怕的是,同质化竞争对手可以按照URL中后面这个ID来遍历您的DB中的内容,写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事,这样的话,你就非常被动了。\"
\r\n4、其他\r\n\r\n上面说的那个Bug我已经提交给作者,详细的参考这里”chinese text can not flow well “,应该很快就可以修复和完善了;\r\n\r\n让我惊奇的是其主页 上竟然有 中文版页面,难道有国人参与?\r\n\r\n其代码库在:http://github.com/sandal/prawn/tree/master\r\n\r\n5、更新\r\n\r\n上面说到的一个对中文自动换行的BUG,提交给作者后,他就修复了,现在我测试的效果非常棒,是我见过的最棒的一个PDF生成类库了,如下是效果图,可以和上面的那个比较下。\r\n\r\n", "created_at"=>2008-08-20 03:39:42 UTC, "updated_at"=>2012-06-24 15:47:02 UTC, "body_html"=>"
比较简单,详细的参考其文档,我直接贴一段我测试用的代码,如下: \n \nRuby代码 \n \n # coding: utf-8 \n \n $LOADPATH << File.join(File.dirname(FILE_), '..', 'lib') \n require "prawn" \n start = Time.now \n Prawn::Document.generate("utf8_text_flow.pdf") do \n font "\#{Prawn::BASEDIR}/data/fonts/simfang.ttf" \n text "我是中文,还有数字+yingwen+898"* 2 \n text "This is a english text, and i will be here ..." \n text "This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ," \n \n font_size!(16) \n text "At size 16" \n \n font_size!(16) \n text "\\nIceskYsl@1sters!" \n font_size!(10) \n text "不考虑安全的开发过程就是不完整的过程,而我只是个懂点安全对于互联网充满期待的程序员…" \n font_size!(12) \n text "更可怕的是,同质化竞争对手可以按照URL中后面这个ID来遍历您的DB中的内容,写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事,这样的话,你就非常被动了。" \n \n \n end \n puts "Spend \#{Time.now-start}s" \n \n \n \n \n \n生成的PDF效果还是比较让人满意的,如下是效果图:
BOSS (Build your Own Search Service) is Yahoo!'s open search web services platform. The goal of BOSS is simple: to foster innovation in the search industry. Developers, start-ups, and large Internet companies can use BOSS to build and launch web-scale search products that utilize the entire Yahoo! Search index. BOSS gives you access to Yahoo!'s investments in crawling and indexing, ranking and relevancy algorithms, and powerful infrastructure. By combining your unique assets and ideas with our search technology assets, BOSS is a platform for the next generation of search innovation, serving hundreds of millions of users across the Web.
yahoo的BOSS web服务比之前Yahoo! Search API更加方便灵活,取消了诸多限制,比如检索的次数等等,其介绍如下: \nBOSS (Build your Own Search Service) is Yahoo!'s open search web services platform. The goal of BOSS is simple: to foster innovation in the search industry. Developers, start-ups, and large Internet companies can use BOSS to build and launch web-scale search products that utilize the entire Yahoo! Search index. BOSS gives you access to Yahoo!'s investments in crawling and indexing, ranking and relevancy algorithms, and powerful infrastructure. By combining your unique assets and ideas with our search technology assets, BOSS is a platform for the next generation of search innovation, serving hundreds of millions of users across the Web. \n \nJay Pignata已经用Ruby写了一个类库BOSSMan,使用非常方便,步骤如下: \n1、安装gem \n \nRuby代码 \n \n gem sources -a http://gems.github.com \n gem install jpignata-bossman \n \n \n \n2、编写代码 \n \nRuby代码 \n \n require 'rubygems' \n require 'bossman' \n include BOSSMan \n \n BOSSMan.application_id = "Your Application ID here" \n \n news = BOSSMan::Search.news("IceskYsl", 0, 3) \n news.results.each do |result| \n puts "\#{result.title} [from \#{result.source}]" \n end \n \n \n参考文档: \nBOSSMan: Build Your Own Search Engine With Yahoo And Ruby: http://www.rubyinside.com/ruby-and-yahoo-boss-with-bossman-1047.html \n插件BOSSman:http://github.com/jpignata/bossman-gem/tree/master \n看视频介绍:http://developer.yahoo.com/search/boss/
Jul 30 17:36:15 www login(pam_unix)[11819]: session opened for user siteview by (uid=0) \r\nJul 30 17:36:15 www -- siteview[11819]: LOGIN ON pts/0 BY siteview FROM 192.168.168.42 \r\nJul 30 17:36:15 www login(pam_unix)[11819]: session closed for user siteview \r\nJul 30 17:47:17 www syslogd: /var/log/secure: No space left on device \r\nJul 30 19:11:58 www PAM-securetty[1611]: Couldn't open /etc/securetty
\r\n \r\n3、修改/etc/audit/audit.conf配置文件 \r\n可以通过修改audit.conf来配置,让其自动处理 \r\n1)修改为自动删除的: \r\nnotify = \"/usr/sbin/audbin -S /var/log/audit.d/save.%u -C -T 20% -N 'rm -f %f'\"; \r\n[The notify line as above should (according to the docs) remove old 'save' files when the filesystem comes within 20% of full (change the figure after -T to specify how close to full you want to start deleting old files).] \r\n \r\n2)修改为自动备份的:(/backup 是另外您想保存数据的分区)\r\n
God是一个使用Ruby写成的用于监视任务运行状态的可扩展框架,它的配置脚本采用Ruby来编写。因此,比起它的前辈Monit,God更为简单,灵活且易于扩展(尤其对于Ruby使用者),你可以很轻易的添加一些自定义规则。 \n \nRuby代码 \n \n MINIONS = [ \n { :rails_root => "/home/mycoolapp/staging/current", \n :mongrel_ports => [4001,4002,4003,4004,4005], \n :uid => 'mycoolapp', \n :gid => 'mycoolapp', \n :pid_path => '/home/mycoolapp/staging/shared/tmp/pids' } \n ] \n \n MINIONS.each do |minion| \n minion[:mongrel_ports].each do |port| \n God.watch do |w| \n w.name = "mongrel-\#{port}" \n w.uid = minion[:uid] \n w.gid = minion[:gid] \n w.interval = 30.seconds # default \n w.start = "mongrel_rails start -c \#{minion[:rails_root]} -p \#{port} </span> \n -P \#{minion[:pid_path]}/mongrel.\#{port}.pid -e production -d" \n w.stop = "mongrel_rails stop -P \#{minion[:pid_path]}/mongrel.\#{port}.pid" \n w.restart = "mongrel_rails restart -P \#{minion[:pid_path]}/mongrel.\#{port}.pid" \n w.start_grace = 10.seconds \n w.restart_grace = 10.seconds \n w.pid_file = "\#{minion[:pid_path]}/mongrel.\#{port}.pid" \n \n w.behavior(:clean_pid_file) \n \n w.start_if do |start| \n start.condition(:process_running) do |c| \n c.interval = 5.seconds \n c.running = false \n end \n end \n \n w.restart_if do |restart| \n restart.condition(:memory_usage) do |c| \n c.above = 150.megabytes \n c.times = [3, 5] # 3 out of 5 intervals \n end \n \n restart.condition(:cpu_usage) do |c| \n c.above = 50.percent \n c.times = 5 \n end \n end \n \n # lifecycle \n w.lifecycle do |on| \n on.condition(:flapping) do |c| \n c.to_state = [:start, :restart] \n c.times = 5 \n c.within = 5.minute \n c.transition = :unmonitored \n c.retry_in = 10.minutes \n c.retry_times = 5 \n c.retry_within = 2.hours \n end \n end \n end \n end \n end \n \n \n要了解更多资料,请参考如下文档: \nhttp://god.rubyforge.org/ \nhttp://ihower.idv.tw/blog/archives/1762 \nhttp://ezinearticles.com/?Why-Rails-Developers-Need-God&id=845672; \nhttp://www.letrails.cn/archives/46
\n", "_id"=>899}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>3, "title"=>"MySQL存储引擎选择和比较", "body"=>"大家都知道MYSQL有很多的存储引擎机制,有人曾说过“多个引擎说明这是MYSQL的软肋,它不能像oracle那样搞出一个通用的”,这句话的具体意思自己揣摩,我就不瞎解读了。\r\n\r\n今天看到一篇文章,是关于其存储引擎的,虽然不长,但是写的很不错,里面有些tips值得学习,不再翻译,其原文地址为《MySQL Storage Engines》。\r\n\r\n\r\n\r\nTip: A well designed MySQL-powered application will use different storage engines for different tables. If you're still stuck with all MyISAM tables, now may be a good time to revisit.", "created_at"=>2008-08-27 06:36:06 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
Tip: A well designed MySQL-powered application will use different storage engines for different tables. If you're still stuck with all MyISAM tables, now may be a good time to revisit.
The problems with PStore are significant enough to warrant a replacement default implementation.
\r\n\t
It’s a bad idea anyway to store sensitive information (like passwords) in the session. It doesn’t matter whether the session data can be seen by the client or not, it’s something nobody should ever do.
\r\n\t
Forging session data is only possible if cracking the secret is feasible.
\r\n\r\n文中,其针对Rails的采用CookieStore机制时,其针对“449fe2e7daee471bffae2fd8dc02313d”这样一个密码是,按照其机型:\r\n“My machine, an Intel Core 2 Duo T5300, can try 285840.1 passwords per second with 2 threads.”\r\n破解下来需要的时间是:\r\n``16^32/2 / 285840.1= 5.952*10^32 seconds= 1.886*10^25 years```\r\n这是个什么概念?\r\n\r\n但是其也提到了由于Rails采用的 Ruby’s CGI::Session的session Id生成器中存在一个缺陷,导致其算法是可以被破解的,不过“Update November 28: The key generation security problem has been fixed.”已经修复了。所以,我也认为基于CookieStore的session存储机制是安全可靠的。\r\n\r\n参考:\r\n
最近在看一本《The Rails way》的书,其中关于session存贮机制一章中,对基于CookieStore的session存储机制持否定态度,认为其存在被破解和Replay attack的可能。就我了解的信息来看,这个观点是不妥的。 \n最详细的一篇文章是写的laigongli写的这篇“Rails 2.0, cookie session store and security”,文章比较长,说的很详细,感兴趣的可以过去看看。其中主要观点为: \n \n The problems with PStore are significant enough to warrant a replacement default implementation. \n It’s a bad idea anyway to store sensitive information (like passwords) in the session. It doesn’t matter whether the session data can be seen by the client or not, it’s something nobody should ever do. \n Forging session data is only possible if cracking the secret is feasible. \n \n文中,其针对Rails的采用CookieStore机制时,其针对“449fe2e7daee471bffae2fd8dc02313d”这样一个密码是,按照其机型: \n“My machine, an Intel Core 2 Duo T5300, can try 285840.1 passwords per second with 2 threads.” \n破解下来需要的时间是: \n16^32/2 / 285840.1= 5.952*10^32 seconds= 1.886*10^25 years` \n这是个什么概念?
\n\n
但是其也提到了由于Rails采用的 Ruby’s CGI::Session的session Id生成器中存在一个缺陷,导致其算法是可以被破解的,不过“Update November 28: The key generation security problem has been fixed.”已经修复了。所以,我也认为基于CookieStore的session存储机制是安全可靠的。
\n\n
参考: \n \n Rails 2.0, cookie session store and security \n BustRailsCookie.rb
\n", "_id"=>901}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Thin: A fast and very simple Ruby web server", "body"=>"知道Thin这个东西很久了,记忆中的还是下面这张和mongrel的性能比较图片,但是一直没深入进去了解其到底如何。\r\n\r\n从图上可以看到,除了总体性能好于mongrel以外,最大的区别在于其在100个并发的时候还能保证高性能,而100个并发的时候mongrel的性能非常差(且消耗很多的资源,经常由此导致请求无法处理,而出现503)。\r\n今天花了点时间,把Thin从头到尾的看了一遍,然后连到一个服务器上试验了下,总体感觉如下:\r\n
\r\n详细的测试比较,请参考“File Uploads in Merb versus Rails”这里文章,其结论差不多是这样的“Merb’s average response time is 16 ms while Rails’s average is 205 ms (over 10x faster), yet the throughput is 3000 vs 2000 req/min (only 50% greater).”,针对其throughput提高不多的情况,merb的人给出的方案是add\":use_mutex: false\"in merb.yml,其原因说因为AR是非线程安全的才需要这个选项,设置成fasle后可以大大的提高性能。\r\n\r\n参考文章:\r\n
做Rails的应该知道,在Rails中处理大文件上传是很头疼的事情,比如你允许用户上传图片,那么其有的时候分辨率高的文件有1-2M的大小,这个时候rails的上传处理是很慢的,也不难理解,看段经典的上传代码: \n \nRails代码 \n \n def upload \n File.open(RAILS_ROOT+"/uploads/\#{params[:file].original_filename}.\#{next_count}”, “w”) { |f| f.write(params[:file].read) } \n render :action => ‘index’ \n end \n \n \n加上Rails是单线程的,这个时候处理大的IO非常慢,慢的后果是什么?拖死你的服务器,比如你使用mongrel,开了10个进程在跑,这个时候,用户上传一个文件要花2分钟,就会占着这个进程不放,导致其他的请求无法响应(好怀念weblogic的队列机制),所以你的系统抛给用户的可能就是503,504之类的错误。 \n有人推荐,这个情况下可以使用merb,这东西也不会很陌生,从rails大红大紫后,其一直在后面追赶,其基本特性就是线程安全的,所以对一个请求可以多线程处理,会加快处理速度,看段类似处理上传的代码: \n \nMerb代码 \n \n def upload \n FileUtils.mv params[:file][:tempfile].path, MERB_ROOT+”/uploads/\#{params[:file][:filename]}.\#{next_count}” \n render :action => ‘index’ \n end \n \n \n详细的测试比较,请参考“File Uploads in Merb versus Rails”这里文章,其结论差不多是这样的“Merb’s average response time is 16 ms while Rails’s average is 205 ms (over 10x faster), yet the throughput is 3000 vs 2000 req/min (only 50% greater).”,针对其throughput提高不多的情况,merb的人给出的方案是add":use_mutex: false"in merb.yml,其原因说因为AR是非线程安全的才需要这个选项,设置成fasle后可以大大的提高性能。
\n\n
参考文章: \n \n File Uploads in Merb versus Rails \n [Mongrel] Uploading Large (100mb+) files \n Taking Merb for a Spin \n Uploading large files to Rails with Merb
\n", "_id"=>903}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"NeverBlock: 非常值得期待的一组类库", "body"=>"\r\nNeverBlock is a Ruby library that allows developers to write non-blocking, concurrent code in a transparent manner. Meaning that you will keep coding in your traditional ways while you get the benefit of non-blocking IO operations.\r\n\r\nRuby的伪线程,Rails的非线程安全性导致其性能始终上不去,前端时间发布的ruby1.9有多处修改,后面的Rails2.2也号称要做线程安全了,如果以上两个条件都满足,Rails的性能将得到大幅的提高。\r\n\r\n由于Rails的AR是非线程安全的,导致其IO性能不是很好,其Mysql驱动一直是单线,不能很好的提高性能,做个Oracle的应该很怀念Oracle,weblogic中的线程池,java5中的concurrent包用来写同步等处理非常方便和高效。\r\n\r\n很高兴看到Ruby世界也有类似的东西出现了,他就是NeverBlock,在其放出PostgreSQL的适配驱动后,近日有发布了针对MYSQL的版本,名字为mysqlplus,非常值得期待。\r\n\r\n另外,关于“同步、异步、阻塞和非阻塞的概念”,请参考其链接上的文章。\r\n\r\n参考文章:\r\n\r\nhttp://chinaonrails.com/topic/view/1974.html\r\n\r\nhttp://www.espace.com.eg/neverblock/blog/2008/08/28/neverblock-mysql-support/\r\n\r\nhttp://github.com/espace/mysqlplus/tree/master\r\n\r\nhttp://zhanjun.net/?q=node/7\r\n\r\n ", "created_at"=>2008-08-30 11:16:35 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
NeverBlock is a Ruby library that allows developers to write non-blocking, concurrent code in a transparent manner. Meaning that you will keep coding in your traditional ways while you get the benefit of non-blocking IO operations.
另外,还有值得期待的就是Ruby的VM是否有改善?目前的GC还是问题大大的有,内存泄露也并不稀罕,希望有新的VM出来;另外,其Ruby的一些app服务器最近好像停止不前了,自从Zed A. Shaw闹脾气后,mongrel就很少有啥更新了,其maillist也冷冷清清的。thin还好,有些小的更新,这些server要针对Rails2.2和Ruby1.9做些大动作了。
SimpleConfig looks nice, but it definitely has a few differences from Configatron. The first big difference is that SimpleConfig is limited to use with Rails. Configatron can be used with any framework, any application, and any script. Configatron also seems a bit easier to use. There are no mixins needed to use it. The configatron method lives in Kernel, which means it’s available everywhere, no ‘configuration’ needed. Different strokes, eh? There are a few other configuration systems out there, I always encourage people to check out the options before they decide on a piece of software to use.
搞Java的人应该很习惯把一些配置(数据库连接、个性化配置等)写到配置文件中,一般会使用XML或者TXT文件中,在启动的时候读取配置,初始化等等。 \nRails中也可以实现类似的功能,虽然Rails提倡“零配置”,但有的时候开发一个系统,比如Blog系统等还是需要一些个性化的配置,我们原来的实现方式是:增加一个配置文件,启动的时候读取,并保存为全局变量,用的时候直接使用。也很方便。 \n其实还可以使用插件或者gem来做,Configatron就是这么一个gem,另外还有一个插件版的SimpleConfig,两者还是有些不同的,按照Configatron 作者的说法,其不同点在于: \nSimpleConfig looks nice, but it definitely has a few differences from Configatron. The first big difference is that SimpleConfig is limited to use with Rails. Configatron can be used with any framework, any application, and any script. Configatron also seems a bit easier to use. There are no mixins needed to use it. The configatron method lives in Kernel, which means it’s available everywhere, no ‘configuration’ needed. Different strokes, eh? There are a few other configuration systems out there, I always encourage people to check out the options before they decide on a piece of software to use. \n其实我们自己也可以写,只是没有必要再搞一套,功能上来说,上述这两个足够了,下面简单的看看Configatron 的用法: \n1、安装 \n$ sudo gem install configatron \n2、定义(支持namespace) \n \nRuby代码 \n \n configatron do |config| \n config.website_url = "http://www.1sters.com" \n config.namespace(:mems) do |mem| \n email.namespace(:iceskysl) do |iceskysl| \n iceskysl.email = "iceskysl@1sters.com" \n pop.blog_url = "http://iceskysl.1sters.com" \n # etc ... \n end \n email.namespace(:shine) do |shine| \n smtp.email = "shine@1sters.com" \n smtp.blog_url = "http://shine.1sters.com" \n # etc ... \n end \n end \n # etc... \n end \n \n \n3、使用 \n \nRuby代码 \n \n configatron.mems.iceskysl.email # => "iceskysl@1sters.com" \n configatron.mems.shine.blog_url # => "http://shine.1sters.com" \n configatron.website_url # => "http://www.1sters.com" \n \n \n4、重写 \n \nRuby代码 \n \n configatron do |config| \n config.website_url = "http://www.1sters.com/index" \n end \n \n \nPS: \n如果你是在自己的Rails里使用,可能simpleconfig会更加适合你,请参考其链接上的Readme。
Log4r is a comprehensive and flexible logging library written in Ruby for use in Ruby programs. It features a hierarchical logging system of any number of levels, custom level names, logger inheritance, multiple output destinations, execution tracing, custom formatting, thread safteyness, XML and YAML configuration, and more.
\r\n但是其从March 2004开始到现在都没人有维护和更新,看来需要寻找新的解决方案了。\r\n2、Logging\r\nLogging is a flexible logging library for use in Ruby programs based on the design of Java‘s log4j library. It features a hierarchical logging system, custom level names, multiple output destinations per log event, custom formatting, and more.\r\n关于Logging的详细API可以参考其doc文档,其详细的用法和注意事项,可以参考“HowtoConfigureLogging”,下面看个例子:\r\n
\r\n
Ruby代码
\r\n\r\n\t
require 'logging'
\r\n\t
\r\n\t
logger = Logging::Logger['example_logger']
\r\n\t
logger.add_appenders(
\r\n\t
Logging::Appender.stdout,
\r\n\t
Logging::Appenders::File.new('example.log')
\r\n\t
)
\r\n\t
logger.level = :info
\r\n\t
\r\n\t
logger.debug \"this debug message will not be output by the logger\"
Rail本身自带的logger虽然好用,但是还是有点太简易了,针对一些特殊的业务需求(比如需要记录一些业务日志供后续的报表系统分析、解析等)就显得有点力不从心了。这个时候可以找找其他的替代品。 \n1、log4r \n做java的应该对这样的名字相当熟悉,大名鼎鼎的log4j在java的世界里非常流行和实用,看这个log4r的名字就可以感受到其强大的功能。 \nLog4r is a comprehensive and flexible logging library written in Ruby for use in Ruby programs. It features a hierarchical logging system of any number of levels, custom level names, logger inheritance, multiple output destinations, execution tracing, custom formatting, thread safteyness, XML and YAML configuration, and more. \n但是截至到目前为止的其log4r-1.0.5版本中和Rails2的版本还存在一个冲突,详细的可以参考“Ticket #3512” (reopened defect)。 \nActionView::TemplateError (Expected kind of Outputter, got NilClass) c:/ruby/lib/ruby/gems/1.8/gems/log4r-1.0.5/src/log4r/logger.rb:115:in each' c:/ruby/lib/ruby/gems/1.8/gems/log4r-1.0.5/src/log4r/logger.rb:115:inadd' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:30:in benchmark' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/partials.rb:57:inrender_partial' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/base.rb:230:in `render' \n但是其从March 2004开始到现在都没人有维护和更新,看来需要寻找新的解决方案了。 \n2、Logging \nLogging is a flexible logging library for use in Ruby programs based on the design of Java‘s log4j library. It features a hierarchical logging system, custom level names, multiple output destinations per log event, custom formatting, and more. \n关于Logging的详细API可以参考其doc文档,其详细的用法和注意事项,可以参考“HowtoConfigureLogging”,下面看个例子: \n \nRuby代码 \n \n require 'logging' \n \n logger = Logging::Logger['example_logger'] \n logger.add_appenders( \n Logging::Appender.stdout, \n Logging::Appenders::File.new('example.log') \n ) \n logger.level = :info \n \n logger.debug "this debug message will not be output by the logger" \n logger.info "just some friendly advice" \n \n \n参考文章: \nhttp://wiki.rubyonrails.org/rails/pages/HowtoConfigureLogging \nhttp://logging.rubyforge.org/ \nhttp://log4r.sourceforge.net/index.html \nhttp://007surfing.com/index.php?hl=f5&q=uggc%3A%2F%2Fapupenvyf.oybtfcbg.pbz%2F2007%2F04%2Fybt.ugzy;
如果能把三种消息自动区分,使用各种的样式表,该多方便!确实,已经有人这么做了, Robby给出了一个plugin,“Flash Message Conductor”,看其介绍: \n``A simple pattern for managing flash messages in your Ruby on Rails application.
前面写过一篇《NeverBlock: 非常值得期待的一组类库》,其中说到了采用NeverBlock的non-blocking, concurrent机制,可以很大程度上提高mysql或者PostgreSQL的使用率,很多限度的提高性能。 \n但是没有给出具体的对比测试数据,今天看到有个哥们已经使用Thin,Rails和PostgreSQL做了一次对比测试,相关环境如下: \n \n服务器配置 \n \n 1 - 1 Thin server, normal postgreSQL Adapter \n 2 - 2 Thin servers (behind nginx), normal postgreSQL Adapter \n 3 - 4 Thin servers (behind nginx), normal postgreSQL Adapter \n 4 - 1 Thin server, neverblock postgreSQL Adapter \n \n \n \n压力配置 \n \n 1 - Very light work load, every 200 requests, one "select sleep(1)" would be issued \n 2 - Light work load, every 100 requests, one "select sleep(1)" would be issued \n 3 - Moderate work load, every 50 requests, one "select sleep(1)" would be issued \n 4 - Heavy work load, every 20 requests, one "select sleep(1)" would be issued \n 5 - Very heavy work load, every 10 requests, one "select sleep(1)" would be issued \n \n \n其结果对比如下:
前面有篇文章介绍了NeverBlock,其一篇是关于NeverBlock 原理介绍的,另外一篇是在ruby1.9下做的对比测试,当时我们说:接下来,,需要等待Ruby1.9和Rails2.2的到来,加上如上的测试对比,可以想象得到,Rails的性能会上很大一个台阶的。现在有个好消息是,NeverBlock支持了Ruby1.8(通过一些手法),这次看到其更新的特性如下: \n \n NeverBlock now supports Ruby1.8. \n NeverBlock support for Thin and Mongrel servers. \n NeverBlock now supports Ruby on Rails.on \n \n也就是说,现在NeverBlock支持Ruby1.8,支持Thin和mongrel服务器,另外支持Rails,测试方法很简单: \n1、安装需要的额外的系统类库 \n \nShell代码 \n \n apt-get install libmysql++-dev \n \n \n \n2、安装需要的gems \n下载这几个包,NeverBlock (zip|tar.gz), Mysqlplus (zip|tar.gz), EventMachine (zip|tar.gz), \n然后解压各自包;tar -zxvf (respective file name).tar.gz \n然后CD到各自目录中build成gem;gem build (respective file name).gemspec \n最后gen install;gem install (generated file name).gem \n3、修改environment.rb \nrequire 'never_block/frameworks/rails' \nrequire 'never_block/servers/thin'(如果是mongrel,则require 'never_block/servers/mongrel') \n4、修改database.yml \nadapter: neverblock_mysql (如果是postgresql,则为 adapter: neverblock_postgresql ) \nconnections: 12 # will spawn 12 connections instead of the defualt 4 #连接数 \n5、重启thin(mongrel即可)
\n\n
以上步骤没有问题,我已经测试过了。
\n\n
下面附几个别人做的对比测试: \n \n测试环境如下: \n \n Rails 2.1 \n Thin 0.82 \n Ruby 1.8.6 \n MySQL 5.0 \n A special build of EventMachine 0.12 \n \n \n \n系统负载构造: \n \n 1 - Moderate work load, one slow request for every 050 requests \n 2 - Heavy work load, one slow request for every 020 requests \n 3 - Very heavy work load, one slow request for every 010 requests \n \n \n \n结果如下:
\r\n详细参考:What's New in Edge Rails: Shallow Routes\r\n\r\n2、Mailer Layouts\r\n在Rails2.2中将加入Mailer布局模板,就像view-template一样,每个mailer可以有一个模板,其默认的是mailer加上_mailer后缀,比如下面:\r\n
\r\n参考:What's New in Edge Rails: Mailer Layouts\r\n\r\n3、Connection Pools\r\n前面说过,在Rails2.2中将会实现线程安全,如此以来,连接池的实现也就不在话下了,在Rails2.2中将增加连接池的特性,使用方法非常简单,直接在database.yml配置即可,如下:\r\n
\r\n``1sters@iceskysl:~> gnuplotset terminal pngset output \"http_benchmark.png\"set xlabel \"request\"set ylabel \"ms\"plot \"http_benchmark.txt\" using 7 with lines title \"ctime\", \\ \"http_benchmark.txt\" using 8 with lines title \"dtime\", \\ \"http_benchmark.txt\" using 9 with lines title \"ttime\", \\\"http_benchmark.txt\" using 10 with lines title \"wait\"\r\n\r\n结果类似:```\r\n\r\n
Apache的AB可以用来做一些性能测试,使用-g参数其结果可以输出到文件,然后使用gnuplot可以绘制相关图片,以更直观的显示。 \n \nab -h \n \n $ ab -h \n Usage: ab [options] [http://]hostname[:port]/path \n Options are: \n -n requests Number of requests to perform \n -c concurrency Number of multiple requests to make \n -t timelimit Seconds to max. wait for responses \n -p postfile File containing data to POST \n -T content-type Content-type header for POSTing \n -v verbosity How much troubleshooting info to print \n -w Print out results in HTML tables \n -i Use HEAD instead of GET \n -x attributes String to insert as table attributes \n -y attributes String to insert as tr attributes \n -z attributes String to insert as td or th attributes \n -C attribute Add cookie, eg. 'Apache=1234. (repeatable) \n -H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip' \n Inserted after all normal header lines. (repeatable) \n -A attribute Add Basic WWW Authentication, the attributes \n are a colon separated username and password. \n -P attribute Add Basic Proxy Authentication, the attributes \n are a colon separated username and password. \n -X proxy:port Proxyserver and port number to use \n -V Print version number and exit \n -k Use HTTP KeepAlive feature \n -d Do not show percentiles served table. \n -S Do not show confidence estimators and warnings. \n -g filename Output collected data to gnuplot format file. \n -e filename Output CSV file with percentages served \n -h Display usage information (this message) \n \n \n \n$ab -g http_benchmark.txt -n 1000 -c 100 http://1stlog.1sters.com/ \n \n \nhttp_benchmark.txt \n \n $ more http_benchmark.txt \n starttime seconds ctime dtime ttime wait \n Mon Sep 08 11:15:52 2008 1220843752427648 516 94524 95040 94521 \n Mon Sep 08 11:15:52 2008 1220843752944235 525 94500 95025 93995 \n Mon Sep 08 11:15:53 2008 1220843753469652 520 94491 95011 93475 \n Mon Sep 08 11:15:53 2008 1220843753990129 514 94478 94992 92960 \n Mon Sep 08 11:15:54 2008 1220843754505018 511 94471 94982 92449 \n Mon Sep 08 11:15:55 2008 1220843755016428 523 100439 100962 91925 \n \n \n \n \n``1sters@iceskysl:~> gnuplotset terminal pngset output "http_benchmark.png"set xlabel "request"set ylabel "ms"plot "http_benchmark.txt" using 7 with lines title "ctime", \\ "http_benchmark.txt" using 8 with lines title "dtime", \\ "http_benchmark.txt" using 9 with lines title "ttime", \\"http_benchmark.txt" using 10 with lines title "wait"
比如你的程序中写了这么一条语句:User.find(:all, :limit => params[:limit]),那么我们就可以构造这个params[:limit]为: "1 UNION (select 1,2,password,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,0 from users)",这句话什么意思?放到前面那个find后,就形成这样的语句: \n \nSQL代码 \n \n select * from users limit 1 UNION (select 1,username,password,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,0 from users) \n \n \n怎样?很邪恶吧,了解点安全的朋友都能看明白,不了解的我说半天还不如你去google下什么是union注射,呵呵。
\n\n
没升级到2.1.1的赶快升级或者按照如下方式修复吧,否则就有危险了。 \n \n Review your application whether you allow the user to control :limit or :offset \n If you are on Rails 2.1.0, please apply this patch or get Rails 2.1.1 \n If you are on the Rails 2.0 or 1.2 branch, apply this backport patch \n \n参考文档:http://www.rorsecurity.info/2008/09/08/sql-injection-issue-in-limit-and-offset-parameter/
\n", "_id"=>922}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"[Tips]自动填充测试需要的随机数据", "body"=>"经常遇到一些新功能开发完了,需要测试一些指标,比如性能测试等等,这个时候如果人工填充数据会非常囧的,你可以写rake来自己构造填充数据,你需要处理随机产生等情况,现在不必费心了,使用Faker Gem和populator可以快速的构造需要的数据。\r\n\r\nFaker\r\nA port of Perl‘s Data::Faker library that generates fake data.\r\n\r\nPopulator\r\nPopulate an Active Record database with mass insert.\r\n\r\n安装需要的gem:\r\n
Usage : haproxy -f <cfgfile> [ -vdVD ] [ -n <maxconn> ] [ -N <maxpconn> ] \n[ -p <pidfile> ] [ -m <max megs> ] \n-v displays version ; -vv shows known build options. \n-d enters debug mode ; -db only disables background mode. \n-V enters verbose mode (disables quiet mode) \n-D goes daemon ; implies -q \n-q quiet mode : don't display messages \n-c check mode : only check config file and exit \n-n sets the maximum total # of connections (2000) \n-m limits the usable amount of memory (in MB) \n-N sets the default, per-proxy maximum # of connections (2000) \n-p writes pids of all children to this file \n-de disables epoll() usage even when available \n-ds disables speculative epoll() usage even when available \n-dp disables poll() usage even when available \n-sf/-st [pid ]* finishes/terminates old pids. Must be last arguments.
晓得TDD,BDD,RSpec这些东西很久了,也看了不少的资料和教程,但总感觉还在门外徘徊,始终不得其要,真是怪异。应该是没在实际项目中实践过的缘故吧。 \n本文记录一些RSpec和BDD(Behaviour Driven Development )的资料和文档,给我自己也给各位路过者提供一些资料,感兴趣的仔细看看吧。 \n \n http://rspec.info/ \n Telling a good story - Rspec stories from the trenches \n Slides from RailsConf \n rspec plain text stories + webrat = chunky bacon! \n http://chinaonrails.com/topic/view/220.html \n Story Driven Development with Rails - Part I: Up and Running \n \n另外,http://rspec.info/documentation/rails/上的资料非常棒。有路过的,玩BDD的朋友还望多多指教,领我进门,多谢!
很早前我就说自我的blackberry8100跌坏以后,就一直没买手机,一直在正Google Android的发布,昨天早上(22号)看到chinaeconomicreview上的“T-Mobile’s Google phone on its way”,按照那个里面的图片,觉得非常不爽,整就一黑莓的造型嘛。于是打算入手黑莓8110.
\n", "_id"=>942}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>9, "title"=>"在Startups时就考虑Scalability", "body"=>"一般说来,项目初期的时候考虑更多的是功能的实现和可用性,而对Scalability考虑的并不是很多,从很多人的Scalability经验分享来看,大家比较认同的一条Scalability路线是基本上类似于:先DB和web server在一台机器上,再分割DB和web server,再集群,再cache,再系统分割,再水平、垂直扩展这样的路线。\r\n\r\n我一直不是很同意这个模式,因为当你有志把系统做大道一定规模的时候,为什么不先做一些Scalability的基础呢,比如功能的切割、子系统的划分等等,为什么非要等到系统压力上来了,再手忙脚乱的去重新规划呢。\r\n\r\n之所以这么说,是因为我做的项目预先会考虑好系统划分,做好接口定义,把不同的功能分割在封装成不同的子系统,子系统和子系统之间通过接口传递消息,而后期的Scalability则可以针对不同的子系统需要灵活选择,比如有的子系统需要较多的内存,而有的子系统CPU吃紧等等。\r\n\r\n今天看到Frank Mashraqi(Director of Business Operations & Technical Strategy for a top 50 website that delivers billions of page views per month.)写了一篇文章“Scalability for Startups: How to Grow Up without Blowing Up”,其“12 Tips for Building a Scalable Startup”列举了一些在Startups时就应该考虑的Scalability因素,值得阅读。其还有一个Doc版本,更加生动的说明了一些东西。\r\n\r\n如果你有类似的经验,欢迎和我讨论和分享。", "created_at"=>2008-10-07 02:28:16 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
今天看到Frank Mashraqi(Director of Business Operations & Technical Strategy for a top 50 website that delivers billions of page views per month.)写了一篇文章“Scalability for Startups: How to Grow Up without Blowing Up”,其“12 Tips for Building a Scalable Startup”列举了一些在Startups时就应该考虑的Scalability因素,值得阅读。其还有一个Doc版本,更加生动的说明了一些东西。
\n\n
如果你有类似的经验,欢迎和我讨论和分享。
\n", "_id"=>943}])
+MONGODB iceylog_development['categories'].find({:_id=>9}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>9}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>3, "title"=>"为Mysql选择更加合适的硬件环境", "body"=>"记得前段时间,博文的一个朋友做一本Mysql技术书籍时,将其策划的大纲给我看,我提出让他增加一章关于Mysql硬件选择的内容,因为Mysql的性能受硬件影响很大,如何选择一套比较合适的硬件环境相当重要,自然,他接受了我的建议。\r\n只是不知道他策划的这本书何时才能编写完成,不过在2008 MySQL Conference & Expo上,确实看到一篇“Scaling Out MySQL: Hardware Today and Tomorrow”,其Doc已经可以在scribd上看到了,嵌到这里。\r\n\r\n\r\n
记得前段时间,博文的一个朋友做一本Mysql技术书籍时,将其策划的大纲给我看,我提出让他增加一章关于Mysql硬件选择的内容,因为Mysql的性能受硬件影响很大,如何选择一套比较合适的硬件环境相当重要,自然,他接受了我的建议。 \n只是不知道他策划的这本书何时才能编写完成,不过在2008 MySQL Conference & Expo上,确实看到一篇“Scaling Out MySQL: Hardware Today and Tomorrow”,其Doc已经可以在scribd上看到了,嵌到这里。
\n\n
Scaling out MySQL - Hardware today and tomorrow - Upload a Document to Scribd \n其内容大致涉及到CPU,Mem,vendor,storage等方面的选择,摘取几条如下: \n \n CPU还是选64位的吧(为了支持更大的内存),Mysql在多核CPU上有些问题; \n 内存越大越好,反正很便宜,但是关于内存的配置使用还是很有学问的; \n 硬盘最后是选择15K而不是10K的,在这上面多花点钱是非常值得的; \n \n其他的大家看Doc里面的总结吧,总结好了别忘记share给我哈。
\n", "_id"=>944}])
+MONGODB iceylog_development['categories'].find({:_id=>3}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>3}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Thin"], "comments_count"=>0, "category_id"=>6, "title"=>"Thin version 1.0.0 is out!", "body"=>"Thin version 1.0.0 (codename That's What She Said) is out!\r\n\r\nYes 1.0! That doesn't mean it's bug free or anything. But, it does\r\nmean that it's been running on a number of servers and no show stopper\r\nbugs have been found since a while.\r\n\r\nAlso see http://macournoyer.wordpress.com/2008/09/30/thin-10/\r\n\r\n== What's new?\r\n\r\n* Fixed vlad.rake to allow TCP or socket [hellekin]\r\n* Updated Mack adapter to handle both <0.8.0 and >0.8.0 [Mark Bates]\r\n* rails rack adapter uses File.readable_real? so it recognizes ACL\r\npermissions [Ricardo Chimal]\r\n* Log a warning if Rack application returns nil body [Michael S.\r\nKlishin]\r\n* Handle nil and Time header values correctly [#76 state:resolved]\r\n[tmm1]\r\n* Add Content-Length header to response automatically when possible\r\n[#74 state:resolved] [dkubb]\r\n* Runner now remembers -r, -D and -V parameters so that clustered\r\nservers inherit those and\r\nkeep your parameters.\r\n* Make Set-Cookie header, in Rails adapter, compatible with current\r\nRack spec [Pedro Belo]\r\n[#73, state:resolved]\r\n* Add --no-epoll option to disable epoll usage on Linux [#61\r\nstate:resolved]\r\n* Add --force (-f) option to force stopping of a daemonized server\r\n[#72 state:resolved]\r\n* Update halycon adapter loader [mtodd]\r\n\r\n== Get it!\r\n\r\nInstall Thin from RubyForge:\r\n\r\ngem install thin\r\n\r\nOr using my mirror:\r\n\r\ngem install thin --source http://code.macournoyer.com\r\n\r\n参考文档:\r\nhttp://groups.google.com/group/thin-ruby/browse_thread/thread/402d51a6d9f2651d", "created_at"=>2008-10-07 09:56:27 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
Thin version 1.0.0 (codename That's What She Said) is out!
\n\n
Yes 1.0! That doesn't mean it's bug free or anything. But, it does \nmean that it's been running on a number of servers and no show stopper \nbugs have been found since a while.
\n", "_id"=>945}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"7 Top Tips for Coding With Currency", "body"=>"As anyone who’s ever made an e-commerce system knows, money is everything. No, really if you don’t get your financial sums right then you can’t hope to build a successful online business (and may find yourself creating potential legal issues with the tax man).\r\n\r\nSo here’s a rundown of the top tips I can give for making your financial calculations that bit easier.\r\n\r\nhttp://www.setfiremedia.com/blog/7-top-tips-for-coding-with-currency", "created_at"=>2008-10-08 09:05:08 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
As anyone who’s ever made an e-commerce system knows, money is everything. No, really if you don’t get your financial sums right then you can’t hope to build a successful online business (and may find yourself creating potential legal issues with the tax man).
\n\n
So here’s a rundown of the top tips I can give for making your financial calculations that bit easier.
Search directory arguments recursively for files to convert.
\r\n\t
-d or --delete
\r\n\t
delete input files after successful conversion. May not be safe yet!!!
\r\n\t
-v or --verbose
\r\n\t
makes sneetchalizer more chatty.
\r\n\t
-s or --show-output
\r\n\t
shows output from conversion tool.
\r\n\t
-p or --pretend
\r\n\t
don't convert anything. sneetchalizer will go through the motions and print out the commands it would run. Useful for preview- ing a complex command line to ensure it does what you intend. You should interpret this option's output with a grain of salt. For example, if you include the '--sanitize' option, the files will not really be renamed when using --pretend, and as such the command's output will not reflect that the filenames would be changed during an actual run.
\r\n\t
-t or --terminate
\r\n\t
terminate sneetchalizer options. This is useful if you have to convert '--coolDir' or '-groovySong.mp3'. This is the only option whose order on the command line is significant.
\r\n\t
-D ARG or --out-directory=ARG
\r\n\t
write all outfiles to a directory argument. This is useful if you want to (re)encode files directly to a mounted portable device.
\r\n\t
--strict and --pedantic
\r\n\t
many errors that sneetchalizer may encounter are recoverable, such as specifying a directory as argument that contains no files to convert, or conversion failures in general. By default the script will print an error message and move on to the next file. If you use '--strict' then sneetchalizer will bail out at the first sign of trouble except for tag errors. With '--pedantic' the script will stop even on tag errors.
\r\n\t
--stasis
\r\n\t
Preserve timestamp (mtime) of original file.
\r\n\t
--threads [N]
\r\n\t
Experimental. Use threads to create concurrent jobs. This option takes an optional integer argument which represents the number of threads to launch. The default is two. Preliminary tests suggest there is little advantage (and even diminishing returns) when setting this number greater than the number of cores/CPUs you have. Due to the asychronous nature of threads the --verbose and --show-output flags will be silently disabled and most screen output is supressed.
\r\n\t
--sanitize
\r\n\t
Removes ,, ;, :, ', \", %, @, #, and ` from filenames and tags.
\r\n\t
-n [FORMAT] or --rename[=FORMAT]
\r\n\t
rename all outfiles (and temporary wavs) according to FORMAT. FORMAT is a string with special designators to be pulled from the file tags. The following options are available:
\r\n\t
\r\n\t
* %t Song title
\r\n\t
* %b Album title
\r\n\t
* %n Track number
\r\n\t
* %a Artist name
\r\n\t
* %y Year
\r\n\t
* %g Genre
\r\n\t
* %c Comment field
\r\n\t
\r\n\t
Directories may be created with this command, as in \"%b/%n - %t\". The default value of FORMAT is \"%n %t\".
\r\n\t
\r\n\t
Bitrate/Quality/Compression options:
\r\n\t
\r\n\t
-b or --bitrate
\r\n\t
mp3/ogg/m4a bitrate.
\r\n\t
-q or --quality
\r\n\t
mp3/ogg quality.
\r\n\t
\r\n\t
quality and bitrate are passed directly to lame or oggenc depending on mp3 or ogg output format respectively. Both tools can handle either a bitrate or quality argument, so it is important to understand what values are valid for the underlying tool in your specific use case. faac will accept a bitrate argument, but not a quality argument. These options will be silently ignored for any output formats other than mp3, ogg or m4a. Make sure you know what you are doing if you decide to use both in one run, and read each tools manpage for valid values. If these options are omitted the tools builtin defaults are used (-q3 for oggenc and -q5 for lame).
\r\n\t
\r\n\t
-c or --compression
\r\n\t
flac/mac compression level.
\r\n\t
\r\n\t
this option allows you to pass a compression argument to flac and mac. See 'flac --help' and/or 'mac --help' if you don't know what this means.
\r\n\t
\r\n\t
Format Options:
\r\n\t
\r\n\t
--out=format
\r\n\t
output format. Default is wav.
\r\n\t
--in=format[,format..]
\r\n\t
input format(s). Default is wav.
\r\n\t
\r\n\t
Valid output formats are: \"aac\", \"aif\", \"aifc\", \"aiff\", \"aiffc\", \"ape\", \"au\", \"cdr\", \"cdda\", \"copy\", \"flac\", \"m4a\", \"m4b\", \"mpc\", \"mp4\", \"mpp\", \"mp3\", \"mp2\", \"ofr\", \"ofs\", \"ogg\", \"snd\", \"spx\", \"tta\", \"wav\", \"wv\". Valid input formats are all of the above plus \"wma\". You can specify multiple input formats using a comma: 'mp3,m4a,wma'. Input format is only neccesary when passing directory arguments, as file arguments are handled by context (read: file extension). The \"copy\" output option copies files directly, bypassing decoding/encoding steps (useful in conjunction with --rename).
\r\n\t
\r\n\t
Tagging Options:
\r\n\t
\r\n\t
--tt or --title
\r\n\t
Set 'title' tag.
\r\n\t
--ta or --artist
\r\n\t
Set 'artist' tag.
\r\n\t
--tl or --album
\r\n\t
Set 'album' tag.
\r\n\t
--ty or --year
\r\n\t
Set 'year' tag.
\r\n\t
--tc or --comment
\r\n\t
Set 'comment' tag.
\r\n\t
--tg or --genre
\r\n\t
Set 'genre' tag.
\r\n\t
--tn or --trackn
\r\n\t
Set 'track number' tag.
\r\n\t
\r\n\t
The short and long versions are different in an important way: Using the long version will clobber any existing tags. The short version will only set the tag if the existing tag has no value. Note that these tags will be placed in _every_ outfile during the run.
\r\n\t
\r\n\t
Alternative Encoder/Decoder Options:
\r\n\t
\r\n\t
--gogo
\r\n\t
use gogo to encode mp3 files.
\r\n\t
--bladeenc
\r\n\t
use bladeenc to encode mp3 files.
\r\n\t
\r\n\t
The default is still 'lame'. If 'lame' is not found, the script will search for one of these two encoders regardless if these options are passed or not.
\r\n\t
\r\n\t
Special Options:
\r\n\t
\r\n\t
--in-optionhook=ARG
\r\n\t
add ARG to infile conversion command. Possibly dangerous!
\r\n\t
--out-optionhook=ARG
\r\n\t
add ARG to outfile conversion command. Possibly dangerous!
Using the same --in and --out format allows us to resample/encode the file at a different bitrate or quality. Note that this will overwrite the original file so only do this on a copy, or use '-D' to write files to another directory.
直接下载其gz包,sneetchalizer-0.9.0是现在的最新版本。下载解包后可以看到: \n \nManifest: \n \n README - You're reading it now. \n LICENSE - A copy of the GPL, under which sneetchalizer is released. \n CHANGES - sneetchalizer's cvs/svn commit log. \n sneetchalizer - The script itself. \n sneetchalizer.1 - The manpage for sneetchalizer. \n sneetchalizer.desktop - A KDE service menu for converting with Konqueror. \n install.rb - A quick and dirty script to install the sneetchalizer. \n \n \n如果有root权限,可以直接运行install.rb,其会将sneetchalizer拷贝到/usr/bin下,将sneetchalizer.1拷贝到/usr/share/man/man1下。
\n\n
2、参数解释
\n\n
不翻译了,都挺简单明了的,如下: \n \nXML/HTML代码 \n \n General options: \n \n -h or --help \n Print quick or full usage details respectively. \n -r or --recursive \n Search directory arguments recursively for files to convert. \n -d or --delete \n delete input files after successful conversion. May not be safe yet!!! \n -v or --verbose \n makes sneetchalizer more chatty. \n -s or --show-output \n shows output from conversion tool. \n -p or --pretend \n don't convert anything. sneetchalizer will go through the motions and print out the commands it would run. Useful for preview- ing a complex command line to ensure it does what you intend. You should interpret this option's output with a grain of salt. For example, if you include the '--sanitize' option, the files will not really be renamed when using --pretend, and as such the command's output will not reflect that the filenames would be changed during an actual run. \n -t or --terminate \n terminate sneetchalizer options. This is useful if you have to convert '--coolDir' or '-groovySong.mp3'. This is the only option whose order on the command line is significant. \n -D ARG or --out-directory=ARG \n write all outfiles to a directory argument. This is useful if you want to (re)encode files directly to a mounted portable device. \n --strict and --pedantic \n many errors that sneetchalizer may encounter are recoverable, such as specifying a directory as argument that contains no files to convert, or conversion failures in general. By default the script will print an error message and move on to the next file. If you use '--strict' then sneetchalizer will bail out at the first sign of trouble except for tag errors. With '--pedantic' the script will stop even on tag errors. \n --stasis \n Preserve timestamp (mtime) of original file. \n --threads [N] \n Experimental. Use threads to create concurrent jobs. This option takes an optional integer argument which represents the number of threads to launch. The default is two. Preliminary tests suggest there is little advantage (and even diminishing returns) when setting this number greater than the number of cores/CPUs you have. Due to the asychronous nature of threads the --verbose and --show-output flags will be silently disabled and most screen output is supressed. \n --sanitize \n Removes ,, ;, :, ', ", %, @, #, and ` from filenames and tags. \n -n [FORMAT] or --rename[=FORMAT] \n rename all outfiles (and temporary wavs) according to FORMAT. FORMAT is a string with special designators to be pulled from the file tags. The following options are available: \n \n * %t Song title \n * %b Album title \n * %n Track number \n * %a Artist name \n * %y Year \n * %g Genre \n * %c Comment field \n \n Directories may be created with this command, as in "%b/%n - %t". The default value of FORMAT is "%n %t". \n \n Bitrate/Quality/Compression options: \n \n -b or --bitrate \n mp3/ogg/m4a bitrate. \n -q or --quality \n mp3/ogg quality. \n \n quality and bitrate are passed directly to lame or oggenc depending on mp3 or ogg output format respectively. Both tools can handle either a bitrate or quality argument, so it is important to understand what values are valid for the underlying tool in your specific use case. faac will accept a bitrate argument, but not a quality argument. These options will be silently ignored for any output formats other than mp3, ogg or m4a. Make sure you know what you are doing if you decide to use both in one run, and read each tools manpage for valid values. If these options are omitted the tools builtin defaults are used (-q3 for oggenc and -q5 for lame). \n \n -c or --compression \n flac/mac compression level. \n \n this option allows you to pass a compression argument to flac and mac. See 'flac --help' and/or 'mac --help' if you don't know what this means. \n \n Format Options: \n \n --out=format \n output format. Default is wav. \n --in=format[,format..] \n input format(s). Default is wav. \n \n Valid output formats are: "aac", "aif", "aifc", "aiff", "aiffc", "ape", "au", "cdr", "cdda", "copy", "flac", "m4a", "m4b", "mpc", "mp4", "mpp", "mp3", "mp2", "ofr", "ofs", "ogg", "snd", "spx", "tta", "wav", "wv". Valid input formats are all of the above plus "wma". You can specify multiple input formats using a comma: 'mp3,m4a,wma'. Input format is only neccesary when passing directory arguments, as file arguments are handled by context (read: file extension). The "copy" output option copies files directly, bypassing decoding/encoding steps (useful in conjunction with --rename). \n \n Tagging Options: \n \n --tt or --title \n Set 'title' tag. \n --ta or --artist \n Set 'artist' tag. \n --tl or --album \n Set 'album' tag. \n --ty or --year \n Set 'year' tag. \n --tc or --comment \n Set 'comment' tag. \n --tg or --genre \n Set 'genre' tag. \n --tn or --trackn \n Set 'track number' tag. \n \n The short and long versions are different in an important way: Using the long version will clobber any existing tags. The short version will only set the tag if the existing tag has no value. Note that these tags will be placed in _every_ outfile during the run. \n \n Alternative Encoder/Decoder Options: \n \n --gogo \n use gogo to encode mp3 files. \n --bladeenc \n use bladeenc to encode mp3 files. \n \n The default is still 'lame'. If 'lame' is not found, the script will search for one of these two encoders regardless if these options are passed or not. \n \n Special Options: \n \n --in-optionhook=ARG \n add ARG to infile conversion command. Possibly dangerous! \n --out-optionhook=ARG \n add ARG to outfile conversion command. Possibly dangerous! \n \n \n另外,你可以运行sneetchalizer -h看到简要的使用说明,也可以使用sneetchalizer --help看到详细的使用信息。
\n\n
3、使用示例
\n\n
如下简要的写几个使用的示例: \n \n使用示例: \n \n $ sneetchalizer song.mp3 \n \n The most simple possible example, creates 'song.wav'. \n \n $ sneetchalizer --out=ogg --in=flac -q5 /some/music/dir \n \n This example converts every flac file in '/some/music/dir' to ogg format at quality 5. \n \n $ sneetchalizer -d --out=mp3 --in=ogg,m4a,wma -b 160 . \n \n Converts every ogg, m4a, and wma file in the current directory to a 160 kbps constant bitrate mp3 file. The original files are deleted. \n \n $ sneetchalizer --out=mp3 --out-optionhook="--preset extreme" /some/wavs \n \n Here we encode every wav in '/some/wavs' to mp3 format passing '--preset extreme' directly to lame. \n \n $ sneetchalizer --in=ogg --out=ogg --quality=1 norvegianWood.ogg /some/more/oggs \n \n Using the same --in and --out format allows us to resample/encode the file at a different bitrate or quality. Note that this will overwrite the original file so only do this on a copy, or use '-D' to write files to another directory. \n \n $ sneetchalizer --in=ogg --out=m4a -D /mnt/ipod/ /some/oggs \n \n Here we re-encode some ogg files to m4a format and write them to our mounted iPod. \n \n \n4、注意事项
\n\n
本脚本只是粘合剂,其他的tool还是需要另外安装的。
\n\n
其他信息请参考其主页说明,如果您有这个方面的问题或经验,欢迎和我讨论。
\n\n\n
\n", "_id"=>947}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["架构"], "comments_count"=>0, "category_id"=>9, "title"=>"网站架构文章列表(持续更新中)", "body"=>"互联网越来越开放,技术人员也越来越乐于分享,分析构架、演变和遇到的问题,虽然说没有真正经历过,很多体验可能会没那么深,但是有些东西提前了解会有诸多好处。在很多地方看到类似的构架分析、分享的文章,统一收集整理如下,遇到其他的,我会持续更新,如果经历允许,我还会写一些读后感或者点评;如果你看到其他的类似文章或者点评,欢迎留言让我知道。\n\n对dbanotes等表示感谢。\n\nWikiPedia 技术架构学习分享\nhttp://www.dbanotes.net/opensource/wikipedia_arch.html\n\nYouTube 的架构扩展\nhttp://www.dbanotes.net/opensource/youtube_web_arch.html\n\nLinkedIn 架构笔记\nhttp://www.dbanotes.net/arch/linkedin.html\n\nLinkedIn 架构与开发过程\nhttp://www.dbanotes.net/arch/linkedin_soa.html\n\nInternet Archive 的海量存储浅析\nhttp://www.dbanotes.net/database/internet_archive_storage.html\n\nTailrank 网站架构\nhttp://www.dbanotes.net/review/tailrank_arch.html\n\nTwitter 的架构扩展: 100 倍性能提升\nhttp://www.dbanotes.net/arch/twitter_arch.html\n\n财帮子(caibangzi.com)网站架构\nhttp://www.dbanotes.net/arch/caibangzi_web_arch.html\n\nYupoo! 的网站技术架构\nhttp://www.dbanotes.net/arch/yupoo_arch.html\n\n37Signals 架构\nhttp://www.dbanotes.net/arch/37signals_arch.html\n\nFlickr 的访问统计实现以及其他\nhttp://www.dbanotes.net/arch/flickr_stats_and_dathan.html\n\nPlentyOfFish 网站架构学习\nhttp://www.dbanotes.net/arch/plentyoffish_arch.html\n\nYahoo!社区架构\nhttp://www.dbanotes.net/arch/yahoo_arch.html\n\n有关 Alexa 与 AOL 部署集群文件系统\nhttp://www.dbanotes.net/arch/alexa_ibrix_san_file_system.html\n\neBay 的存储一瞥\nhttp://www.dbanotes.net/arch/ebay_storage.html\n\neBay 的数据量\nhttp://www.dbanotes.net/database/ebay_storage.html\n\neBay 的数据库分布扩展架构\nhttp://www.dbanotes.net/database/ebay_database_scale_out.html\n\neBay 的数据层扩展经验\nhttp://www.dbanotes.net/arch/ebay_db_scale_out.html\n\neBay 的应用服务器规模\nhttp://www.dbanotes.net/web/ebay_application_server.html\n\n性能扩展问题要趁早\nhttp://www.dbanotes.net/arch/scaling_an_early_stage_startup.html\n\nScaling an early stage startup\nhttp://www.scribd.com/doc/429986/Scaling-an-early-stage-startup\n\nFacebook 的 PHP 性能与扩展性\nhttp://www.dbanotes.net/arch/facebook_php.html\n\nSkype 用 PostgreSQL 支撑海量用户\nhttp://www.dbanotes.net/arch/skype_postgresql.html\n\n闲谈 Web 图片服务器\nhttp://www.dbanotes.net/web/web_image_server.html\n\n说说北京奥运购票系统瘫痪这事儿\nhttp://www.dbanotes.net/review/beijing_olympic_ticketes_system_crash.html\n\nArchitectures You’ve Always Wondered About\nhttp://qcon.infoq.com/london-2008/tracks/show_track.jsp?trackOID=82\n\neBay’s Architectural Principles\nhttp://www.eos1.dk/qcon-london-2008/slides/RandyShoup_eBaysArchitecturalPrinciples.pdf\n\nBuilding a large scale SaaS app\nhttp://www.eos1.dk/qcon-london-2008/slides/Dan_Hanley_Building_a_large_scale_SaaS_app.pdf\n\nScaling an early stage startup\nhttp://www.scribd.com/doc/429986/Scaling-an-early-stage-startup\n\n互联星空播客架构(原文在张宴blog上,但是后来文章撤下,很可惜.此为转载)\nhttp://www.flashmov.com/blog_1632.html\n\nQQ游戏百万人同时在线服务器架构实现\nhttp://www.libing.net.cn/read.php?41\n\n大型Web2.0站点构建技术初探\nhttp://blog.csdn.net/heiyeshuwu/archive/2007/11/18/1890793.aspx\n\nWeb站点数据库分布存储浅谈\nhttp://blog.csdn.net/heiyeshuwu/archive/2007/11/18/1891639.aspx\n\nQQ的架构讨论\nhttp://groups.google.com/group/dev4server/browse_thread/thread/0d72668d11c4886b/a6d202489cabf285#a6d202489cabf285\n\nNotes from Scaling MySQL - Up or Out\nhttp://venublog.com/2008/04/16/notes-from-scaling-mysql-up-or-out/\n\nYapache-Yahoo! Apache 的秘密\nhttp://www.dbanotes.net/web/yapache_yahoo_apache.html\n\nScalability Best Practices: Lessons from eBay\nhttp://www.infoq.com/articles/ebay-scalability-best-practices", "created_at"=>2008-10-09 06:51:05 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
Google的产品很多都深得我心,一直在使用,整理整合了一些Gmail的快捷方式,备忘。 \n \n \n \n快捷键 \n定义 \n作用 \n \n \nc \nCompose \n撰写新邮件。“Shift+C”打开新窗口撰写新邮件 \n \n \n<tab> then <Enter> \nSend message \n新邮件撰写完后,先<tab>后<Enter>可发送邮件。(在Windows中,使用IE和Firefox有效) \n \n \nk \nMove to newer conversation \n在收件箱中,向上移动光标,按<Enter>查看邮件;在查看邮件时,打开下一封新邮件 \n \n \nj \nMove to older conversation \n在收件箱中,向下移动光标,按<Enter>查看邮件;在查看邮件时,打开下一封旧邮件 \n \n \nn \nNext message \n查看邮件时,定位光标到 \n \n \np \nPrevious message \n移动光标到前一个消息。<Enter>展开或折叠消息。(只在“会话模式”(Conversation View)中有效) \n \n \no or <Enter> \nOpen \n打开会话。在“Conversation View”中,也可用于打开消息。 \n \n \nu \nReturn to conversation list \n刷新页面、返回收件箱或返回会话列表 \n \n \ny \nArchive* \nRemove from current view \n \n删除会话或消息。 \n在收件箱中,<Y>可“存档”选中的会话
\n\n
在“已加星标示”中,<Y>可取消选中会话的星号; \n 在查看有标签的邮件时,<Y>可取消标签。 \n 在“垃圾邮件”、“已发邮件”和“所有邮件”中,<Y>没有作用 \n \n \n \n \nx \nSelect conversation \n选中会话,配合其他快捷键可为会话存档、添加标签或从下拉菜单中选择其他命令 \n \n \ns \nStar a message or conversation \n为会话或消息加星标。 \n \n \n! \nReport spam \n将消息标记为垃圾邮件并从会话中删除 \n \n \nr \nReply \n回复邮件或会话。“shift+r”可在新窗口中回复消息(只在“会话模式”中有效) \n \n \na \nReply all \n回复所有收件人。“Shift+a”可打开新窗口中回复。(PConline注:如果邮件有抄送地址,<r>回复发件人,<a>则回复所有抄送地址) \n \n \nf \nForward \n转发消息。“Shift+f”可打开新窗口转发。(只在“查看消息模式”(“Conversation View”)中有效) \n \n \n<Esc> \nEscape from input field \nRemoves the cursor from your current input field.(PConline注:在中文版Gmail中暂未有效果) \n \n \ny then o \nArchive and next \n存档选中的会话并打开下一个 \n \n \ng then a \nGo to 'All Mail' \n转到“所有邮件” \n \n \ng then s \nGo to 'Starred' \n转到“已加星标” \n \n \ng then c \nGo to 'Contacts' \n转到“通讯录” \n \n \ng then d \nGo to 'Drafts' \n转到“草稿” \n \n \ng then i \nGo to 'Inbox' \n转到“收件箱” \n \n \n/ \nSearch \n将光标定位到搜索栏中的输入框中 \n \n \n \n
\n", "_id"=>949}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["analyzer"], "comments_count"=>0, "category_id"=>7, "title"=>"Request-log-analyzer: Rails&Merb的日志分析", "body"=>"生产环境下,需要对环境持续监控以尽快的发现问题,找到耗费资源较多的地方加以改进,比较常见的做法是使用moint或者God实时监控;另外,还可以定期分析日志找到特定的请求,虽然可以是shell来做这件事,但是何必再造轮子呢,因为我们已经有了Request log analyzer :\r\n``简介:This is a simple command line tool to analyze request log files of both Rails andMerb. Its purpose is to find what actions are best candidates for optimization.This tool will parse all requests in the logfile and aggregate theinformation. Once it is finished parsing the log file, it will show therequests that take op most server time. Different metrics are used (cumulativetime, average time, blockers, DB time, etc)\r\n\r\n安装:gem sources -a http://gems.github.comsudo gem install wvanbergen-request-log-analyzer\r\n\r\n使用:Usage: request-log-analyzer [FILE] [OPTION]Analyze the given log FILE with the given OPTIONExample: request-log-analyzer mongrel.log\r\n\r\n --fast, -t: Only use completed requests --guess-database-time, -g: Guesses the database duration of requests if they are not in the log --output, -o: Comma-separated list of reports to show --amount, -c: Displays the top <amount> elements in the reports --colorize, -z: Fancy bash coloring\r\n\r\n示例:Note that this example was shortened for your viewing pleasure.$ request-log-analyzer /var/log/my_app.log\r\n\r\nRequest log analyzer, by Willem van Bergen and Bart ten Brinke\r\n\r\nProcessing all log lines...========================================================================Successfully analyzed 58908 requests from log file\r\n\r\nTimestamp first request: 2008-07-13T06:25:58+00:00Timestamp last request: 2008-07-20T06:18:53+00:00Total time analyzed: 7 daysMethods: DELETE (1%), GET (50%), POST (22%), PUT (25%).\r\n\r\nTop 10 most requested actions========================================================================/overview/:date/ : 19359 requests/overview/day/:date/ : 6365 requests/overview/:date/set/ : 5589 requests/overview/ : 3985 requests/clients/:id/ : 1976 requests........\r\n\r\nTop 10 actions by time - cumulative========================================================================/overview/:date/ : 9044.582s [19359 requests]/overview/ : 8478.767s [3985 requests]/overview/:date/set/ : 3309.041s [5589 requests]/clients/:id/products/:id/ : 1479.911s [924 requests]/clients/:id/ : 750.080s [1976 requests]........\r\n\r\nTop 10 actions by time - per request mean========================================================================/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]/clients/:id/ : 0.380s [1976 requests]........\r\n\r\nTop 10 worst DB offenders - cumulative time========================================================================/overview/:date/ : 8773.993s [19359 requests]/overview/ : 8394.754s [3985 requests]/overview/:date/set/ : 3307.928s [5589 requests]/clients/:id/products/:id/ : 1425.220s [924 requests]/clients/:id/ : 535.229s [1976 requests]........\r\n\r\nTop 10 worst DB offenders - mean time========================================================================/overview/:id/:id/:id/print/ : 6.994s [448 requests]/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]........\r\n\r\nMongrel process blockers (> 1.0 seconds)========================================================================/overview/:date/ : 7494.233s [3144 requests]/overview/ : 8320.293s [1549 requests]/overview/:date/set/ : 1149.235s [803 requests]/overview/:id/:id/:id/print/new/ : 613.693s [341 requests]/clients/:id/products/:id/ : 1370.693s [313 requests]........\r\n\r\nRequests graph - per hour======================================================================== ........ 7:00 - 2731 : XXXXXXX 8:00 - 6139 : XXXXXXXXXXXXXXXX 9:00 - 7465 : XXXXXXXXXXXXXXXXXXXX 10:00 - 7118 : XXXXXXXXXXXXXXXXXXX 11:00 - 7409 : XXXXXXXXXXXXXXXXXXX 12:00 - 6450 : XXXXXXXXXXXXXXXXX 13:00 - 5377 : XXXXXXXXXXXXXX 14:00 - 6058 : XXXXXXXXXXXXXXXX 15:00 - 4156 : XXXXXXXXXXX 16:00 - 2767 : XXXXXXX 17:00 - 1598 : XXXX 18:00 - 792 : XX ........\r\n\r\nErrors========================================================================ArgumentError: [237 requests] -> invalid dateStaleObjectError: [28 requests] -> Attempted to update a stale objectRuntimeError: [3 requests] -> Cannot destroy rule before it was createdStatementError: [2 requests] -> Mysql::Error: Deadlock found when trying to get lock; try restarting transactionNoMethodError: [1 requests] -> undefined method `code' for nil:NilClass```", "created_at"=>2008-10-13 08:45:11 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
生产环境下,需要对环境持续监控以尽快的发现问题,找到耗费资源较多的地方加以改进,比较常见的做法是使用moint或者God实时监控;另外,还可以定期分析日志找到特定的请求,虽然可以是shell来做这件事,但是何必再造轮子呢,因为我们已经有了Request log analyzer : \n``简介:This is a simple command line tool to analyze request log files of both Rails andMerb. Its purpose is to find what actions are best candidates for optimization.This tool will parse all requests in the logfile and aggregate theinformation. Once it is finished parsing the log file, it will show therequests that take op most server time. Different metrics are used (cumulativetime, average time, blockers, DB time, etc)
\n\n
安装:gem sources -a http://gems.github.comsudo gem install wvanbergen-request-log-analyzer
\n\n
使用:Usage: request-log-analyzer [FILE] [OPTION]Analyze the given log FILE with the given OPTIONExample: request-log-analyzer mongrel.log
\n\n
--fast, -t: Only use completed requests --guess-database-time, -g: Guesses the database duration of requests if they are not in the log --output, -o: Comma-separated list of reports to show --amount, -c: Displays the top <amount> elements in the reports --colorize, -z: Fancy bash coloring
\n\n
示例:Note that this example was shortened for your viewing pleasure.$ request-log-analyzer /var/log/my_app.log
\n\n
Request log analyzer, by Willem van Bergen and Bart ten Brinke
\n\n
Processing all log lines...========================================================================Successfully analyzed 58908 requests from log file
\n\n
Timestamp first request: 2008-07-13T06:25:58+00:00Timestamp last request: 2008-07-20T06:18:53+00:00Total time analyzed: 7 daysMethods: DELETE (1%), GET (50%), POST (22%), PUT (25%).
\n\n
Top 10 most requested actions========================================================================/overview/:date/ : 19359 requests/overview/day/:date/ : 6365 requests/overview/:date/set/ : 5589 requests/overview/ : 3985 requests/clients/:id/ : 1976 requests........
\n\n
Top 10 actions by time - cumulative========================================================================/overview/:date/ : 9044.582s [19359 requests]/overview/ : 8478.767s [3985 requests]/overview/:date/set/ : 3309.041s [5589 requests]/clients/:id/products/:id/ : 1479.911s [924 requests]/clients/:id/ : 750.080s [1976 requests]........
\n\n
Top 10 actions by time - per request mean========================================================================/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]/clients/:id/ : 0.380s [1976 requests]........
Errors========================================================================ArgumentError: [237 requests] -> invalid dateStaleObjectError: [28 requests] -> Attempted to update a stale objectRuntimeError: [3 requests] -> Cannot destroy rule before it was createdStatementError: [2 requests] -> Mysql::Error: Deadlock found when trying to get lock; try restarting transactionNoMethodError: [1 requests] -> undefined method code' for nil:NilClass``
Nginx有个Log Rotation模块,nginx will re-open it's logs in response to the USR1 signal.参考如下脚本: \n`$ mv access.log access.log.0$ kill -USR1cat master.nginx.pid`$ sleep 1$ gzip access.log.0 # do something with access.log.0
\r\n``2、Hpricot```Pros: Cool name, created by _why, faster than REXML, also does HTML, creative APICons: Not as fast as libxml-ruby, more of an HTML parser linguistically (ie: uses innerHTML instead of text or content, etc.)```\r\n
\r\n
Ruby代码
\r\n\r\n\t
%w[benchmark pp rubygems].each { |x| require x }
\r\n\t
gem 'hpricot', '>= 0.6'
\r\n\t
require 'hpricot'
\r\n\t
\r\n\t
##################################
\r\n\t
# Parsing Delicious API Response #
\r\n\t
##################################
\r\n\t
xml = File.read('posts.xml')
\r\n\t
puts Benchmark.measure {
\r\n\t
doc, posts = Hpricot::XML(xml), []
\r\n\t
(doc/:post).eachdo |p|
\r\n\t
posts << p.attributes
\r\n\t
end
\r\n\t
# pp posts
\r\n\t
}
\r\n\t
\r\n\t
################################
\r\n\t
# Parsing Twitter API Response #
\r\n\t
################################
\r\n\t
xml = File.read('timeline.xml')
\r\n\t
puts Benchmark.measure {
\r\n\t
doc, statuses = Hpricot::XML(xml), []
\r\n\t
(doc/:status).eachdo |s|
\r\n\t
h = {:user => {}}
\r\n\t
%w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].eachdo |a|
\r\n\t
h[a.intern] = s.at(a).innerHTML
\r\n\t
end
\r\n\t
%w[id name screen_name location description profile_image_url url protected followers_count].eachdo |a|
\r\n\t
h[:user][a.intern] = s.at('user').at(a).innerHTML
\r\n\t
end
\r\n\t
statuses << h
\r\n\t
end
\r\n\t
# pp statuses
\r\n\t
}
\r\n\r\n
\r\n3、libxml-ruby \r\n\r\nPros: Blistering fast\r\nCons: Hpricot has cooler name, REXML and Hpricot both feel easier to use out of the box\r\n
Ruby可以很方便的解析XML格式的文档,目前用的比较多的lib主要有三个,分别是:REXML, Hpricot, libxml-ruby,如下选取两个XML文档,分别使用这三个lib解析,感受下各自的速度和易用性。 \n一、原料 \n \n posts.xml – Uses xml element for object (post) and xml attributes for object attributes \n timeline.xml – Uses xml element for object (status) and child xml elements for attributes \n \n二、解析过程 \n1、REXML
\n\n
Pros: In the standard library \nCons: Slow, I don’t like the name \n \nRuby代码 \n \n %w[benchmark pp rexml/document].each { |x| require x } \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n doc, posts = REXML::Document.new(xml), [] \n doc.elements.each('posts/post') do |p| \n posts << p.attributes \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n doc, statuses = REXML::Document.new(xml), [] \n doc.elements.each('statuses/status') do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.elements[a].text \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.elements['user'].elements[a].text \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n<code class="ruby"><strong>2、Hpricot</strong><strong>Pros:</strong> Cool name, created by _why, faster than <span class="caps">REXML</span>, also does <span class="caps">HTML</span>, creative <span class="caps">API</span><strong>Cons:</strong> Not as fast as libxml-ruby, more of an <span class="caps">HTML</span> parser linguistically (ie: uses innerHTML instead of text or content, etc.)`` \n \nRuby代码 \n \n %w[benchmark pp rubygems].each { |x| require x } \n gem 'hpricot', '>= 0.6' \n require 'hpricot' \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n doc, posts = Hpricot::XML(xml), [] \n (doc/:post).each do |p| \n posts << p.attributes \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n doc, statuses = Hpricot::XML(xml), [] \n (doc/:status).each do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.at(a).innerHTML \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.at('user').at(a).innerHTML \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n3、libxml-ruby
\n\n
Pros: Blistering fast \nCons: Hpricot has cooler name, REXML and Hpricot both feel easier to use out of the box \n \nRuby代码 \n \n %w[benchmark pp rubygems].each { |x| require x } \n gem 'libxml-ruby', '>= 0.8.3' \n require 'xml' \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n parser, parser.string = XML::Parser.new, xml \n doc, posts = parser.parse, [] \n doc.find('//posts/post').each do |p| \n posts << p.attributes.inject({}) { |h, a| h[a.name] = a.value; h } \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n parser, parser.string = XML::Parser.new, xml \n doc, statuses = parser.parse, [] \n doc.find('//statuses/status').each do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.find(a).first.content \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.find('user').first.find(a).first.content \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n<code class="ruby"><strong>三、结论</strong> \n<div class="codeText"> \n<div class="codeHead">结果如下:</div> \n<ol class="dp-xml" start="1"> \n <li class="alt"><span><span>=rexml </span></span></li> \n <li><span>delicious 0.020000 0.000000 0.020000 ( 0.021139) </span></li> \n <li class="alt"><span>twitter 0.940000 0.020000 0.960000 ( 0.988666) </span></li> \n <li><span> </span></li> \n <li class="alt"><span>=hpricot </span></li> \n <li><span>delicious 0.010000 0.000000 0.010000 ( 0.005548) </span></li> \n <li class="alt"><span>twitter 0.250000 0.010000 0.260000 ( 0.258320) </span></li> \n <li><span> </span></li> \n <li class="alt"><span>=libxml-ruby </span></li> \n <li><span>delicious 0.000000 0.000000 0.000000 ( 0.007829) </span></li> \n <li class="alt"><span>twitter 0.030000 0.010000 0.040000 ( 0.034040) </span></li> \n</ol> \n</div> \n``<code class="ruby">参考文档:http://railstips.org/2008/8/12/parsing-xml-with-ruby``
\n", "_id"=>953}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Tips"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["oauth"], "comments_count"=>0, "category_id"=>4, "title"=>"初识oauth: 为API访问授权提供一个开放的标准", "body"=>"最近在准备一些API设计开发工作,初步了解了下oauth,OAuth是由Blaine Cook、Chris Messina、Larry Halff 及David Recordon共同发起的,目的在于为API访问授权提供一个开放的标准。\r\noauth目前看来进展比较顺利,可以看到其有主流语言的lib(Java、C#、Objective-C、Perl、PHP及Ruby语言),目前支持oauth的API有twitter,douban等应用。\r\n\r\nOAuth is the great new standard allowing your users to use your application to talk to their accounts on other applications. I won’t go more into it here as it’s pretty well covered on the OAuth site.\r\n\r\nOAuth’s Goal\r\nWebsite X can access your protected data at API Y\r\n
\r\n\t
All without sharing your password off-site
\r\n\t
especially when there isn’t one like with OpenID
\r\n
\r\n其基本流程为:\r\n\r\n\t
Register your consumer application with the OAuth compliant service to receive your Consumer Credentials (This is only done once)
\r\n\t
You initiate the OAuth Token exchange process for a user by requesting a RequestToken from the Service
\r\n\t
You store the RequestToken in your database or in the users session object
\r\n\t
You redirect your user to the service providers authorize_url with the RequestToken’s key appended
\r\n\t
Your user is asked by the service provider to authorize your RequestToken
\r\n\t
Your user clicks yes and is redirected to your CallBack URL
OAuth is the great new standard allowing your users to use your application to talk to their accounts on other applications. I won’t go more into it here as it’s pretty well covered on the OAuth site. \n \nOAuth’s Goal \nWebsite X can access your protected data at API Y \n \n All without sharing your password off-site \n especially when there isn’t one like with OpenID \n \n其基本流程为: \n \n Register your consumer application with the OAuth compliant service to receive your Consumer Credentials (This is only done once) \n You initiate the OAuth Token exchange process for a user by requesting a RequestToken from the Service \n You store the RequestToken in your database or in the users session object \n You redirect your user to the service providers authorize_url with the RequestToken’s key appended \n Your user is asked by the service provider to authorize your RequestToken \n Your user clicks yes and is redirected to your CallBack URL \n Your callback action exchanges the RequestToken for an AccessToken \n Now you can access your users data by performing http requests signed by your consumer credentials and the AccessToken. \n ???? \n PROFIT!!! \n \n如果你想了解,请参考如下文档,如果你有经验,请分享,谢谢! \n \n参考文档: \n \n Developing OAuth clients in Ruby \n How to turn your rails site into an OAuth Provider \n OAuth不断获得动力 \n Rails plugin for OAuth \n OAuth implementation for Ruby \n 豆瓣 API 认证授权说明 \n The How of OAuth --这个PPT挺不错 \n
\n", "_id"=>957}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>7, "title"=>"在crontab中调用rake task定时跑job", "body"=>"在Rails中可以使用很大插件来实现后台定时JOB,但是最环保的应该是使用crontab来调用rake,也很简单,基本上分成如下几步:\r\n\r\nin the root of my app i have notify_answerers.sh\r\n``#!/bin/shexport PATH='/usr/local/ruby/bin':$PATH cd /opt/dev/Monier/usr/local/ruby/bin/rake nginx:fetch_status RAILS_ENV=production```\r\nin myapp/lib/tasks i have myapp.rake\r\n``namespace :nginx do desc \"Notify answerers of new questions\" task :fetch_status => :environment do Nginx.find(:all).each do |nginx| puts \"nginx=\#{nginx.name}\" nginx.do_fetch_nginx_status_job nginx.update_attribute(:updated_at,Time.now) end endend```\r\nIn my cron file i have:\r\n``*/2 * * * * /bin/sh /opt/dev/Monier/lib/crontabs/fetch_nginx_status.sh```\r\n(use \"crotab -e\" on the server to edit this file)", "created_at"=>2008-10-24 16:51:45 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
in the root of my app i have notify_answerers.sh \n#!/bin/shexport PATH='/usr/local/ruby/bin':$PATH cd /opt/dev/Monier/usr/local/ruby/bin/rake nginx:fetch_status RAILS_ENV=production \nin myapp/lib/tasks i have myapp.rake \nnamespace :nginx do desc "Notify answerers of new questions" task :fetch_status => :environment do Nginx.find(:all).each do |nginx| puts "nginx=\#{nginx.name}" nginx.do_fetch_nginx_status_job nginx.update_attribute(:updated_at,Time.now) end endend \nIn my cron file i have: \n*/2 * * * * /bin/sh /opt/dev/Monier/lib/crontabs/fetch_nginx_status.sh``` \n(use "crotab -e" on the server to edit this file)
merb的1.0终于出来了,等的实在不易,1.0版的merb已经足够完善了,可以拿来做一些production的东西了,例如以前说到的代替rails做上传文件等等。 \nrubyinsite已经发了一篇参考资源文件,感兴趣的可以过去瞧瞧,地址如下:Merb 1.0 Released So Here’s 44 Links and Resources To Get You Going。
Q:how to get distance between two GeoPoints in sdk 1.0 ? MapPoint.distanceSquared(MapPoint) is gone \nthaks!! \n
\n
A:you'll need to brush up on your trigonometry, and first compute the Haversine function (this is the standard way of doing it). In order to use the Java trig functions, you'll have to first convert all your angles from degrees to radians. \nGiven two longitude/latitude pairs, and the earth's average radius (assume 6356.78km for your calculations), \nyou can calculate the distance between the 2 points via this Java code: \n \n \tdouble EarthRad = 6356.78;\t// in km ! \n// first convert to radians... \ndouble geo1_lat = geo1.getLatitude()*java.lang.Math.PI/360; \ndouble geo1_lng = geo1.getLongitude()*java.lang.Math.PI/360; \ndouble geo2_lat = geo2.getLatitude()*java.lang.Math.PI/360; \ndouble geo2_lng = geo2.getLongitude()*java.lang.Math.PI/360; \n \ndouble deltaLat = java.lang.Math.abs(java.lang.Math.abs(geo2_lat) - java.lang.Math.abs(geo1_lat)); \ndouble deltaLng = java.lang.Math.abs(java.lang.Math.abs(geo2_lng) - java.lang.Math.abs(geo1_lng)); \n \ndouble dist = 2*EarthRad*java.lang.Math.asin(java.lang.Math.sqrt(haversine(deltaLat) \n+ java.lang.Math.cos(pair1_lat) \n*java.lang.Math.cos(pair1_lng)*haversine(deltaLng))); \n \nWhere "dist" now contains the distance between along the earth's surface. \nYou can find the Haversine function trig equation by Googling it, then construct a method that returns the appropriate value.
\n
Computing the speed is straightforward: you know your sampling frequency, and you now know the distance between the most recent two points, so, employee speed = distance / sampling interval
Q:how to get distance between two GeoPoints in sdk 1.0 ? MapPoint.distanceSquared(MapPoint) is gone \nthaks!! \n \nA:you'll need to brush up on your trigonometry, and first compute the Haversine function (this is the standard way of doing it). In order to use the Java trig functions, you'll have to first convert all your angles from degrees to radians. \nGiven two longitude/latitude pairs, and the earth's average radius (assume 6356.78km for your calculations), \nyou can calculate the distance between the 2 points via this Java code: \n \n double EarthRad = 6356.78; // in km ! \n// first convert to radians... \ndouble geo1_lat = geo1.getLatitude()*java.lang.Math.PI/360; \ndouble geo1_lng = geo1.getLongitude()*java.lang.Math.PI/360; \ndouble geo2_lat = geo2.getLatitude()*java.lang.Math.PI/360; \ndouble geo2_lng = geo2.getLongitude()*java.lang.Math.PI/360; \n \ndouble deltaLat = java.lang.Math.abs(java.lang.Math.abs(geo2_lat) - java.lang.Math.abs(geo1_lat)); \ndouble deltaLng = java.lang.Math.abs(java.lang.Math.abs(geo2_lng) - java.lang.Math.abs(geo1_lng)); \n \ndouble dist = 2*EarthRad*java.lang.Math.asin(java.lang.Math.sqrt(haversine(deltaLat) \n+ java.lang.Math.cos(pair1_lat) \n*java.lang.Math.cos(pair1_lng)*haversine(deltaLng))); \n \nWhere "dist" now contains the distance between along the earth's surface. \nYou can find the Haversine function trig equation by Googling it, then construct a method that returns the appropriate value. \nComputing the speed is straightforward: you know your sampling frequency, and you now know the distance between the most recent two points, so, employee speed = distance / sampling interval \n参考:http://www.anddev.org/distance_between_two_geopoints_in_sdk10-t4195.html \nhttp://www.anddev.org/calculating_distance_between_two_gps_points-t3708.html \n
\n", "_id"=>982}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Ruby&Rails", "to_xml"], "comments_count"=>0, "category_id"=>11, "title"=>"Rails: Disabling XML character escaping for to_xml & xml builder", "body"=>"
In my case, I had to genarate the xml view for api render,but in rails, i got a &XXX format string for non englisg, it also appears to_xml will automatically escape any entities into their corresponding &XXX representation. There's a piece in the documentation that says "If $KCODE is set to u and encoding set to UTF8, then escaping will NOT be performed." \n \nUnfortunately, this doesn't appear to be the case. Even after following the docs and ensuring that default_charset is indeed UTF-8 (actually the default for Rails nowadays), we still get encoded characters in to_xml output. \n \nSince our client is UTF-8 aware, we need to pass thru the UTF-8 data intact. The only way we've found to do this is thru the following horrible monkey-patch:
\n
\n
Ruby代码
\n\n
module Builder
\n
class XmlBase
\n
def _escape(text)
\n
text
\n
end
\n
end
\n
end
\n\n
\n
\nWhat's the proper way to do this? \n \nPS: \nsomebody say that to "set $KCODE='UTF8' in config/environment.rb can solve this issue." but it's not for me. \n \nmore infos: \nhttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2c13ad7c0f8c0781
In my case, I had to genarate the xml view for api render,but in rails, i got a &XXX format string for non englisg, it also appears to_xml will automatically escape any entities into their corresponding &XXX representation. There's a piece in the documentation that says "If $KCODE is set to u and encoding set to UTF8, then escaping will NOT be performed." \n \nUnfortunately, this doesn't appear to be the case. Even after following the docs and ensuring that default_charset is indeed UTF-8 (actually the default for Rails nowadays), we still get encoded characters in to_xml output. \n \nSince our client is UTF-8 aware, we need to pass thru the UTF-8 data intact. The only way we've found to do this is thru the following horrible monkey-patch: \n \nRuby代码 \n \n module Builder \n class XmlBase \n def _escape(text) \n text \n end \n end \n end \n \n \n \nWhat's the proper way to do this? \n \nPS: \nsomebody say that to "set $KCODE='UTF8' in config/environment.rb can solve this issue." but it's not for me. \n \nmore infos: \nhttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2c13ad7c0f8c0781 \n
\n", "_id"=>983}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["random", "ruby"], "comments_count"=>0, "category_id"=>11, "title"=>"Generate a random string", "body"=>"Generates a random string of lowercase letters. Great for email verification codes or user password salt....\n
Some tips for mount&umount ,maybe give you some help..
\n
cdrom: \n# mount -t is09660 /dev/cdrom /mnt/cdrom \n# umount /mnt/cdrom \n \nfloppy: \n# mount /dev/fd0 /mnt/floppy \n#umount /mnt/floppy \n \nusb: \n1.use 'fdisk -l' to show the usb nums,something like '/dev/sda'; \n2.then use 'mkdir /mnt/usb' to create a dir for mount this usb; \n3.at last,use '# mount -t msdos /dev/sda1 /mnt/usb" to mount it. \n4.#umount /mnt/usb \n \nhda: \n1.use 'fdisk -l' to show the disk nums,like '/dev/hda1'; \n2.then use 'make /mnt/vfat' to create a mount point; \n3.at last,use '# mount -t vfat /dev/hda1 /mnt/vfat'to mount it.. \n4.#umount /mnt/vfat
Some tips for mount&umount ,maybe give you some help.. \ncdrom:
\n\n
mount -t is09660 /dev/cdrom /mnt/cdrom
\n\n
umount /mnt/cdrom
\n\n
floppy:
\n\n
mount /dev/fd0 /mnt/floppy
\n\n
umount /mnt/floppy
\n\n
usb: \n1.use 'fdisk -l' to show the usb nums,something like '/dev/sda'; \n2.then use 'mkdir /mnt/usb' to create a dir for mount this usb; \n3.at last,use '# mount -t msdos /dev/sda1 /mnt/usb" to mount it. \n4.#umount /mnt/usb \n \nhda: \n1.use 'fdisk -l' to show the disk nums,like '/dev/hda1'; \n2.then use 'make /mnt/vfat' to create a mount point; \n3.at last,use '# mount -t vfat /dev/hda1 /mnt/vfat'to mount it.. \n4.#umount /mnt/vfat \nand some usefull resource links and docs here: \nhttp://unix-cd.com/unixcd12/article_3967.html \nhttp://blog.oracle.com.cn/index.php/121320/viewspace-6733.html
In my case, I need do send big files to users, yes, you can do it with nginx,just like others static files,but i need some control for the request action,The delivery of a static file which depends on an application header is known as the X-Sendfile feature. \nLighttpd has this feature and there is a mod_xsendfile for Apache2. \nNginx also has this feature, but implemented a little bit differently. In Nginx this feature is called X-Accel-Redirect. \nThere are two main differences:
\n\n
The header must contain a URI
\n
The location should be defined as internal; to prevent the client going directly to the URI
\n\n
\n
\n
Ruby代码
\n\n
location /files {
\n
root /var/www;
\n
internal;
\n
}
\n\n
\n
\n
Ruby代码
\n\n
// Get requested file name
\n
path = @params["path"]
\n
\n
# ...
\n
# Perform any required security checks, validation
In my case, I need do send big files to users, yes, you can do it with nginx,just like others static files,but i need some control for the request action,The delivery of a static file which depends on an application header is known as the X-Sendfile feature. \nLighttpd has this feature and there is a mod_xsendfile for Apache2. \nNginx also has this feature, but implemented a little bit differently. In Nginx this feature is called X-Accel-Redirect. \nThere are two main differences: \n \n The header must contain a URI \n The location should be defined as internal; to prevent the client going directly to the URI \n \n \n \nRuby代码 \n \n location /files { \n root /var/www; \n internal; \n } \n \n \n \nRuby代码 \n \n // Get requested file name \n path = @params["path"] \n \n # ... \n # Perform any required security checks, validation \n # and/or stats accounting \n # ... \n \n # And redirect user to internal location \n response.headers['X-Accel-Redirect'] = "/files/" + path \n \n \n \nsome userfull link resource come here: \n \n http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/ \n http://wiki.codemongers.com/NginxXSendfile \n http://www.motionstandingstill.com/using-nginx-to-send-files-with-x-accel-redirect/2008-09-03/ \n \n
I store user sessions in memcache,and then i want do share theres sessions with sub domains,but i notice some strange things when i put session into memcached,there are: \n1. In my older website(rails 2.0),It genenrated sessions key for memcached as \#{namespace}-\#{RAILS_ENV}:"session:\#{id}"; \n2.In my newer website(reails 2.3),It generated seesions key for memcached just as "\#{namespace}:\#{id}"; \n \nso,i can not get the same seesion datas with diff session keys. i do have spend lots of time for sove this , i do have some userfull dis, \n \n1. In rails2.3 ,it's vendor memcache-client-1.5.0.5 in ruby\\lib\\ruby\\gems\\1.8\\gems\\activesupport-2.3.0\\lib\\active_support\\vendor; \n2. you can config namespace in you environment.rb file like " ActionController::Base.session_options[:namespace] = 'session'" \n3. In rails2.0,when you use memcached,you will use cached_fu and act_as_cache plugins,and you may have a config file in your config dir named memcached.yml, and in this file,you can config defaults,production,test and developer..with lots of filed,like namespace,servers etc.. \n4. you will notice it generate memcached key as mentioned above. \n \nI track it,and got this:
I store user sessions in memcache,and then i want do share theres sessions with sub domains,but i notice some strange things when i put session into memcached,there are: \n1. In my older website(rails 2.0),It genenrated sessions key for memcached as \#{namespace}-\#{RAILS_ENV}:"session:\#{id}"; \n2.In my newer website(reails 2.3),It generated seesions key for memcached just as "\#{namespace}:\#{id}"; \n \nso,i can not get the same seesion datas with diff session keys. i do have spend lots of time for sove this , i do have some userfull dis, \n \n1. In rails2.3 ,it's vendor memcache-client-1.5.0.5 in ruby\\lib\\ruby\\gems\\1.8\\gems\\activesupport-2.3.0\\lib\\active_support\\vendor; \n2. you can config namespace in you environment.rb file like " ActionController::Base.session_options[:namespace] = 'session'" \n3. In rails2.0,when you use memcached,you will use cached_fu and act_as_cache plugins,and you may have a config file in your config dir named memcached.yml, and in this file,you can config defaults,production,test and developer..with lots of filed,like namespace,servers etc.. \n4. you will notice it generate memcached key as mentioned above. \n \nI track it,and got this: \n \nRuby代码 \n \n def setup_memcache(config) \n config[:namespace] << "-\#{RAILS_ENV}" \n \n silence_warnings do \n Object.const_set :CACHE, memcache_klass.new(config) \n end \n \n CACHE.servers = Array(config.delete(:servers)) \n \n setup_session_store if config[:sessions] \n setup_fragment_store! if config[:fragments] \n setup_fast_hash! if config[:fast_hash] \n setup_fastest_hash! if config[:fastest_hash] \n \n CACHE \n end \n \n \nshit,it append RAILS_ENV to namespace with "-",that's it...I hate some hardcode config in plugin,blalal.... \nsome userfull link resources... \n \n http://errtheblog.com/posts/22-sessions-n-such \n http://www.raecoo.com/2008/10/25/rails-store-format-in-memcache/ \n http://www.scribd.com/doc/2203398/Scaling-Rails-with-memcached \n http://railscasts.com/episodes/115-caching-in-rails-2-1
In some case,you may want do get Uniquely Identifying for a 'real' android phone,and you can do it like this:
\n
In Android.Provider.Settings.System we have some interesting values that could be of use, one specifically is “Android_ID”. From the documentation it is the following;
\n
\n
String \tANDROID_ID \tThe Android ID (a unique 64-bit value) as a hex string. \t“android_id”
\nAlso, note that in an emulator this will return “null”, though a real device will return an actual value. The nice thing about this tid-bit of code is that you are not required any special permissions to call it, since it’s essentially a passive call to get information. No write access is (obviously) required.\n
Garry Tan, cofounder of Posterous, lists 12 lessons for scaling that apply to more than just Rails,and i mark some word below. \n \nUse cloud storage for static files. --S3,I do not care it 's fine in china. \nUse HTTP Cache Control to tell the browser what it can cache. --this is true,etag is great. \nUse Sphinx for text search. --sometimes,you do have others chose. \nUse InnoDB for more crash resistant and faster writes. --maybe it's right. \nDon't use textbook Rails ActiveRecord objects. Use New Relic to find exactly what is slow in your system. --yep \nUse memcache later so you find your database bottlenecks now. --this is very important. \nUse mongrel proctitle to find your slow queries. You are only as fast as your slowest queries. -maybe mongrel is not only chose,think about thin,ok? \nUse asynchronous job queuing to do work in parallel. --yes,but sometimes crontab is enough. \nUse monitoring so you'll know when your site went down and why. --that's it,just do it. \nLearn by reading the source code, fixing problems, and submitting them back to the community. --very userfull when you got some strange questions.. \nUse new plugins. Old plugins can't be trusted. --and check chang histroy carefully. \nUse new information. Old information can't be trusted. --and what's this? \n \ngo to http://axonflux.com/building-and-scaling-a-startup for more infos.
When it asks for driver location choose the unzipped folderand install the driver for it.
\n
You'll see sth like "HTC Dream Composite ADB Interface" on success
\n
(Re)Start Eclipse
\n
Your G1 should now be listed in the DDMS-Perspective under Devices
\n
Go to the AndroidManifest.xml of your App and modify it to containandroid:debuggable="true"in the <application ... >-Tag,look like this:<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
\n
Go Debug as usual. \n
\n\nps: I do not upload the zip file here,you can find it via the link above,but if you can not download it,you can mail me to fetch one.
I konw,you can dev app and test it on the simulator,but if you had a real driver,G1,you can do debug on it,very great,here is the tips for this: \n \n On your G1, go to Settings Applications Development [X] USB debugging \n Download this file: android_usb_windows.zip \n Unzip it to a folder \n Connect your G1 with your PC \n When it asks for driver location choose the unzipped folder and install the driver for it. \n You'll see sth like "HTC Dream Composite ADB Interface" on success \n (Re)Start Eclipse \n Your G1 should now be listed in the DDMS-Perspective under Devices \n Go to the AndroidManifest.xml of your App and modify it to contain android:debuggable="true" in the <application ... >-Tag ,look like this:<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> \n Go Debug as usual. \n \n \nps: I do not upload the zip file here,you can find it via the link above,but if you can not download it,you can mail me to fetch one. \nBtw: \nYou can now install (signed)APKs via USB: \nD:\\dev\\Android\\android-sdk-windows-1.0_r1\\tools>adb -d install D:\\Workspace\\keytools\\AndNav_signed.apk \n1305 KB/s (1975987 bytes in 1.478s) \npkg: /data/local/tmp/AndNav_signed.apk \nSuccess \n \n \nAnd uninstall them: \nD:\\dev\\Android\\android-sdk-windows-1.0_r1\\tools>adb uninstall org.andnav \nSuccess \n \n
In some case,you may want do get Uniquely Identifying for a 'real' android phone,such as IMEI code,SimOperator etc, and we all kown ,the IMEI like ID card,and you can use TelephonyManager to get it,some usefull codes like this :
Apr 1 01:47:49 garden kernel: Linux version 2.6.18-92.1.17.el5 (mockbuild@builder10.centos.org) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)) #1 SMP Tue Nov 4 13:43:30 EST 2008
\n
\n \nlooks like something wrong about "ip_conntrack",and i do some check like this: \n\n
Installing ri documentation for fastercsv-1.4.0...
\n
Installing RDoc documentation for fastercsv-1.4.0...
\n
iceskysl ~/webroot: cd ..
\n\n
\nand do not forget to add "require 'fastercsv'" in your class file.", "created_at"=>2009-04-22 17:12:15 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
some tips is here. \n \nRuby代码 \n \n def self.imp_init_owner_data \n fp = "\#{RAILS_ROOT}/datas/inumbers/ini_owner.csv" \n FasterCSV.open(fp, "w") do |csv| \n InumberCate.find_all_by_typee("owner").each do |owner| \n csv << [owner.name,owner.id] \n end \n end \n end \n \n \ninstall fastercsv gems like this.. \n \n \n \nRuby代码 \n \n iceskysl ~/webroot: gem install fastercsv \n Successfully installed fastercsv-1.4.0 \n 1 gem installed \n Installing ri documentation for fastercsv-1.4.0... \n Installing RDoc documentation for fastercsv-1.4.0... \n iceskysl ~/webroot: cd .. \n \n \nand do not forget to add "require 'fastercsv'" in your class file.
you can use apt-spy to update sources.list ,here is some step and tips. \n1.open /etc/apt/sources.list and add this \ndeb http://http.us.debian.org/debian/ stable main \n2.do "apt-get update" \n3.then "apt-get install apt-spy" \n4.then "apt-spy update" \n5.last,"apt-spy -d unstable -a asia -t 5" \n \nref: \nhttp://http.us.debian.org/debian/README.mirrors.txt
you can use apt-spy to update sources.list ,here is some step and tips. \n1.open /etc/apt/sources.list and add this \ndeb http://http.us.debian.org/debian/ stable main \n2.do "apt-get update" \n3.then "apt-get install apt-spy" \n4.then "apt-spy update" \n5.last,"apt-spy -d unstable -a asia -t 5" \n \nref: \nhttp://http.us.debian.org/debian/README.mirrors.txt
\n", "_id"=>998}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["iowait"], "comments_count"=>0, "category_id"=>11, "title"=>"How can I find out what is generating iowait on my server?", "body"=>"
A question I’m asked daily is “How can I find out what is generating iowait on my server?” Sure, you can dig through pages of lsof output, restart services, or run strace, but it can be a frustrating process. I saw a process on this blog post, and a guy changed the regexes to fit Red Hat and CentOS systems a bit better: \n
A question I’m asked daily is “How can I find out what is generating iowait on my server?” Sure, you can dig through pages of lsof output, restart services, or run strace, but it can be a frustrating process. I saw a process on this blog post, and a guy changed the regexes to fit Red Hat and CentOS systems a bit better: \n \nRuby代码 \n \n [root@5-3 ~]# /etc/init.d/syslog stop \n Shutting down kernel logger: [ OK ] \n Shutting down system logger: [ OK ] \n [root@5-3 ~]# echo 1 > /proc/sys/vm/block_dump \n [root@5-3 ~]# dmesg | egrep "READ|WRITE|dirtied" | egrep -o '([a-zA-Z]*)' | sort | uniq -c | sort -rn | head \n 202 kjournald \n 16 egrep \n 9 irqbalance \n 9 bash \n 2 java \n 1 sda \n 1 mailserver \n [root@5-3 ~]# echo 0 > /proc/sys/vm/block_dump \n [root@5-3 ~]# /etc/init.d/syslog start \n Starting system logger: [ OK ] \n Starting kernel logger: [ OK ] \n \n \nIn my specific situation, it looks like kjournald is the biggest abuser of my disk. \nDon’t forget to set things back to their normal state when you’re done! \n \nXML/HTML代码 \n \n # echo 0 > /proc/sys/vm/block_dump \n # /etc/init.d/syslog start \n \n \n \n \nref: \nhttp://rackerhacker.com/2008/03/11/hunting-down-elusive-sources-of-iowait/ \nhttp://blog.eikke.com/index.php/ikke/2007/03/22/who_s_abusing_my_sata_controller \nhttp://hi.baidu.com/dipsey/blog/item/900bbbaf3e46dcc97cd92aba.html \nhttp://www.ducea.com/2009/03/11/howto-install-iotop-on-debian-etch/ \n \nhttp://www.cppblog.com/go-benny/archive/2008/04/23/47908.html \n
--attach PID Quit god when the attached process dies
\n
--no-events Disable the event system
\n
--bleakhouse Enable bleakhouse profiling
\n
[iceskysl@ws_api]#
\n\n
\n1.DYNAMICALLY LOADING CONFIG FILES INTO AN ALREADY RUNNING GOD\n
\n
God allows you to load or reload configurations into an already running instance. There are a few things to consider when doing this:
\n
\n
Existng Watches with the samename```as the incoming Watches will be overidden by the new config.
\n
All paths must be either absolute or relative to the path from which god was started.
\n
\n
To load a config into a running god, issue the following command:
\n
$ sudo god load path/to/config.god # god load /data/www/api/config/config_thin_api.god```\n
Config files that are loaded dynamically can contain anything that a normal config file contains, however, global options such asGod.pid_file_directory```blocks will be ignored (and produce a warning in the logs).
\n
\n
2.show logs
\n
\n
\n
XML/HTML代码
\n\n
[iceskysl@ws_api]# god log thin-thin-7514
\n
I, [2009-04-28T08:24:16.705870 #23174] INFO -- : thin-thin-7514 moved 'up' to 'up'
\n
I, [2009-04-28T08:24:16.706346 #23174] INFO -- : thin-thin-7514 [trigger] process is not running (ProcessRunning)
\n
I, [2009-04-28T08:24:16.888477 #23174] INFO -- : thin-thin-7514 sent email to iceskysl@gmail.com (Email)
\n
I, [2009-04-28T08:24:16.888642 #23174] INFO -- : thin-thin-7514 move 'up' to 'start'
\n
I, [2009-04-28T08:24:16.888976 #23174] INFO -- : thin-thin-7514 before_start: no pid file to delete (CleanPidFile)
\n
I, [2009-04-28T08:24:16.889109 #23174] INFO -- : thin-thin-7514 start: thin start -C /data/www/web/current/config/thin.yml -o 7514
some days before,i posted a article 《God: 比Monit更好用的monitoring》,today,i will post more useful tips for God. \n \n \nRuby代码 \n \n [iceskysl@ws_api]# god --help \n Usage: \n Starting: \n god [-c <config file>] [-p <port> | -b] [-P <file>] [-l <file>] [-D] \n \n Querying: \n god <command> <argument> [-p <port>] \n god <command> [-p <port>] \n god -v \n god -V (must be run as root to be accurate on Linux) \n \n Commands: \n start <task or group name> start task or group \n restart <task or group name> restart task or group \n stop <task or group name> stop task or group \n monitor <task or group name> monitor task or group \n unmonitor <task or group name> unmonitor task or group \n remove <task or group name> remove task or group from god \n load <file> load a config into a running god \n log <task name> show realtime log for given task \n status show status of each task \n quit stop god \n terminate stop god and all tasks \n check run self diagnostic \n \n Options: \n -c, --config-file CONFIG Configuration file \n -p, --port PORT Communications port (default 17165) \n -b, --auto-bind Auto-bind to an unused port number \n -P, --pid FILE Where to write the PID file \n -l, --log FILE Where to write the log file \n -D, --no-daemonize Don't daemonize \n -v, --version Print the version number and exit \n -V Print extended version and build information \n --log-level LEVEL Log level [debug|info|warn|error|fatal] \n --no-syslog Disable output to syslog \n --attach PID Quit god when the attached process dies \n --no-events Disable the event system \n --bleakhouse Enable bleakhouse profiling \n [iceskysl@ws_api]# \n \n \n1.DYNAMICALLY LOADING CONFIG FILES INTO AN ALREADY RUNNING GOD \n \nGod allows you to load or reload configurations into an already running instance. There are a few things to consider when doing this: \n \n Existng Watches with the same name<span class="Apple-converted-space"> </span>as the incoming Watches will be overidden by the new config.</li> \n <li style="margin: 0px; font-size: 13px;">All paths must be either absolute or relative to the path from which god was started.</li> \n</ul> \n<p style="margin: 0px 0px 1em; font-size: 13px;">To load a config into a running god, issue the following command:</p> \n<pre style="border: 1px solid rgb(204, 204, 204); margin: 1em 0px; padding: 1em; font-size: 10px; line-height: 1.3; background-color: rgb(239, 239, 239);">$ sudo god load path/to/config.god<br /># god load /data/www/api/config/config_thin_api.god \nConfig files that are loaded dynamically can contain anything that a normal config file contains, however, global options such as God.pid_file_directory``` blocks will be ignored (and produce a warning in the logs). \n \n2.show logs \n \n \nXML/HTML代码 \n \n [iceskysl@ws_api]# god log thin-thin-7514 \n I, [2009-04-28T08:24:16.705870 #23174] INFO -- : thin-thin-7514 moved 'up' to 'up' \n I, [2009-04-28T08:24:16.706346 #23174] INFO -- : thin-thin-7514 [trigger] process is not running (ProcessRunning) \n I, [2009-04-28T08:24:16.888477 #23174] INFO -- : thin-thin-7514 sent email to iceskysl@gmail.com (Email) \n I, [2009-04-28T08:24:16.888642 #23174] INFO -- : thin-thin-7514 move 'up' to 'start' \n I, [2009-04-28T08:24:16.888976 #23174] INFO -- : thin-thin-7514 before_start: no pid file to delete (CleanPidFile) \n I, [2009-04-28T08:24:16.889109 #23174] INFO -- : thin-thin-7514 start: thin start -C /data/www/web/current/config/thin.yml -o 7514 \n \n \n \nresource links: \nhttp://god.rubyforge.org/ \n
If you have recently updated to Rails 2.2.2, you may encounter this error when you want to start your application: \n \n/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in \n`load_missing_constant': uninitialized constant Inflector (NameError) \n \nthe usage of Inflector class is changed a bit. You can see the difference when you compare the inflections.rb files. Path of the file is yourApp/config/initializers/inflections.rb \n \n
\n
inflections.rb (Rails 2.1.0)
\n\n
\n
\n
Inflector.inflections do |inflect|
\n
.
\n
.
\n
.
\n
end
\n\n
\n \n
\n
inflections.rb (Rails 2.2.2)
\n\n
ActiveSupport::Inflector.inflections do |inflect|
\n
.
\n
.
\n
.
\n
end
\n\n
\nthe situation changing Inflector to ActiveSupport::Inflector was enough to solve the problem.", "created_at"=>2009-05-05 13:37:01 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
If you have recently updated to Rails 2.2.2, you may encounter this error when you want to start your application: \n \n/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in \n`load_missing_constant': uninitialized constant Inflector (NameError) \n \nthe usage of Inflector class is changed a bit. You can see the difference when you compare the inflections.rb files. Path of the file is yourApp/config/initializers/inflections.rb \n \n \ninflections.rb (Rails 2.1.0) \n \n \n \n Inflector.inflections do |inflect| \n . \n . \n . \n end \n \n \n \n \ninflections.rb (Rails 2.2.2) \n \n ActiveSupport::Inflector.inflections do |inflect| \n . \n . \n . \n end \n \n \nthe situation changing Inflector to ActiveSupport::Inflector was enough to solve the problem.
\n", "_id"=>1002}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["God", "ruby", "Ruby&Rails"], "comments_count"=>0, "category_id"=>11, "title"=>"Socket Errno::EAFNOSUPPORT with God in ruby", "body"=>"
when i start god.sh,then give some error msg like this:
\n
\n
\n
XML/HTML代码
\n\n
I [2009-05-16 21:25:41] INFO: Using pid file directory: /var/run/god
\n
/usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `initialize': Address family not supported by protocol - socket(2) (Errno::EAFNOSUPPORT)
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `open'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `open_server_inaddr_any'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:863:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:759:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in `each'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1340:in `initialize'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in `new'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in `start_service'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:78:in `start'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:43:in `initialize'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in `new'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in `start'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:633:in `at_exit'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:666
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/cli/run.rb:87
\n\n
\nok,then i find some userful messsage,like here:\n
Errno::EAFNOSUPPORT - the specifiedsockaddrisnot a valid address for the family of the callingsocket
\n
and here, i notice where is the problen,the god find hostname,name map it to ip address,then create some sockets on the ip,and the error point is here,so i nano my /etc/hosts file,and add map for hostname and 127.0.0.1,that's it! \n
when i start god.sh,then give some error msg like this: \n \n \nXML/HTML代码 \n \n I [2009-05-16 21:25:41] INFO: Using pid file directory: /var/run/god \n /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in initialize': Address family not supported by protocol - socket(2) (Errno::EAFNOSUPPORT) </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in open' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in open_server_inaddr_any' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:863:in open_server' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:759:in open_server' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in each' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in open_server' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1340:in initialize' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in new' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in start_service' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:78:in start' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:43:in initialize' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in new' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in start' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:633:in `at_exit' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:666 \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/cli/run.rb:87 \n \n \nok,then i find some userful messsage,like here: \nErrno::EAFNOSUPPORT - the specified sockaddr isnot a valid address for the family of the calling socket \nand here, i notice where is the problen,the god find hostname,name map it to ip address,then create some sockets on the ip,and the error point is here,so i nano my /etc/hosts file,and add map for hostname and 127.0.0.1,that's it!
\n", "_id"=>1003}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["书"], "comments_count"=>0, "category_id"=>6, "title"=>"我写的书:《Google Android开发入门与实战》等即将上市.", "body"=>"这篇文章是非技术性的,所以使用中文写,免得写了大家看不懂,呵呵。\r\n\r\n写书不是第一次,出版却是第一本,至于原因,就不详述了,去年9月开始参与一些图书的翻译和撰写中,截至到目前,这段时间一共参与了三本书,按照参与的先后顺序,分别是《The Rails Way》,《Google API 编程.开发.实例》以及《Google Android开发入门与实战》。\r\n\r\n其中《The Rails Way》是做为译者参与,其他翻译者都是国内第一批Rails技术人员,分散在全国各地,还有一名译者在加拿大,我一共翻译了5章内容,分别是第2章“Working_with_Controllers”,第10章“ActionView”,第13章“Session__Session_Management”,第15章“XML_and_ActiveResource”和第16章“ActionMailer”,翻译很早前就结束了,目前好像还在审稿、校核工作,由YiTan在跟,至于何时出版,我还真不知道。\r\n\r\n《Google API 编程.开发.实例》我是从去年9月份介入,开始参与选题和策划,截至撰写相关内容,因为我自身是Google重度使用者,平时也比较多的使用和了解GoogleAPI,所以写起来得心应手,一共写了“Google Account Authentication”,“Google AJAX Language API”,“Google Chart API”,“Blogger Data API”,“Feedburner API”,“Google Code Search Data API”和“Google Book Search Book Viewability API”这些章节,前前后后也花了不少零碎的时间。其他作者大多都Google内部的同学,本书已经进入出版流程,由博文视点出版社策划出版,应该在6.5号Google开发者大会上可以看到,如下是本书第一版封面。\r\n\r\n\r\n\r\n本书特点:本书覆盖了Google绝大多数的API,其中针对每个API就其原理、用法做了详细说明,最后基本上都有实际的例子演示如何使用。\r\n\r\n《Google Android开发入门与实战》是08年11月份开始撰写的,和另外一个朋友一起,两个人陆续的差不多用了半年时间,在09年4月份差不多全部写完,后面主要是都在校核和审稿,由人民邮电出版社出版,5月底6月初即可上市,封面如下:\r\n\r\n\r\n\r\n \r\n
《Google API 编程.开发.实例》我是从去年9月份介入,开始参与选题和策划,截至撰写相关内容,因为我自身是Google重度使用者,平时也比较多的使用和了解GoogleAPI,所以写起来得心应手,一共写了“Google Account Authentication”,“Google AJAX Language API”,“Google Chart API”,“Blogger Data API”,“Feedburner API”,“Google Code Search Data API”和“Google Book Search Book Viewability API”这些章节,前前后后也花了不少零碎的时间。其他作者大多都Google内部的同学,本书已经进入出版流程,由博文视点出版社策划出版,应该在6.5号Google开发者大会上可以看到,如下是本书第一版封面。
and now,you can open a cmd shell,and input sqlite3 like this: \n
\n
C:\\Documents and Settings\\Administrator>sqlite3 \nSQLite version 3.5.9 \nEnter ".help" for instructions
\n
and some help infos is here:
\n
sqlite> .help \n.bail ON|OFF Stop after hitting an error. Default OFF \n.databases List names and files of attached databases \n.dump ?TABLE? ... Dump the database in an SQL text format \n.echo ON|OFF Turn command echo on or off \n.exit Exit this program \n.explain ON|OFF Turn output mode suitable for EXPLAIN on or off. \n.header(s) ON|OFF Turn display of headers on or off \n.help Show this message \n.import FILE TABLE Import data from FILE into TABLE \n.indices TABLE Show names of all indices on TABLE \n.load FILE ?ENTRY? Load an extension library \n.mode MODE ?TABLE? Set output mode where MODE is one of: \n csv Comma-separated values \n column Left-aligned columns. (See .width) \n html HTML <table> code \n insert SQL insert statements for TABLE \n line One value per line \n list Values delimited by .separator string \n tabs Tab-separated values \n tcl TCL list elements \n.nullvalue STRING Print STRING in place of NULL values \n.output FILENAME Send output to FILENAME \n.output stdout Send output to the screen \n.prompt MAIN CONTINUE Replace the standard prompts \n.quit Exit this program \n.read FILENAME Execute SQL in FILENAME \n.schema ?TABLE? Show the CREATE statements \n.separator STRING Change separator used by output mode and .import \n.show Show the current values for various settings \n.tables ?PATTERN? List names of tables matching a LIKE pattern \n.timeout MS Try opening locked tables for MS milliseconds \n.width NUM NUM ... Set column widths for "column" mode
Install SQLite3 for Windows by downloading the following 2 zip files and unzipping them into /WINDOWS/system32 \nhttp://www.sqlite.org/sqlite-3_6_14_1.zip \nhttp://www.sqlite.org/sqlitedll-3_6_14_1.zip \nIf those don't work try the official download site here \nand now,you can open a cmd shell,and input sqlite3 like this: \n \nC:\\Documents and Settings\\Administrator>sqlite3 \nSQLite version 3.5.9 \nEnter ".help" for instructions \nand some help infos is here: \nsqlite> .help \n.bail ON|OFF Stop after hitting an error. Default OFF \n.databases List names and files of attached databases \n.dump ?TABLE? ... Dump the database in an SQL text format \n.echo ON|OFF Turn command echo on or off \n.exit Exit this program \n.explain ON|OFF Turn output mode suitable for EXPLAIN on or off. \n.header(s) ON|OFF Turn display of headers on or off \n.help Show this message \n.import FILE TABLE Import data from FILE into TABLE \n.indices TABLE Show names of all indices on TABLE \n.load FILE ?ENTRY? Load an extension library \n.mode MODE ?TABLE? Set output mode where MODE is one of: \n csv Comma-separated values \n column Left-aligned columns. (See .width) \n html HTML <table> code \n insert SQL insert statements for TABLE \n line One value per line \n list Values delimited by .separator string \n tabs Tab-separated values \n tcl TCL list elements \n.nullvalue STRING Print STRING in place of NULL values \n.output FILENAME Send output to FILENAME \n.output stdout Send output to the screen \n.prompt MAIN CONTINUE Replace the standard prompts \n.quit Exit this program \n.read FILENAME Execute SQL in FILENAME \n.schema ?TABLE? Show the CREATE statements \n.separator STRING Change separator used by output mode and .import \n.show Show the current values for various settings \n.tables ?PATTERN? List names of tables matching a LIKE pattern \n.timeout MS Try opening locked tables for MS milliseconds \n.width NUM NUM ... Set column widths for "column" mode
add this line into /etc/lftp.conf \nset net:limit-rate 10240000,40960 \n \nthat's limit upload rate to 10M,and download to 40K \n \nsome useful resource:
when i ssh to a server,i get some message like this: \nAddress 192.168.5.12 maps to localhost, but this does not map back to the address - POSSIBLE BREAKIN ATTEMPT! \nSolution: \nModify the "/etc/ssh/ssh_config" file at localhost \n GSSAPIAuthentication no \nexp: \nssh 192.168.1.110时报错上述错,本地是192.168.1.20 ,则修改本地192.168.1.20中的/etc/ssh/ssh_config,把参数GSSAPIAuthentication no修改就可以了。。或者修改服务器端192.168.1.110上的/etc/ssh/sshd_config ,把参数GSSAPIAuthentication no改了也可以。要注意的是/etc/ssh/ssh_config和/etc/ssh/sshd_confg的区别。
\ncURL figures out which protocol to use from the URL you provide, and when \"http:\" is specified will, unless otherwise instructed (using -0), default to using HTTP 1.1. The first argument, -u, instructs cURL to use the next two parameters (separated by a colon) as the account name and password for basic authentication. The next argument, -d, specifies the data (maximum 140 characters) to be sent via a POST request.\n\nOf course what cURL expects is a response to the POST request so the result will be the requested page (update.xml) sent to stdout. This page will be encoded according to the file type used in the request, thus as we just requested update.xml we’ll get XML-formatted data. The alternatives are JSON (JavaScript Object Notation), RSS and Atom formats.\n\nfrom:\nhttp://www.networkworld.com/columnists/2008/052108-gearhead.html?page=2", "created_at"=>2009-09-27 18:26:17 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
curl -u email:passw -d status="text" http://twitter.com/statuses/update.xml \ncURL figures out which protocol to use from the URL you provide, and when "http:" is specified will, unless otherwise instructed (using -0), default to using HTTP 1.1. The first argument, -u, instructs cURL to use the next two parameters (separated by a colon) as the account name and password for basic authentication. The next argument, -d, specifies the data (maximum 140 characters) to be sent via a POST request.
\n\n
Of course what cURL expects is a response to the POST request so the result will be the requested page (update.xml) sent to stdout. This page will be encoded according to the file type used in the request, thus as we just requested update.xml we’ll get XML-formatted data. The alternatives are JSON (JavaScript Object Notation), RSS and Atom formats.
I like Unicorn because it's Unix \n RailsConf 2009: powered by OMG UNICORNS!!!! \n
\n", "_id"=>1019}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["rails", "rails-2.3.4"], "comments_count"=>0, "category_id"=>6, "title"=>"rails-2.3.4 发布了", "body"=>"Ruby on Rails 2.3.4, this release fixes bugs and introduces a few minor features. Due to the inclusion of two security fixes, all users of the 2.3 series are recommended to upgrade as soon as possible.\n\nC:\\Documents and Settings\\Administrator>gem install rails\nSuccessfully installed activesupport-2.3.4\nSuccessfully installed activerecord-2.3.4\nSuccessfully installed actionpack-2.3.4\nSuccessfully installed actionmailer-2.3.4\nSuccessfully installed activeresource-2.3.4\nSuccessfully installed rails-2.3.4\n6 gems installed\nInstalling ri documentation for activesupport-2.3.4...\nInstalling ri documentation for activerecord-2.3.4...\nInstalling ri documentation for actionpack-2.3.4...\nInstalling ri documentation for actionmailer-2.3.4...\nInstalling ri documentation for activeresource-2.3.4...\nInstalling RDoc documentation for activesupport-2.3.4...\nInstalling RDoc documentation for activerecord-2.3.4...\nInstalling RDoc documentation for actionpack-2.3.4...\nInstalling RDoc documentation for actionmailer-2.3.4...\nInstalling RDoc documentation for activeresource-2.3.4...\n\n详细信息:\n\nhttp://weblog.rubyonrails.org/2009/9/4/ruby-on-rails-2-3-4", "created_at"=>2009-10-14 07:47:04 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
Ruby on Rails 2.3.4, this release fixes bugs and introduces a few minor features. Due to the inclusion of two security fixes, all users of the 2.3 series are recommended to upgrade as soon as possible.
\n\n
C:\\Documents and Settings\\Administrator>gem install rails \nSuccessfully installed activesupport-2.3.4 \nSuccessfully installed activerecord-2.3.4 \nSuccessfully installed actionpack-2.3.4 \nSuccessfully installed actionmailer-2.3.4 \nSuccessfully installed activeresource-2.3.4 \nSuccessfully installed rails-2.3.4 \n6 gems installed \nInstalling ri documentation for activesupport-2.3.4... \nInstalling ri documentation for activerecord-2.3.4... \nInstalling ri documentation for actionpack-2.3.4... \nInstalling ri documentation for actionmailer-2.3.4... \nInstalling ri documentation for activeresource-2.3.4... \nInstalling RDoc documentation for activesupport-2.3.4... \nInstalling RDoc documentation for activerecord-2.3.4... \nInstalling RDoc documentation for actionpack-2.3.4... \nInstalling RDoc documentation for actionmailer-2.3.4... \nInstalling RDoc documentation for activeresource-2.3.4...
\nany hg command fails with:\nValueError: unknown locale: UTF-8\n\nThis is mercurial 1.3.1and Python 2.6.1, but its seem that its caused by Leopard’s Term.app not setting the local encoding correctly. To resolve this, add the following to .profile:\n
This is mercurial 1.3.1and Python 2.6.1, but its seem that its caused by Leopard’s Term.app not setting the local encoding correctly. To resolve this, add the following to .profile: \nexport LC_ALL=en_US.UTF-8 \nexport LANG=en_US.UTF-8 \nthen i clone the code for Go Programming Language \neoe:system IceskYsl$ printenv LANG \neoe:system IceskYsl$ export LC_ALL=en_US.UTF-8 \neoe:system IceskYsl$ export LANG=en_US.UTF-8 \neoe:system IceskYsl$ hg clone -r release https://go.googlecode.com/hg/ go \nrequesting all changes \nadding changesets \nadding manifests \nadding file changes \nadded 3976 changesets with 16799 changes to 2931 files \nupdating working directory \n1640 files updated, 0 files merged, 0 files removed, 0 files unresolved \nhttp://www.ibm.com/developerworks/cn/opensource/os-cn-mercurial/
\n", "_id"=>1025}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>11, "title"=>"how to avoid Net::SMTPFatalError (555 5.5.2 Syntax error.", "body"=>"i can not get notify email from my ExceptionNotifier in rails project,i notice some useful msg in the production logs:\n
@from = \"\#{sender}\"\n If I submit an email id, It is giving error as\n (Net::SMTPFatalError) \"555 5.5.2 Syntax error. d29sm1994943and.38\\n\"\n\nThe from line is the problem. The Net::SMTP library was recently changed\nso it adds angle brackets to your sender, so you cannot have any in your\nstring. Try this as a workaround:\n@from = \"a...@xxxxxxx\"
\n\nso,just fix it like this:\nExceptionNotifier.sender_address = %(\"iceskysl\" )\nto\nExceptionNotifier.sender_address = %(iceskysl@eoemobile.com)", "created_at"=>2009-11-12 19:58:54 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
i can not get notify email from my ExceptionNotifier in rails project,i notice some useful msg in the production logs: \nNet::SMTPFatalError (555 5.5.2 Syntax error. b17sm72261fka.43
\n\n
google.... \n@from = "\#{sender}a...@xxxxxxx" \n If I submit an email id, It is giving error as \n (Net::SMTPFatalError) "555 5.5.2 Syntax error. d29sm1994943and.38\\n"
\n\n
The from line is the problem. The Net::SMTP library was recently changed \nso it adds angle brackets to your sender, so you cannot have any in your \nstring. Try this as a workaround: \n@from = "a...@xxxxxxx"
\n\n
so,just fix it like this: \nExceptionNotifier.sender_address = %("iceskysl" iceskysl@eoemobile.com) \nto \nExceptionNotifier.sender_address = %(iceskysl@eoemobile.com)
\n", "_id"=>1027}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["package", "ubuntu", "uninstall"], "comments_count"=>0, "category_id"=>7, "title"=>"Uninstall / Delete / Remove Package", "body"=>"Just use the following syntax:\n\nsudo apt-get remove {package-name}\n\nFor example remove package called mplayer, enter:\n$ sudo apt-get remove mplayer\n\nRemove package called lighttpd along with all configuration files, enter:\n$ sudo apt-get --purge remove lighttpd\n\nTo list all installed package, enter:\\\ndpkg --list\ndpkg --list | less\ndpkg --list | grep -i 'http'", "created_at"=>2009-11-22 18:48:23 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
Just use the following syntax:
\n\n
sudo apt-get remove {package-name}
\n\n
For example remove package called mplayer, enter: \n$ sudo apt-get remove mplayer
\n\n
Remove package called lighttpd along with all configuration files, enter: \n$ sudo apt-get --purge remove lighttpd
\n\n
To list all installed package, enter:\\ \ndpkg --list \ndpkg --list | less \ndpkg --list | grep -i 'http'
\n", "_id"=>1028}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["delegate", "ImageMagick"], "comments_count"=>0, "category_id"=>7, "title"=>"ImageMagick够折腾得,no decode delegate", "body"=>"估计RP出问题了,以前安装和今天在mac上安装都很顺利,但是在服务器上装得时候,出现一大堆得问题,极度诡异,最后查了N多资料,改了N多东西,也不晓得最后是哪个生效了,终于折腾好了.\n记录下我参考过得资料:\nhttp://www.imagemagick.org/script/command-line-processing.php\nhttp://wanguan2000.blog.ubuntu.org.cn/2009/01/04/ubuntu-下rmagick的安装/\nhttp://infrastacks.com/?p=57\nhttp://hi.baidu.com/yttxuehui/blog/item/9f1a21978d6fa96a55fb96d5.html\nhttp://www.blogjava.net/fl1429/archive/2009/06/17/282895.html\nhttp://hi.baidu.com/countryroadtao/blog/item/225c72dad2adc16cd0164e97.html\nhttp://www.cnscn.org/htm_data/602/0705/8717.html\nhttp://stackoverflow.com/questions/1483968/imagemagick-convert-error-wrong-jpeg-library-version-library-is-62-caller-expe\n我读最后一个问题印象深刻\n\"Looks like it is reading the wrong jpeg ibrary, but I have jpeg 7 installed. How do i tell ImageMagick to look up the right JPEG library version(I don't care 62 or 70 as long as it works).\"\nroot@li84-64:/data/soft/ImageMagick-6.5.7-9# convert -list format | grep JPEG\n see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS),\n and supplement 61 which adds JPEG-2000 encoding.\n JNG* PNG rw- JPEG Network Graphics\n JP2* JP2 rw- JPEG-2000 File Format Syntax\n JPC* JPC rw- JPEG-2000 Code Stream Syntax\n JPEG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n JPG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n JPX* JPX rw- JPEG-2000 File Format Syntax\n PGX* PGX r-- JPEG-2000 VM Format\n PJPEG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n\n看到其需要得JPEG得lib是70,但是我装得是\n\nroot@li84-64:/data/soft/ImageMagick-6.5.7-9# dpkg --list | grep \"magick\"\nrc imagemagick 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation programs\nii libmagick++10 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library\nii libmagick++9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library - develop\nii libmagick10 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library\nii libmagick9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library - development fil\nii libmagickcore1 7:6.4.5.4.dfsg1-1ubuntu3.1 low-level image manipulation library\nii libmagickwand1 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation library\nii librmagick-ruby 1.15.11-1ubuntu1 ImageMagick API for Ruby\nii librmagick-ruby1.8 1.15.11-1ubuntu1 ImageMagick API for Ruby", "created_at"=>2009-11-22 20:30:32 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
root@li84-64:/data/soft/ImageMagick-6.5.7-9# dpkg --list | grep "magick" \nrc imagemagick 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation programs \nii libmagick++10 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library \nii libmagick++9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library - develop \nii libmagick10 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library \nii libmagick9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library - development fil \nii libmagickcore1 7:6.4.5.4.dfsg1-1ubuntu3.1 low-level image manipulation library \nii libmagickwand1 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation library \nii librmagick-ruby 1.15.11-1ubuntu1 ImageMagick API for Ruby \nii librmagick-ruby1.8 1.15.11-1ubuntu1 ImageMagick API for Ruby
\n", "_id"=>1029}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["find", "inject", "rails", "ruby", "select"], "comments_count"=>0, "category_id"=>5, "title"=>"用Ruby在已知数组中找到和目标最匹配得元素", "body"=>"有个需求,给定一个数组,然后给出一个变量,需要在这个数组中找到和这个变量得值最接近得那个元素,开始用find或者select都不是很合适,最后找到inject,很好得解决了这个需求,现在记录下:\n首先看下inject这个函数\n````\nenum.inject(initial) {| memo, obj | block } => obj\nenum.inject {| memo, obj | block } => obj\nCombines the elements of enum by applying the block to an accumulator value (memo) and each element in turn. At each step, memo is set to the value returned by the block. The first form lets you supply an initial value for memo. The second form uses the first element of the collection as a the initial value (and skips that element while iterating).\n\n # Sum some numbers\n (5..10).inject {|sum, n| sum + n } #=> 45\n # Multiply some numbers\n (5..10).inject(1) {|product, n| product * n } #=> 151200\n\n # find the longest word\n longest = %w{ cat sheep bear }.inject do |memo,word|\n memo.length > word.length ? memo : word\n end\n longest #=> \"sheep\"\n\n # find the length of the longest word\n longest = %w{ cat sheep bear }.inject(0) do |memo,word|\n memo >= word.length ? memo : word.length\n end\n longest #=> 5\n```\n\n然后根据我得需求,写出一个函数如下:\n````\n # find the min abs size\n def self.select_h(h)\n if ALL_FORMATS.include?(h)\n return h\n else\n ok_size = ALL_FORMATS.inject do |i,j|\n (i-h).abs < (j-h).abs ? i : j\n end\n return ok_size\n end\n end\n```\n首先看是否包含这个变量,如果又,直接返回,如果没有就inject来取一个最合适得。", "created_at"=>2009-11-24 08:06:13 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
有个需求,给定一个数组,然后给出一个变量,需要在这个数组中找到和这个变量得值最接近得那个元素,开始用find或者select都不是很合适,最后找到inject,很好得解决了这个需求,现在记录下: \n首先看下inject这个函数 \n```` \nenum.inject(initial) {| memo, obj | block } => obj \nenum.inject {| memo, obj | block } => obj \nCombines the elements of enum by applying the block to an accumulator value (memo) and each element in turn. At each step, memo is set to the value returned by the block. The first form lets you supply an initial value for memo. The second form uses the first element of the collection as a the initial value (and skips that element while iterating).
\n\n
# Sum some numbers \n (5..10).inject {|sum, n| sum + n } #=> 45 \n # Multiply some numbers \n (5..10).inject(1) {|product, n| product * n } #=> 151200
\n\n
# find the longest word \n longest = %w{ cat sheep bear }.inject do |memo,word| \n memo.length > word.length ? memo : word \n end \n longest #=> "sheep"
\n\n
# find the length of the longest word \n longest = %w{ cat sheep bear }.inject(0) do |memo,word| \n memo >= word.length ? memo : word.length \n end \n longest #=> 5 \n```
\n\n
然后根据我得需求,写出一个函数如下: \n` \n # find the min abs size \n def self.select_h(h) \n if ALL_FORMATS.include?(h) \n return h \n else \n ok_size = ALL_FORMATS.inject do |i,j| \n (i-h).abs < (j-h).abs ? i : j \n end \n return ok_size \n end \n end \n \n首先看是否包含这个变量,如果又,直接返回,如果没有就inject来取一个最合适得。
\n", "_id"=>1030}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Facebooker error UnableToLoadAdapter", "body"=>"If you see an error that looks like\n
\nIts because you haven’t configured config/facebooker.yml file correctly, or at all. (Most tutorials etc. have you creating and editing this file after you install facebooker)", "created_at"=>2009-11-26 13:31:29 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
If you see an error that looks like \n/home/brickfactor/facebooker_tutorial/vendor/plugins/facebooker/lib/facebooker \n/adapters/adapter_base.rb:43:in load_adapter': Facebooker::AdapterBase::UnableToLoadAdapter (Facebooker::AdapterBase::UnableToLoadAdapter) \n/RAILS_APP/vendor/plugins/facebooker/lib/facebooker/adapters/adapter_base.rb:43:inload_adapter': Facebooker::AdapterBase::UnableToLoadAdapter (Facebooker::AdapterBase::UnableToLoadAdapter) \nfrom /RAILS_APP/vendor/plugins/facebooker/lib/facebooker.rb:121:in load_adapter' \nfrom /RAILS_APP/vendor/plugins/facebooker/lib/facebooker.rb:65:inapply_configuration' \nfrom /RAILS_APP/vendor/plugins/facebooker/lib/facebooker.rb:45:in `load_configuration' \nfrom /RAILS_APP/vendor/plugins/facebooker/rails/../init.rb:6 \nIts because you haven’t configured config/facebooker.yml file correctly, or at all. (Most tutorials etc. have you creating and editing this file after you install facebooker)
\n", "_id"=>1034}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["GD", "php", "ubuntu"], "comments_count"=>0, "category_id"=>7, "title"=>"Install GD Support for PHP in Ubuntu", "body"=>"I am in the process of building my blog using wordpress ,then i install SI CAPTCHA Anti-Spam ,but it's say i didn’t have GD support for PHP5 installed on my server. so i need to do:\n\nOpen terminal and type in the following command:\n
\n\nThere you go, you now have GD Support for PHP5 in Ubuntu. Get your Drupal on!", "created_at"=>2010-01-13 02:25:36 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
I am in the process of building my blog using wordpress ,then i install SI CAPTCHA Anti-Spam ,but it's say i didn’t have GD support for PHP5 installed on my server. so i need to do:
\n\n
Open terminal and type in the following command: \n$ sudo apt-get install php5-gd
\n\n
Now restart Apache \n# sudo /etc/init.d/apache2 restart
\n\n
or restart spawn-fcgi \n/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9100 -u www-data -g www-data -f /usr/bin/php-cgi -C 10
\n\n
There you go, you now have GD Support for PHP5 in Ubuntu. Get your Drupal on!
\n", "_id"=>1035}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>7, "title"=>"Fixing Ruby no such file to load readline error in centOS", "body"=>"Does this error message look familar when you script/console?\n````[iceskysl@li1248 current]$ ./script/console production\nLoading production environment (Rails 2.3.5)\n/usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load -- readline (LoadError)\n from /usr/local/lib/ruby/1.8/irb/completion.rb:10\n from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `require'\n from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `load_modules'\n from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `each'\n from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `load_modules'\n from /usr/local/lib/ruby/1.8/irb/init.rb:21:in `setup'\n from /usr/local/lib/ruby/1.8/irb.rb:54:in `start'\n from /usr/local/bin/irb:13```\nthis happens when readline is somehow different than your current version of ruby or corrupted. The quick fix is to recompile readline. To do it in CentOS with yum:\n````$> yum install readline-devel -y\n$> cd /root/src/ruby-1.8.6-p114/ext/readline/\n$> ruby extconf.rb\n$> make\n$> sudo make install ```\nNow you should have script/console working.", "created_at"=>2010-01-19 21:46:28 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
Does this error message look familar when you script/console? \n[iceskysl@li1248 current]$ ./script/console production \nLoading production environment (Rails 2.3.5) \n/usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load -- readline (LoadError) \n from /usr/local/lib/ruby/1.8/irb/completion.rb:10 \n from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `require' \n from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `load_modules' \n from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `each' \n from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `load_modules' \n from /usr/local/lib/ruby/1.8/irb/init.rb:21:in `setup' \n from /usr/local/lib/ruby/1.8/irb.rb:54:in `start' \n from /usr/local/bin/irb:13``` \nthis happens when readline is somehow different than your current version of ruby or corrupted. The quick fix is to recompile readline. To do it in CentOS with yum: \n$> yum install readline-devel -y \n$> cd /root/src/ruby-1.8.6-p114/ext/readline/ \n$> ruby extconf.rb \n$> make \n$> sudo make install ``` \nNow you should have script/console working.
\n", "_id"=>1036}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["centOS", "Swap"], "comments_count"=>0, "category_id"=>7, "title"=>"Swap Space in centOS", "body"=>"Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.\n\nSwap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.\n\nSwap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.\n\nSo, if:\n\nM = Amount of RAM in GB, and S = Amount of swap in GB, then\n
If M < 2\n\tS = M *2\nElse\n\tS = M + 2
\nUsing this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.\n\nFor systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).\n\nsource:http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-swapspace.html", "created_at"=>2010-01-21 02:01:34 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.
\n\n
Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
\n\n
Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.
\n\n
So, if:
\n\n
M = Amount of RAM in GB, and S = Amount of swap in GB, then \nIf M < 2 \n S = M *2 \nElse \n S = M + 2 \nUsing this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.
\n\n
For systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).
\n", "_id"=>1037}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["劫持", "电信"], "comments_count"=>0, "category_id"=>5, "title"=>"深圳电信耍流氓,劫持浏览器", "body"=>"今天无意发现在浏览器的左下角经常出现一个页面无法打开的提示,如下\nThe webpage at http://121.15.207.133:4022/logo.jpg?p=undefined|778|1276|24|800|1280might be temporarily down or it may have moved permanently to a new web address.\n\n看其样式是请求了一个121.15.207.133上的一个logo图片,然后传入了几个参数,但是这个图片的服务器貌似除了电问题,导致请求不到。\n无缘无故的,咋会去请求这个玩意呢,查了吓这个IP归属,属于:\n
\n", "_id"=>1038}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["C", "ruby", "RubyInline"], "comments_count"=>0, "category_id"=>2, "title"=>"RubyInline, Making Making Things Faster Easier", "body"=>"发现一篇好文,讲的是如何使用RubyInline,在Ruby中直接嵌入C并运行,相比之前些lib,要方便的多,由于这个文章在墙外,就转了一份过来,可以翻墙的可以去看原文\nhttp://on-ruby.blogspot.com/2006/07/rubyinline-making-making-things-faster.html\n\nToday on ruby-talk, I caught a thread called \"For Performance, Write it in C\". I'd like to present a slight amendment to that thesis. Let me explain.\n\nIt all started with an email at work. Someone was passing around a bunch of prime number printers in various languages (C, Java, C#, Perl, and Python). They all used the same (ugly) algorithm, and were supposed to show just how 'performant the languages were. Since I'm the local Ruby evangelist, I was asked to write a Ruby version. Here's what I came up with (warning, ugly algorithm ahead):\n\n#!/usr/bin/ruby\n\nfor num in 1..10_000 do\nis_prime = 1\nfor x in 2..(num - 1) do\nif (num % x == 0)\nis_prime = x\nbreak\nend\nend\nif is_prime == 1\nputs \"\#{num} is a prime number\"\nelse\nputs \"\#{num} equals \#{is_prime} * \#{num/is_prime}\"\nend\nend\nHow fast is it? Well, time says:\n\n$ time ./primes.rb > /dev/null\n\nreal 0m2.905s\nuser 0m2.716s\nsys 0m0.004s\n$\n\nCertainly, nothing to write home about, but not too far from Perl or Python either.\nWanting to improve it, and not being able to touch the algorithm (we want to be comparing apples to quinces after all, not apples to oranges). I know my only hope is to find the bottleneck(s) and rewrite it (them?) in C. My first step is to grab Ruby's profiler and see what it says (oh, by the way, I reduced the value of num to 100 so that this would complete in my lifetime ... the profiler is slow).\n\n$ ruby -rprofile primes.rb > /dev/null\n% cumulative self self total\ntime seconds seconds calls ms/call ms/call name\n63.64 0.14 0.14 101 1.39 3.56 Range#each\n13.64 0.17 0.03 1133 0.03 0.03 Fixnum#%\n9.09 0.19 0.02 1233 0.02 0.02 Fixnum#==\n4.55 0.20 0.01 100 0.10 0.20 Kernel.puts\n4.55 0.21 0.01 200 0.05 0.05 IO#write\n4.55 0.22 0.01 248 0.04 0.04 Fixnum#to_s\n0.00 0.22 0.00 74 0.00 0.00 Fixnum#/\n0.00 0.22 0.00 100 0.00 0.00 Fixnum#-\n0.00 0.22 0.00 1 0.00 220.00 #toplevel\n$\n\nWhich tells me that most of my time is spent in each (well, it's actually spent in the block I sent to each. It's taking a whopping 1.39 msec per call, compared to .0X msec for everything else. What would happen if I rewrote just that block?\nEnter RubyInline (A great tool written by zenspider and Eric Hodel). I'm not a C wiz by any stretch of the imagination, but this stuff is pretty easy to bang out. My new code looks like this:\n\n#!/usr/bin/ruby\n\nrequire \"rubygems\"\nrequire \"inline\"\n\nclass Primes\ninline do |builder|\nbuilder.c '\nint prime(int num) {\nint x;\nfor (x = 2; x < (num - 1) ; x++) { if (num == 2) { return 1; } if (num % x == 0) { return x; } } return 1; }' end end p = Primes.new for num in 2..10_000 do is_prime = p.prime(num) if is_prime == 1 puts \"\#{num} is a prime number\" else puts \"\#{num} equals \#{is_prime} * \#{num/is_prime}\" end end Not too ugly. At least I can still see what's happening. The main loop being in Ruby helps a lot too (especially if this were a much bigger program). How much of a difference does it make? time says: $ time ./cprimes.rb > /dev/null\n\nreal 0m0.328s\nuser 0m0.288s\nsys 0m0.020s\n\nAn order of magnitude improvement. Not too shabby.\nWhat's the lesson here? Optimize what you need to (and only what you need to), profile find out what that is (it may be slow, but profiling is your friend), and use the right tools (rewriting a bit of code with RubyInline is way better than rewriting the whole app in C).", "created_at"=>2010-01-24 10:51:47 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
Today on ruby-talk, I caught a thread called "For Performance, Write it in C". I'd like to present a slight amendment to that thesis. Let me explain.
\n\n
It all started with an email at work. Someone was passing around a bunch of prime number printers in various languages (C, Java, C#, Perl, and Python). They all used the same (ugly) algorithm, and were supposed to show just how 'performant the languages were. Since I'm the local Ruby evangelist, I was asked to write a Ruby version. Here's what I came up with (warning, ugly algorithm ahead):
\n\n
!/usr/bin/ruby
\n\n
for num in 1..10_000 do \nis_prime = 1 \nfor x in 2..(num - 1) do \nif (num % x == 0) \nis_prime = x \nbreak \nend \nend \nif is_prime == 1 \nputs "\#{num} is a prime number" \nelse \nputs "\#{num} equals \#{is_prime} * \#{num/is_prime}" \nend \nend \nHow fast is it? Well, time says:
\n\n
$ time ./primes.rb > /dev/null
\n\n
real 0m2.905s \nuser 0m2.716s \nsys 0m0.004s \n$
\n\n
Certainly, nothing to write home about, but not too far from Perl or Python either. \nWanting to improve it, and not being able to touch the algorithm (we want to be comparing apples to quinces after all, not apples to oranges). I know my only hope is to find the bottleneck(s) and rewrite it (them?) in C. My first step is to grab Ruby's profiler and see what it says (oh, by the way, I reduced the value of num to 100 so that this would complete in my lifetime ... the profiler is slow).
Which tells me that most of my time is spent in each (well, it's actually spent in the block I sent to each. It's taking a whopping 1.39 msec per call, compared to .0X msec for everything else. What would happen if I rewrote just that block? \nEnter RubyInline (A great tool written by zenspider and Eric Hodel). I'm not a C wiz by any stretch of the imagination, but this stuff is pretty easy to bang out. My new code looks like this:
\n\n
!/usr/bin/ruby
\n\n
require "rubygems" \nrequire "inline"
\n\n
class Primes \ninline do |builder| \nbuilder.c ' \nint prime(int num) { \nint x; \nfor (x = 2; x < (num - 1) ; x++) { if (num == 2) { return 1; } if (num % x == 0) { return x; } } return 1; }' end end p = Primes.new for num in 2..10_000 do is_prime = p.prime(num) if is_prime == 1 puts "\#{num} is a prime number" else puts "\#{num} equals \#{is_prime} * \#{num/is_prime}" end end Not too ugly. At least I can still see what's happening. The main loop being in Ruby helps a lot too (especially if this were a much bigger program). How much of a difference does it make? time says: $ time ./cprimes.rb > /dev/null
\n\n
real 0m0.328s \nuser 0m0.288s \nsys 0m0.020s
\n\n
An order of magnitude improvement. Not too shabby. \nWhat's the lesson here? Optimize what you need to (and only what you need to), profile find out what that is (it may be slow, but profiling is your friend), and use the right tools (rewriting a bit of code with RubyInline is way better than rewriting the whole app in C).
\n# Example MySQL config file for large systems.\n#\n# This is for a large system with memory = 512M where the system runs mainly\n# MySQL.\n#\n# You can copy this file to\n# /etc/my.cnf to set global options,\n# mysql-data-dir/my.cnf to set server-specific options (in this\n# installation this directory is /var/lib/mysql) or\n# ~/.my.cnf to set user-specific options.\n#\n# In this file, you can use all long options that a program supports.\n# If you want to know which options a program supports, run the program\n# with the \"--help\" option.\n\n# The following options will be passed to all MySQL clients\n[client]\nport = 3306\nsocket = /var/lib/mysql/mysql.sock\n\n# Here follows entries for some specific programs\n\n# The MySQL server\n[mysqld]\ndatadir=/var/lib/mysql\nsocket=/var/lib/mysql/mysql.sock\nuser=mysql\nskip-locking\n\n# By default, the wait_timeout value is 28800. Unless you want MySQL to keep waiting for 28800 seconds (480 minutes or 8 hours),\n# please decrease its value according to your application needs.\nwait_timeout=60\n# Increase connect_timeout from 5 to 10\nconnect_timeout=10\n# Decrease interactive_timeout from 28800 to 100\ninteractive_timeout=120\n# Increase join_buffer_size from 131072 to 1M\njoin_buffer_size=1M\n# Increase query_cache_size from 0 to 128M\nquery_cache_size=32M\n# Increase query cache limit from 1048576 to 2M\nquery_cache_limit=2M\n# Increase max allowed packet size from 1M to 16M\nmax_allowed_packet=2M\n# Increase table cache cache from 256 to 1024\ntable_cache=1024\n# Increase sort buffer size from 1M\nsort_buffer_size=2M\n# Increase read buffer size from 1M\nread_buffer_size=2M\n# Increase read_rnd_buffer_size to 4M\nread_rnd_buffer_size=4M\n\n#Other settings\nsort_buffer_size=8M\nkey_buffer = 256M\nkey_buffer_size=64M\nmyisam_sort_buffer_size = 64M\nthread_cache_size = 8\n# Try number of CPU's*2 for thread_concurrency\nthread_concurrency = 2\n\n\n# Don't listen on a TCP/IP port at all. This can be a security enhancement,\n# if all processes that need to connect to mysqld run on the same host.\n# All interaction with mysqld must be made via Unix sockets or named pipes.\n# Note that using this option without enabling named pipes on Windows\n# (via the \"enable-named-pipe\" option) will render mysqld useless!\n#\n#skip-networking\n\n# Disable Federated by default\nskip-federated\n\nold_passwords=1\n\n#for slow queries\nlog-slow-queries = /var/log/mysql-slow.log\nlong_query_time = 3\n\n[mysqldump]\nquick\nmax_allowed_packet = 16M\n\n[mysql]\nno-auto-rehash\n# Remove the next comment character if you are not familiar with SQL\n#safe-updates\n\n[isamchk]\nkey_buffer = 128M\nsort_buffer_size = 128M\nread_buffer = 2M\nwrite_buffer = 2M\n\n[myisamchk]\nkey_buffer = 128M\nsort_buffer_size = 128M\nread_buffer = 2M\nwrite_buffer = 2M\n\n[mysqlhotcopy]\ninteractive-timeout\n\n[mysqld_safe]\nlog-error=/var/log/mysqld.log\npid-file=/var/run/mysqld/mysqld.pid\n
mysql> SHOW VARIABLES like \"%sort%\";\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| max_length_for_sort_data | 1024 |\n| max_sort_length | 1024 |\n| myisam_max_sort_file_size | 2146435072 |\n| myisam_sort_buffer_size | 67108864 |\n| sort_buffer_size | 8388608 |\n+---------------------------+------------+\n5 rows in set (0.00 sec)
\n\n不晓得是做啥用的,查了下资料:\n
http://forge.mysql.com/wiki/MySQL_Internals_Algorithms\n\nUsing the modified filesort algorithm, the tuples are longer than the pairs used in the original method, and fewer of them fit in the sort buffer (the size of which is given by sort_buffer_size). As a result, it is possible for the extra I/O to make the modified approach slower, not faster. To avoid a slowdown, the optimization is used only if the total size of the extra columns in the sort tuple does not exceed the value of the max_length_for_sort_data system variable. (A symptom of setting the value of this variable too high is that you should see high disk activity and low CPU activity.)
Using the modified filesort algorithm, the tuples are longer than the pairs used in the original method, and fewer of them fit in the sort buffer (the size of which is given by sort_buffer_size). As a result, it is possible for the extra I/O to make the modified approach slower, not faster. To avoid a slowdown, the optimization is used only if the total size of the extra columns in the sort tuple does not exceed the value of the max_length_for_sort_data system variable. (A symptom of setting the value of this variable too high is that you should see high disk activity and low CPU activity.)
\n", "_id"=>1045}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "filesort"], "comments_count"=>0, "category_id"=>11, "title"=>"What does Using filesort mean in MySQL?", "body"=>"一直以来,只要我看到explain出来的结果有“Using filesort ”,我就要想方设法的优化和改善,因为我以前以为这个的意思就是使用文件系统来排序(那该多慢呀!),其实不是这样的。\n在mysqlperformanceblog上看到一篇文章《What does Using filesort mean in MySQL?》其中作者说自己每次面世的时候都会问“what does Using filesort mean in EXPLAIN,” 结果没有一个人回答的是对的,结果让其比较郁闷,就写了这个文章说明:\n
The usual answer is something like “rows are being placed into a temporary table which is too big to fit in memory, so it gets sorted on disk.” Unfortunately, this is not the same thing. First of all, this is Using temporary. Secondly, temporary tables may go to disk if they are too big, but EXPLAIN doesn’t show that. (If I interview you, I might ask you what “too big” means, or I might ask you the other reason temporary tables go to disk!)
The truth is, filesort is badly named. Anytime a sort can’t be performed from an index, it’s a filesort. It has nothing to do with files. Filesort should be called “sort.” It is quicksort at heart.
\n正解是,filesort这个名字有问题,容易给人误解,在mysql中,任何不能通过index进行的sort都称之为filesort,这里的filesort和文件没有任何关系,应该称之为“sort”而不是“filesort”,它的内部实现就是快速排序。\n\n参考资料:\nWhat does Using filesort mean in MySQL?\nhttp://www.mysqlperformanceblog.com/2009/03/05/what-does-using-filesort-mean-in-mysql/\n\nHow MySQL executes ORDER BY\nhttp://s.petrunia.net/blog/?p=24", "created_at"=>2010-02-03 03:51:36 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
一直以来,只要我看到explain出来的结果有“Using filesort ”,我就要想方设法的优化和改善,因为我以前以为这个的意思就是使用文件系统来排序(那该多慢呀!),其实不是这样的。 \n在mysqlperformanceblog上看到一篇文章《What does Using filesort mean in MySQL?》其中作者说自己每次面世的时候都会问“what does Using filesort mean in EXPLAIN,” 结果没有一个人回答的是对的,结果让其比较郁闷,就写了这个文章说明: \nThe usual answer is something like “rows are being placed into a temporary table which is too big to fit in memory, so it gets sorted on disk.” Unfortunately, this is not the same thing. First of all, this is Using temporary. Secondly, temporary tables may go to disk if they are too big, but EXPLAIN doesn’t show that. (If I interview you, I might ask you what “too big” means, or I might ask you the other reason temporary tables go to disk!) \n通常的解释是:选择出来的记录太多了,需要排序时内存中放不下了,所以会存储在磁盘中,并通过操作磁盘的文件的方式来排序。但是呢,这是不对的。
\n\n
The truth is, filesort is badly named. Anytime a sort can’t be performed from an index, it’s a filesort. It has nothing to do with files. Filesort should be called “sort.” It is quicksort at heart. \n正解是,filesort这个名字有问题,容易给人误解,在mysql中,任何不能通过index进行的sort都称之为filesort,这里的filesort和文件没有任何关系,应该称之为“sort”而不是“filesort”,它的内部实现就是快速排序。
\n", "_id"=>1046}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "variables"], "comments_count"=>0, "category_id"=>11, "title"=>"Mysql动态修改参数", "body"=>"mysql数据库也像ORACLE数据库一样,可以动态的修改参数,可以修改会话级变量只对当前会话产生影响;也可以修改全局变量,对所有新连接的会话都产生影响。\n\n修改会话级变量\n用show variables 命令查看当前参数的值,like 'pattern'用于模式匹配,查找指定的参数\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n用set SESSION命令设置会话级变量的新值\n\nmysql> set SESSION sort_buffer_size=7000000;\nQuery OK, 0 rows affected (0.00 sec)\n\n--修改会话级变量对当前会话来说立刻生效\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 7000000 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\nmysql> exit\nBye\n退出重新连接后,此参数恢复原值\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 40 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n修改全局变量\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 40 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n用set GLOBAL 命令设置全局变量\n\nmysql> set GLOBAL sort_buffer_size = 7000000;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n当前此参数的值并不发生变化,先退出,然后重新连进去\nmysql> exit\nBye\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 41 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 7000000 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n新的参数值生效", "created_at"=>2010-02-03 04:00:12 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
--修改会话级变量对当前会话来说立刻生效 \nmysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 7000000 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
mysql> exit \nBye \n退出重新连接后,此参数恢复原值 \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 40 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
修改全局变量 \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 40 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
用set GLOBAL 命令设置全局变量
\n\n
mysql> set GLOBAL sort_buffer_size = 7000000; \nQuery OK, 0 rows affected (0.00 sec)
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec) \n当前此参数的值并不发生变化,先退出,然后重新连进去 \nmysql> exit \nBye \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 41 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 7000000 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec) \n新的参数值生效
\n", "_id"=>1048}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Tips"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Textmate", "theme"], "comments_count"=>0, "category_id"=>4, "title"=>"Installing a New Textmate Theme", "body"=>"To install a new theme, select one of the .tmTheme links listed below, download it to your desktop and double-click on the file. This will place it in ~/Library/Application Support/TextMate/Themes, at which point the new theme will appear in the list found in Preferences → Fonts & Colors. This will also set it as the active theme. (Once the theme is installed, you may remove the .tmTheme from your desktop.)\n\nRails Envy TextMate Theme\n http://railsenvy.com/2008/9/18/rails-envy-textmate-theme\n\nUser Submitted Themes\n http://wiki.macromates.com/Themes/UserSubmittedThemes", "created_at"=>2010-02-04 18:24:02 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
To install a new theme, select one of the .tmTheme links listed below, download it to your desktop and double-click on the file. This will place it in ~/Library/Application Support/TextMate/Themes, at which point the new theme will appear in the list found in Preferences → Fonts & Colors. This will also set it as the active theme. (Once the theme is installed, you may remove the .tmTheme from your desktop.)
\n\nrestart teatmate and it's done!\n\nIn the TextMate preferences, advanced tab, shell variables, set the TM_GIT variable to point to your installation of git (ie /usr/local/bin/git)\nMany shortcuts are available from the Git-shortcut (Ctrl-Shift-G). Subversion commands are Command-Option-g. Less frequent commands are accessed via the menu.\nUpdate your bundle by running the “Update Git Bundle” command.", "created_at"=>2010-02-04 23:39:24 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
In the TextMate preferences, advanced tab, shell variables, set the TM_GIT variable to point to your installation of git (ie /usr/local/bin/git) \nMany shortcuts are available from the Git-shortcut (Ctrl-Shift-G). Subversion commands are Command-Option-g. Less frequent commands are accessed via the menu. \nUpdate your bundle by running the “Update Git Bundle” command.
SIMBL (SIMple Bundle Loader) - pronounced like \"symbol\" or \"cymbal\" - enables hacks and plugins. For instance, SIMBL enables PithHelmet to enhance Safari.
Install SIMBL and make sure you have latest SIMBL 0.9.x\nPlace Visor.bundle into ~/Library/Application Support/SIMBL/Plugins (create this directory if it does not exist)\nRelaunch Terminal.app - You should now see the Visor Status Menu Item\nConfigure your keyboard trigger by selecting the Visor Status Menu Item -> Visor Preferences ... and edit your keyboard hot-key\nYou can now trigger Visor with your hot-key from any application to get an instant terminal session.\n\nTo hide Visor, you can either:\nre-trigger with your key-combo\noptionally you can click off of the Visor window
如果你和我一样经常使用终端程序,这个小程序一定可以帮到你。他能将终端窗口变成类似雷神或CS那样的下拉窗口,非常酷。 \n可以从这里下载 http://visor.binaryage.com/ \n这个软件需要SIMBL ,如果你没有安装,要先安装这个。 \nhttp://www.culater.net/software/SIMBL/SIMBL.php \nSIMBL (SIMple Bundle Loader) - pronounced like "symbol" or "cymbal" - enables hacks and plugins. For instance, SIMBL enables PithHelmet to enhance Safari. \n之后将下载下来的文件解压,将解压后的文件拷贝至/Library/Application Support/SIMBL/Plugins,之后再重新启动你的终端你就可以看到效果了。 默认的快捷启动键是Ctrl+` \nvisor: http://visor.binaryage.com/
\n\n
Installation
\n\n
Install SIMBL and make sure you have latest SIMBL 0.9.x \nPlace Visor.bundle into ~/Library/Application Support/SIMBL/Plugins (create this directory if it does not exist) \nRelaunch Terminal.app - You should now see the Visor Status Menu Item \nConfigure your keyboard trigger by selecting the Visor Status Menu Item -> Visor Preferences ... and edit your keyboard hot-key \nYou can now trigger Visor with your hot-key from any application to get an instant terminal session.
\n\n
To hide Visor, you can either: \nre-trigger with your key-combo \noptionally you can click off of the Visor window
前段时间写了一篇《实例优化mysql配置文件my.cnf》,这几天看到效果非常明显,别的不说,单mysql cache_hits就很不错(之前竟然没注意到这个参数) \n# Increase query_cache_size from 0 to 128M \nquery_cache_size=128M
Rails 3 in Action by Yehuda Katz and Mike Gunderloy. Currently available is their Early Access Edition, which gives you access to chapters as they are written.
\n\t
Beginning Rails 3 by Jeffrey Allan Hardy , Cloves Carneiro Jr. & Rida Al Barazi
这次升级需要新装很多的gem,如下: \ngem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n \ngem install rails --pre \n期间遇到一个错误: \nDue to a rubygems bug, you must uninstall all older versions of bundler for 0.9 to work \n然后这边有N多关于Rails3的资料供参考:
\n\n
Rails 3 Tutorials & Blog Posts
\n\n
Edging your way towards Ruby 1.9.1 and Rails 3.0pre \n Unobtrusive JavaScript in Rails 3 by Zach Carter \n A Fresh Cup: Seed Data in Rails 3 tutorial – feature summary + code example by Mike Gunderloy. \n Rails3: Stepping off of the golden path slides by Matt Aimonetti \n Rails Magazine – RailsConf 2009 Edition page 5 has a section called The Unofficial Guide to What’s New in Rails 3 by Rupak Ganguly \n Jason Ting’s RailsConf 2009 Notes includes some basic notes about Rails 3 \n Noel Rappin: Railsconf 09 – After the RailsConfening article \n Yehuda Katz: Railsconf Wrapup blog – contains links to jQuery talk by Katz at RailsConf 09 \n How to Begin Playing With Rails 3 by Oscar Del Ben \n My Five Favorite Things About Rails 3 by Yehuda Katz \n Rails 3: The Great Decoupling by Yehuda Katz \n Rails Edge Architecture by Yehuda Katz \n How to Build Sinatra on Rails 3 by Yehuda Katz
\n\n
Rails 3 Presentations & Conference Talks
\n\n
Yehuda: What to Expect in Rails 3.0 webcast recording \n Scotland on Rails: Yehuda on Rails & Merb Merge video. For more Scotland on Rails videos, check out this Ruby Inside post. \n Yehuda Katz on Rails 3 and beyond interview by Mark Coleman \n RailsConf: Yehuda – The Russian Doll Pattern video \n RailsConf 09: DHH Keynote video – DHH previews unobtrusive javascript, default escaping & more.
\n\n
Rails 3 Books
\n\n
Rails 3 in Action by Yehuda Katz and Mike Gunderloy. Currently available is their Early Access Edition, which gives you access to chapters as they are written. \n Beginning Rails 3 by Jeffrey Allan Hardy , Cloves Carneiro Jr. & Rida Al Barazi
\n\n
Rails 3 Commentary
\n\n
Internet News: Rails 3 Gets Supersized With Merb \n eWeek: Rubyists Unite Ruby on Rails and Merb to Merge in Rails 3 \n CIO: Rails 3 to add security enhancement \n Yehuda Katz: Rails and Merb Merge \n RubyOnRails.org: Rails + Merb Merge Announcement
\n", "_id"=>1053}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"02. 产品设计 | PM"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Axure", "Balsamiq Mockups", "原型设计"], "comments_count"=>0, "category_id"=>13, "title"=>"Balsamiq Mockups,理想的原型设计工具", "body"=>"由于经常要讨论产品,包括web和手机(\bAandroid,Iphone)的产品原型设计,尝试过很多的原型设计工具,例如Axure等,后来换了mac book,就一直找不到合适的原型设计工具,就一直在Google Doc中直接draw,其做了很多无用功。\n比较偶然的机会看到Balsamiq Mockups这个软件,和Pixelmator一样,是个人开发者(意大利人Peldi)开发的产品,其地址为http://www.balsamiq.com/ ,在其提供的demo页面上试了下http://www.balsamiq.com/demos/mockups/Mockups.html,效果很好,符合我的预期。\n虽然是由个人设计的,但功能却一点不弱于其他大牌的原型设计工具:\n操作方面,拖拽,控件分组,甚至元素之间的对齐都做得很贴心;\n预制了很多界面元素,从简单的输入框,下拉框,浏览器主要元素,到经常用得到的导航条,日历,表格,到复杂的Tag Cloud,Cover Flow, 地图,WYSWYG的格式工具栏等,有了这些不用从头画起,往往比用白板都快;\n界面元素的修改很简单,比如导航条的几个标签页的label,就是用逗号分隔的文字,下拉框的选项就是分行的文字;\n使用xml语言来记录和保存界面元素和布局,\n这使得每个设计都能被很好得放进SVN,Git,和CVS等工具中进行管理和跟踪;\n可以设计复杂的界面元素,保存后,以后可以重复使用(包括修改);\n可以将设计导出成PNG格式的图片;\n可以用命令行进行导出操作,这样就能让我写个脚本,从svn里checkout某个目录下的所有设计文件后,导出图片,打包后用邮件发到项目经理,工程师甚至客户那;\n跨平台,Balsamiq Mokups是用Flex和Air实现的,所以在Mac OS, Linux和Windows下都能使用;\n不仅仅有桌面版本,还有能集成在Confluence,JIRA,和XWiki中的版本,使得异地在线协作更方便有效。\n\n以下是关于Balsamiq Mockups的一些特点:\n易操作:从 Balsamiq Mockups 自带的元素里可以很方便地拖拽,效果图轻易形成;元素对齐很贴心;\n可偷懒:根据 Balsamiq Mockups 提供的 Wiki 风格的代码规则,画图时可以「偷懒」,输入文本符号则能生成图标。因此相比其它繁琐的软件操作,Balsamiq Mockups 也能更快地完成画图任务。\n控件足:Balsamiq Mockups 软件包括 50 多个控件, 70 多个图标。基本自带了所有常用的小控件,并在导航处进行分类;图标设计赏心悦目。要是 Balsamiq Mockups 允许用户导入自定义的控件就更好了,当然现有的也足够了 -\n新风格:让人眼前一亮的涂鸦风格,很能还原手绘效果;\n可中文:在菜单栏 View 里将 Use System Fonts 勾上,就能完美支持中文输入(注:非 Balsamiq Mockups 中文版);\n其它点:Balsamiq Mockups 使用 xml 记录,方便移植、二次利用;可导出为 png 格式图片。\n\n另外还有跨平台与多版本两个优点:\n跨平台:Balsamiq Mockups 基于 Air ,因此能同时在 Windows、Mac OS 及 Linux 下使用;\n多版本:包括桌面版本,以及集成于 Confluence、JIRA、XWiki、FogBugz 中的版本\n\n软件可以从其网站上下载,其中桌面版本售价是$79。但作者非常厚道,提供了几种免费使用的方式:http://www.balsamiq.com/products/mockups/desktop\n\nYou can download Mockups for Desktop for free. Some of the features of the app, like saving and loading multiple mockups or linking mockups together can only get unlocked using a license key.\n", "created_at"=>2010-02-21 18:39:26 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
You can download Mockups for Desktop for free. Some of the features of the app, like saving and loading multiple mockups or linking mockups together can only get unlocked using a license key.
\n", "_id"=>1054}])
+MONGODB iceylog_development['categories'].find({:_id=>13}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>13}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "socket"], "comments_count"=>0, "category_id"=>3, "title"=>"Can’t connect to local MySQL server through socket 解决办法", "body"=>"Rails启动后报错,ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/temp/mysql.sock’ (2)\n\n1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.\n另外看看是不是权限问题.\n\n2、确定你的mysql.sock是不是在那个位置,\nmysql -u 你的mysql用户名 -p -S /var/lib/mysql/mysql.sock\n\n3、试试:service mysqld start\n\n4、如果是权限问题,则先改变权限 #chown -R mysql:mysql /var/lib/mysql\n\n[root@localhost ~]# /etc/init.d/mysqld start\n启动 MySQL: [ 确定 ]\n[root@localhost ~]# mysql -uroot -p", "created_at"=>2010-02-23 21:24:14 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
Rails启动后报错,ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/temp/mysql.sock’ (2)
\n\n
1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动. \n另外看看是不是权限问题.
\n", "_id"=>1055}])
+MONGODB iceylog_development['categories'].find({:_id=>3}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>3}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Passenger", "REE"], "comments_count"=>0, "category_id"=>2, "title"=>"Download Ruby Enterprise Edition(REE)", "body"=>"前段时间用上了Passenger ,尔后就看到很多的人推荐使用Ruby Enterprise Edition(REE),今天得闲,试了一把。\nStep 1: Download\nSource code: version 1.8.7-2010.01\nStep 2: Install\nExtract it:\ntar xzvf ruby-enterprise-X.X.X.tar.gz\nRun the installer (completely safe, none of your system files will be touched!):\n./ruby-enterprise-X.X.X/installer\n
Welcome to the Ruby Enterprise Edition installer
\n
This installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.
\n
Don't worry, none of your system files will be touched if you don't want them
\n
to, so there is no risk that things will screw up.
\n
You can expect this from the installation process:
\n
1. Ruby Enterprise Edition will be compiled and optimized for speed for this
\n
system.
\n
2. Ruby on Rails will be installed for Ruby Enterprise Edition.
\n
3. You will learn how to tell Phusion Passenger to use Ruby Enterprise
\n
Edition instead of regular Ruby.
\n
Press Enter to continue, or Ctrl-C to abort.
\n
Welcome to the Ruby Enterprise Edition installerThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.Don't worry, none of your system files will be touched if you don't want themto, so there is no risk that things will screw up.\nYou can expect this from the installation process:\n1. Ruby Enterprise Edition will be compiled and optimized for speed for this system.\n\n2. Ruby on Rails will be installed for Ruby Enterprise Edition.\n\n3. You will learn how to tell Phusion Passenger to use Ruby Enterprise Edition instead of regular Ruby.\nPress Enter to continue, or Ctrl-C to abort.
\nStep 3: Make Phusion Passenger use Ruby Enterprise Edition instead of regular Ruby\nFollow the instructions that the Ruby Enterprise Edition installer gave you.", "created_at"=>2010-03-03 16:53:29 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
前段时间用上了Passenger ,尔后就看到很多的人推荐使用Ruby Enterprise Edition(REE),今天得闲,试了一把。 \nStep 1: Download \nSource code: version 1.8.7-2010.01 \nStep 2: Install \nExtract it: \ntar xzvf ruby-enterprise-X.X.X.tar.gz \nRun the installer (completely safe, none of your system files will be touched!): \n./ruby-enterprise-X.X.X/installer \nWelcome to the Ruby Enterprise Edition installer \nThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01. \nDon't worry, none of your system files will be touched if you don't want them \nto, so there is no risk that things will screw up. \nYou can expect this from the installation process: \n1. Ruby Enterprise Edition will be compiled and optimized for speed for this \nsystem. \n2. Ruby on Rails will be installed for Ruby Enterprise Edition. \n3. You will learn how to tell Phusion Passenger to use Ruby Enterprise \nEdition instead of regular Ruby. \nPress Enter to continue, or Ctrl-C to abort. \nWelcome to the Ruby Enterprise Edition installerThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.Don't worry, none of your system files will be touched if you don't want themto, so there is no risk that things will screw up. \nYou can expect this from the installation process: \n1. Ruby Enterprise Edition will be compiled and optimized for speed for this system.
\n\n\n
Ruby on Rails will be installed for Ruby Enterprise Edition.
\n
You will learn how to tell Phusion Passenger to use Ruby Enterprise Edition instead of regular Ruby. \nPress Enter to continue, or Ctrl-C to abort. \nStep 3: Make Phusion Passenger use Ruby Enterprise Edition instead of regular Ruby \nFollow the instructions that the Ruby Enterprise Edition installer gave you.
\n\n", "_id"=>1056}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"02. 产品设计 | PM"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Border-radius", "css3"], "comments_count"=>0, "category_id"=>13, "title"=>"Border-radius: create rounded corners with CSS!", "body"=>"W3C has offered some new options for borders in CSS3, of which one is border-radius. Both Mozila/Firefox and Safari 3 have implemented this function, which allows you to create round corners on box-items. This is an example:\n\nMozilla/Firefox and Safari 3 users should see a nicely rounded box, with a nicely rounded border.\nThe code for this example above is actually quite simple:\n\nThese different corners can also each be handled on their own, Mozilla has other names for the feature than the spec says it should have though, as it has f.i. -moz-border-radius-topright as opposed to -webkit-border-top-right-radius:\n\nMozilla/Firefox and Safari 3 users should see a box with a rounded left upper corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded right upper corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded left lower corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded right lower corner.\nThese are handled by / should be handled by:\n\n````-moz-border-radius-topleft / -webkit-border-top-left-radius\n-moz-border-radius-topright / -webkit-border-top-right-radius\n-moz-border-radius-bottomleft / -webkit-border-bottom-left-radius\n-moz-border-radius-bottomright / -webkit-border-bottom-right-radius```", "created_at"=>2010-03-05 10:38:13 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
W3C has offered some new options for borders in CSS3, of which one is border-radius. Both Mozila/Firefox and Safari 3 have implemented this function, which allows you to create round corners on box-items. This is an example:
\n\n
Mozilla/Firefox and Safari 3 users should see a nicely rounded box, with a nicely rounded border. \nThe code for this example above is actually quite simple: \n \nThese different corners can also each be handled on their own, Mozilla has other names for the feature than the spec says it should have though, as it has f.i. -moz-border-radius-topright as opposed to -webkit-border-top-right-radius:
\n\n
Mozilla/Firefox and Safari 3 users should see a box with a rounded left upper corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded right upper corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded left lower corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded right lower corner. \nThese are handled by / should be handled by:
\n", "_id"=>1059}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["action_mailer_optional_tls", "Gmail", "Redmine"], "comments_count"=>0, "category_id"=>2, "title"=>"Setup Redmine to send email using GMail", "body"=>"Redmine是用Rails写的一套很不错的项目管理系统,其提供了诸多很方便实用的功能,诸如里程碑管理,BUG跟踪,代码库变更管理等等。\n搭建以后在管理面板中测试邮件不通,主要原因是由于采用的Gmail的邮箱,于是找到一些解决方案,如下:\n1. Install the action_mailer_optional_tls plugin\nThe action_mailer_optional_tls_plugin adds a TLS option to Redmine's emailing library, ActionMailer. TLS is a version of SSL which is required by GMail in order to send email.\n\nTo install this plugin, use the script/plugin command in your Redmine directory:\n ./script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git\n\n2. Configure your email.yml\n# File: config/email.yml\nproduction:\n delivery_method: :smtp\n smtp_settings:\n tls: true\n address: \"smtp.gmail.com\"\n port: 587\n domain: \"www.YOURDOAMIN.com\" # 'your.domain.com' for GoogleApps\n authentication: :plain\n user_name: \"username@youdomain.com\"\n password: \"password\"\n\n3. Start up Redmine and test your Email\nNext it's time to start up Redmine and to send a test email. Make sure that you start Redmine in the same mode as you configured above (e.g. production). To send a test email:\nLogin as an administrator\nGo to the Administration panel\nGo into the Settings and select the \"Email notifications\" tab\nIn the bottom right, click the link to \"Send a test email\"", "created_at"=>2010-03-14 18:31:57 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
Redmine是用Rails写的一套很不错的项目管理系统,其提供了诸多很方便实用的功能,诸如里程碑管理,BUG跟踪,代码库变更管理等等。 \n搭建以后在管理面板中测试邮件不通,主要原因是由于采用的Gmail的邮箱,于是找到一些解决方案,如下: \n1. Install the action_mailer_optional_tls plugin \nThe action_mailer_optional_tls_plugin adds a TLS option to Redmine's emailing library, ActionMailer. TLS is a version of SSL which is required by GMail in order to send email.
\n\n
To install this plugin, use the script/plugin command in your Redmine directory: \n ./script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git
3. Start up Redmine and test your Email \nNext it's time to start up Redmine and to send a test email. Make sure that you start Redmine in the same mode as you configured above (e.g. production). To send a test email: \nLogin as an administrator \nGo to the Administration panel \nGo into the Settings and select the "Email notifications" tab \nIn the bottom right, click the link to "Send a test email"
\n", "_id"=>1061}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["concat", "Database"], "comments_count"=>0, "category_id"=>3, "title"=>"MySQL CONCAT", "body"=>"MySQL CONCAT function is used to concatenate two strings to form a single string. Try out following example:\nmysql> SELECT CONCAT('FIRST ', 'SECOND');\n+----------------------------+\n| CONCAT('FIRST ', 'SECOND') |\n+----------------------------+\n| FIRST SECOND |\n+----------------------------+\n1 row in set (0.00 sec)\n\nie.\nmysql -u eoewallpapers -p123456123 wallpapers -e 'set names 'utf8'; select CONCAT(base_url,\"400\",title) from photos where state > 10 ' > photos_400.txt", "created_at"=>2010-03-19 20:34:34 UTC, "updated_at"=>2012-06-24 15:47:03 UTC, "body_html"=>"
MySQL CONCAT function is used to concatenate two strings to form a single string. Try out following example: \nmysql> SELECT CONCAT('FIRST ', 'SECOND'); \n+----------------------------+ \n| CONCAT('FIRST ', 'SECOND') | \n+----------------------------+ \n| FIRST SECOND | \n+----------------------------+ \n1 row in set (0.00 sec)
\n\n
ie. \nmysql -u eoewallpapers -p123456123 wallpapers -e 'set names 'utf8'; select CONCAT(base_url,"400",title) from photos where state > 10 ' > photos_400.txt
alias ls=”ls -G”是给”ls -G”起了一个别名,当执行ls时,就相当于执行了ls -G。
\n\n
CLICOLOR是用来设置是否进行颜色的显示。CLI是Command Line Interface的缩写。 \nLSCOLORS是用来设置当CLICOLOR被启用后,各种文件类型的颜色。LSCOLORS的值中每两个字母为一组,分别设置某个文件类型的文字颜色和背景颜色。LSCOLORS中一共11组颜色设置,按照先后顺序,分别对以下的文件类型进行设置:
\n\n
directory \nsymbolic link \nsocket \npipe \nexecutable \nblock special \ncharacter special \nexecutable with setuid bit set \nexecutable with setgid bit set \ndirectory writable to others, with sticky bit \ndirectory writable to others, without sticky bit \nLSCOLORS中,字母代表的颜色如下:
\n", "_id"=>1067}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["10.6.3", "rails3", "railties"], "comments_count"=>0, "category_id"=>7, "title"=>"解决升级mac OS 10.6.3后rails3无法启动的问题", "body"=>"昨晚看hero的时候顺带update到mac OS 10.6.3,早上重启机器安装成功,发现rails3无法启动,报:\n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception)\nfrom /usr/bin/rails:19\n\n这个错误我之前安装rails3的时候遇到过,解决如下:\n1.先尝试下重新安装rails\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install rails --pre\nPassword:\nSuccessfully installed treetop-1.4.5\n1 gem installed\nInstalling ri documentation for treetop-1.4.5...\nInstalling RDoc documentation for treetop-1.4.5..\n发现多了个treetop的gem,查查是啥:\n
Treetop is a language for describing languages. Combining the elegance of Ruby with cutting-edge parsing expression grammars, it helps you analyze syntax with revolutionarily ease.
\n\n再次执行rails,发现\n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception)\n from /usr/bin/rails:19\n\n还是不行,那就是railties的问题了,重新装下\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install railties --pre\nSuccessfully installed railties-3.0.0.beta\n1 gem installed\nInstalling ri documentation for railties-3.0.0.beta...\nInstalling RDoc documentation for railties-3.0.0.beta...\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ rails -v\nRails 3.0.0.beta\n\nOK,可以了~", "created_at"=>2010-03-31 22:01:38 UTC, "updated_at"=>2012-06-24 15:47:04 UTC, "body_html"=>"
昨晚看hero的时候顺带update到mac OS 10.6.3,早上重启机器安装成功,发现rails3无法启动,报: \n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception) \nfrom /usr/bin/rails:19
\n\n
这个错误我之前安装rails3的时候遇到过,解决如下: \n1.先尝试下重新安装rails \nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install rails --pre \nPassword: \nSuccessfully installed treetop-1.4.5 \n1 gem installed \nInstalling ri documentation for treetop-1.4.5... \nInstalling RDoc documentation for treetop-1.4.5.. \n发现多了个treetop的gem,查查是啥: \nTreetop is a language for describing languages. Combining the elegance of Ruby with cutting-edge parsing expression grammars, it helps you analyze syntax with revolutionarily ease.
\n\n
再次执行rails,发现 \n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception) \n from /usr/bin/rails:19
\nThis Rails plugin allows users to take advantage of nginx's X-Accel-Redirect header, similar to X-Send-File.```\n
== Install\nYou should install it as a plugin, running this command on your projects root directory:\n $ script/plugin install git://github.com/goncalossilva/X-Accel-Redirect.git```\n
== Usage\nX-Accel-Redirect has an equivalent method to Rails <i>send_file</i>, called <b>x_accel_redirect</b>. Using is as easy as:\n x_accel_redirect \"/path/to/file\", :filename => \"filename\"\nAll <i>send_file</i> options are available using this method. Now you can even let your old <b>:x_sendfile</b> option since the plugin will discard it.```\n```\n
于是聪明的人们就想,可以使用app server处理业务逻辑,然后再让web server来接管处理剩下的文件发送,所以就有了mod_xsendfile for Apache2和Lighttp中提供的X-Sendfile功能,Nginx自然也有类似的功能,只是其名字不叫X-Sendfile,而是叫X-Accel-Redirect(这个名字好像更容易理解)。 这里主要说Nginx,Apache的自行查阅资料,先了解下原理: \n \n The header must contain a URI \n The location should be defined as internal; to prevent the client going directly to the URI \n \n定义一段配置: \n<a href="/NginxHttpCoreModule#location">location</a> /protected/ { \n <a href="/NginxHttpCoreModule#internal">internal</a>; \n <a href="/NginxHttpCoreModule#root">root</a> /some/path; \n} \n然后在你的应用中: \n \nadd_header("X-Accel-Redirect: /protected/iso.img"); \n然后Nginx就接管了你的请求,发送<strong>/some/path/protected/iso.img</strong>这个文件。 \n原理了解了,看看如何使用更快捷,自然是用插件,有人写出了一个插件:X-Accel-Redirect \n`` \n<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;"> \n<div id="_mcePaste">= X-Accel-Redirect</div> \nThis Rails plugin allows users to take advantage of nginx's X-Accel-Redirect header, similar to X-Send-File. \n== Install \nYou should install it as a plugin, running this command on your projects root directory: \n $ script/plugin install git://github.com/goncalossilva/X-Accel-Redirect.git \n<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;">== Usage \nX-Accel-Redirect has an equivalent method to Rails <i>send_file</i>, called <b>x_accel_redirect</b>. Using is as easy as: \n x_accel_redirect "/path/to/file", :filename => "filename" \nAll <i>send_file</i> options are available using this method. Now you can even let your old <b>:x_sendfile</b> option since the plugin will discard it. \n \n<div id="_mcePaste"><strong>参考:</strong></div> \n \nwiki.nginx.org/NginxXSendfile \n``<span style="font-family: Georgia, Times, 'Times New Roman', serif; line-height: 21px; white-space: normal; color: #21211e; font-size: 13px;"> \n<h1 class="entry-title" style="outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; font-weight: bold; clear: both; text-transform: uppercase; letter-spacing: 2px; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;"><a href="http://www.motionstandingstill.com/using-nginx-to-send-files-with-x-accel-redirect/2008-09-03/">USING NGINX TO SEND FILES WITH X-ACCEL-REDIRECT</a></h1> \n</span> \nThe complete nginx solution to sending flowers and files with rails \n``<a href="http://bianbian.org/technology/linux/154.html">[译]利用Nginx的X-Accel-Redirect头实现下载控制(附带php和rails实例)</a>
\n", "_id"=>1070}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"publish a rails plugin:Nginx-X-Accel-Redirect", "body"=>"前面2个文章说到了在Rails中使用send_file实现断点续传《在rails下实现多线程下载和断点续传》和利用Nginx的X-Accel-Redirect实现发送大文件《使用Nginx的X-Accel-Redirect在Rails中发送文件》,项目中需要两个功能,就把他整合起来,同时发布到github上了,Nginx-X-Accel-Redirect。\n\n简介:\nThis Rails plugin allows users to take advantage of nginx’s X-Accel-Redirect header, similar to X-Send-File and Content-Range.\n\n安装:\n$ script/plugin install git://github.com/IceskYsl/Nginx-X-Accel-Redirect.git\n\n使用:\nx_accel_redirect \"/path/to/file\", :filename => \"filename\",:root=>\"/path/to/root\"\n\n详细信息:github.com/IceskYsl/Nginx-X-Accel-Redirect", "created_at"=>2010-04-17 21:37:59 UTC, "updated_at"=>2012-06-24 15:47:04 UTC, "body_html"=>"
\n", "_id"=>1079}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>3, "title"=>"TEXT fields in MySQL", "body"=>"MySQL TEXT fields have a limit of 65,000 bytes. If you insert anything larger than that in to a normal TEXT field mySQL will silently truncate your data without telling you (meaning software checks are probably a good idea). MEDIUMTEXT will store 16 million characters and LONGTEXT can handle over 4 trillion, but this information does not appear to be readily available in the online mySQL manual (although it is hinted at in this table). Something to bare in mind when designing database applications.\n\nMyISAM tables in MySQL have a maximum size of a row of 65,535 bytes, so all the data in a row must fit within that limit. However, the TEXT types are stored outside the table itself and only contribute 9 to 12 bytes towards that limit. (For more information about this refer to the MySQL Manual - Data Storage Requirements chapter).\n\nref::http://www.electrictoolbox.com/maximum-length-mysql-text-field-types/\nTEXT data types are also able to store much more data than VARCHAR and CHAR text types so TEXT types are what you need to use when storing web page or similar content in a database.\n\nThe maximum amount of data that can be stored in each data type is as follows:\n\nTINYTEXT\t256 bytes\nTEXT\t65,535 bytes\t~64kb\nMEDIUMTEXT\t 16,777,215 bytes\t~16MB\nBIGTEXT\t4,294,967,295 bytes\t~4GB\nIn most circumstances the TEXT type is probably sufficient, but if you are coding a content management system it's probably best to use the MEDIUMTEXT type for longer pages to ensure there are no issues with data size limits.", "created_at"=>2010-06-27 20:56:02 UTC, "updated_at"=>2012-06-24 15:47:04 UTC, "body_html"=>"
MySQL TEXT fields have a limit of 65,000 bytes. If you insert anything larger than that in to a normal TEXT field mySQL will silently truncate your data without telling you (meaning software checks are probably a good idea). MEDIUMTEXT will store 16 million characters and LONGTEXT can handle over 4 trillion, but this information does not appear to be readily available in the online mySQL manual (although it is hinted at in this table). Something to bare in mind when designing database applications.
\n\n
MyISAM tables in MySQL have a maximum size of a row of 65,535 bytes, so all the data in a row must fit within that limit. However, the TEXT types are stored outside the table itself and only contribute 9 to 12 bytes towards that limit. (For more information about this refer to the MySQL Manual - Data Storage Requirements chapter).
The maximum amount of data that can be stored in each data type is as follows:
\n\n
TINYTEXT 256 bytes \nTEXT 65,535 bytes ~64kb \nMEDIUMTEXT 16,777,215 bytes ~16MB \nBIGTEXT 4,294,967,295 bytes ~4GB \nIn most circumstances the TEXT type is probably sufficient, but if you are coding a content management system it's probably best to use the MEDIUMTEXT type for longer pages to ensure there are no issues with data size limits.
做移动互联网的过程中,有这样一些词是必须知道的,如MO,MT,GSM,LINKID \n上行(MO)上行的意思就是短信发送到服务器端 MO又称 Mobile Original \n下行(MT)下行的意思就是短信从服务器端发回到手机上,MT又称Mobile Terminated \n简单的说,从手机发起一个的过程叫上行(MO),到手机结束的过程叫下行(MT),比如,平时给你的朋友发送一条短信,对你来说就是上行(MO),而对你的朋友来说,就是下行(MT)。在企业、行业应用中,从系统给手机发送信息的过程叫下行(MT),而手机发送信息给系统的过程叫上行(MO)。
\n", "_id"=>1086}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["log", "rails3", "slice_before"], "comments_count"=>0, "category_id"=>2, "title"=>"Parse Rails 3 log file using Enumerable#slice_before", "body"=>"``def parse_rails_log_file(file)\n # Remove all empty lines\n lines = file.each_line.map(&:strip).reject(&:empty?)\n\n # Use +Enumerable#slice_before+ to slice log file into sections for each request\n lines.slice_before(/Started (GET|POST|PUT|DELETE)/).each_with_object({}) do |request_log, totals|\n # Only include successfully finished actions in report\n if duration = request_log.last[/Completed 200 OK in (?<duration>\\d+)ms/, :duration]\n action_name = request_log.first[/Started (GET|POST|PUT|DELETE) \"(?<action>.+?)\" for/, :action]\n totals[action_name] ||= 0\n totals[action_name] += duration.to_i\n end\n end\nend\n\nif __FILE__ == $PROGRAM_NAME\n require \"pp\"\n puts \"Parsing Rails 3 log file (extracting cumulative running time per request path):\"\n puts \"=================\"\n\n log_file = <<-LOG_FILE\n Started GET \"/index\" for 192.168.74.1 at 2010-03-09 11:37:40\n Processing by UpdatesController#index as HTML\n Update Load (0.5ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (16.7ms)\n Completed 200 OK in 71ms (Views: 44.3ms | ActiveRecord: 0.5ms)\n\n Started POST \"/updates\" for 192.168.74.1 at 2010-03-09 11:37:43\n Processing by UpdatesController#create as HTML\n Parameters: {\"commit\"=>\"Save changes\"}\n Update Load (0.4ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (1.3ms)\n Completed 200 OK in 60ms (Views: 32.1ms | ActiveRecord: 0.4ms)\n\n Started GET \"/updates\" for 192.168.74.1 at 2010-03-09 11:45:51\n Processing by UpdatesController#index as HTML\n\n TypeError (exception class/object expected):\n app/controllers/updates_controller.rb:3:in `raise'\n app/controllers/updates_controller.rb:3:in `index'\n\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.6ms)\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.9ms)\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb (23.9ms)\n\n Started GET \"/updates\" for 192.168.74.1 at 2010-03-09 11:45:58\n Processing by UpdatesController#index as HTML\n Update Load (0.3ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (1.1ms)\n Completed 200 OK in 100ms (Views: 29.3ms | ActiveRecord: 0.3ms)\n LOG_FILE\n\n pp parse_rails_log_file(log_file) # => {\"/index\"=>71, \"/updates\"=>160}\nend```", "created_at"=>2010-07-26 21:42:33 UTC, "updated_at"=>2012-06-24 15:47:04 UTC, "body_html"=>"
# Use +Enumerable#slice_before+ to slice log file into sections for each request \n lines.slice_before(/Started (GET|POST|PUT|DELETE)/).each_with_object({}) do |request_log, totals| \n # Only include successfully finished actions in report \n if duration = request_log.last[/Completed 200 OK in (?<duration>\\d+)ms/, :duration] \n action_name = request_log.first[/Started (GET|POST|PUT|DELETE) "(?<action>.+?)" for/, :action] \n totals[action_name] ||= 0 \n totals[action_name] += duration.to_i \n end \n end \nend
\n\n
if FILE == $PROGRAM_NAME \n require "pp" \n puts "Parsing Rails 3 log file (extracting cumulative running time per request path):" \n puts "================="
\n\n
log_file = <<-LOG_FILE \n Started GET "/index" for 192.168.74.1 at 2010-03-09 11:37:40 \n Processing by UpdatesController#index as HTML \n Update Load (0.5ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (16.7ms) \n Completed 200 OK in 71ms (Views: 44.3ms | ActiveRecord: 0.5ms)
\n\n
Started POST "/updates" for 192.168.74.1 at 2010-03-09 11:37:43 \n Processing by UpdatesController#create as HTML \n Parameters: {"commit"=>"Save changes"} \n Update Load (0.4ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (1.3ms) \n Completed 200 OK in 60ms (Views: 32.1ms | ActiveRecord: 0.4ms)
\n\n
Started GET "/updates" for 192.168.74.1 at 2010-03-09 11:45:51 \n Processing by UpdatesController#index as HTML
Started GET "/updates" for 192.168.74.1 at 2010-03-09 11:45:58 \n Processing by UpdatesController#index as HTML \n Update Load (0.3ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (1.1ms) \n Completed 200 OK in 100ms (Views: 29.3ms | ActiveRecord: 0.3ms) \n LOG_FILE
\n写完申明后,去看消息出处看到其竟然做了修改,我早料到其会做相关的行为,所有早些时候截了屏幕如下:\n\n\n\n而现在的文章被修改为:\n\n\n\n看我用鼠标标识的地方,对关键信息进行了修改,感兴趣的人可以去 http://mobile.venturebeat.com/2010/07/28/android-wallpaper-app-that-steals-your-data-was-downloaded-by-millions/ 查看原文,对于这种标题党用子虚乌有的事情炒作,等消息传播后再修改自己的内容算什么行为!而对国内部分媒体在传播时不但不对真实性进行验证,还添油加醋,歪曲意思的报道,我非常无奈(看到有人还说可以获取信用卡信息,还加密传输,我实在无语)。\n\n按照我个人的感觉,他们应该紧接着要开始拿这个事件来炒作自己的产品了,我个人懒得去关注,如果有人发现有人借此炒作自己的产品,请帮忙分析分析,看看到底是什么人用这样手法。\n\n再次update!!!\n\n通过email和mylookout的人取得联系,说明我取得诸如设备号,手机屏幕大小是为了更智能的给设备适配图片,而获取部分的sim卡号是后来用户反馈说自己换了手机还想使用之前的收藏记录才使用的,这些信息只在该应用中使用,并没提供给任何第三方!\n\n同时让其确认venturebeat上文章中说到的获取浏览器历史,短信息,密码等高敏感性信息是否是他们说的还是写文章的人自己写的(Lots of my users send me the email ask me why I collect their text message and voicemail passward, I just want to make sure whether you and your ceo said that I collected browsing history,text message ,voicemail passward during the meeting.)。\n\n其cto给我回复说他们没有说过我的应用获取过诸如text messages or browsing history这些信息( We never stated that the wallpaper applications gathered users text messages or browsing history.),是媒体在撰写和传播的时候错误报道了(A member of the press misreported our research and he has since corrected it. )。\n\n我非常无语~\n\n2010年8月4日第二次次update!\n\n多谢这些天很多朋友的关心,我很好,谢谢!这些天和google android组,lookout公司和venturebeat的作者,以及国内外很多媒体,博客们,记者们都有很多的接触。\n\n1. google就前段时间将应用暂停和我一起分析了这个应用,今天发来调查的结果:\n\nOur investigation has concluded that there's no obvious malicious code in your apps, though the implementation accesses data that it doesn't need to. We've restored your apps (and they'll be available on Market again once you publish them), and are looking forward to seeing them updated to use ANDROID_ID. We are likely to make a statement about this issue this week--I'll let you know.\n\n我早就说过,我配合调查,我把代码提供给他们,google也做出了公正的评判,另外也给我提了一些建议(ANDROID_ID)。\n\n2. 当时写这篇报道的venturebeat记者Dean Takahashi发来了mail,为自己犯的错误道歉,并道歉该事带来的恶劣影响,会再写一篇文章澄清这个事情以消除影响。\n\n3. 那个安全公司lookout的人写邮件来要于我一起“ We wanted to coordinate with you to prevent further misunderstandings. ”。\n\n4.好几个不认识的国外记者很负责任,发邮件和gt和我交流询问事情的真相,并帮我喊冤,谢谢这些有职业精神的记者们。\n\n这个事情到这差不多就结束了,其中看到很多假丑恶,也看到很多真善美!谢谢所有帮助过我的人(很多很多,就不一一列举)。", "created_at"=>2010-07-29 08:41:39 UTC, "updated_at"=>2012-06-24 15:47:04 UTC, "body_html"=>"
同时让其确认venturebeat上文章中说到的获取浏览器历史,短信息,密码等高敏感性信息是否是他们说的还是写文章的人自己写的(Lots of my users send me the email ask me why I collect their text message and voicemail passward, I just want to make sure whether you and your ceo said that I collected browsing history,text message ,voicemail passward during the meeting.)。
\n\n
其cto给我回复说他们没有说过我的应用获取过诸如text messages or browsing history这些信息( We never stated that the wallpaper applications gathered users text messages or browsing history.),是媒体在撰写和传播的时候错误报道了(A member of the press misreported our research and he has since corrected it. )。
Our investigation has concluded that there's no obvious malicious code in your apps, though the implementation accesses data that it doesn't need to. We've restored your apps (and they'll be available on Market again once you publish them), and are looking forward to seeing them updated to use ANDROID_ID. We are likely to make a statement about this issue this week--I'll let you know.
\n", "_id"=>1088}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Munin", "netstat", "passive"], "comments_count"=>0, "category_id"=>7, "title"=>"Fix the passive netstat connections in Munin", "body"=>"\n\nIf your running Munin in WHM they you may have noticed the passive netstat connections have been rising steadily over the last couple of weeks. This isn't a problem with your server, its a Munin bug that can be easily fixed.\n\n\n\n\n\nApparently the problem stemms from Munin counting the passive connections rejected. You can fix this problem quite easily by following the instructions below\n\nEdit the following file:\n/usr/share/munin/plugins/netstat\n\nand change the line\n
If your running Munin in WHM they you may have noticed the passive netstat connections have been rising steadily over the last couple of weeks. This isn't a problem with your server, its a Munin bug that can be easily fixed.
\n\n\n\n
Apparently the problem stemms from Munin counting the passive connections rejected. You can fix this problem quite easily by following the instructions below
\n\n
Edit the following file: \n/usr/share/munin/plugins/netstat
\n", "_id"=>1089}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Charts", "Highcharts", "rails"], "comments_count"=>0, "category_id"=>2, "title"=>"ChartsOnRails", "body"=>"这几天需要找到漂亮的Charts类库,找了几个,发现一个很不粗的,mark下待使用,介绍如下:\n\nHighcharts is a charting library written in pure JavaScript, offering an easy way of adding interactive charts to your web site or web application. Highcharts currently supports line, spline, area, areaspline, column, bar, pie and scatter chart types.\n\n有兴趣的可以参考如下连接去看看:\n\nhttp://highcharts.com/\n\nhttp://railscasts.com/episodes/223-charts\n\nhttp://www.spritle.com/blogs/?p=859", "created_at"=>2010-08-20 21:48:59 UTC, "updated_at"=>2012-06-24 15:47:04 UTC, "body_html"=>"
这几天需要找到漂亮的Charts类库,找了几个,发现一个很不粗的,mark下待使用,介绍如下:
\n\n
Highcharts is a charting library written in pure JavaScript, offering an easy way of adding interactive charts to your web site or web application. Highcharts currently supports line, spline, area, areaspline, column, bar, pie and scatter chart types.
\n", "_id"=>1090}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"malformed format string on rails~", "body"=>"在rails中使用find进行模糊查询时,出现了malformedformat string(输入为字符)或非法字符(输入为数字)的提示。\n(1) @vendors = Vendor.find(:all,:conditions=>[@sql])\n(2) @vendors = Vendor.find_by_sql(\"select * from vendor where \"+@sql)\n错误发生在按(1)方式查询过程中,采用(2)方式可以避免这个错误,这间接说明了find_by_sql确实相当不安全。\n查阅了一下资料,对于这个问题的说法如下:Rails uses sprintf (%) on the inside. So, Escape your % with %,因此只要将模糊查询的地方一个百分号全部换成两个便可以解决问题。", "created_at"=>2010-09-03 16:39:58 UTC, "updated_at"=>2012-06-24 15:47:04 UTC, "body_html"=>"
在rails中使用find进行模糊查询时,出现了malformed format string(输入为字符)或非法字符(输入为数字)的提示。 \n(1) @vendors = Vendor.find(:all,:conditions=>[@sql]) \n(2) @vendors = Vendor.find_by_sql("select * from vendor where "+@sql) \n错误发生在按(1)方式查询过程中,采用(2)方式可以避免这个错误,这间接说明了find_by_sql确实相当不安全。 \n查阅了一下资料,对于这个问题的说法如下:Rails uses sprintf (%) on the inside. So, Escape your % with %,因此只要将模糊查询的地方一个百分号全部换成两个便可以解决问题。
\n", "_id"=>1095}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Using the Rails logger outside of models and controllers", "body"=>"You can use the Rails logger outside of Rails models in at least version 2.3.X and up of Rails. You might be used to doing the following in your models or controllers:\n\nlogger.info \"Some debugging info I want to see in my development log.\"\n\nIf you make a regular model that doesn’t inherit from ActiveRecord, though, you may see the following error:\n\nundefined local variable or method `logger' for #<Class:0x42fd77c>\n\nThe solution is to call Rails.logger.info (or debug, or warn) as follows:\n\nRails.logger.info \"Some debugging info I want to see in my development log.\"\n\nI hope that helps someone.", "created_at"=>2010-09-17 01:50:49 UTC, "updated_at"=>2012-06-24 15:47:04 UTC, "body_html"=>"
<!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px} -->You can use the Rails logger outside of Rails models in at least version 2.3.X and up of Rails. You might be used to doing the following in your models or controllers:
\n\n
logger.info "Some debugging info I want to see in my development log."
\n\n
If you make a regular model that doesn’t inherit from ActiveRecord, though, you may see the following error:
\n\n
undefined local variable or method `logger' for #<Class:0x42fd77c>
\n\n
The solution is to call Rails.logger.info (or debug, or warn) as follows:
\n\n
Rails.logger.info "Some debugging info I want to see in my development log."
svn remove log/* \nsvn commit -m"removing log files" \nsvn propset svn:ignore ".log" log/ \nsvn update log/ \nsvn commit -m 'Ignoring all files in /log/ ending in .log' \nsvn move config/database.yml config/database.example \nsvn commit -m 'Moving database.yml to database.example to provide a template for anyone who checks out the code' \nsvn propset svn:ignore "database.yml" config/ \nsvn update config/ \nsvn commit -m 'Ignoring database.yml' \nsvn remove tmp/ \nsvn propset svn:ignore "*" tmp/ \nsvn update tmp/ \nsvn commit -m "ignore tmp/ content from now" \nsvn propset svn:ignore ".htaccess" config/ \nsvn update config/ \nsvn commit -m 'Ignoring .htaccess' \nsvn propset svn:ignore "dispatch.fcgi" config/ \nsvn update config/ \nsvn commit -m 'Ignoring dispatch.fcgi'
\n", "_id"=>1098}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>3, "title"=>"delete & not exists in Mysql", "body"=>"This works\n\nselect * from tb_patient p where not exists (select col_patient_id from tb_payment where col_patient_id = p.col_unid);\n\nHowever, this does NOT work\n\ndelete from tb_patient p where not exists (select col_patient_id from tb_payment where col_patient_id = p.col_unid);\n\nwhy? Because of the alias p!!! Table alias is not allowed in not exists subquery!! Instead, you have to use the full table name~~~~ faint!\n\nCorrect code\n delete from tb_patient where not exists (select col_patient_id from tb_payment where col_patient_id = tb_patient.col_unid);", "created_at"=>2010-10-04 06:49:42 UTC, "updated_at"=>2012-06-24 15:47:04 UTC, "body_html"=>"
This works
\n\n
select * from tb_patient p where not exists (select col_patient_id from tb_payment where col_patient_id = p.col_unid);
\n\n
However, this does NOT work
\n\n
delete from tb_patient p where not exists (select col_patient_id from tb_payment where col_patient_id = p.col_unid);
\n\n
why? Because of the alias p!!! Table alias is not allowed in not exists subquery!! Instead, you have to use the full table name~~~~ faint!
\n\n
Correct code \n delete from tb_patient where not exists (select col_patient_id from tb_payment where col_patient_id = tb_patient.col_unid);
/var/run/sshd must be owned by root and not group or world-writable.
\n
root@e:/home/iceskysl# chmod 600 /var/run/sshd
\nroot@e:/home/iceskysl# /etc/init.d/ssh restart/var/run/sshd must be owned by root and not group or world-writable.root@li84-64:/home/iceskysl# chmod 600 /var/run/sshd", "created_at"=>2010-10-18 18:45:27 UTC, "updated_at"=>2012-06-24 15:47:04 UTC, "body_html"=>"
于是偶chmod 600 /etc/ssh/*,然后再次重启了ssh。 \nroot@e:/home/iceskysl# /etc/init.d/ssh restart \n/var/run/sshd must be owned by root and not group or world-writable. \nroot@e:/home/iceskysl# chmod 600 /var/run/sshd \nroot@e:/home/iceskysl# /etc/init.d/ssh restart/var/run/sshd must be owned by root and not group or world-writable.root@li84-64:/home/iceskysl# chmod 600 /var/run/sshd
\n", "_id"=>1100}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Android & Java"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["certificate"], "comments_count"=>0, "category_id"=>12, "title"=>"“Debug certificate expired” error in eclipse android plugins", "body"=>"I am using eclipse android plugins to build a project, But i am getting this error in the console window:\n\n[2010-02-03 10:31:14 - androidVNC]Error generating final archive:\nDebug certificate expired on 1/30/10 2:35 PM!\n\nIceskYsl@eoe ~/.android $ pwd\n/Users/IceskYsl/.android\nIceskYsl@eoe ~/.android $ ll\ntotal 48\ndrwxr-xr-x 9 IceskYsl staff 306 Nov 17 2009 .\ndrwxr-xr-x+ 62 IceskYsl staff 2108 Nov 30 13:51 ..\n-rw-r--r-- 1 IceskYsl staff 123 Sep 30 15:42 adb_usb.ini\n-rw-r--r-- 1 IceskYsl staff 204 Dec 1 00:52 androidtool.cfg\ndrwxr-xr-x 6 IceskYsl staff 204 Oct 16 16:17 avd\n-rw-r--r-- 1 IceskYsl staff 1393 Dec 1 00:37 ddms.cfg\n-rw-r--r-- 1 IceskYsl staff 1267 Nov 17 2009 debug.keystore\n-rw-r--r-- 1 IceskYsl staff 759 Nov 17 2009 default.keyset\n-rw-r--r-- 1 IceskYsl staff 78 Dec 1 00:52 repositories.cfg\n\nDelete your debug certificate under ~/.android/debug.keystore (on Linux and Mac OS X); the directory is something like %USERHOME%/.androidon Windows.\n\nThe Eclipse plugin should then generate a new certificate when you next try to build a debug package.", "created_at"=>2010-11-30 09:10:04 UTC, "updated_at"=>2012-06-24 15:47:04 UTC, "body_html"=>"
I am using eclipse android plugins to build a project, But i am getting this error in the console window:
\n\n
[2010-02-03 10:31:14 - androidVNC]Error generating final archive: \nDebug certificate expired on 1/30/10 2:35 PM!
\n", "_id"=>1106}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["brew"], "comments_count"=>0, "category_id"=>7, "title"=>"Installs Homebrew to /usr/local so you don't need sudo to `brew install`", "body"=>"$ curl https://raw.github.com/gist/323731/install_homebrew.rb -o /tmp/install_homebrew.rb\n % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n100 4569 100 4569 0 0 1605 0 0:00:02 0:00:02 --:--:-- 2346\n\n $ ruby /tmp/install_homebrew.rb\n==> This script will install:\n/usr/local/bin/brew\n/usr/local/Library/Formula/...\n/usr/local/Library/Homebrew/...\n==> The following directories will be made group writable:\n/usr/local/.\n/usr/local/bin\n==> The following directories will have their group set to admin:\n/usr/local/.\n/usr/local/bin\n\nPress enter to continue\n==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin\n==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin\n==> Downloading and Installing Homebrew...\nWarning: The following *evil* dylibs exist in /usr/local/lib\nThey may break builds or worse. You should consider deleting them:\n/usr/local/lib/libevent-1.4.2.1.3.dylib\n/usr/local/lib/libevent_core-1.4.2.1.3.dylib\n/usr/local/lib/libevent_extra-1.4.2.1.3.dylib\n/usr/local/lib/libkyotocabinet.4.8.0.dylib\n/usr/local/lib/libprotobuf-lite.6.dylib\n/usr/local/lib/libprotobuf.6.dylib\n/usr/local/lib/libprotoc.6.dylib\n==> Installation successful!\nNow type: brew help\n\n参考:https://gist.github.com/323731", "created_at"=>2011-09-03 08:29:42 UTC, "updated_at"=>2012-06-24 15:47:04 UTC, "body_html"=>"
$ curl https://raw.github.com/gist/323731/install_homebrew.rb -o /tmp/install_homebrew.rb \n % Total % Received % Xferd Average Speed Time Time Time Current \n Dload Upload Total Spent Left Speed \n100 4569 100 4569 0 0 1605 0 0:00:02 0:00:02 --:--:-- 2346
\n\n
$ ruby /tmp/install_homebrew.rb \n==> This script will install: \n/usr/local/bin/brew \n/usr/local/Library/Formula/... \n/usr/local/Library/Homebrew/... \n==> The following directories will be made group writable: \n/usr/local/. \n/usr/local/bin \n==> The following directories will have their group set to admin: \n/usr/local/. \n/usr/local/bin
\n\n
Press enter to continue \n==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin \n==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin \n==> Downloading and Installing Homebrew... \nWarning: The following evil dylibs exist in /usr/local/lib \nThey may break builds or worse. You should consider deleting them: \n/usr/local/lib/libevent-1.4.2.1.3.dylib \n/usr/local/lib/libevent_core-1.4.2.1.3.dylib \n/usr/local/lib/libevent_extra-1.4.2.1.3.dylib \n/usr/local/lib/libkyotocabinet.4.8.0.dylib \n/usr/local/lib/libprotobuf-lite.6.dylib \n/usr/local/lib/libprotobuf.6.dylib \n/usr/local/lib/libprotoc.6.dylib \n==> Installation successful! \nNow type: brew help
\n", "_id"=>1108}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["perl", "Twig", "xml"], "comments_count"=>0, "category_id"=>7, "title"=>"install perl module for XML-Twig in RHEL-Red Hat/Fedora Linux?", "body"=>"This module provides a way to process XML documents. It is build on top of XML::Parser. XML::Twig offers a tree interface to the document, while allowing you to output the parts of it that have been completely processed. It allows minimal resource (CPU and memory) usage by building the tree only for the parts of the documents that need actual processing, through the use of the twig_roots and twig_print_outside_roots options.(as pointed by yum info)\r\n\r\nLet’s first search for the package\r\n$ yum search perl-XML-Twig\r\nperl-XML-Twig.noarch : A perl module for processing huge XML documents in tree\r\n\r\nNote that you must be the root/administrator to install the package. To install this package in Red Hat/Fedora Linux.\r\n$ yum install perl-XML-Twig.noarch\r\n\r\nYou can check the details of this package perl-XML-Twig\r\n$ yum info perl-XML-Twig.noarch\r\n\r\n或者:\r\nperl -MCPAN -e 'install XML::Twig'", "created_at"=>2011-12-10 10:53:02 UTC, "updated_at"=>2012-06-24 15:47:04 UTC, "body_html"=>"
This module provides a way to process XML documents. It is build on top of XML::Parser. XML::Twig offers a tree interface to the document, while allowing you to output the parts of it that have been completely processed. It allows minimal resource (CPU and memory) usage by building the tree only for the parts of the documents that need actual processing, through the use of the twig_roots and twig_print_outside_roots options.(as pointed by yum info)
\n\n
Let’s first search for the package \n$ yum search perl-XML-Twig \nperl-XML-Twig.noarch : A perl module for processing huge XML documents in tree
\n\n
Note that you must be the root/administrator to install the package. To install this package in Red Hat/Fedora Linux. \n$ yum install perl-XML-Twig.noarch
\n\n
You can check the details of this package perl-XML-Twig \n$ yum info perl-XML-Twig.noarch
\r\n#Add this gem to your Gemfile:\r\ngem 'ruby-akismet', :require => 'akismet'\r\n```\r\n\r\n\r\n#Create an initializer file like config/initializers/akismet.rb with your configuration:\r\n
\n", "_id"=>1112}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["nginx", "statistics", "upstream"], "comments_count"=>0, "category_id"=>9, "title"=>"NGINX upstream statistics", "body"=>"使用过nginx的应该都都晓得upstream,前面一篇文章说到《nginx upstream的5种配置方式》,例如如下是很常见的一段配置\r\n\r\n#create by ice 2011.12.22\r\nupstream unicon_v2_www {\r\n# This is the socket we configured in unicorn.rb\r\nserver unix:/var/www/v2/tmp/sockets/unicorn.sock backup;\r\nserver 192.168.0.1:5000 weight=9 max_fails=2 fail_timeout=30s;\r\nserver 192.168.0.2:5000 weight=3 max_fails=2 fail_timeout=30s;\r\n}\r\nserver {\r\nlisten 80;\r\nserver_name www.iceskysl.com;\r\nerror_log /opt/nginx/logs/error/error_v2_www.log;\r\naccess_log /opt/nginx/logs/access/access_v2_www.log main;\r\n\r\nroot /var/www/v2/public/;\r\nindex index.html index.htm;\r\n\r\nlocation / {\r\nproxy_redirect off;\r\nproxy_set_header X-Real-IP $remote_addr;\r\nproxy_set_header Host $host;\r\nproxy_set_header Content-Length $content_length;\r\nproxy_set_header X-Forwarded-For $remote_addr;\r\nclient_max_body_size 10m;\r\nclient_body_buffer_size 128k;\r\nproxy_connect_timeout 90;\r\nproxy_send_timeout 90;\r\nproxy_read_timeout 90;\r\nproxy_buffer_size 4k;\r\nproxy_buffers 4 32k;\r\nproxy_busy_buffers_size 64k;\r\nproxy_temp_file_write_size 64k;\r\nchunked_transfer_encoding off;\r\nproxy_pass http://unicon_v2_www/;\r\n}\r\n}\r\n\r\n其中upstream的这段配置:\r\nupstream unicon_v2_www {\r\n# This is the socket we configured in unicorn.rb\r\nserver unix:/var/www/v2/tmp/sockets/unicorn.sock backup;\r\nserver 192.168.0.1:5000 weight=9 max_fails=2 fail_timeout=30s;\r\nserver 192.168.0.2:5000 weight=3 max_fails=2 fail_timeout=30s;\r\n}\r\n\r\n我们了解到socket模式的这个是backup,其他两个机器分别weight=3和weight=9,于是我们想监控下upstream每个后端具体处理了多少请求,有没有问题等,这个好像就不好监控了,nginx自带的status模块只能监控总的请求数,无法区分每个upstream的具体情况。\r\n找到一个ustats(http://code.google.com/p/ustats/),其介绍是:NGINX basic upstream statistics module,具体的如下:\r\n
USTATS module provides basic statistics for each backend in nginx upstreams:\r\n\r\nNumber of requests\r\nHttp 499/500/503 errors count\r\nTcp errors\r\nHttp read/write timeouts\r\nFail timeout\r\nMax fails count\r\nLast failed access time\r\nTotal fails count\r\nBlacklisted backend highlighting\r\nDown backends highlighting\r\nThe module allows you to sort values in some columns for each separate upstream. The data can be retrieved as JSON by appending \"?json\" to the end of location on which the module was set to work on (see configuration instructions below).
我们了解到socket模式的这个是backup,其他两个机器分别weight=3和weight=9,于是我们想监控下upstream每个后端具体处理了多少请求,有没有问题等,这个好像就不好监控了,nginx自带的status模块只能监控总的请求数,无法区分每个upstream的具体情况。 \n找到一个ustats(http://code.google.com/p/ustats/),其介绍是:NGINX basic upstream statistics module,具体的如下:<!--more--> \nUSTATS module provides basic statistics for each backend in nginx upstreams:
\n\n
Number of requests \nHttp 499/500/503 errors count \nTcp errors \nHttp read/write timeouts \nFail timeout \nMax fails count \nLast failed access time \nTotal fails count \nBlacklisted backend highlighting \nDown backends highlighting \nThe module allows you to sort values in some columns for each separate upstream. The data can be retrieved as JSON by appending "?json" to the end of location on which the module was set to work on (see configuration instructions below). \n看上去正是我需要的,有时间试试看~(为啥nginx不学haproxy官方自带一个详细statistics的页面呢~haproxy那个statistics很详细很好用~) \n详细使用指南:http://code.google.com/p/ustats/
\r\nThe reason is simple. I installed an extension called SEO Site Tools which installs an icon on the right of the address bar. When you click the button, on the window displayed there is the option “Show no follo” which is an option for displaying links that have the value nofollow for the attribute rel of an HTML element.\r\n\r\nThis attribute instructs some search engines that a hyperlink should not influence the link target’s ranking in the search engine’s index. (Source: wikipedia.org)\r\n
\r\n\r\n修复的方法很简单,去掉“Show no follo”的勾选就好了~\r\n", "created_at"=>2012-01-28 01:48:36 UTC, "updated_at"=>2012-06-24 15:47:04 UTC, "body_html"=>"
经过检查(Library/Application Support/Google/Chrome/Default/User StyleSheets/Custom.css),发现不是本地的css配置,最后找到是一个叫“SEO Site Tools”导致的,具体原因是: \n \nThe reason is simple. I installed an extension called SEO Site Tools which installs an icon on the right of the address bar. When you click the button, on the window displayed there is the option “Show no follo” which is an option for displaying links that have the value nofollow for the attribute rel of an HTML element.
\n\n
This attribute instructs some search engines that a hyperlink should not influence the link target’s ranking in the search engine’s index. (Source: wikipedia.org)
\n\n
修复的方法很简单,去掉“Show no follo”的勾选就好了~
\n", "_id"=>1121}])
+MONGODB iceylog_development['categories'].find({:_id=>10}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>10}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Html/css/js"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["CoffeeScript", "Connect", "Express", "jade", "JavaScript", "Node.js", "npm"], "comments_count"=>0, "category_id"=>10, "title"=>"CoffeeScript解决JavaScript不美,Node.js潜力巨大", "body"=>"如果你对JavaScript感兴趣,但是不喜欢写一大堆一大堆的JavaScript代码,那真的不是你的错,因为很多人都说JavaScript不美,究其原因,可以归纳为:JavaScript的诞生是个悲剧. 它是函数式+动态语言的优秀内核, 却硬被绑上了C/Java的语法。\r\n\r\n如果你真的喜欢JavaScript,那么你可以尝试了解更多~比如CoffeeScript,再比如Node.js,再比如Connect,再比如Express,再再比如jade,再再再比如npm等等,于是我们从安装npm(a package manager for node)开始~\r\n\r\n#装npm\r\nice@mac:~ > curl http://npmjs.org/install.sh | sh\r\n % Total % Received % Xferd Average Speed Time Time Time Current\r\n Dload Upload Total Spent Left Speed\r\n100 7881 100 7881 0 0 3664 0 0:00:02 0:00:02 --:--:-- 8584\r\ntar=/usr/bin/tar\r\nversion:\r\nbsdtar 2.8.3 - libarchive 2.8.3\r\ninstall npm@1.1\r\nfetching: http://registry.npmjs.org/npm/-/npm-1.1.0-3.tgz\r\n0.6.2\r\n1.1.0-3\r\ncleanup prefix=/usr/local\r\n\r\nAll clean!\r\n/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js\r\nnpm@1.1.0-3 /usr/local/lib/node_modules/npm\r\nIt worked\r\n\r\n#看看怎么用\r\nice@mac:~ > npm help\r\n\r\nUsage: npm \r\n\r\nwhere is one of:\r\n adduser, apihelp, author, bin, bugs, c, cache, completion,\r\n config, deprecate, docs, edit, explore, faq, find, get,\r\n help, help-search, home, i, info, init, install, la, link,\r\n list, ll, ln, login, ls, outdated, owner, pack, prefix,\r\n prune, publish, r, rb, rebuild, remove, restart, rm, root,\r\n run-script, s, se, search, set, show, star, start, stop,\r\n submodule, tag, test, un, uninstall, unlink, unpublish,\r\n unstar, up, update, version, view, whoami\r\n\r\nnpm -h quick help on \r\nnpm -l display full usage info\r\nnpm faq commonly asked questions\r\nnpm help search for help on \r\nnpm help npm involved overview\r\n\r\nSpecify configs in the ini-formatted file:\r\n /Users/ice/.npmrc\r\nor on the command line via: npm --key value\r\nConfig info can be viewed via: npm help config\r\n\r\nnpm@1.1.0-3 /usr/local/lib/node_modules/npm\r\n\r\n#用npm装connect\r\nice@mac:~ > npm install connect\r\nnpm http GET https://registry.npmjs.org/connect\r\nnpm http 200 https://registry.npmjs.org/connect\r\nnpm http GET https://registry.npmjs.org/connect/-/connect-1.8.5.tgz\r\nnpm http 200 https://registry.npmjs.org/connect/-/connect-1.8.5.tgz\r\nnpm http GET https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/mime\r\nnpm http GET https://registry.npmjs.org/formidable\r\nnpm http 200 https://registry.npmjs.org/formidable\r\nnpm http 200 https://registry.npmjs.org/mime\r\nnpm http 200 https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/formidable/-/formidable-1.0.8.tgz\r\nnpm http GET https://registry.npmjs.org/mime/-/mime-1.2.4.tgz\r\nnpm http GET https://registry.npmjs.org/qs/-/qs-0.4.1.tgz\r\nnpm http 200 https://registry.npmjs.org/mime/-/mime-1.2.4.tgz\r\nnpm http 200 https://registry.npmjs.org/formidable/-/formidable-1.0.8.tgz\r\nnpm http 200 https://registry.npmjs.org/qs/-/qs-0.4.1.tgz\r\nconnect@1.8.5 ./node_modules/connect \r\n├── mime@1.2.4\r\n├── qs@0.4.1\r\n└── formidable@1.0.8\r\n\r\n#用npm装express\r\nice@mac:~ > npm install express\r\nnpm http GET https://registry.npmjs.org/express\r\nnpm http 200 https://registry.npmjs.org/express\r\nnpm http GET https://registry.npmjs.org/express/-/express-2.5.6.tgz\r\nnpm http 200 https://registry.npmjs.org/express/-/express-2.5.6.tgz\r\nnpm http GET https://registry.npmjs.org/mime\r\nnpm http GET https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/mkdirp/0.0.7\r\nnpm http 304 https://registry.npmjs.org/qs\r\nnpm http 304 https://registry.npmjs.org/mime\r\nnpm http 200 https://registry.npmjs.org/mkdirp/0.0.7\r\nnpm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.0.7.tgz\r\nnpm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.0.7.tgz\r\nexpress@2.5.6 ./node_modules/express \r\n├── mkdirp@0.0.7\r\n├── mime@1.2.4\r\n└── qs@0.4.1\r\n\r\n#用npm装jade\r\nice@mac:~ > npm install jade\r\nnpm http GET https://registry.npmjs.org/jade\r\nnpm http 200 https://registry.npmjs.org/jade\r\nnpm http GET https://registry.npmjs.org/jade/-/jade-0.20.0.tgz\r\nnpm http 200 https://registry.npmjs.org/jade/-/jade-0.20.0.tgz\r\nnpm http GET https://registry.npmjs.org/commander\r\nnpm http GET https://registry.npmjs.org/mkdirp\r\nnpm http 200 https://registry.npmjs.org/mkdirp\r\nnpm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz\r\nnpm http 200 https://registry.npmjs.org/commander\r\nnpm http GET https://registry.npmjs.org/commander/-/commander-0.2.1.tgz\r\nnpm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz\r\nnpm http 200 https://registry.npmjs.org/commander/-/commander-0.2.1.tgz\r\njade@0.20.0 ./node_modules/jade \r\n├── commander@0.2.1\r\n└── mkdirp@0.3.0\r\n\r\n好了,你入门了,更多资料,请自行查看如下链接的资料吧~\r\n\r\n相关资料\r\n\r\nCoffeeScript: CoffeeScript is a little language that compiles into JavaScript\r\nhttp://coffeescript.org/\r\n\r\n为什么CoffeeScript这么美?\r\nhttp://cnodejs.org/blog/?p=1584\r\n\r\nCoffeeScript: The beautiful way to write JavaScript\r\nhttp://amix.dk/blog/post/19612\r\n\r\n10个让朋友对你刮目相看的CoffeeScript单行代码绝技\r\nhttp://heikezhi.com/2011/06/08/10-coffeescript-one-liners-to-impress-your-friends/\r\n\r\nnpm: a package manager for node\r\nhttps://github.com/isaacs/npm\r\n\r\nExpress:http://expressjs.com/\r\nHigh performance, high class web development for Node.js\r\n\r\nConnect: Connect is a middleware layer for Node.js\r\nhttp://www.senchalabs.org/connect/\r\n\r\njade: http://jade-lang.com/\r\nNode Template Engine\r\n\r\ncoffee-box: Blog engine for fashionable developers. Built upon Node.js, Express, MongoDB and CoffeeScript.\r\nhttps://github.com/qiao/coffee-box", "created_at"=>2012-01-28 14:57:06 UTC, "updated_at"=>2012-06-24 15:47:04 UTC, "body_html"=>"
如果你真的喜欢JavaScript,那么你可以尝试了解更多~比如CoffeeScript,再比如Node.js,再比如Connect,再比如Express,再再比如jade,再再再比如npm等等,于是我们从安装npm(a package manager for node)开始~
\n\n
#装npm \nice@mac:~ > curl http://npmjs.org/install.sh | sh \n % Total % Received % Xferd Average Speed Time Time Time Current \n Dload Upload Total Spent Left Speed \n100 7881 100 7881 0 0 3664 0 0:00:02 0:00:02 --:--:-- 8584 \ntar=/usr/bin/tar \nversion: \nbsdtar 2.8.3 - libarchive 2.8.3 \ninstall npm@1.1 \nfetching: http://registry.npmjs.org/npm/-/npm-1.1.0-3.tgz \n0.6.2 \n1.1.0-3 \ncleanup prefix=/usr/local
\n\n
All clean! \n/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js \nnpm@1.1.0-3 /usr/local/lib/node_modules/npm \nIt worked \n<!--more-->
npm -h quick help on \nnpm -l display full usage info \nnpm faq commonly asked questions \nnpm help search for help on \nnpm help npm involved overview
\n\n
Specify configs in the ini-formatted file: \n /Users/ice/.npmrc \nor on the command line via: npm --key value \nConfig info can be viewed via: npm help config
首先安装Graphviz \n% brew install cairo pango graphviz # Homebrew on Mac OS X \n% sudo port install graphviz # Macports on Mac OS X \n% sudo aptitude install graphviz # Debian and Ubuntu
更多信息参考:http://rails-erd.rubyforge.org/ \n<!--more--> \n附:常见错误处理: \nCould not find gem 'choice (~> 0.1.4) ruby', which is required by gem 'rails-erd (>= 0) ruby', in any of the sources.
\n\n
原因是rails-erd依赖choice这个gem,装下 \nice@mac:/www/trunk > sudo gem install choice \nPassword: \nSuccessfully installed choice-0.1.4 \n1 gem installed \nInstalling ri documentation for choice-0.1.4... \nInstalling RDoc documentation for choice-0.1.4...
\r\n其实比较成熟的标记语言还是有不少的,比如wiki format,又比如今天要讲的Markdown,甚至还有国内bbs喜欢用的bbcode都还是不错的标记语言,这里主要讲的是Markdown和Mou。\r\n\r\nhttp://apple4.us/上有篇文章写的不错《为什么作家应该用 Markdown 保存自己的文稿》,其中说了为什么作家需要用Markdown保存自己的文稿,其实对技术人员也一样有用,大家可以仔细看看~同时被介绍的还有Mou(Mou The missing Markdown editor for web developers)。\r\n\r\nMou真是个不错的东西,让不会编程的人也很快接收其用法,当你已经熟练掌握其语法后,其实也可以不用Mou,比如技术人员一般直接在textmate里写或者直接写都还蛮不错的。\r\n\r\n大概汇总下用 Markdown 有如下好处:\r\n\r\n\t
http://apple4.us/上有篇文章写的不错《为什么作家应该用 Markdown 保存自己的文稿》,其中说了为什么作家需要用Markdown保存自己的文稿,其实对技术人员也一样有用,大家可以仔细看看~同时被介绍的还有Mou(Mou The missing Markdown editor for web developers)。
\n", "created_at"=>2012-06-24 15:52:58 UTC, "_id"=>1}])
+MONGODB iceylog_development['categories'].find({:_id=>1}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>1}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['system.namespaces'].find({})
+MONGODB iceylog_development['$cmd'].find({:create=>"sites"}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({"count"=>"sites", "query"=>{"$or"=>[{:url=>"http://www.iceskysl.com"}]}, "fields"=>nil}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"sites"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['sites'].insert([{"name"=>"Iceskysl Blog", "url"=>"http://www.iceskysl.com", "favicon"=>"http://www.google.com/profiles/c/favicons?domain=www.iceskysl.com", "updated_at"=>2012-06-24 15:52:58 UTC, "created_at"=>2012-06-24 15:52:58 UTC, "_id"=>1}])
+
+
+Started GET "/cpanel/posts" for 127.0.0.1 at 2012-06-24 23:53:06 +0800
+Processing by Cpanel::PostsController#index as HTML
+SiteConfig.site_author_username.to_s:true
+SiteConfig.site_author_password.to_s:true
+MONGODB iceylog_development['system.namespaces'].find({})
+MONGODB iceylog_development['$cmd'].find({"count"=>"posts", "query"=>{}, "fields"=>nil}).limit(-1)
+MONGODB iceylog_development['posts'].find({}).limit(30).sort([[:_id, :desc]])
+ Rendered cpanel/posts/index.html.erb within layouts/cpanel (1.2ms)
+Completed 200 OK in 87ms (Views: 38.3ms | Mongo: 1.2ms)
+MONGODB [WARNING] Please note that logging negatively impacts client-side performance. You should set your logging level no lower than :info in production.
+MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1)
+MONGODB iceylog_development['system.namespaces'].find({})
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>nil}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({"count"=>"categories", "query"=>{:name=>"Ruby & Rails"}, "fields"=>nil}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"categories"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['categories'].insert([{"sort"=>0, "posts_count"=>0, "name"=>"Ruby & Rails", "updated_at"=>2012-06-24 15:53:10 UTC, "created_at"=>2012-06-24 15:53:10 UTC, "_id"=>2}])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['system.namespaces'].find({})
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Making rhtml better", "body"=>"It’s even easier like this:in app/views/layouts/application.rhtml:<%= xhtml_doctype :strict %><%= html_tag :lang => Globalize::Locale.active.language.iso_639_1 %><%= @content_for_layout %><%= end_html_tag %>and in app/helpers/application_helper.rb:module ApplicationHelper # Renders an xhtml doctype declaration for the document's prolog. Defaults to xhtml transitional. # <tt>xhtml_doctype :strict</tt> def xhtml_doctype( doctype=:transitional ) doctype = :transitional unless [:transitional, :strict, :frameset].include? doctype case doctype when :transitional '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' when :strict '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' when :frameset '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">' end end # Displays an html tag, complete with xhtml namespace and language. Accepts language as an option, but defaults to English. # <tt>html_tag :lang => 'de'</tt> def html_tag( options={} ) options[:lang] ||= 'en' lang = options.delete( :lang ) "<html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"\#{lang}\\" xml:lang=\\"\#{lang}\\" \#{options.map { |k,v| "\#{k}=\\"\#{v}\\"" }.join( ' ' )}>" end # End html tag. def end_html_tag; "</html>" endend", "created_at"=>2007-05-19 01:37:13 UTC, "updated_at"=>2012-06-24 15:53:10 UTC, "body_html"=>"
It’s even easier like this:in app/views/layouts/application.rhtml:<%= xhtml_doctype :strict %><%= html_tag :lang => Globalize::Locale.active.language.iso_639_1 %><%= @content_for_layout %><%= end_html_tag %>and in app/helpers/application_helper.rb:module ApplicationHelper # Renders an xhtml doctype declaration for the document's prolog. Defaults to xhtml transitional. # <tt>xhtml_doctype :strict</tt> def xhtml_doctype( doctype=:transitional ) doctype = :transitional unless [:transitional, :strict, :frameset].include? doctype case doctype when :transitional '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' when :strict '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' when :frameset '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">' end end # Displays an html tag, complete with xhtml namespace and language. Accepts language as an option, but defaults to English. # <tt>html_tag :lang => 'de'</tt> def html_tag( options={} ) options[:lang] ||= 'en' lang = options.delete( :lang ) "<html xmlns="http://www.w3.org/1999/xhtml\\" lang="\#{lang}" xml:lang="\#{lang}" \#{options.map { |k,v| "\#{k}="\#{v}"" }.join( ' ' )}>" end # End html tag. def end_html_tag; "</html>" endend
\n", "_id"=>2}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Quick add slashes filter for Rails", "body"=>"读后:有的时候,需要在提交的URL后面自动加上"/",这个方法实现这样一个需求,你还可以扩展下去,比如在域名前加"http:\\\\"这样的字符。def add_slash unless %r{/$}.match(@request.path) redirect_to @request.path << '/' endendThis ensures you always have the trailing slash at the end of your URLs. Maybe it could be done better, but for now it works. Django has some stock middleware that does just this, as well as ensuring the first part of the hostname is ‘www’. The point is that your resource can be accessed with one and only one URL, rather than with potentially 4 combinations of / and www. I have no hard evidence, but this is supposedly good for teh Google, and some people find it elegant.I am thinking about maybe whipping up a module of such utilities that you could include in your ApplicationController and never think about again.", "created_at"=>2007-05-19 01:34:51 UTC, "updated_at"=>2012-06-24 15:53:10 UTC, "body_html"=>"
读后:有的时候,需要在提交的URL后面自动加上"/",这个方法实现这样一个需求,你还可以扩展下去,比如在域名前加"http:\\"这样的字符。def add_slash unless %r{/$}.match(@request.path) redirect_to @request.path << '/' endendThis ensures you always have the trailing slash at the end of your URLs. Maybe it could be done better, but for now it works. Django has some stock middleware that does just this, as well as ensuring the first part of the hostname is ‘www’. The point is that your resource can be accessed with one and only one URL, rather than with potentially 4 combinations of / and www. I have no hard evidence, but this is supposedly good for teh Google, and some people find it elegant.I am thinking about maybe whipping up a module of such utilities that you could include in your ApplicationController and never think about again.
\n", "_id"=>3}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Introducing the AJAX Feed API FeedControl", "body"=>"Google放出来的AJAX feed API我老早就关注到了,也试用了一些,感觉还真的不错,现在又添加了一些东西,如下:其API都很简单,详细的可以看这个页面上的介绍:http://code.google.com/apis/ajaxfeeds/documentation/reference.html#FeedControl只有一个构造器:FeedControl四个函数:1.addFeed(url, label) //添加需要显示的FEED的URL2.addFeed(element, opt_options?);//这个其实就是draw方法,指定显示的方式,例如:feedControl.draw( document.getElementById("feedControl"), { drawMode : google.feeds.FeedControl.DRAW_MODE_TABBED });feedControl这个是页面的DOM的ID名称,google.feeds.FeedControl.DRAW_MODE_TABBED 就是指定的显示方式,默认值是:google.feeds.FeedControl.DRAW_MODE_LINEAR.3.setNumEntries(num); //设定显示的条数(貌似只能统一指定,不能为各个FEED单独指定)4.setLinkTarget(linkTarget) //设定链接的打开方式,其值分别如下: * google.feeds.LINK_TARGET_BLANK - links will open in a new window * google.feeds.LINK_TARGET_SELF - links will open in the current window * google.feeds.LINK_TARGET_TOP - links will open in the topmost frame * google.feeds.LINK_TARGET_PARENT - links will open in either the topmost frame, or replace the current frame. * anything-else - the value of target in the resulting anchor element is set to linkTarget附录其网站上的说明:---------------This morning we added a new class to the Google AJAX Feed API designed to allow you to more easily add a collection of feeds to your pages. The FeedControl is pretty simple:var feedControl = new google.feeds.FeedControl();feedControl.addFeed("http://www.digg.com/rss/index.xml", "Digg");feedControl.addFeed("http://feeds.feedburner.com/Techcrunch", "TechCrunch");feedControl.draw(document.getElementById("feedControl"));In addition to the formal documentation, we have put together a few samples to help you quickly come up to speed. * Basic FeedControl - feedcontrol.html * Tabbed FeedControl - tabbed.html * Sidebar Style FeedControl - sidebar.html * AJAX Feed API Playground Blog", "created_at"=>2007-05-19 01:32:26 UTC, "updated_at"=>2012-06-24 15:53:10 UTC, "body_html"=>"
Google放出来的AJAX feed API我老早就关注到了,也试用了一些,感觉还真的不错,现在又添加了一些东西,如下:其API都很简单,详细的可以看这个页面上的介绍:http://code.google.com/apis/ajaxfeeds/documentation/reference.html#FeedControl只有一个构造器:FeedControl四个函数:1.addFeed(url, label) //添加需要显示的FEED的URL2.addFeed(element, opt_options?);//这个其实就是draw方法,指定显示的方式,例如:feedControl.draw( document.getElementById("feedControl"), { drawMode : google.feeds.FeedControl.DRAW_MODE_TABBED });feedControl这个是页面的DOM的ID名称,google.feeds.FeedControl.DRAW_MODE_TABBED 就是指定的显示方式,默认值是:google.feeds.FeedControl.DRAW_MODE_LINEAR.3.setNumEntries(num); //设定显示的条数(貌似只能统一指定,不能为各个FEED单独指定)4.setLinkTarget(linkTarget) //设定链接的打开方式,其值分别如下: * google.feeds.LINK_TARGET_BLANK - links will open in a new window * google.feeds.LINK_TARGET_SELF - links will open in the current window * google.feeds.LINK_TARGET_TOP - links will open in the topmost frame * google.feeds.LINK_TARGET_PARENT - links will open in either the topmost frame, or replace the current frame. * anything-else - the value of target in the resulting anchor element is set to linkTarget附录其网站上的说明:---------------This morning we added a new class to the Google AJAX Feed API designed to allow you to more easily add a collection of feeds to your pages. The FeedControl is pretty simple:var feedControl = new google.feeds.FeedControl();feedControl.addFeed("http://www.digg.com/rss/index.xml", "Digg");feedControl.addFeed("http://feeds.feedburner.com/Techcrunch", "TechCrunch");feedControl.draw(document.getElementById("feedControl"));In addition to the formal documentation, we have put together a few samples to help you quickly come up to speed. * Basic FeedControl - feedcontrol.html * Tabbed FeedControl - tabbed.html * Sidebar Style FeedControl - sidebar.html * AJAX Feed API Playground Blog
\n", "_id"=>4}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({"count"=>"categories", "query"=>{:name=>"Database"}, "fields"=>nil}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"categories"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['categories'].insert([{"sort"=>0, "posts_count"=>0, "name"=>"Database", "updated_at"=>2012-06-24 15:53:10 UTC, "created_at"=>2012-06-24 15:53:10 UTC, "_id"=>3}])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>3, "title"=>"Counting Distinct Records In Rails", "body"=>"If you ever need to count your Rails records based on a distinct column, here is a simple solution:Gift.count_by_sql("select count(distinct url) from gifts")In this example, I am counting the number of distinct gift urls from my gifts table.", "created_at"=>2007-05-19 01:30:32 UTC, "updated_at"=>2012-06-24 15:53:10 UTC, "body_html"=>"
If you ever need to count your Rails records based on a distinct column, here is a simple solution:Gift.count_by_sql("select count(distinct url) from gifts")In this example, I am counting the number of distinct gift urls from my gifts table.
\n", "_id"=>5}])
+MONGODB iceylog_development['categories'].find({:_id=>3}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>3}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Appending to a string(ROR中的+=和<<操作符的比较)", "body"=>"If you come from another language, you might be tempted to use the += operator when appending to a string. 1. my_str = "Marco " 2. my_str += "Polo"It works… but there is a better way to do it : the << method. 1. my_str = "Marco " 2. my_str << "Polo"#UPDATEI have removed my initial claim about operator precedence as it isn’t really accurate. There is a much better reason to use << instead of += when appending to a string... something I didn't even realize (Thanks to Gregory). += will create a new String instance and will assign it to your left object. On the other hand, << will append the new string directly into your already existing left object. One could argue that += is only different than << and not better, but to me << is what you'll want to use 99% of the time (if not 100%) when appending to a String. I have yet to see a real case where one would want to "lose" it's existing String instance just to get a new one containing the exact same value.You can also use the << method with arrays : 1. [1,2,3] << 4 #gives [1,2,3,4]、 Be careful however when using << with Fixnum/Bignum instances. With these objects, the << method will shift the bits of your integer to the left. If you want to do a summation (append style that is), you will have to use +=", "created_at"=>2007-05-19 01:29:16 UTC, "updated_at"=>2012-06-24 15:53:10 UTC, "body_html"=>"
If you come from another language, you might be tempted to use the += operator when appending to a string. 1. my_str = "Marco " 2. my_str += "Polo"It works… but there is a better way to do it : the << method. 1. my_str = "Marco " 2. my_str << "Polo"#UPDATEI have removed my initial claim about operator precedence as it isn’t really accurate. There is a much better reason to use << instead of += when appending to a string... something I didn't even realize (Thanks to Gregory). += will create a new String instance and will assign it to your left object. On the other hand, << will append the new string directly into your already existing left object. One could argue that += is only different than << and not better, but to me << is what you'll want to use 99% of the time (if not 100%) when appending to a String. I have yet to see a real case where one would want to "lose" it's existing String instance just to get a new one containing the exact same value.You can also use the << method with arrays : 1. [1,2,3] << 4 #gives [1,2,3,4]、 Be careful however when using << with Fixnum/Bignum instances. With these objects, the << method will shift the bits of your integer to the left. If you want to do a summation (append style that is), you will have to use +=
\n", "_id"=>6}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["ruby"], "comments_count"=>0, "category_id"=>2, "title"=>"Check for nil and initialize on a single line", "body"=>"点评:关于ROR中的一中“遇nil赋值”的写法,这个很早的时候在书上看到的是||=操作符,也一直这么用,今天发现作者的另外这个写法也挺好的。\n\nSometimes, you want to initialize a variable to some value only if that variable is equal to nil. If you like to write your methods as short, clean and readable as possible, you can do that task in a single line instead of taking the traditionnal 3 lines approach. You have two options :\n\n1) You can use the if modifier 1. x = get_some_object if x.nil?Very easy to read. This is my favorite.\n\n2) Or you can use the ||= operator 1. x ||= get_some_object This one is even shorter. The ||= operator is a little bit less verbose and might confuse a ruby newcomer… but I’m not saying that it should be a reason for not using it. This is more a matter of personal taste than anything else.Both of these methods are better than this :\n\n1. #eeww… we don’t like this one.\n\n2. if(x.nil?)\n\n3. x = get_some_object 4. end", "created_at"=>2007-05-19 01:23:10 UTC, "updated_at"=>2012-06-24 15:53:10 UTC, "body_html"=>"
Sometimes, you want to initialize a variable to some value only if that variable is equal to nil. If you like to write your methods as short, clean and readable as possible, you can do that task in a single line instead of taking the traditionnal 3 lines approach. You have two options :
\n\n
1) You can use the if modifier 1. x = get_some_object if x.nil?Very easy to read. This is my favorite.
\n\n
2) Or you can use the ||= operator 1. x ||= get_some_object This one is even shorter. The ||= operator is a little bit less verbose and might confuse a ruby newcomer… but I’m not saying that it should be a reason for not using it. This is more a matter of personal taste than anything else.Both of these methods are better than this :
\n", "_id"=>10}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({"count"=>"categories", "query"=>{:name=>"01. 视觉观察 | Observe"}, "fields"=>nil}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"categories"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['categories'].insert([{"sort"=>0, "posts_count"=>0, "name"=>"01. 视觉观察 | Observe", "updated_at"=>2012-06-24 15:53:11 UTC, "created_at"=>2012-06-24 15:53:11 UTC, "_id"=>6}])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>6, "title"=>"CodeGear公司准备发布Ruby", "body"=>"CodeGear公司本周宣布他们将在2007年下半年发布针对rails的开发者Ruby集成开发环境(IDE)…… 隶属Borland软件公司的开发工具业务公司CodeGear公布了即将发布的被称为“Ruby IDE”的部分信息,其主要特征包括: * A full set of development and deployment modules including Ruby, Rails, Gems and Database. * 全面支持Ruby和Rails,具有代码完成、重构、类型浏览和导航等开发特性。 * 创新性的管理器集成了命令行的功能和IDE、向导与代码浏览器的易用性,提高了生产率。 * 可视化和导航依赖可以无缝的利用各种资源进行工作,不管它们的关系、位置或格式。 * 完整的开发和部署模块包括Ruby、Rails、 Gems和数据库。 Ruby IDE所包含的技术将有利于推动开源技术发展。CodeGear已经表示他们将为Ruby提供补丁及分发代码以支持Eclipse动态语言工具包的支持。 CodeGear生产战略事务副总裁Michael Swindell 在该公司发布的一次讲话中说到:“Ruby on Rails已经成为一个重要的Web应用程序开发平台,因为它使得利用最少的代码开发丰富、数据驱动Web2.0应用更快更简单。然而,生产力背后的“魔法”对开发人员“现实世界”生产力水平上Web应用的构建,开发和维护带来了新的挑战。” Swindell说到:“我们新的Ruby on Rails 技术通过不再是仅仅编辑和调试Ruby脚本解决了这些挑战。它提供了一个综合的以Rails为中心的开发环境,该集成环境即适用于新手也适用于流线开发专家。同时,基于CodeGear IDE 的创新性,这是我们开发的第一个可同时吸引命令行开发者,IDE开发者和可视化开发者的工具。”来源:IT专家网", "created_at"=>2007-05-19 23:05:07 UTC, "updated_at"=>2012-06-24 15:53:11 UTC, "body_html"=>"
CodeGear公司本周宣布他们将在2007年下半年发布针对rails的开发者Ruby集成开发环境(IDE)…… 隶属Borland软件公司的开发工具业务公司CodeGear公布了即将发布的被称为“Ruby IDE”的部分信息,其主要特征包括: * A full set of development and deployment modules including Ruby, Rails, Gems and Database. * 全面支持Ruby和Rails,具有代码完成、重构、类型浏览和导航等开发特性。 * 创新性的管理器集成了命令行的功能和IDE、向导与代码浏览器的易用性,提高了生产率。 * 可视化和导航依赖可以无缝的利用各种资源进行工作,不管它们的关系、位置或格式。 * 完整的开发和部署模块包括Ruby、Rails、 Gems和数据库。 Ruby IDE所包含的技术将有利于推动开源技术发展。CodeGear已经表示他们将为Ruby提供补丁及分发代码以支持Eclipse动态语言工具包的支持。 CodeGear生产战略事务副总裁Michael Swindell 在该公司发布的一次讲话中说到:“Ruby on Rails已经成为一个重要的Web应用程序开发平台,因为它使得利用最少的代码开发丰富、数据驱动Web2.0应用更快更简单。然而,生产力背后的“魔法”对开发人员“现实世界”生产力水平上Web应用的构建,开发和维护带来了新的挑战。” Swindell说到:“我们新的Ruby on Rails 技术通过不再是仅仅编辑和调试Ruby脚本解决了这些挑战。它提供了一个综合的以Rails为中心的开发环境,该集成环境即适用于新手也适用于流线开发专家。同时,基于CodeGear IDE 的创新性,这是我们开发的第一个可同时吸引命令行开发者,IDE开发者和可视化开发者的工具。”来源:IT专家网
\n", "_id"=>16}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Tips"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>4, "title"=>"去掉CSS中的链接图片的外边框", "body"=>"在ROR的实际开发中,遇到这么一个情况:例如凡是有图片的地方,在图片外面显示了一个边框,很不好看,找了下资料,可以这样修复:1.如果是直接用image_tag来实现的 ,则加上:border => 0,结果如下:<%= link_to(image_tag("/images/btn_home.png", :border => 0), {:controller => "code"}) %>2.如果这个图片使用的是CSS中的DIV格式,则需要添加:border: 0就可以了.归结为:when images are used in links they put a border around them.To disable this globally (as most people do) add "img {border: 0}" to your css.", "created_at"=>2007-05-19 22:21:02 UTC, "updated_at"=>2012-06-24 15:53:11 UTC, "body_html"=>"
在ROR的实际开发中,遇到这么一个情况:例如凡是有图片的地方,在图片外面显示了一个边框,很不好看,找了下资料,可以这样修复:1.如果是直接用image_tag来实现的 ,则加上:border => 0,结果如下:<%= link_to(image_tag("/images/btn_home.png", :border => 0), {:controller => "code"}) %>2.如果这个图片使用的是CSS中的DIV格式,则需要添加:border: 0就可以了.归结为:when images are used in links they put a border around them.To disable this globally (as most people do) add "img {border: 0}" to your css.
\n", "_id"=>18}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"ruby操作时间对象", "body"=>"在开发过程中,难免需要对时间对象进行一系列操作,比如统计新发的文章,统计在线会员等,如下是对时间对象的操作方法:distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)Reports the approximate distance in time between two Time or Date objects or integers as seconds. Set include_seconds to true if you want more detailed approximations when distance < 1 min, 29 secs Distances are reported base on the following table:0 <-> 29 secs # => less than a minute 30 secs <-> 1 min, 29 secs # => 1 minute 1 min, 30 secs <-> 44 mins, 29 secs # => [2..44] minutes 44 mins, 30 secs <-> 89 mins, 29 secs # => about 1 hour 89 mins, 29 secs <-> 23 hrs, 59 mins, 29 secs # => about [2..24] hours 23 hrs, 59 mins, 29 secs <-> 47 hrs, 59 mins, 29 secs # => 1 day 47 hrs, 59 mins, 29 secs <-> 29 days, 23 hrs, 59 mins, 29 secs # => [2..29] days 29 days, 23 hrs, 59 mins, 30 secs <-> 59 days, 23 hrs, 59 mins, 29 secs # => about 1 month 59 days, 23 hrs, 59 mins, 30 secs <-> 1 yr minus 31 secs # => [2..12] months 1 yr minus 30 secs <-> 2 yrs minus 31 secs # => about 1 year 2 yrs minus 30 secs <-> max time or date # => over [2..X] yearsWith include_seconds = true and the difference < 1 minute 29 seconds 0-4 secs # => less than 5 seconds 5-9 secs # => less than 10 seconds 10-19 secs # => less than 20 seconds 20-39 secs # => half a minute 40-59 secs # => less than a minute 60-89 secs # => 1 minuteExamples: from_time = Time.now distance_of_time_in_words(from_time, from_time + 50.minutes) # => about 1 hour distance_of_time_in_words(from_time, from_time + 15.seconds) # => less than a minute distance_of_time_in_words(from_time, from_time + 15.seconds, true) # => less than 20 secondsNote: Rails calculates one year as 365.25 days.[ show source ] # File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 4848: def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)49: from_time = from_time.to_time if from_time.respond_to?(:to_time)50: to_time = to_time.to_time if to_time.respond_to?(:to_time)51: distance_in_minutes = (((to_time - from_time).abs)/60).round52: distance_in_seconds = ((to_time - from_time).abs).round53: 54: case distance_in_minutes55: when 0..156: return (distance_in_minutes == 0) ? 'less than a minute' : '1 minute' unless include_seconds57: case distance_in_seconds58: when 0..4 then 'less than 5 seconds'59: when 5..9 then 'less than 10 seconds'60: when 10..19 then 'less than 20 seconds'61: when 20..39 then 'half a minute'62: when 40..59 then 'less than a minute'63: else '1 minute'64: end65: 66: when 2..44 then "\#{distance_in_minutes} minutes"67: when 45..89 then 'about 1 hour'68: when 90..1439 then "about \#{(distance_in_minutes.to_f / 60.0).round} hours"69: when 1440..2879 then '1 day'70: when 2880..43199 then "\#{(distance_in_minutes / 1440).round} days"71: when 43200..86399 then 'about 1 month'72: when 86400..525959 then "\#{(distance_in_minutes / 43200).round} months"73: when 525960..1051919 then 'about 1 year'74: else "over \#{(distance_in_minutes / 525960).round} years"75: end76: enddistance_of_time_in_words_to_now(from_time, include_seconds = false)Alias for time_ago_in_words", "created_at"=>2007-05-19 22:18:11 UTC, "updated_at"=>2012-06-24 15:53:11 UTC, "body_html"=>"
在开发过程中,难免需要对时间对象进行一系列操作,比如统计新发的文章,统计在线会员等,如下是对时间对象的操作方法:distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)Reports the approximate distance in time between two Time or Date objects or integers as seconds. Set include_seconds to true if you want more detailed approximations when distance < 1 min, 29 secs Distances are reported base on the following table:0 <-> 29 secs # => less than a minute 30 secs <-> 1 min, 29 secs # => 1 minute 1 min, 30 secs <-> 44 mins, 29 secs # => [2..44] minutes 44 mins, 30 secs <-> 89 mins, 29 secs # => about 1 hour 89 mins, 29 secs <-> 23 hrs, 59 mins, 29 secs # => about [2..24] hours 23 hrs, 59 mins, 29 secs <-> 47 hrs, 59 mins, 29 secs # => 1 day 47 hrs, 59 mins, 29 secs <-> 29 days, 23 hrs, 59 mins, 29 secs # => [2..29] days 29 days, 23 hrs, 59 mins, 30 secs <-> 59 days, 23 hrs, 59 mins, 29 secs # => about 1 month 59 days, 23 hrs, 59 mins, 30 secs <-> 1 yr minus 31 secs # => [2..12] months 1 yr minus 30 secs <-> 2 yrs minus 31 secs # => about 1 year 2 yrs minus 30 secs <-> max time or date # => over [2..X] yearsWith include_seconds = true and the difference < 1 minute 29 seconds 0-4 secs # => less than 5 seconds 5-9 secs # => less than 10 seconds 10-19 secs # => less than 20 seconds 20-39 secs # => half a minute 40-59 secs # => less than a minute 60-89 secs # => 1 minuteExamples: from_time = Time.now distance_of_time_in_words(from_time, from_time + 50.minutes) # => about 1 hour distance_of_time_in_words(from_time, from_time + 15.seconds) # => less than a minute distance_of_time_in_words(from_time, from_time + 15.seconds, true) # => less than 20 secondsNote: Rails calculates one year as 365.25 days.[ show source ] # File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 4848: def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)49: from_time = from_time.to_time if from_time.respond_to?(:to_time)50: to_time = to_time.to_time if to_time.respond_to?(:to_time)51: distance_in_minutes = (((to_time - from_time).abs)/60).round52: distance_in_seconds = ((to_time - from_time).abs).round53: 54: case distance_in_minutes55: when 0..156: return (distance_in_minutes == 0) ? 'less than a minute' : '1 minute' unless include_seconds57: case distance_in_seconds58: when 0..4 then 'less than 5 seconds'59: when 5..9 then 'less than 10 seconds'60: when 10..19 then 'less than 20 seconds'61: when 20..39 then 'half a minute'62: when 40..59 then 'less than a minute'63: else '1 minute'64: end65: 66: when 2..44 then "\#{distance_in_minutes} minutes"67: when 45..89 then 'about 1 hour'68: when 90..1439 then "about \#{(distance_in_minutes.to_f / 60.0).round} hours"69: when 1440..2879 then '1 day'70: when 2880..43199 then "\#{(distance_in_minutes / 1440).round} days"71: when 43200..86399 then 'about 1 month'72: when 86400..525959 then "\#{(distance_in_minutes / 43200).round} months"73: when 525960..1051919 then 'about 1 year'74: else "over \#{(distance_in_minutes / 525960).round} years"75: end76: enddistance_of_time_in_words_to_now(from_time, include_seconds = false)Alias for time_ago_in_words
\n", "_id"=>26}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"find out the current url / uri in *.rhtml file", "body"=>"// find out the current url / uri in *.rhtml file// is quite simple with the request object<% page = request.request_uri %>page: <%= page %>// but then different urls mean the same page// (../admin = ../admin/ = ../admin/index = ..admin/index/)// and maybe the id is unwanted too (../admin/show/8)// so below is an alternative with control on which parameter is used<% page = "/" + request.path_parameters['controller'] + "/" + request.path_parameters['action'] %>page: <%= page %>", "created_at"=>2007-05-19 21:58:09 UTC, "updated_at"=>2012-06-24 15:53:12 UTC, "body_html"=>"
// find out the current url / uri in *.rhtml file// is quite simple with the request object<% page = request.request_uri %>page: <%= page %>// but then different urls mean the same page// (../admin = ../admin/ = ../admin/index = ..admin/index/)// and maybe the id is unwanted too (../admin/show/8)// so below is an alternative with control on which parameter is used<% page = "/" + request.path_parameters['controller'] + "/" + request.path_parameters['action'] %>page: <%= page %>
\n", "_id"=>27}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"image_tag with popup for alt attribute", "body"=>"Firefox doesn't display a popup for the alt attribute for images. While this is according to spec, it's slightly annoying to put the same text in both the alt and the title. Put the following in your ApplicationHelper to copy the alt to the title for every image. Please don't tell me how wrong this is. I don't care.module ApplicationHelper def image_tag(location, options) options[:title] ||= options[:alt] super(location, options) endend", "created_at"=>2007-05-19 21:56:35 UTC, "updated_at"=>2012-06-24 15:53:12 UTC, "body_html"=>"
Firefox doesn't display a popup for the alt attribute for images. While this is according to spec, it's slightly annoying to put the same text in both the alt and the title. Put the following in your ApplicationHelper to copy the alt to the title for every image. Please don't tell me how wrong this is. I don't care.module ApplicationHelper def image_tag(location, options) options[:title] ||= options[:alt] super(location, options) endend
\n", "_id"=>32}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Introduction to ActiveMessaging for Rails", "body"=>"ActiveMessaging是个感觉很不错的一个插件,通过它你可以发送、接收MO,总得来说很有诱惑力,还没有看完,下面这篇文章对这个东西做了详细的介绍,感兴趣的可以自己去看看,我就不翻译了,等我自己试用后,可以再些些心得什么的。*introduction*Rails has already planted its flag firmly in the ground of database driven web applications. *ActiveMessaging*is a Rails plugin framework that extends the borders of Rails territory by adding simplified messaging integration. With ActiveMessaging and Rails now you can loosely integrate with systems as disparate as mainframes sending MQ messages or J2EE webapps, offload processing long-running tasks, or create applications with event or message-driven architectures. As others have put it, ActiveMessaging is trying to do for messaging what ActiveRecord does for databases. This article will introduce you to ActiveMessaging and related technologies, and get you started using it in your Rails applications now.http://www.infoq.com/articles/intro-active-messaging-rails", "created_at"=>2007-05-30 21:12:54 UTC, "updated_at"=>2012-06-24 15:53:12 UTC, "body_html"=>"
ActiveMessaging是个感觉很不错的一个插件,通过它你可以发送、接收MO,总得来说很有诱惑力,还没有看完,下面这篇文章对这个东西做了详细的介绍,感兴趣的可以自己去看看,我就不翻译了,等我自己试用后,可以再些些心得什么的。*introduction*Rails has already planted its flag firmly in the ground of database driven web applications. *ActiveMessaging*is a Rails plugin framework that extends the borders of Rails territory by adding simplified messaging integration. With ActiveMessaging and Rails now you can loosely integrate with systems as disparate as mainframes sending MQ messages or J2EE webapps, offload processing long-running tasks, or create applications with event or message-driven architectures. As others have put it, ActiveMessaging is trying to do for messaging what ActiveRecord does for databases. This article will introduce you to ActiveMessaging and related technologies, and get you started using it in your Rails applications now.http://www.infoq.com/articles/intro-active-messaging-rails
\n", "_id"=>33}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"清除HTML标签中的危险字符", "body"=>"很多时候,我们需要处理用户输入,为了适合WEB2的特性,做为开发者我们也会设计很对个途径让用户参与进去,但是“盖茨”大叔说得很对:*凡是用户的输入都是有害的!*一点不假,有时候用户可能是无意的或者一些不怀好意的用户会输入一些我们并不想让他们输入的东西,以防止破坏页面结构或者造成其他的危害(比如SQL注射和XSS攻击),所以我们需要对用户的输入认真的检验和过滤。在页面上显示的时候,我们可以选择+h()+或者+sanitize+或者+strip_tags+等等rails提供的方法进行过滤,但是这些危险的字符还适度会存在数据库,或许有一天就会引爆了呢,所以呢,最好的办法是在存入数据库的时候就做一些过滤或转换,一下一点点代码段只是一个小例子,真实世界中需要过滤和清除的危险字符是很多的,大家注意主机收集和完善,也希望大家一起来实现这个功能,做一个通用的 helper方法。<code> def stripped_html(html) # this is a copynpaste of the routine in article.rb # so the one in article.rb can change w/o breaking this. self.html.gsub(/<[^>]*>/,'').to_url end</code>对于HTML标签的过滤和清除,你有什么好的方法么?欢迎分享!", "created_at"=>2007-05-29 21:24:57 UTC, "updated_at"=>2012-06-24 15:53:12 UTC, "body_html"=>"
很多时候,我们需要处理用户输入,为了适合WEB2的特性,做为开发者我们也会设计很对个途径让用户参与进去,但是“盖茨”大叔说得很对:凡是用户的输入都是有害的!*一点不假,有时候用户可能是无意的或者一些不怀好意的用户会输入一些我们并不想让他们输入的东西,以防止破坏页面结构或者造成其他的危害(比如SQL注射和XSS攻击),所以我们需要对用户的输入认真的检验和过滤。在页面上显示的时候,我们可以选择+h()+或者+sanitize+或者+strip_tags+等等rails提供的方法进行过滤,但是这些危险的字符还适度会存在数据库,或许有一天就会引爆了呢,所以呢,最好的办法是在存入数据库的时候就做一些过滤或转换,一下一点点代码段只是一个小例子,真实世界中需要过滤和清除的危险字符是很多的,大家注意主机收集和完善,也希望大家一起来实现这个功能,做一个通用的 helper方法。<code> def stripped_html(html) # this is a copynpaste of the routine in article.rb # so the one in article.rb can change w/o breaking this. self.html.gsub(/<[^>]>/,'').to_url end</code>对于HTML标签的过滤和清除,你有什么好的方法么?欢迎分享!
\n", "_id"=>35}])
+MONGODB iceylog_development['categories'].find({:_id=>9}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>9}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"日期上的迭代问题", "body"=>"给定一个时间点,希望得到其他时间点的解决方案如下,Ruby 的所有时间对象都可像数字一样用在值域中。Date和DateTime对象按天递增,而Time对象按秒递增:*例子*require 'date'(Date.new(1976, 7, 2)..Date.new(1976, 7, 4)).each { |x| puts x }1976-07-021976-07-031976-07-04span = DateTime.new(1776, 7, 2, 1, 30, 15)..DateTime.new(1776, 7, 4, 7, 0,0)span.each { |x| puts x } 1776-07-02T01:30:15Z 1776-07-03T01:30:15Z 1776-07-04T01:30:15Z(Time.at(100)..Time.at(102)).each { |x| puts x } Wed Dec 31 19:01:40 EST 1969 Wed Dec 31 19:01:41 EST 1969 Wed Dec 31 19:01:42 EST 1969Ruby 的Date类定义了*step*和*upto*两种方便的由数字使用的迭代器:the_first = Date.new(2004, 1, 1)the_fifth = Date.new(2004, 1, 5)the_first.upto(the_fifth) { |x| puts x } 2004-01-01 2004-01-02 2004-01-03 2004-01-04 2004-01-05*讨论*Ruby的日期对象在内部被存储为数字,并且一定范围的这种对象可被视为一定范围的数字。对于Date和DateTime对象而言,内部表示是儒略历日期:每次在一定范围的这种对象上累加一天。对于Time对象而言,内部表示是自Unix 纪元以来的秒数:每次在一定范围的Time对象上累加一秒。*Time*没有定义step和upto方法,但添加它们也很简单:class Timebq. def step(other_time, increment) raise ArgumentError, "step can't be 0" if increment == 0 increasing = self < other_time if (increasing && increment < 0) || (!increasing && increment > 0) yield self return end d = self begin yield d d += increment end while (increasing ? d <= other_time : d >= other_time) enddef upto(other_time) step(other_time, 1) { |x| yield x } endendthe_first = Time.local(2004, 1, 1)the_second = Time.local(2004, 1, 2)the_first.step(the_second, 60 * 60 * 6) { |x| puts x } Thu Jan 01 00:00:00 EST 2004 Thu Jan 01 06:00:00 EST 2004 Thu Jan 01 12:00:00 EST 2004 Thu Jan 01 18:00:00 EST 2004 Fri Jan 02 00:00:00 EST 2004the_first.upto(the_first) { |x| puts x } Thu Jan 01 00:00:00 EST 2004", "created_at"=>2007-05-27 05:09:33 UTC, "updated_at"=>2012-06-24 15:53:12 UTC, "body_html"=>"
给定一个时间点,希望得到其他时间点的解决方案如下,Ruby 的所有时间对象都可像数字一样用在值域中。Date和DateTime对象按天递增,而Time对象按秒递增:*例子*require 'date'(Date.new(1976, 7, 2)..Date.new(1976, 7, 4)).each { |x| puts x }1976-07-021976-07-031976-07-04span = DateTime.new(1776, 7, 2, 1, 30, 15)..DateTime.new(1776, 7, 4, 7, 0,0)span.each { |x| puts x } 1776-07-02T01:30:15Z 1776-07-03T01:30:15Z 1776-07-04T01:30:15Z(Time.at(100)..Time.at(102)).each { |x| puts x } Wed Dec 31 19:01:40 EST 1969 Wed Dec 31 19:01:41 EST 1969 Wed Dec 31 19:01:42 EST 1969Ruby 的Date类定义了*step*和*upto*两种方便的由数字使用的迭代器:the_first = Date.new(2004, 1, 1)the_fifth = Date.new(2004, 1, 5)the_first.upto(the_fifth) { |x| puts x } 2004-01-01 2004-01-02 2004-01-03 2004-01-04 2004-01-05*讨论*Ruby的日期对象在内部被存储为数字,并且一定范围的这种对象可被视为一定范围的数字。对于Date和DateTime对象而言,内部表示是儒略历日期:每次在一定范围的这种对象上累加一天。对于Time对象而言,内部表示是自Unix 纪元以来的秒数:每次在一定范围的Time对象上累加一秒。*Time*没有定义step和upto方法,但添加它们也很简单:class Timebq. def step(other_time, increment) raise ArgumentError, "step can't be 0" if increment == 0 increasing = self < other_time if (increasing && increment < 0) || (!increasing && increment > 0) yield self return end d = self begin yield d d += increment end while (increasing ? d <= other_time : d >= other_time) enddef upto(other_time) step(other_time, 1) { |x| yield x } endendthe_first = Time.local(2004, 1, 1)the_second = Time.local(2004, 1, 2)the_first.step(the_second, 60 * 60 * 6) { |x| puts x } Thu Jan 01 00:00:00 EST 2004 Thu Jan 01 06:00:00 EST 2004 Thu Jan 01 12:00:00 EST 2004 Thu Jan 01 18:00:00 EST 2004 Fri Jan 02 00:00:00 EST 2004the_first.upto(the_first) { |x| puts x } Thu Jan 01 00:00:00 EST 2004
\n", "_id"=>36}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Textile Editor Helper", "body"=>"*Textile*是一种语言标记格式,目前在ROR领域用的相当多,本着简洁好用的原则,这套规则就像PHP领域内的BBCODE一样流行,但是一直一来,都是靠手工去写这些标识符号,很不方便,也曾萌发了写一套可视化的东西来,可惜一直没有时间和精力,今天看到slate blog的blog上有关于这个的东西,感觉就是自己想实现的那个,看了下视频(http://www.youtube.com/watch?v=wQYedmbsJf4)和DEMO(http://slateinfo.blogs.wvu.edu/plugins/textile_editor_helper/demo),果然是的,试用了下,很方便,效果很好,再各种浏览器下都表现不错,推荐给大家。可以先看下它的功能:安装也挺方便的:+script/plugin install http://svn.webtest.wvu.edu/repos/rails/plugins/textile_editor_helper/+使用:bq. # 1. run rake textile_editor_helper:install 2. for the textarea(s) that you want to add the TEH toolbar to replace the text area tag(s) with: <%= textile_editor 'object', 'field' -%> just like writing a text area tag, same options 3. at the end of your form put in the following code: <%= textile_editor_initialize -%> Important! 4. save your view and check it out*注意*:To use Textile, you must install the RedCloth gem first.", "created_at"=>2007-05-24 21:08:58 UTC, "updated_at"=>2012-06-24 15:53:12 UTC, "body_html"=>"
*Textile*是一种语言标记格式,目前在ROR领域用的相当多,本着简洁好用的原则,这套规则就像PHP领域内的BBCODE一样流行,但是一直一来,都是靠手工去写这些标识符号,很不方便,也曾萌发了写一套可视化的东西来,可惜一直没有时间和精力,今天看到slate blog的blog上有关于这个的东西,感觉就是自己想实现的那个,看了下视频(http://www.youtube.com/watch?v=wQYedmbsJf4)和DEMO(http://slateinfo.blogs.wvu.edu/plugins/textile_editor_helper/demo),果然是的,试用了下,很方便,效果很好,再各种浏览器下都表现不错,推荐给大家。可以先看下它的功能:安装也挺方便的:+script/plugin install http://svn.webtest.wvu.edu/repos/rails/plugins/textile_editor_helper/+bq使用:. # 1. run rake textile_editor_helper:install 2. for the textarea(s) that you want to add the TEH toolbar to replace the text area tag(s) with: <%= textile_editor 'object', 'field' -%> just like writing a text area tag, same options 3. at the end of your form put in the following code: <%= textile_editor_initialize -%> Important! 4. save your view and check it out*注意*:To use Textile, you must install the RedCloth gem first.
\n", "_id"=>37}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>7, "title"=>"安装mongrel服务器", "body"=>"需要安装这个的很简单,下面就是我在自己机子上安装的时候的过程演示,比起Apache等的配置,这个东西好多了。D:\\>gem install mongrelSelect which gem to install for your platform (i386-mswin32) 1. mongrel 1.0.1 (mswin32) 2. mongrel 1.0.1 (ruby) 3. mongrel 1.0 (mswin32) 4. mongrel 1.0 (ruby) 5. Skip this gem 6. Cancel installation> 1Install required dependency gem_plugin? [Yn] yInstall required dependency cgi_multipart_eof_fix? [Yn] ySuccessfully installed mongrel-1.0.1-mswin32Successfully installed gem_plugin-0.2.2Successfully installed cgi_multipart_eof_fix-2.1Installing ri documentation for mongrel-1.0.1-mswin32...Installing ri documentation for gem_plugin-0.2.2...Installing ri documentation for cgi_multipart_eof_fix-2.1...Installing RDoc documentation for mongrel-1.0.1-mswin32...Installing RDoc documentation for gem_plugin-0.2.2...Installing RDoc documentation for cgi_multipart_eof_fix-2.1...D:\\>", "created_at"=>2007-05-23 22:27:14 UTC, "updated_at"=>2012-06-24 15:53:12 UTC, "body_html"=>"
需要安装这个的很简单,下面就是我在自己机子上安装的时候的过程演示,比起Apache等的配置,这个东西好多了。D:>gem install mongrelSelect which gem to install for your platform (i386-mswin32) 1. mongrel 1.0.1 (mswin32) 2. mongrel 1.0.1 (ruby) 3. mongrel 1.0 (mswin32) 4. mongrel 1.0 (ruby) 5. Skip this gem 6. Cancel installation> 1Install required dependency gem_plugin? [Yn] yInstall required dependency cgi_multipart_eof_fix? [Yn] ySuccessfully installed mongrel-1.0.1-mswin32Successfully installed gem_plugin-0.2.2Successfully installed cgi_multipart_eof_fix-2.1Installing ri documentation for mongrel-1.0.1-mswin32...Installing ri documentation for gem_plugin-0.2.2...Installing ri documentation for cgi_multipart_eof_fix-2.1...Installing RDoc documentation for mongrel-1.0.1-mswin32...Installing RDoc documentation for gem_plugin-0.2.2...Installing RDoc documentation for cgi_multipart_eof_fix-2.1...D:>
有的时候,虚拟主机提供商并不能按照每个用户的需求安装全部的gem,这个时候,我们就需要自己动手了,如下是我在一家虚拟主机上的安装builder的过程,主要就是先FTP把gem包放上去,然后本地安装的时候使用一个--install-dir来指定安装到的目录。<code>[1ster@1ster.cn@bee-00 gemdir]$ gem install builder-2.1.1.gem --install-dir /var///1ster.cn/gemdirSuccessfully installed builder, version 2.1.1Installing ri documentation for builder-2.1.1...Installing RDoc documentation for builder-2.1.1...</code>
我们使用创建表的时候,是不想想初始化一些数据呢,比如一个默认的分类什么的,可以使用migration按照下面这个来实现: <code> def self.up create_table :words do |t| t.column :eng, :string t.column :pl, :string end Word.new(:eng=>'yes', :pl=>'tak').save Word.new(:eng=>'no', :pl=>'nie').save Word.new(:eng=>'everything', :pl=>'wszystko').save end def self.down drop_table :words end</code>
\n", "_id"=>40}])
+MONGODB iceylog_development['categories'].find({:_id=>3}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>3}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"15步创建一个测试驱动(TDD)的Rails应用~", "body"=>"题外话:这个文章展示了一种测试驱动(TDD)的开发模式,针对Rails的基本步骤,原文很清楚,我就随便翻译下关键的部分,见下:原文地址:http://andrzejonsoftware.blogspot.com/2007/05/15-tdd-steps-to-create-rails.html15 TDD steps to create a Rails applicationIntroductionSeveral times recently, I have been asked how to develop a Rails application using the Test Driven Development approach. I'm not an expert here, but I've put together some notes on how to start working on a Rails application whilst being test-driven all the time.As an example I will use a word-learning web application. The simplest use case is to display a random word object (with its polish translation) from the database.Every time we refresh we want to see a different word.1. Create a new Rails applicationsrails my_appcd my_appRun tests with 'rake test'. It fails due to missing database configuration.2. Set up the databases - config/database.ymlThe code below assumes sqlite3 databases. development: adapter: sqlite3 database: db/my_app_development.sqlite test: adapter: sqlite3 database: db/my_app_test.sqlite'rake test' now runs fine.3. Create a Word class with a corresponding unit testscript/generate model Word4. Write a unit test for the Word class. Edit the test/unit/word_test.rb. def test_word_is_english_and_polish word = Word.new :eng=>'never', :pl=>'nigdy' assert_equal 'never', word.eng assert_equal 'nigdy', word.pl end'rake test' now fails due to missing words table.5. Edit db/migrate/001_create_words.rbWe are using a migration here in order to create a table. It's a recommended way of dealing with database changes. def self.up create_table :words do |t| t.column :eng, :string t.column :pl, :string end Word.new(:eng=>'yes', :pl=>'tak').save Word.new(:eng=>'no', :pl=>'nie').save Word.new(:eng=>'everything', :pl=>'wszystko').save end def self.down drop_table :words endThe sample words that we are adding use Word.new .. lines, will be added to the development database. It's important to distinguish the 'test' and 'development' database. The first one is only used during tests. The latter is used by default when you start the application.Apply the migration with 'rake db:migrate'.'rake test' now succeeds with the following:'1 tests, 2 assertions, 0 failures, 0 errors'6. Fixtures and test for word.random. Edit word_test again.It's not easy to test a method which behaves randomly. Let's assume that it's enough to test that if we have only two words in our database then one of them should be called at least once per 10 calls.fixtures :wordsdef test_random results = [] 10.times {results << Word.random.eng} assert results.include?("yes")endNote the 'fixtures :words' line. Edit the 'words.yml' file.yes: id: 1 pl: 'tak' eng: 'yes'no: id: 2 pl: 'nie' eng: 'no'This will be loaded to the test database before every run of tests.7. Implement the Word.random method def self.random all = Word.find :all all[rand(all.size)] endWarning: The code above could be slow for many words in a database (we retrieve all words only for selecting a random element). It's good enough for our needs.8. Generate the Words controller with a 'learn' actionscript/generate controller Words learn9. Write a test for the learn methodJust as there is a one-to-one ratio between unit tests and models, so there is between functional tests and controllers. The Controller's responsibility is to retrieve objects from the Model layer and pass them to the View. Let's test the View part first. We use the 'assigns' collection which contains all the objects passed to the View.def test_learn_passes_a_random_word get 'learn' assert_kind_of Word, assigns('word')end10. Make the Test Passdef learn @word = Word.newend11. Write more tests in the words_controller_testHow can we test that controller uses the Word.random method? We don't want to duplicate the tests for the Word.random method.Mocks to the rescue! We will only test that the controller calls the Word.random method. The returned value will be faked with a prepared word.Let's install the mocha framework:gem install mochaNow we can use 'expects' and 'returns' methods.'expects' is used for setting an expectation on an object or a class. In this case we expect that the 'random' method will be called. We also set a return value by using 'returns' method. Setting a return value means faking (stubbing) the real method. The real Word.random won't be called. If an expectation isn't met the test fails.require 'mocha'def test_learn_passes_a_random_word random_word = Word.new Word.expects(:random).returns(random_word) get 'learn' assert_equal random_word, assigns('word')end'rake test' now fails. The Word.method wasn't called.12. Rewrite the implementationdef learn @word = Word.randomend'rake test' now passes.13. Test that a word is displayed:Extend the existing test with assert_tag calls.def test_learn_passes_a_random_word random_word = Word.new(:pl=>'czesc', :eng=>'hello') Word.expects(:random).returns(random_word) get 'learn' assert_equal random_word, assigns('word') assert_tag :tag=>'div', :child => /czesc/ assert_tag :tag=>'div', :child => /hello/end14. Implement the view - learn.rhtml <div> <%= word.eng %> <%= word.pl %> </div>15. Manual testingscript/serverGo to 'http://localhost:3000/words/learn'.Refresh several times.If you want to read more about testing in Rails go to the Guide To Testing The Rails.", "created_at"=>2007-05-22 21:30:02 UTC, "updated_at"=>2012-06-24 15:53:12 UTC, "body_html"=>"
题外话:这个文章展示了一种测试驱动(TDD)的开发模式,针对Rails的基本步骤,原文很清楚,我就随便翻译下关键的部分,见下:原文地址:http://andrzejonsoftware.blogspot.com/2007/05/15-tdd-steps-to-create-rails.html15 TDD steps to create a Rails applicationIntroductionSeveral times recently, I have been asked how to develop a Rails application using the Test Driven Development approach. I'm not an expert here, but I've put together some notes on how to start working on a Rails application whilst being test-driven all the time.As an example I will use a word-learning web application. The simplest use case is to display a random word object (with its polish translation) from the database.Every time we refresh we want to see a different word.1. Create a new Rails applicationsrails my_appcd my_appRun tests with 'rake test'. It fails due to missing database configuration.2. Set up the databases - config/database.ymlThe code below assumes sqlite3 databases. development: adapter: sqlite3 database: db/my_app_development.sqlite test: adapter: sqlite3 database: db/my_app_test.sqlite'rake test' now runs fine.3. Create a Word class with a corresponding unit testscript/generate model Word4. Write a unit test for the Word class. Edit the test/unit/word_test.rb. def test_word_is_english_and_polish word = Word.new :eng=>'never', :pl=>'nigdy' assert_equal 'never', word.eng assert_equal 'nigdy', word.pl end'rake test' now fails due to missing words table.5. Edit db/migrate/001_create_words.rbWe are using a migration here in order to create a table. It's a recommended way of dealing with database changes. def self.up create_table :words do |t| t.column :eng, :string t.column :pl, :string end Word.new(:eng=>'yes', :pl=>'tak').save Word.new(:eng=>'no', :pl=>'nie').save Word.new(:eng=>'everything', :pl=>'wszystko').save end def self.down drop_table :words endThe sample words that we are adding use Word.new .. lines, will be added to the development database. It's important to distinguish the 'test' and 'development' database. The first one is only used during tests. The latter is used by default when you start the application.Apply the migration with 'rake db:migrate'.'rake test' now succeeds with the following:'1 tests, 2 assertions, 0 failures, 0 errors'6. Fixtures and test for word.random. Edit word_test again.It's not easy to test a method which behaves randomly. Let's assume that it's enough to test that if we have only two words in our database then one of them should be called at least once per 10 calls.fixtures :wordsdef test_random results = [] 10.times {results << Word.random.eng} assert results.include?("yes")endNote the 'fixtures :words' line. Edit the 'words.yml' file.yes: id: 1 pl: 'tak' eng: 'yes'no: id: 2 pl: 'nie' eng: 'no'This will be loaded to the test database before every run of tests.7. Implement the Word.random method def self.random all = Word.find :all all[rand(all.size)] endWarning: The code above could be slow for many words in a database (we retrieve all words only for selecting a random element). It's good enough for our needs.8. Generate the Words controller with a 'learn' actionscript/generate controller Words learn9. Write a test for the learn methodJust as there is a one-to-one ratio between unit tests and models, so there is between functional tests and controllers. The Controller's responsibility is to retrieve objects from the Model layer and pass them to the View. Let's test the View part first. We use the 'assigns' collection which contains all the objects passed to the View.def test_learn_passes_a_random_word get 'learn' assert_kind_of Word, assigns('word')end10. Make the Test Passdef learn @word = Word.newend11. Write more tests in the words_controller_testHow can we test that controller uses the Word.random method? We don't want to duplicate the tests for the Word.random method.Mocks to the rescue! We will only test that the controller calls the Word.random method. The returned value will be faked with a prepared word.Let's install the mocha framework:gem install mochaNow we can use 'expects' and 'returns' methods.'expects' is used for setting an expectation on an object or a class. In this case we expect that the 'random' method will be called. We also set a return value by using 'returns' method. Setting a return value means faking (stubbing) the real method. The real Word.random won't be called. If an expectation isn't met the test fails.require 'mocha'def test_learn_passes_a_random_word random_word = Word.new Word.expects(:random).returns(random_word) get 'learn' assert_equal random_word, assigns('word')end'rake test' now fails. The Word.method wasn't called.12. Rewrite the implementationdef learn @word = Word.randomend'rake test' now passes.13. Test that a word is displayed:Extend the existing test with assert_tag calls.def test_learn_passes_a_random_word random_word = Word.new(:pl=>'czesc', :eng=>'hello') Word.expects(:random).returns(random_word) get 'learn' assert_equal random_word, assigns('word') assert_tag :tag=>'div', :child => /czesc/ assert_tag :tag=>'div', :child => /hello/end14. Implement the view - learn.rhtml <div> <%= word.eng %> <%= word.pl %> </div>15. Manual testingscript/serverGo to 'http://localhost:3000/words/learn'.Refresh several times.If you want to read more about testing in Rails go to the Guide To Testing The Rails.
\n", "_id"=>44}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Get XML or YAML output of your data quickly", "body"=>"It's not necessary to create a Builder .rxml template to export data as XML. ActiveRecord has a to_xml method that will output the object or result set in XML format. It works with simple objects, to complete tables with includes. Examples:User.find(:all).to_xmlPost.find(:all, :include => [:comments]).to_xmlYAML is also supported, by using to_yaml instead.", "created_at"=>2007-05-21 07:27:24 UTC, "updated_at"=>2012-06-24 15:53:12 UTC, "body_html"=>"
It's not necessary to create a Builder .rxml template to export data as XML. ActiveRecord has a to_xml method that will output the object or result set in XML format. It works with simple objects, to complete tables with includes. Examples:User.find(:all).to_xmlPost.find(:all, :include => [:comments]).to_xmlYAML is also supported, by using to_yaml instead.
什么是Trackback呢?简单说来,Trackback是网站与网站之间互相通告的一种方法。它能让甲对乙说:“这篇文章可能是你感兴趣的”,要实现这一动作,甲向乙发送一个 Trackback Ping(引用通告)即可。在这种情况下,一个ping就是一条从一个web服务器发送到另一个服务器的短消息(a small message)。Trackback Ping是由Moveable Type发明的规范,他们说Trackback是:<blockquote>"a framework for peer-to-peer communication and notifications between web sites"。</blockquote>这里是他们的Trackback技术规范文档:http://www.movabletype.org/docs/mttrackback.html举个例子来说明一下。比如B在A的Blog中看了一篇我感兴趣的文章,对这篇文章B自己有一些看法,如果按照传统BBS的做法,B需要在A这篇文章下发表自己的评论,但这样做的话B的文字只能存在于A的网站上,B无法再维护自己的这篇评论。另一个情况是B在自己的Blog中也在写一篇相类似的文章,B希望A也能来看一看B的这篇,传统BBS的习惯还是得到A的文章下发一篇回复,把B的URL贴过去。但有了Trackback Ping,我们的Blog不再需要这样做。Blog 跟BBS有点重要的不同,Blog是一种个人创作,用Blog来发表自己的东西,保存自己的东西,即使是对他人Blog文章的评论也要在自己的Blog中永久保留下来。通过Trackbak,我就可以在自己的Blog中发表文章,同时把自己这篇文章的URL地址Ping到A的那篇文章上去。这样,所有阅读A文章的人也能通过Trackback顺藤摸瓜地来我的Blog看我的文章。所以,当我们的Blog有了Trackback Ping功能,那么谁都可以通过Trackback Ping来发表意见和评论了。这样,多家Blog网站就通过相关话题而联接起来。各种评论在Internet上相互连接而织成一张大网。因此,可以说, Trackback创造出了Blog与BBS、Diary完全不同的文化,Blog的世界通过Trackback而变成真正的无限互连。作为Blogger,让我们习惯于这样讨论问题和做评论吧:把内容写在自己的Blog里面,Trackback Ping到别人的Blog。这个概念是论坛模式里从来没有的,称为Remote Commenting。如何在Blog中实现Trackback?在有Trackback功能的Blog系统中,每篇Blog文章都有两个URL,一个是要访问这篇文章所使用的URL,另一个就是Trackback Ping URL(引用通告地址),它是用来接受来自其他Blog网站Trackback Ping的程序。当我发表文章的时候,想要通知鱼头的话,只需要把鱼头那篇文章的Trackback Ping URL贴到我这边文章中来,我提交文章时,系统就会按照这个URL发送一个Ping给A的那篇文章。而鱼头则将在自己的文章下看到类似这样的一个引用通告:标题: 1ster的文章来自: 1ster的Blog摘要: 1ster的文章内容摘要...地址: http://1ster的文章地址这个Trackback Ping是通过标准的HTTP协议从我的Blog发送到鱼头的Blog的,我的Blog发送一个POST格式的HTTP请求到A那篇文章的 Trackback Ping URL。这个请求的content type是application/x-www-form-URLencoded,它大概是这个样子的:POST http://A文章的TrackbackPingURLContent-Type: application/x-www-form-URLencodedtitle=1ster的文章&url=http://1ster的文章地址&excerpt=1ster的文章摘要&blog_name=1ster的Blog早期版本的Trackback规范中,Ping是GET方式的HTTP请求,现在不再支持GET方式,只能用POST方式。参数包括: * title - 文章的标题 * excerpt - 文章的摘要。在Movable Type系统中,如果摘录信息超过255个字符将会被截断为252个字符,并在后面增加...三个字符 * url - 文章的永久连接。象其它永久连接一样,这个连接应可能准确地在页面中定位文章的入口,因有疑问时这个链接会用到 * blog_name - 发表文章的blog的名称在上述的参数中只有url是必须的。如果title没有提供,url的值将被用作标题。当我的Blog发出这个Trackback Ping后,将接收一个简单的XML格式应答,如果Ping成功,那么应答的格式如下:<blockquote><?xml version="1.0" encoding="iso-8859-1"?><response><error>0</error></response></blockquote>而失败应答的格式为:<blockquote><?xml version="1.0" encoding="iso-8859-1"?><response><error>1</error><message>The error message</message></response></blockquote>
\n", "_id"=>47}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"witter发布Gem包提供witter主要功能", "body"=>"witter越来越火了,这个提供IM服务的应用,越来越受到大家的关注,越来越多的人加入其中,昨天台湾的一个朋友还说对witter的这个IM功能很感兴趣,想了解是怎么实现的,呵呵~witter通过网络或者SMS(短消息)使得你和自己的朋友取得及时沟通。你有没有考虑过给自己的WebApp加上这样的功能呢,现在借助witter发布的Gem包,可以很方便的实现这个功能了,更多说明请到http://www.rubyinside.com/twitter-gem-twitterize-your-ruby-application-498.html查看,我这里稍微说下用法,如下:# to post an update to twitter$ twitter post "posting from the twitter gem"# to see you and your friends timeline$ twitter timeline命令行接口很简单,支持YAML配置,也支持Ruby的API:twit.update('me got dizzy this time')# Show your friends' statustwit.timeline(:friends).each do |s| puts s.text, s.user.nameendUse RubyGems as usual to install it:gem install twitter --include-dependenciesps:One note, the gem uses hpricot to parse the xml and there is an annoying bug that reared it's head in the 0.5+ versions (it doesn't like xml elements named text). That said, be sure to sudo gem install hpricot --source http://code.whytheluckystiff.net -v 0.4.86 and uninstall any hpricot versions 0.5+.", "created_at"=>2007-05-20 21:17:49 UTC, "updated_at"=>2012-06-24 15:53:12 UTC, "body_html"=>"
witter越来越火了,这个提供IM服务的应用,越来越受到大家的关注,越来越多的人加入其中,昨天台湾的一个朋友还说对witter的这个IM功能很感兴趣,想了解是怎么实现的,呵呵~witter通过网络或者SMS(短消息)使得你和自己的朋友取得及时沟通。你有没有考虑过给自己的WebApp加上这样的功能呢,现在借助witter发布的Gem包,可以很方便的实现这个功能了,更多说明请到http://www.rubyinside.com/twitter-gem-twitterize-your-ruby-application-498.html#查看,我这里稍微说下用法,如下: to post an update to twitter$ twitter post "posting from the twitter gem"# to see you and your friends timeline$ twitter timeline命令行接口很简单,支持YAML配置,也支持Ruby的API:twit.update('me got dizzy this time')# Show your friends' statustwit.timeline(:friends).each do |s| puts s.text, s.user.nameendUse RubyGems as usual to install it:gem install twitter --include-dependenciesps:One note, the gem uses hpricot to parse the xml and there is an annoying bug that reared it's head in the 0.5+ versions (it doesn't like xml elements named text). That said, be sure to sudo gem install hpricot --source http://code.whytheluckystiff.net -v 0.4.86 and uninstall any hpricot versions 0.5+.
\n", "_id"=>66}])
+MONGODB iceylog_development['categories'].find({:_id=>3}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>3}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"在windows上安装RMagick", "body"=>"看到网上很多人说再WIN下安装RMagick的方法都是这样的,gem install ImageMagick-6.3.0-7-Q8-windows-dll.exe,这样我感觉谁有问题的,至少我这样安装的时候是有错误的,如:D:\\gem\\RMagick-1.14.1_IM-6.3.0-7-Q8>gem install ImageMagick-6.3.0-7-Q8-windows-dll.exeERROR: Error installing gem ImageMagick-6.3.0-7-Q8-windows-dll.exe[.gem]: string contains null byte所以正确的应该是用gem包来安装,如下:D:\\gem\\RMagick-1.14.1_IM-6.3.0-7-Q8>gem install rmagick-1.14.1-win32.gemSuccessfully installed rmagick, version 1.14.1看看是不是安装上了:D:\\gem\\RMagick-1.14.1_IM-6.3.0-7-Q8>gem listrmagick (1.14.1) RMagick is an interface between the Ruby programming language and the ImageMagick and GraphicsMagick image processing libraries.", "created_at"=>2007-06-04 22:06:54 UTC, "updated_at"=>2012-06-24 15:53:12 UTC, "body_html"=>"
看到网上很多人说再WIN下安装RMagick的方法都是这样的,gem install ImageMagick-6.3.0-7-Q8-windows-dll.exe,这样我感觉谁有问题的,至少我这样安装的时候是有错误的,如:D:\\gem\\RMagick-1.14.1_IM-6.3.0-7-Q8>gem install ImageMagick-6.3.0-7-Q8-windows-dll.exeERROR: Error installing gem ImageMagick-6.3.0-7-Q8-windows-dll.exe[.gem]: string contains null byte所以正确的应该是用gem包来安装,如下:D:\\gem\\RMagick-1.14.1_IM-6.3.0-7-Q8>gem install rmagick-1.14.1-win32.gemSuccessfully installed rmagick, version 1.14.1看看是不是安装上了:D:\\gem\\RMagick-1.14.1_IM-6.3.0-7-Q8>gem listrmagick (1.14.1) RMagick is an interface between the Ruby programming language and the ImageMagick and GraphicsMagick image processing libraries.
\n", "_id"=>67}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>6, "title"=>"mini_magick 1.2.2 Released", "body"=>"*mini_magick* version 1.2.2 has been released!RMagick是大家用的最多的图片处理类库,但是它台复杂了,消耗太多的内存,比如下面这段最简单的代码都会吃掉100M的内存:<code>Magick::read("image.jpg") do |f|f.write("manipulated.jpg")end</code>*mini_magick*是把ImageMagick进行的一次封装,使得可以很方便的使用MiniMagick的commandline,可以在http://www.imagemagick.org/script/mogrify.php 查看可耕多的ImageMagick has 信息。*mini_magick*1.2.2包含如下更新:# 1.) all image commands return the image object (The output of the last command is saved in @output)# 2.) identify doesn't trip over strangley named files# 3.) TempFile uses file extention now (Thanks http://marsorange.com/archives/of-mogrify-ruby-tempfile-dynamic-class-definitions)# 4.) identify commands escape output path correctly", "created_at"=>2007-06-03 00:01:12 UTC, "updated_at"=>2012-06-24 15:53:12 UTC, "body_html"=>"
mini_magick version 1.2.2 has been released!RMagick是大家用的最多的图片处理类库,但是它台复杂了,消耗太多的内存,比如下面这段最简单的代码都会吃掉100M的内存:<code>Magick::read("image.jpg") do |f|f.write("manipulated.jpg")end</code>*mini_magick*是把ImageMagick进行的一次封装,使得可以很方便的使用MiniMagick的commandline,可以在http://www.imagemagick.org/script/mogrify.php 查看可耕多的ImageMagick has 信息。*mini_magick*1.2.2包含如下更新:# 1.) all image commands return the image object (The output of the last command is saved in @output)# 2.) identify doesn't trip over strangley named files# 3.) TempFile uses file extention now (Thanks http://marsorange.com/archives/of-mogrify-ruby-tempfile-dynamic-class-definitions#) 4.) identify commands escape output path correctly
\n", "_id"=>68}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"days_in_month函数介绍", "body"=>"days_in_month这个函数返回给定的年月的月的天数,对于写阴历什么的很有帮助,下面是英文的介绍。Descriptiondays_in_month(month, year=nil)Return the number of days in the given month. If a year is given, February will return the correct number of days for leap years. Otherwise, this method will always report February as having 28 days.<code> 1. >> Time.days_in_month(4) => 30 2. >> Time.days_in_month(4,2006) => 30 3. >> Time.days_in_month(2,2006) => 28 4. >> Time.days_in_month(2) => 28 5. >> Time.days_in_month(2,2008) => 29</code>", "created_at"=>2007-06-02 00:29:03 UTC, "updated_at"=>2012-06-24 15:53:12 UTC, "body_html"=>"
days_in_month这个函数返回给定的年月的月的天数,对于写阴历什么的很有帮助,下面是英文的介绍。Descriptiondays_in_month(month, year=nil)Return the number of days in the given month. If a year is given, February will return the correct number of days for leap years. Otherwise, this method will always report February as having 28 days.<code> 1. >> Time.days_in_month(4) => 30 2. >> Time.days_in_month(4,2006) => 30 3. >> Time.days_in_month(2,2006) => 28 4. >> Time.days_in_month(2) => 28 5. >> Time.days_in_month(2,2008) => 29</code>
由于一个系统需要对外提供数据,自然使用widget来实现,JS中自然是对json支持最好,也是就可以吧数据组装成json格式的,再用JS解析显示,于是就有了这个需求:在rails中生成JSON,尽管rails1.1版本就增加了对json的支持,但要想更加灵活,自然使用插件来实现了,而Jsonifier 正是我们需要的。 \n看看Jsonifier的自我介绍: \nJsonifier is a Rails plugin that adds options to the ActiveRecord#to_json method similar to ActiveRecord#to_xml. It's time to treat the JSON encoding of AR objects with more respect ;)The :only, :except, :methods, and :include options are supported. Check out the examples below. \n \n*安装:* \n很简单,script/plugin install svn://svn.codefront.net/jsonifier/trunk \n \n*使用:*
\n", "_id"=>75}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"在rails中实现跟踪记录每个用户的最近十条记录", "body"=>"有的时候,你可能想显示给每个用户他最近浏览的页面,这个时候的一个很自然的想法就是使用数据库来存放,但是这样如果你的用户足够的多,而且页面的读取数据库又很频繁的话,就会对性能造成很大的影响,换个思路,我们可以在session里面存取,示范代码如下:<code>class ApplicationController < ActionController::Base\tbefore_filter :add_to_history\tbefore_filter :page_title\t###def add_to_history session[:history] ||= []## if File.exists?("\#{RAILS_ROOT}/app/views/\#{self.controller_name}/\#{self.action_name}.rhtml") && session[:history].empty? || session[:history].first['uri'] != @request.request_uri session[:history].unshift({ 'uri' => @request.request_uri, 'name' => page_title }) session[:history].pop while session[:history].length > 11 endend######## This bit came from Peter Cooper's snippets source and was moved into the application controller:###\tdef page_title\t\tcase self.controller_name\t\t\twhen 'tag' \t\t\t\ttitle = "Tags » " + @params[:tags].join(" > ")\t\t\twhen 'user'\t\t\t\ttitle = "Users » \#{@params[:user]}"\t \t\t\twhen 'features'\t\t\t\t\tcase self.action_name\t\t\t\t\t\twhen 'show' then title = "Feature » \#{Feature.find(@params[:id]).title}"\t\t\t\t\t\telse title = APP_CONFIG["default_title"]\t\t\t\t\tend\t\t\telse \t\t\t\ttitle = APP_CONFIG["default_title"] + self.controller_name + ":" + self.action_name\t\tend\tend\thelper_method :page_title###...end</code>然后在页面上就可以这样显示了:<code><h4>User History</h4><% for cur in session[:history][0..9] -%> <p><a href="<%= cur["url"] %>"><%= cur["name"] %></a></p><% end -%></code>", "created_at"=>2007-07-03 16:47:31 UTC, "updated_at"=>2012-06-24 15:53:12 UTC, "body_html"=>"
有的时候,你可能想显示给每个用户他最近浏览的页面,这个时候的一个很自然的想法就是使用数据库来存放,但是这样如果你的用户足够的多,而且页面的读取数据库又很频繁的话,就会对性能造成很大的影响,换个思路,我们可以在session里面存取,示范代码如下:<code>class ApplicationController < ActionController::Base before_filter :add_to_history before_filter :page_title ###def add_to_history session[:history] ||= []## if File.exists?("\#{RAILS_ROOT}/app/views/\#{self.controller_name}/\#{self.action_name}.rhtml") && session[:history].empty? || session[:history].first['uri'] != @request.request_uri session[:history].unshift({ 'uri' => @request.request_uri, 'name' => page_title }) session[:history].pop while session[:history].length > 11 endend######## This bit came from Peter Cooper's snippets source and was moved into the application controller:### def page_title case self.controller_name when 'tag' title = "Tags » " + @params[:tags].join(" > ") when 'user' title = "Users » \#{@params[:user]}" when 'features' case self.action_name when 'show' then title = "Feature » \#{Feature.find(@params[:id]).title}" else title = APP_CONFIG["default_title"] end else title = APP_CONFIG["default_title"] + self.controller_name + ":" + self.action_name end end helper_method :page_title###...end</code>然后在页面上就可以这样显示了:<code><h4>User History</h4><% for cur in session[:history][0..9] -%> <p><a href="<%= cur["url"] %>"><%= cur["name"] %></a></p><% end -%></code>
returnfalse, "You made the most idiot error in history. Way to go…"
\n
elsereturntrue, "You made no error, you are still an idiot"
\n
end
\n
end
\n
\n
success, msg = a_method_to_insult_innocent_people
\n
do_something_with_success(success)
\n
destroy_hateful_words!(msg) \n
\n\n
\n
但是这段代码还是只能返回一个结果,如何实现返回多个值呢,很简单,使用数组来实现,只要把上面这段代码中的- return false, "you made a stupid error"- 修改为 *return [false, "you made a stupid error"]*就可以了。记录记录以备不时之需。
大家知道,在一般的编程实现中,一个method只能返回一个结果,如果想实现返回多个结果,java中可以使用VO来实现,但是ruby借助其灵活的语法,我们可以一次返回多个结果,我记得前些时候还不晓得这么做,问了几个人貌似也没有提到,今天五一看到了这个实现,分享给大家:首先,按照这个需求,你可能会写出类似下面的这段代码来检验,如下: \n \nRuby代码 \n \n def a_method_to_insult_innocent_people \n error = compute_error \n if error == :stupid \n return false, "You made a stupid error" \n elsif error == :ridiculous \n return false, "You made a ridiculous error" \n elsif error == :worst_of_all_time \n return false, "You made the most idiot error in history. Way to go…" \n else return true, "You made no error, you are still an idiot" \n end \n end \n \n success, msg = a_method_to_insult_innocent_people \n do_something_with_success(success) \n destroy_hateful_words!(msg) \n \n \n \n但是这段代码还是只能返回一个结果,如何实现返回多个值呢,很简单,使用数组来实现,只要把上面这段代码中的- return false, "you made a stupid error"- 修改为 *return [false, "you made a stupid error"]*就可以了。记录记录以备不时之需。
\n", "_id"=>88}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"关于rails启动报500错误的可能问题点", "body"=>"当你启动rails的时候可能会遇到500错误“500- Premature end of script.”或者类似的错误,使得程序跑不起来~问题可能出在两个地方: 1、 The file permissions are not set to allow the dispatch.cgi to execute properly. Chmod the dispatch.cgi to +0755+. 2、The path to Ruby is is incorrect in the dispatch.cgi file. The first line of the file is called the shebang-- it sets the location of the intrepretor (in this case ruby). Change the shebang to the correct path to Ruby (/usr/bin/ruby). The first line of the dispatch.cgi file should look like this: #!/usr/bin/ruby", "created_at"=>2007-06-19 19:24:55 UTC, "updated_at"=>2012-06-24 15:53:12 UTC, "body_html"=>"
当你启动rails的时候可能会遇到500错误“500- Premature end of script.”或者类似的错误,使得程序跑不起来~问题可能出在两个地方: 1、 The file permissions are not set to allow the dispatch.cgi to execute properly. Chmod the dispatch.cgi to +0755+. 2、The path to Ruby is is incorrect in the dispatch.cgi file. The first line of the file is called the shebang-- it sets the location of the intrepretor (in this case ruby). Change the shebang to the correct path to Ruby (/usr/bin/ruby). The first line of the dispatch.cgi file should look like this: #!/usr/bin/ruby
记不得时候在本地机子上安装了mongrel,今天把1stlog用mongrel运行时,报告:-e:3:in `load': no such file to load -- mongrel_rails (LoadError) from -e:3看错误提示貌似mongrel_rails 这个加载不到,那么应该就是配置的问题了,问题解决如下:找到RadRails的 preferences > Rails > configuration ,在这里指定mongrel_rails的路径就可以了(注意不是bat也不是cmd,而是那个没有后缀的)ok,解决了,如果有谁遇到这个问题,也算帮忙了。呵呵。。。
\n", "_id"=>105}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"警惕rails中的保留字带来的问题~", "body"=>"这个问题还真一直没有关注过,只是晓得rails和ruby中有些关键字、保留字,也没太注意,昨天开始遇到一个很奇怪的问题,我建立了一个用来存放友情链接的表links,里面有title,desc,*type*,created_at等字段,然后在controller中取记录的时候类似如下语句: @friend_links = Link.find(:all, :conditions => { :type => 1, :visible => 1 })貌似一切都很平常,却发生如下的错误:compile errorD:/soft/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1358: syntax errorObject::1一切都很平常呀,试着换个find的写法,还是一样出问题,真是够邪门的~!然后今天问了几个朋友,也说奇怪,没有遇到过,还好google还是找到了这个问题的根源:保留字。请注意,这里我使用了一个保留字*type*做为字段名,导致这个错误的发生,就像一个朋友这样解释的一样:Its because *type *is a reserved word, so you'll have to change that column's name (perhaps to kind or something). Otherwise you're code looks fine wink.大家以后一定要注意,这个小问题浪费了不少时间~", "created_at"=>2007-07-12 05:10:19 UTC, "updated_at"=>2012-06-24 15:53:12 UTC, "body_html"=>"
这个问题还真一直没有关注过,只是晓得rails和ruby中有些关键字、保留字,也没太注意,昨天开始遇到一个很奇怪的问题,我建立了一个用来存放友情链接的表links,里面有title,desc,*type*,created_at等字段,然后在controller中取记录的时候类似如下语句: @friend_links = Link.find(:all, :conditions => { :type => 1, :visible => 1 })貌似一切都很平常,却发生如下的错误:compile errorD:/soft/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1358: syntax errorObject::1一切都很平常呀,试着换个find的写法,还是一样出问题,真是够邪门的~!然后今天问了几个朋友,也说奇怪,没有遇到过,还好google还是找到了这个问题的根源:保留字。请注意,这里我使用了一个保留字*type*做为字段名,导致这个错误的发生,就像一个朋友这样解释的一样:Its because *type *is a reserved word, so you'll have to change that column's name (perhaps to kind or something). Otherwise you're code looks fine wink.大家以后一定要注意,这个小问题浪费了不少时间~
The easiest and fastest way to install Ruby gems is to install them in your local directory, you will need shell access. To install your own gems use the following steps: \n \n1) Using File Manager in your cPanel make a copy of the .bashrc file in your root directory, name it .bashrc.bak. \n2) Now edit the .bashrc file and add the following to the end of the file:
3) Using your favorite SSH client connect to your site. \n \n4) at the prompt type: \n \ncp /usr/lib/ruby/gems/1.8/cache/sources-0.0.1.gem ./ \ngem install sources-0.0.1.gem \ngem update -y \n \nThis will update rails to the latest version and install it to your local gem directory. \n \n5) When using a rails application, make sure you add the following to your ./config/environment.rb: \n \nENV['GEM_PATH'] = '/path/to/your/home/.gems:/usr/lib/ruby/gems/1.8' \n \n这里还有一个帖子,可以参考下: \nhttp://www.bluehostforum.com/showthread.php?t=1064
BH 上缺少了一些我需要的gem,于是需要自己安装,BH允许把Gems安装到自己的目录下,于是找了些资料,操作步骤如下: \nThe easiest and fastest way to install Ruby gems is to install them in your local directory, you will need shell access. To install your own gems use the following steps: \n \n1) Using File Manager in your cPanel make a copy of the .bashrc file in your root directory, name it .bashrc.bak. \n2) Now edit the .bashrc file and add the following to the end of the file: \n \nlunix代码 \n \n export PATH="$PATH:$HOME/packages/bin:$HOME/.gems/bin" \n export GEM_HOME="$HOME/.gems" \n export GEM_PATH="$GEM_HOME:/usr/lib/ruby/gems/1.8" \n \n export GEM_CACHE=”$GEM_HOME/cache” \n \n \n \n3) Using your favorite SSH client connect to your site. \n \n4) at the prompt type: \n \ncp /usr/lib/ruby/gems/1.8/cache/sources-0.0.1.gem ./ \ngem install sources-0.0.1.gem \ngem update -y \n \nThis will update rails to the latest version and install it to your local gem directory. \n \n5) When using a rails application, make sure you add the following to your ./config/environment.rb: \n \nENV['GEM_PATH'] = '/path/to/your/home/.gems:/usr/lib/ruby/gems/1.8' \n \n这里还有一个帖子,可以参考下: \nhttp://www.bluehostforum.com/showthread.php?t=1064 \n \n另外:还可以把在本地安装好gem后把其copy到Vendor目录下,但是这个方法我不喜欢,不晓得能不能直接把gem包copy到Vendor目录下?试过的告诉下下,多谢!
Ruby on Rails does a decent job in handling security concerns in the background. You will have to configure your application to avoid few security attacks while plugins would be required for many security concerns which are not at all or poorly managed by rails.
\n
In this article I have described the security issues related to a ruby on rails web application. I have followed DRY by linking to articles with good explanation and solutions to security concerns wherever required. This guide can also be used as a quick security check for your current web application.
\n好久没去ROR官方站点了,今天google到他上面的一个wiki,看完后随手到其blog里面看看,看到一篇好文章,是介绍Rails中安全控制的,于是跟着那个链接过去,看了一部分,没时间看完,特转回来记录着有时间再看~ \nRuby on Rails does a decent job in handling security concerns in the background. You will have to configure your application to avoid few security attacks while plugins would be required for many security concerns which are not at all or poorly managed by rails. \nIn this article I have described the security issues related to a ruby on rails web application. I have followed DRY by linking to articles with good explanation and solutions to security concerns wherever required. This guide can also be used as a quick security check for your current web application. \n原文地址:http://www.quarkruby.com/2007/9/20/ruby-on-rails-security-guide
content_for这个方法竟然一直没看到过,今天也是无意中看到的,看到对此介绍为: \nIf you want to change something in the layout on a per-template basis, content_for is your answer! This allows templates to specify view code that can be placed anywhere in a layout. \n也就是说,如果你想动态的改变你原来layout中的东西,你可以使用content_for这个方法,结合代码就很好理解了,如下:
\nThe parameters as following: \n * q = quality level ( 30-70% ) \n * h = output height \n * w = output width \n * sdx = crop area horizontally \n * sdy = crop area vertically \n \nIf you omit the sdx & sdy values, the whole page gets snapped. \nDon't forget to add a backlink to www.artviper.net or www.artviper.de ( textlink is enough ) but please place the link good visible. \nhttp://www.artviper.net/screenshots/screener.php?&url=http://www.itechtag.com&q=70&h=180&w=360\n
\n", "_id"=>141}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Html/css/js"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({"count"=>"categories", "query"=>{:name=>"Html/css/js"}, "fields"=>nil}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"categories"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['categories'].insert([{"sort"=>0, "posts_count"=>0, "name"=>"Html/css/js", "updated_at"=>2012-06-24 15:53:12 UTC, "created_at"=>2012-06-24 15:53:12 UTC, "_id"=>10}])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>10, "title"=>"Introducing the AJAX Feed API FeedControl", "body"=>" 这篇文章是我很早前写的,放在原来的blog上的,无奈那个blog坏掉了,幸好还有”百度快照 “(http://cache.baidu.com/c?word=feedcontrol&url=http%3A//weblog% 2E1ster%2Ecn/%3Faction%3Dshow%26id%3D112&p=98769a45dcd011a05be7d3284c0096& user=baidu),找回来了,呵呵。以下是原文。\r\n\r\nGoogle放出来的AJAX feed API我老早就关注到了,也试用了一些,感觉还真的不错,现在又添加了一些东西,如下:\r\n其API都很简单,详细的可以看这个页面上的介绍:\r\nhttp://code.google.com/apis/ajaxfeeds/documentation/reference.html#FeedControl\r\n只有一个构造器:FeedControl\r\n四个函数:\r\n1.addFeed(url, label) //添加需要显示的FEED的URL\r\n2.addFeed(element, opt_options?);//这个其实就是draw方法,指定显示的方式,例如:\r\n\r\nfeedControl.draw(\r\ndocument.getElementById(\"feedControl\"),\r\n{\r\ndrawMode : google.feeds.FeedControl.DRAW_MODE_TABBED\r\n});\r\n\r\nfeedControl这个是页面的DOM的ID名称,google.feeds.FeedControl.DRAW_MODE_TABBED 就是指定的显示方式,默认值是:google.feeds.FeedControl.DRAW_MODE_LINEAR.\r\n\r\n3.setNumEntries(num); //设定显示的条数(貌似只能统一指定,不能为各个FEED单独指定)\r\n4.setLinkTarget(linkTarget) //设定链接的打开方式,其值分别如下:\r\n\r\n* google.feeds.LINK_TARGET_BLANK - links will open in a new window\r\n* google.feeds.LINK_TARGET_SELF - links will open in the current window\r\n* google.feeds.LINK_TARGET_TOP - links will open in the topmost frame\r\n* google.feeds.LINK_TARGET_PARENT - links will open in either the topmost frame, or replace the current frame.\r\n* anything-else - the value of target in the resulting anchor element is set to linkTarget\r\n\r\n附录其网站上的说明:\r\n---------------\r\nThis morning we added a new class to the Google AJAX Feed API designed to allow you to more easily add a collection of feeds to your pages. The FeedControl is pretty simple:\r\n\r\nvar feedControl = new google.feeds.FeedControl();\r\nfeedControl.addFeed(\"http://www.digg.com/rss/index.xml\", \"Digg\");\r\nfeedControl.addFeed(\"http://feeds.feedburner.com/Techcrunch\", \"TechCrunch\");\r\nfeedControl.draw(document.getElementById(\"feedControl\"));\r\n\r\nIn addition to the formal documentation, we have put together a few samples to help you quickly come up to speed.\r\n
google.feeds.LINK_TARGET_BLANK - links will open in a new window
\n
google.feeds.LINK_TARGET_SELF - links will open in the current window
\n
google.feeds.LINK_TARGET_TOP - links will open in the topmost frame
\n
google.feeds.LINK_TARGET_PARENT - links will open in either the topmost frame, or replace the current frame.
\n
anything-else - the value of target in the resulting anchor element is set to linkTarget
\n
\n\n
附录其网站上的说明:
\n\n
This morning we added a new class to the Google AJAX Feed API designed to allow you to more easily add a collection of feeds to your pages. The FeedControl is pretty simple:
This release closes a JSON XSS vulnerability, fixes a couple of minor regressions introduced in 1.2.4, and backports a handful of features and fixes from the 2.0 preview release.
\n
All users of Rails 1.2.4 or earlier are advised to upgrade to 1.2.5, though it isn’t strictly necessary if you aren’t working with JSON. For more information the JSON vulnerability, see CVE-2007-3227.
\n
Summary of changes:
\n
\n
acts_as_list: fixed an edge case where removing an item from the list then destroying the item leads to incorrect item positioning
\n
deprecated calling .create on has_many associations with an unsaved owner (like post = Post.new; post.comments.create)
\n
backport array and hash query parameters
\n
fix in place editor’s setter action with non-string fields
\n
updated config/boot.rb to correctly recognize RAILS_GEM_VERSION
\n
\n
To upgrade, `gem install rails`, set RAILS_GEM_VERSION to ‘1.2.5’ in config/environment.rb, and `rake rails:update:configs`.
This release closes a JSON XSS vulnerability, fixes a couple of minor regressions introduced in 1.2.4, and backports a handful of features and fixes from the 2.0 preview release. \nAll users of Rails 1.2.4 or earlier are advised to upgrade to 1.2.5, though it isn’t strictly necessary if you aren’t working with JSON. For more information the JSON vulnerability, see CVE-2007-3227. \nSummary of changes: \n \n acts_as_list: fixed an edge case where removing an item from the list then destroying the item leads to incorrect item positioning \n deprecated calling .create on has_many associations with an unsaved owner (like post = Post.new; post.comments.create) \n backport array and hash query parameters \n fix in place editor’s setter action with non-string fields \n updated config/boot.rb to correctly recognize RAILS_GEM_VERSION \n \nTo upgrade, gem install rails, set RAILS_GEM_VERSION to ‘1.2.5’ in config/environment.rb, and rake rails:update:configs.
从上看到的,随手记录如下,可能需要用到。 \n \nRails URL Validation \n \n validates_each :href, :on => :create do |record, attr, value| \n begin \n uri = URI.parse(value) \n if uri.class != URI::HTTP \n record.errors.add(attr, 'Only HTTP protocol addresses can be used') \n end \n rescue URI::InvalidURIError \n record.errors.add(attr, 'The format of the url is not valid.') \n end \n end \n \n \n以前我判断的时候都是按照是不是http://开头等做的判断,感觉好傻,这样的判断才更加专业和准确。
\n", "_id"=>145}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"image_tag with popup for alt attribute", "body"=>"
"Freezing Rails is recommended if you are using a Rails application for a business site or another production environment where stability is the most important concern (if you don't freeze your application, there is a small possibility that your application might stop working due to compatibility problems when a new version of Rails is installed on our servers)."
早上起了一个大早,打开电脑,打开技能云,寒~出错了,信息如下: \nRails application failed to start properly"RewriteCond %{HTTP_REFERER} !^http://1stimes.liquidchinaware.com/.*$ [NC] \n看来有点问题,赶紧打开log看看,没有任何错误,看来还没到这步,奇怪,感觉应该是.htaccess的问题,但是我没改过呀,copy一个好的过去,还是不行,郁闷! \n赶紧./script/server 试试,提示找不到1.2.3版本的rails,接着rails -v 看下,我靠,咋成1.2.5了,看来是Bl自己升级了,也不通知下,囧~ \n找到问题就好办了,修改配置文件environment.rb,把rails版本改成1.2.5即可! \n引出另外一个话题,需要freeze你的Rails么?答案是肯定的,转另外一个老外写的一段话,如下: \n"Freezing Rails is recommended if you are using a Rails application for a business site or another production environment where stability is the most important concern (if you don't freeze your application, there is a small possibility that your application might stop working due to compatibility problems when a new version of Rails is installed on our servers)." \n方法很简单:rake rails:freeze:gems等几个命令就ok,会把rails单独拷贝到你的 vender下,而rails启动的时候先看这个目录,如果有就加载,没有的话再加载系统的。 \n至于为什么这么做,你可以参考他写的文章:http://support.tigertech.net/freeze-rails \n参考命令: \n<a name="freezing-to-a-different">rake rails:freeze:gems<br />rake rails:freeze:edge<br /></a><a name="freezing-to-a-different">rake rails:freeze:edge TAG=rel_1-1-6<br /></a><a name="unfreezing-thawing-rails">rake rails:unfreeze</a>` \n
It can be run with 2 optional parameters: “atime”, which defines the time in minutes that will be compared against the last access time of a session file and “ctime” which defines the time in minutes that will be compared against the creation time of a session file. The default values are: ctime = 120 (minutes) and atime = 20 (miuntes) which means that the session files not accessed in the last 20 minutes and created earlier than 2 hours ago will be removed when the script runs.
Here's a cron-only one liner which, every 30 min, removes all session files that haven't been accessed in 4 hours. 10,40 * * * * /usr/bin/find /u/apps/*/current/tmp/sessions -name "ruby_sess*" -amin +240 -exec rm {} \\;
早上6点半起床,打开电脑,打开技能云,一切正常,开始写Gtalk的发送消息的ruby代码,很顺利,全部搞定,准备关机的时候,刷新了下技能云,显示启动错误! \n晕,哪里出问题了呢?我刚才没有更新代码上去呀,看来是系统的问题,SSH上去,看日志没有任何有用的信息,调试一把,可以启动,难道是 sessions的问题(我的session还是保存在文件系统里面的),转到tmp/sessions下wc -l 了一下,寒,7W多个文件,恐怖,貌似我忘记清理了,直接rm * (保存密码的人别骂我哈),显示参数过长,郁闷,看来文件数太多了,文件貌似也没有什么规律,总不能一个一个删吧(傻瓜才这个干),于是寻找解决办法。 \nGoogle到这段代码,试了下可以正常工作,共享给大家: \n \nRuby代码 \n \n require 'find' \n namespace :tmp do \n namespace :sessions do \n desc 'Clear expired sessions' \n task :clear_expired => :environment do \n ctime = (ENV['ctime'] || 120).to_i \n atime = (ENV['atime'] || 20).to_i \n Find.find(RAILS_ROOT + "/tmp/sessions/") do |path| \n if FileTest.directory?(path) \n if File.basename(path)[0] == ?. \n Find.prune \n else \n next \n end \n else \n File.delete(path) if File.ctime(path) < ctime.minutes.ago or File.atime(path) < atime.minutes.ago \n end \n end \n end \n end \n end \n \n \n按照作者给出的用法,如下: \nIt can be run with 2 optional parameters: “atime”, which defines the time in minutes that will be compared against the last access time of a session file and “ctime” which defines the time in minutes that will be compared against the creation time of a session file. The default values are: ctime = 120 (minutes) and atime = 20 (miuntes) which means that the session files not accessed in the last 20 minutes and created earlier than 2 hours ago will be removed when the script runs. \n保存到你的lib/tasks目录下,然后用rake -T就可以看到这个rake命令,可以接受两个参数,举个例子,如下: \n \n \nRuby代码 \n \n rake tmp:sessions:clear_expired atime=15 ctime=60 \n \n \n另外,还google到一段直接配置的脚本,如下: \nHere's a cron-only one liner which, every 30 min, removes all session files that haven't been accessed in 4 hours. 10,40 * * * * /usr/bin/find /u/apps//current/tmp/sessions -name "ruby_sess" -amin +240 -exec rm {} \\; \n如果你有更优雅的方法,请分享给我,谢谢~ \n参考地址: \nhttp://www.taknado.com/2007/7/25/rake-task-to-clear-expired-session-files
来源:http://errtheblog.com/post/8 \nGiven a piece of XML:
\n
\n
XML/HTML代码
\n\n
<Export>
\n
<Product>
\n
<SKU>403276</SKU>
\n
<ItemName>Trivet</ItemName>
\n
<CollectionNo>0</CollectionNo>
\n
<Pages>0</Pages>
\n
</Product>
\n
</Export>
\n\n
\n
One might assume that REXML is the way to parse it, but we all know how slow it is. \n \nEnter _why’s HTML parser, Hpricot. It’s written in C and since XHTML is a subset of XML, there’s no reason it shouldn’t be able to parse my file. \n \nTurns out it does, it’s really fast, and the code is dead simple.
来源:http://errtheblog.com/post/8 \nGiven a piece of XML: \n \nXML/HTML代码 \n \n <Export> \n <Product> \n <SKU>403276</SKU> \n <ItemName>Trivet</ItemName> \n <CollectionNo>0</CollectionNo> \n <Pages>0</Pages> \n </Product> \n </Export> \n \n \nOne might assume that REXML is the way to parse it, but we all know how slow it is. \n \nEnter _why’s HTML parser, Hpricot. It’s written in C and since XHTML is a subset of XML, there’s no reason it shouldn’t be able to parse my file. \n \nTurns out it does, it’s really fast, and the code is dead simple. \n \nRuby代码 \n \n FIELDS = %w[SKU ItemName CollectionNo Pages] \n \n doc = Hpricot.parse(File.read("my.xml")) \n (doc/:product).each do |xml_product| \n product = Product.new \n for field in FIELDS \n product[field] = (xml_product/field.intern).first.innerHTML \n end \n product.save \n end \n \n \nUpdate: Slight refactoring of the code above. Chris figured out last night that you can use innerHTML which eliminated the only ugly part of the code.
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\Folder\\shell\\DeleteSVN\\command]@=”cmd.exe /c \\”TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \\”%1\\” %%f IN (.svn) DO RD /s /q \\”%%f\\” \\”“```\n
FeedTools is a simple Ruby library for handling rss, atom, and cdf parsing, generation, and translation as well as caching. It attempts to adhere to Postel’s law—i.e. a liberal parsing and conservative generation policy.
由于需要抽时间重新1st的站点,按照我设想的模式,会抓取指定的RSS功能,以前都是自己写的,前些日志看到ruby有个gem,可以找时间试试, \nFeedTools is a simple Ruby library for handling rss, atom, and cdf parsing, generation, and translation as well as caching. It attempts to adhere to Postel’s law—i.e. a liberal parsing and conservative generation policy. \n参考如下2篇文章: \nhttp://sporkmonger.com/projects/feedtools/ \nhttp://sporkmonger.com/2005/08/11/tutorial
“Just when I thought it was safe to upgrade, another version appears!
\n
I’m going to start upgrading our servers to Rails 2.0.2. This involves packaging, testing, and then slowly rolling it out. The jump is to a 2.x version from 1.2.6, so I’m going to take my time with this one to make sure nothing goes horribly wrong, so it might be right after the new year when it’s all done, just to be safe.
\n
For your new year’s resolution, you will freeze your rails! Login via shell, and in your rails directory, run “rake freeze_gems” - that should do the trick!
\n
Please contact support if you have any questions or concerns.”
早上看RSS订阅的时候,发现DH有一则公告,仔细看了下,原来其准备升级到Rails2.0.2版本了,看来Rails2的时代以及来临了,引起原话如下: \n \n \n \n“Just when I thought it was safe to upgrade, another version appears! \nI’m going to start upgrading our servers to Rails 2.0.2. This involves packaging, testing, and then slowly rolling it out. The jump is to a 2.x version from 1.2.6, so I’m going to take my time with this one to make sure nothing goes horribly wrong, so it might be right after the new year when it’s all done, just to be safe. \nFor your new year’s resolution, you will freeze your rails! Login via shell, and in your rails directory, run “rake freeze_gems” - that should do the trick! \nPlease contact support if you have any questions or concerns.” \n \n \n \n
Application configuration shouldn't be spread throughout your code base. Instead a much better place to put it is an external YAML file. See how to do that in this episode.
其实很早前我就用过这个,貌似还是在读书的时候吧,现在技能云上我突然感觉这个相当不错的一个功能,可惜的是,在其站上发现,已经不在提供了,看到其公告如下: \n“ \nf December 5, 2006, we are no longer issuing new API keys for the SOAP Search API. Developers with existing SOAP Search API keys will not be affected. \n
\n
Depending on your application, the AJAX Search API may be a better choice for you instead. It tends to be better suited for search-based web applications and supports additional features like Video, News, Maps, and Blog search results.
\n
For developers who are already using the SOAP Search API, we've kept the documentation live on this site.
\n
”
\n
唉,按照其意思是推荐大家使用更强大的AJAX Search API,但是我不觉得其好用,也不符合我的需要,可惜了哦。 \n还是贴一段代码吧,如下: \nrequire 'soap/wsdlDriver' \n$KCODE = "UTF8" \nkey = 'LVJnAm5QFHblahblahblah your key here' \n \n#create driver \nwsdl = "http://api.google.com/GoogleSearch.wsdl" \ndriver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver \nquery = "your query string here" \nstart = 0 \nmax = 10 \n \n# see http://dev.ctor.org/soap4r/browser/trunk/sample/wsdl/googleSearch/wsdlDriver.rb \n@results = driver.doGoogleSearch( key, query, start, max, true, "", true, 'lang_en', '','') \nsnippets = @results.resultElements.collect { |r| r.snippet } # you can get all kinds'a' info here \nself.update_attribute(:html, snippets.join("\\n")) # or whatever \n \n=================================== \ndef search \n require 'soap/wsdlDriver' \n @title = 'Search Results' \n key = 'YOUR GOOGLE API KEY HERE' \n yoursite = 'YOUR SITE ADDRESS HERE' \n driver = SOAP::WSDLDriverFactory.new("http://api.google.com/GoogleSearch.wsdl").createDriver \n @results = driver.doGoogleSearch(key, @params['term']+" site:\#{yoursite}", 0, 10, true, " ", false, " ", " ", " ") \nend \n \n \n<% for result in @results.resultElements %> \n <h2><%= result.title %></h2> \n <p><%= result.snippet %></p> \n <p><a href="<%= result.URL %>"><%= result.URL %></a></p> \n<% end %>
其实很早前我就用过这个,貌似还是在读书的时候吧,现在技能云上我突然感觉这个相当不错的一个功能,可惜的是,在其站上发现,已经不在提供了,看到其公告如下: \n“ \nf December 5, 2006, we are no longer issuing new API keys for the SOAP Search API. Developers with existing SOAP Search API keys will not be affected. \n \nDepending on your application, the AJAX Search API may be a better choice for you instead. It tends to be better suited for search-based web applications and supports additional features like Video, News, Maps, and Blog search results. \nFor developers who are already using the SOAP Search API, we've kept the documentation live on this site. \n” \n唉,按照其意思是推荐大家使用更强大的AJAX Search API,但是我不觉得其好用,也不符合我的需要,可惜了哦。 \n还是贴一段代码吧,如下: \nrequire 'soap/wsdlDriver' \n$KCODE = "UTF8" \nkey = 'LVJnAm5QFHblahblahblah your key here'
I found the following lines of code on Wikipedia today. It’s a very succinct description of one important difference between a lambda and a Proc. Try printing the return value of f.call for more insight.
\n
\n
摘录部分内容如下:
\n`` def foo f = Proc.new{ return "return from foo from inside proc"} f.call# control leaves foo here return "return from foo" end
def bar f = lambda { return "return from lambda"} f.call# control does not leave bar here return "return from bar" end
puts foo # prints "return from foo from inside proc" puts bar # prints "return from bar"
一直都不是很能把ruby的Proc运用自由,今天看一个gem的时候,又发现另外一个比较让我迷惑的东西Lambda ,好读书不求甚解,先找到一篇相关的文章,如下: \nhttp://samdanielson.com/2007/3/19/proc-new-vs-lambda-in-ruby \n原作者是这么说的: \n \nI found the following lines of code on Wikipedia today. It’s a very succinct description of one important difference between a lambda and a Proc. Try printing the return value of f.call for more insight. \n \n摘录部分内容如下: \n<code class="ruby"><br /><span class="keywords">def</span> foo<br /> f = <span class="constants">Proc</span><span class="method">.new</span> <span class="brackets">{</span> return <span class="string">"return from foo from inside proc"</span> <span class="brackets">}</span><br /> f<span class="method">.call</span> <span class="comment"># control leaves foo here</span><br /> return <span class="string">"return from foo"</span> <br /><span class="keywords">end</span><br /><br /><span class="keywords">def</span> bar<br /> f = lambda <span class="brackets">{</span> return <span class="string">"return from lambda"</span> <span class="brackets">}</span><br /> f<span class="method">.call</span> <span class="comment"># control does not leave bar here</span><br /> return <span class="string">"return from bar"</span> <br /><span class="keywords">end</span><br /><br />puts foo <span class="comment"># prints "return from foo from inside proc" </span><br />puts bar <span class="comment"># prints "return from bar" </span><br /><br />在wiki上也有,地址如下:http://en.wikipedia.org/wiki/Closure_(computer_science)````
Fast, simple, designed to mirror the style of memcached. Rails plugin available, or usable with a simple Ruby-based API. Server written in C, but is very easy to install. Memory only…jobs are not persistent. New, so the internal protocol may change. Workers may be difficult to manage.
开始的时候,有人说Rails没有队列机制,无法达到企业级的需求,时间没多久,现在再来看看Rails有没有队列机制吧。 \n \n别看一组可行的列表,如下: \nbeanstalkd \nFast, simple, designed to mirror the style of memcached. Rails plugin available, or usable with a simple Ruby-based API. Server written in C, but is very easy to install. Memory only…jobs are not persistent. New, so the internal protocol may change. Workers may be difficult to manage. \nbj \nRails plugin. Self-spawning. Can only send shell commands. Jobs start a full copy of your Rails app on every execution. \nBackgroundRB \nRuby-based. Can be polled for incremental feedback on the progress of a job. Recently rewritten. \nAmazon SQS \nRuns on Amazon’s cluster, so it can handle a ton of traffic. Operated by Amazon, so it doesn’t run locally. Not open source. \nApache ActiveMQ \nWell-known. Persistent. Requires several installation steps and database tables. \nActiveMessaging \nRails plugin. Works with ActiveMQ and others. Requires external job server. \nBBQ \nNothing to install…involves only a single line of code! Doesn’t work on Windows NT4. \n如下是几篇介绍的文章: \nhttp://www.thewebfellas.com/blog/2008/1/17/queues \nhttp://nubyonrails.com/articles/about-this-blog-beanstalk-messaging-queue
I ported the php code for open flash chart to ruby and so far it has worked quite well with Rails. Just ported the latest 1.9.6 version – see the many graph examples below. To install and use the open flash chart plugin for Rails do the following:
/config/../log/sql/production_2008-01-24.log.20080124' already exists.):” \n看上去感觉是在1.25号凌晨的时候,将原来的日志改名为production_2008-01-24.log.20080124,而此时已经存在名字为“production_2008-01-24.log.20080124”的文件,导致改名失败的。 \n但是这个“production_2008-01-24.log.20080124”是哪里来的呢?backgroundrb应该是没有进行改名操作的。 \n \n于是乎开始google,找到有类似问题的文章如下: \n1、Rails application not working, no error displayed, just error code 500 \n错误基本上是一样的,但是这个文章没有仔细说是什么原因,只说了: \n
And the problem was almost solved - problem with log rotation. \nSo, if you face the same problem, try to perform few operations in your rails console... and if you are lucky, you will find the bug. \n
\n``ActionView::TemplateError (undefined method `[]' for nil:NilClass) on line #57 of companies/_cannot_edit_item.rhtml: 而这行却是没有代码的,真的奇怪的很。翻遍这个文件也没有发现什么可疑的地方,最后 没有办法就挨个的测试,发现有的公司展示页面是可以的,进数据库比较不同,发现有些 字段是没有值的,难道这个问题,于是挨个的加上值,测试,果然通过,后来再仔细看看 错误信息:
Do you get annoyed when you have a SSH session open, visit your browser for a while, and then return only to find you were disconnected? Most home NAT routers are the cause of this. If your router doesn’t offer an option to not shut off idle connections, you are probably better off by setting a keep-alive setting.
\n
To do this, just open /etc/ssh/ssh_config on your home (client) computer. Add the following line:
\n
\n
\n
配置代码
\n\n
ServerAliveInterval 180
\n\n
\nThere you have it! Just remember now, if you leave SSH open accidentally, anyone else can get on it. Remember to close your session when finished.PS:If you’re using AbsoluteTelnet (for Windows), you can do this from the Options->Properties->Connection page. There is an option there to enable keepalives and you can specify the duration between them.
不管我是使用linux的的SSH还是windows下的putty、SecureCRT还是AbsoluteTelnet,当我连接到服务器端 后,离开一会或者做点其他的事情,再回到SSH的时候,常常发现客户端自动掉出来了;有的时候甚至跑一个需要时间比较长的JOB的时候,还没跑完就掉出来 了,导致JOB跑了一半,等等。。 \n所以一直在找解决这个问题的办法,今天在googleReader上找到了一个解决办法,如下: \n \nDo you get annoyed when you have a SSH session open, visit your browser for a while, and then return only to find you were disconnected? Most home NAT routers are the cause of this. If your router doesn’t offer an option to not shut off idle connections, you are probably better off by setting a keep-alive setting. \nTo do this, just open /etc/ssh/ssh_config on your home (client) computer. Add the following line: \n \n \n配置代码 \n \n ServerAliveInterval 180 \n \n \nThere you have it! Just remember now, if you leave SSH open accidentally, anyone else can get on it. Remember to close your session when finished.PS:If you’re using AbsoluteTelnet (for Windows), you can do this from the Options->Properties->Connection page. There is an option there to enable keepalives and you can specify the duration between them.
今天无意在Google订阅里面看到了人评价说“itechtag 纯粹靠自我声明或者相互吹捧的是没有办法 建立creditibility(可信度) 如果像ohloh.net那种有真凭实据的还差不多”。 \n哦,有人这样评价技能云,还提到了ohloh.net,这个是什么网站呢?赶紧瞧瞧去。 \nOhloh is an open source network that connects people through the software they create and use. \n \nwowo,和我们的技能云的定位有些神似呀,有时间好好研究下:( \n
AviScreen - As the name would imply, this capture program records the video into AVI files, but can also do BMP photos. It’s Windows only and does not record audio.
\n
CamStudio.org - An open source program for capturing your on-screen video and audio as AVI files. Windows only, and absolutely free.
\n
Copernicus - A free program for Macs that focuses heavily on making quick and speedy films by recording the video to your RAM for quicker access. Does not include any support for audio.
\n
JingProject.com - Beyond recording video, Jing allows you to take a picture of any portion fo your desktop, draw on it, add a message, and immediately upload your media to a free hosting account. You are then given a small URL that you can give to whomever needs to see the image or video. Works with Macs and Windows machines.
\n
Screencast-O-Matic.com - A Java-based screencasting tool that requires no downloads and will allow you to automatically upload to hosting. According to their site it works well with Macs and Windows machines, but does have some issues with Linux.
\n
Wink - Screencasting software that focuses on making tutorials with audio and text annotation abilities. Outputs to Flash, PDF, HTML, EXE files and more. \n \n以及在ubuntu下的xvidcap。
经常看一些视频教程,觉得视频教程简单易懂,相当不错,如下两个文章列了一些制作视频教程的工具,被点名的有: \nAviScreen - As the name would imply, this capture program records the video into AVI files, but can also do BMP photos. It’s Windows only and does not record audio. \nCamStudio.org - An open source program for capturing your on-screen video and audio as AVI files. Windows only, and absolutely free. \nCopernicus - A free program for Macs that focuses heavily on making quick and speedy films by recording the video to your RAM for quicker access. Does not include any support for audio. \nJingProject.com - Beyond recording video, Jing allows you to take a picture of any portion fo your desktop, draw on it, add a message, and immediately upload your media to a free hosting account. You are then given a small URL that you can give to whomever needs to see the image or video. Works with Macs and Windows machines. \nScreencast-O-Matic.com - A Java-based screencasting tool that requires no downloads and will allow you to automatically upload to hosting. According to their site it works well with Macs and Windows machines, but does have some issues with Linux. \nWink - Screencasting software that focuses on making tutorials with audio and text annotation abilities. Outputs to Flash, PDF, HTML, EXE files and more. \n \n以及在ubuntu下的xvidcap。 \n【1】http://www.freecharity.org.uk/2007/04/12/the-secret-to-screencasting-with-ubuntu-and-free-software/ \n【2】http://mashable.com/2008/02/21/screencasting-video-tutorials/
\n", "_id"=>222}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"50 Questions to Evaluate the Quality of Your Website", "body"=>"
If the answer to every question that follows below was answered with yes, you can be very pleased with yourself and consider yourself the top of the crop, because most websites have flaws for a number of different reasons, mostly related to the limitation of resources and sacrifices that must be made as a direct result of the shortage.
\n
These questions are divided into following main categories: Accessibility, Navigation, Design, Content, Security, Other Technical Considerations, Other Marketing Considerations and Legal Stuff/Re-Assurance/Legitimization.
作为一个互联网人,你对自己的网站有多少理解和把握,对其前途是否能看好,能否认识到目前的现况和不足,都是十分重要的。 \nCarstenCumbrowski from SearchEngineJournal has come up with a great and pretty detailed list of 50 questions that a website owner should asked himself about his own website. \nIf the answer to every question that follows below was answered with yes, you can be very pleased with yourself and consider yourself the top of the crop, because most websites have flaws for a number of different reasons, mostly related to the limitation of resources and sacrifices that must be made as a direct result of the shortage. \nThese questions are divided into following main categories: Accessibility, Navigation, Design, Content, Security, Other Technical Considerations, Other Marketing Considerations and Legal Stuff/Re-Assurance/Legitimization. \n【1】http://www.searchenginejournal.com/50-questions-to-evaluate-the-quality-of-your-website/6400/
虽然我使用Ubuntu工作已经很长一段时间,虽然我也使用过Kubuntu、Xubuntu,虽然我也对ubuntu的前途比较看好,虽然。。 \nN多的虽然,但当我第一次看到Ubuntu Mobile Edition的时候,还是不免呢喃了一句“世界太疯狂了!”难道不是么。 \n \n自从iphone的成功,到Google的潜力修行,加上nokia的大半市场和windowmobile的无可奈何,现在又多了Ubuntu Mobile Edition。
\n
\n
“Ubuntu Mobile Edition 是 Ubuntu 家族的又一新成员。与 Kubuntu、Xubuntu、Edubuntu 这些版本相同的是,Ubuntu Mobile 一样基于 Ubuntu;不同的是,Ubuntu Mobile 是专门为 MID (Mobile Internet Devices,移动互联网设备) 而设计的。”
\n
“Ubuntu Mobile 不仅包含丰富的应用软件,而且集成了流行的 Web 2.0 服务,如 Facebook、MySpace、YouTube 等。使用者通过 Ubuntu Mobile 能够执行诸如网络浏览、收发邮件、分享视频/音乐/照片、即时通讯、撰写博客、玩游戏等常见操作。”
虽然我使用Ubuntu工作已经很长一段时间,虽然我也使用过Kubuntu、Xubuntu,虽然我也对ubuntu的前途比较看好,虽然。。 \nN多的虽然,但当我第一次看到Ubuntu Mobile Edition的时候,还是不免呢喃了一句“世界太疯狂了!”难道不是么。 \n \n自从iphone的成功,到Google的潜力修行,加上nokia的大半市场和windowmobile的无可奈何,现在又多了Ubuntu Mobile Edition。 \n \n“Ubuntu Mobile Edition 是 Ubuntu 家族的又一新成员。与 Kubuntu、Xubuntu、Edubuntu 这些版本相同的是,Ubuntu Mobile 一样基于 Ubuntu;不同的是,Ubuntu Mobile 是专门为 MID (Mobile Internet Devices,移动互联网设备) 而设计的。” \n“Ubuntu Mobile 不仅包含丰富的应用软件,而且集成了流行的 Web 2.0 服务,如 Facebook、MySpace、YouTube 等。使用者通过 Ubuntu Mobile 能够执行诸如网络浏览、收发邮件、分享视频/音乐/照片、即时通讯、撰写博客、玩游戏等常见操作。” \n \n其他的介绍: \nhttp://linuxtoy.org/archives/ubuntu-mobile-edition.html \nhttp://moblin.org/
先来看这篇文章“How To Manage Your Online Reputation”,文章中说到:You've spent a lot of time building up your reputation and image both online and off, so it's important to make sure that someone isn't out there dragging it through the mud. The latest tool for reputation management is Trackur, but its bottom-level price is $88/month, so the question on my mind, is: "Is it worth it?" There are already many different ways to monitor your online reputation as it is. Let's see how they stack up.
Did you know that 52% of individuals put their trust in what others have to say about you? \n \nDid you know that 87% of consumers look at the reputation of your CEO, when judging your company's reputation? \n \nDid you know that 59% of hiring managers are influenced by your online reputation? \n \nDid you know that Trackur will monitor the web 24/7 and alert you whenever your reputation is being discussed?( 这条是宣传自己网站的)
个人在线声望真的越来越被看重了,我一直在做的“技能云”的目的就是建立良好的个人声望,虽然目前国内的很多人还没有意识到这点,但毋庸置疑的是,真的越来越重要了,前段时间MR.6就写过一篇文章,几天又发现了一个文章专门说这个问题的,我也顺着这个思路说说看。 \n先来看这篇文章“How To Manage Your Online Reputation”,文章中说到:You've spent a lot of time building up your reputation and image both online and off, so it's important to make sure that someone isn't out there dragging it through the mud. The latest tool for reputation management is Trackur, but its bottom-level price is $88/month, so the question on my mind, is: "Is it worth it?" There are already many different ways to monitor your online reputation as it is. Let's see how they stack up. \n而后列举了几个可以使用的工具(网站)来管理自己的在线声望,其中提到了一个网站http://www.trackur.com/竟然是收费的,而且还不便宜,最便宜的还88美刀/月,另外还有像google通知等。详细的可以去看这篇文章:http://www.readwriteweb.com/archives/how_to_manage_your_online_reputation.php \n接着看上面说到的这个收费的网站,真的是个监视、管理个人在线声望的网站,价格也真不便宜,呵呵,看看他是怎么说个人声望的: \nDid you know that 52% of individuals put their trust in what others have to say about you? \n \nDid you know that 87% of consumers look at the reputation of your CEO, when judging your company's reputation? \n \nDid you know that 59% of hiring managers are influenced by your online reputation? \n \nDid you know that Trackur will monitor the web 24/7 and alert you whenever your reputation is being discussed?( 这条是宣传自己网站的) \n看看上面列举的几个数据,怎么来的,我们无法得知,但是其在一定程度上说明了个人声望是如何的重要,可能国外会更普及一点;但是对于国内来说,其他行业我不了解,至少和互联网沾边的,不如软件开发行业等,会比较看重的。 \n都说国内什么都要落后老外们几年时间,但是值得我们高兴的事,我们这次我们的意识并没有晚,我们与2007年中开始做的”技能云“正是在这个方面的体现,我们希望的是通过用户的努力,创建良好的个人声望,并勇敢的把自己的声望show出去;此外,我们还将创建公司和项目的声望。 \n虽然我们才刚刚起步,虽然很多人还不能意识到这点的重要性,但是我们相信,随着时间的推移,随着个人不断的体会和经历,加上技能云平台的不断完善,我们肯定会让所有的对自己声望在意的朋友建立起自己的”技能云“。
最近比较清闲,就到处转悠,然后写些自己的感受,今天要说的是FriendFeed,FriendFeed enables you to keep up-to-date on the web pages, photos, videos and music that your friends and family are sharing. It offers a unique way to discover and discuss information among friends.
最近比较清闲,就到处转悠,然后写些自己的感受,今天要说的是FriendFeed,FriendFeed enables you to keep up-to-date on the web pages, photos, videos and music that your friends and family are sharing. It offers a unique way to discover and discuss information among friends. \n注册试用了下,感觉比以前试用的那几个好点,比如facebook我一进去就晕,校内也差不多的模式,其他的什么占座之类的就看几眼就再不会去了。而FriendFeed有点点不一样,可能是由于其”亲缘“关系的缘故(大多数人都死来自Google成员)做事风格也和Google比较类似,简洁明了。其主要的抓取功能还是挺强大的,速度相当的快。 \n应该是在Google中积累的经验,使得这个项目在Google排名等都表现相当不错,在改进”技能云“的时候可以学习下他的表现形式,再琢磨下Google的一些规则。 \n我向来不是很喜欢这类SNS的东西,不过这个FriendFeed倒让我觉得可以忍受。 \n慢慢的,我也学会了冷静的观察~
(Sends the file by streaming it 4096 bytes at a time. This way the whole \nfile doesn‘t need to be read into memory at once. This makes it \nfeasible to send even large files.) \n
有个需求是需要在程序里生成压缩文件,并通过浏览器下载,在rails中发送文件的方式有2中,分别是send_data和send_file,两者还是有些区别的,详细的可以参考Rails的API文档(http://api.rubyonrails.com/classes/ActionController/Streaming.html2个方式,如下:),这里简单的记录 \n<strong>send_file '/path/to.zip'</strong> \n<blockquote>(Sends the file by streaming it <strong>4096 </strong>bytes at a time. This way the whole<br /> \nfile doesn‘t need to be read into memory at once. This makes it<br /> \nfeasible to send even large files.)<br /> \n</blockquote> \n恩,我的需求差不多也是这样的,需要发送的文件比较大,大概在10M左右的大小,按照上<br />面的这个说明,15M的文件差不多需要下载一分钟(理论速度,和实际的网速还是有关系的);<br />挺方便了。<br />参考:<br />http://api.rubyonrails.com/classes/ActionController/Streaming.html<br />http://www.javaeye.com/post/219997``
請不要管它是真還是假,試一下! 如下文章的意思是:(水平有限,可能翻譯得不是很正確,班門弄斧了!) \nDear Friends, \nPlease do not take this for a junk letter. Bill Gates is sharing his fortune. If you ignore this you will repent later. Microsoft and AOL are now the largest Internet companies and in an effort to make sure that Internet Explorer remains the most widely used program, Microsoft and AOL are running an e-mail beta test. \n親愛的朋友們, \n請不要把此郵件當作是垃圾郵件。比爾.蓋茨正在施捨他的財富。如果你無視此封郵件稍後你將會追悔莫及.Microsoft and AOL 是現今最大的因特網公司並致力於確保因特網Windows資源管理器依然是使用最廣的程序,Microsoft and AOL 正在進行E-mail第二個階段的測試。 \n \nWhen you forward this e-mail to friends, Microsoft can and will track it (if you are a Microsoft Windows user) for a two week time period. \n噹你把此e-mail轉送給你的朋友時,微軟將跟在兩周內蹤它(如果你是Microsoft Windows 的使用者)。 \nFor every person that you forward this e-mail to, Microsoft will pay you $245.00, for every person that you sent it to that forwards it on, Microsoft will pay you $243.00 and for every third person that receives it, you will be paid $241.00. Within two week! s, Microsoft will contact you for your address and then send you a cheque. \n對於每一個轉發此mail給朋友的人,微軟將會付給你$245。對於每一個你轉發了的人,別人又繼續轉發的人,微軟將付給你$243並且每三個人收到此mail,你將會得及$241的付款。在兩周內,微軟將會聯繫你的地址並給你一張支票! \nDon’t Know True Or False, Just Have a Try \n \nDear Friends, \nPlease do not take this for a junk letter. Bill Gates is sharing his fortune. If you ignore this you will repent later. Microsoft and AOL are now the largest Internet companies and in an effort to make sure that Internet Explorer remains the most widely used program, Microsoft and AOL are running an e-mail beta test. \n \nWhen you forward this e-mail to friends, Microsoft can and will track it (if you are a Microsoft Windows user) for a two week time period. \n \nFor every person that you forward this e-mail to, Microsoft will pay you $245.00, for every person that you sent it to that forwards it on, Microsoft will pay you $243.00 and for every third person that receives it, you will be paid $241.00. Within two week! s, Microsoft will contact you for your address and then send you a cheque. \n
最近,老是收到一封名字为“spam轉寄^_^”的邮件,内容相当老套,和以往的思路差不多,这次是鼓吹“比尔盖茨”多NB,说起在施舍自己的财富啥的,只要转发那个邮件就可以自动汇入多少多少美金。。 \n对于这类的馅饼,偶从来就不放心上的,搞过计算机安全,偶也懂得一点的”社会工程学“的,利用社会学的例子,在不知不觉中,有些人就得到了其需要的东西而不会被人发觉。这就是社工的魅力和内涵。 \n来看下这个邮件,其诱惑点有如下几个: \n1、有英文及其对应的翻译(繁体字),让人觉得有那么点可信; \n2、开始有几个炒作的,都说收到钱了,等等,让人稍微动心了; \n3、反正不费事,于是很多人就开始抱着试试看的心情大量转发咯; \n那么这样会给开始策划的人带来什么好处呢? \n具体的我不知道,有可能是测试中国人的心里;有可能是闹着玩等等,但是偶认为其还可以收集大家的工作邮箱,想想这么多人的真实、活跃邮箱,这可是比较珍贵的东西呀。 \n抑或在某些版本的邮件接收中有类似跨站,取cookie、溢出下载等等的漏洞,这样就可以有更多的用处了。 \n哎,对于这类”馅饼“,大家还是小心为妙,不要为了”馅饼“调到”陷阱“里啦。 \n附:原文: \n請不要管它是真還是假,試一下! 如下文章的意思是:(水平有限,可能翻譯得不是很正確,班門弄斧了!) \nDear Friends, \nPlease do not take this for a junk letter. Bill Gates is sharing his fortune. If you ignore this you will repent later. Microsoft and AOL are now the largest Internet companies and in an effort to make sure that Internet Explorer remains the most widely used program, Microsoft and AOL are running an e-mail beta test. \n親愛的朋友們, \n請不要把此郵件當作是垃圾郵件。比爾.蓋茨正在施捨他的財富。如果你無視此封郵件稍後你將會追悔莫及.Microsoft and AOL 是現今最大的因特網公司並致力於確保因特網Windows資源管理器依然是使用最廣的程序,Microsoft and AOL 正在進行E-mail第二個階段的測試。 \n \nWhen you forward this e-mail to friends, Microsoft can and will track it (if you are a Microsoft Windows user) for a two week time period. \n噹你把此e-mail轉送給你的朋友時,微軟將跟在兩周內蹤它(如果你是Microsoft Windows 的使用者)。 \nFor every person that you forward this e-mail to, Microsoft will pay you $245.00, for every person that you sent it to that forwards it on, Microsoft will pay you $243.00 and for every third person that receives it, you will be paid $241.00. Within two week! s, Microsoft will contact you for your address and then send you a cheque. \n對於每一個轉發此mail給朋友的人,微軟將會付給你$245。對於每一個你轉發了的人,別人又繼續轉發的人,微軟將付給你$243並且每三個人收到此mail,你將會得及$241的付款。在兩周內,微軟將會聯繫你的地址並給你一張支票! \nDon’t Know True Or False, Just Have a Try \n \nDear Friends, \nPlease do not take this for a junk letter. Bill Gates is sharing his fortune. If you ignore this you will repent later. Microsoft and AOL are now the largest Internet companies and in an effort to make sure that Internet Explorer remains the most widely used program, Microsoft and AOL are running an e-mail beta test. \n \nWhen you forward this e-mail to friends, Microsoft can and will track it (if you are a Microsoft Windows user) for a two week time period. \n \nFor every person that you forward this e-mail to, Microsoft will pay you $245.00, for every person that you sent it to that forwards it on, Microsoft will pay you $243.00 and for every third person that receives it, you will be paid $241.00. Within two week! s, Microsoft will contact you for your address and then send you a cheque.
Scout是Highgroove Studios写的一个很有趣的应用,他提供了一个大的框架,使得其他人可以以插件(集成)的方式实现他的方法(run),进而按照他预定的格式,将采集到的数据发送到其中央服务器,进而可以存储,并以报表的形式展示出来。 \n我大概了看了下起实现方式,和插件的编写方式,其实也挺简单的,其原理也就是在*unix上可以采用crob之类的做定时调度,采集数据(可以使用系统的一些命令,比如ps,top)等等,再把数据组合成他预定义的格式就可以了。 \n看个插件的代码以及我的注释,就很清楚了: \n \n \nRuby代码 \n \n # TODO: use alternate process open to catch STDOUT, STDERR for those \n # processes that use \n #分析: IceskYsl@1sters!(http://iceskysl.1sters.com) \n #这个插件实现的是,定时监控指定的进程,需要的时候重启,并生成报告 \n class KeepProcessRunning < Scout::Plugin \n \n def run \n #预定义返回的数据格式 \n report = {:report => {}, :alerts => [], :memory => {}} \n #取需要监控的进程的名字和重启进程的命令 \n process_to_monitor = @options[:process_name] || "" \n restart_action = @options[:restart_action] || process_to_monitor \n \n # Search all running processes for the process (do not match the grep \n # process nor the locally running scout client). \n #这就是调用系统的ps命令,并grep,看是否有指定的进程存在 \n ps_output = ps auxww | grep <span class="string">"\#{process_to_monitor}"</span><span> | grep -v </span><span class="string">"grep"</span><span> | grep -v </span><span class="string">"scout"</span><span> \n #如果不存在,则根据上面给的重启命令来重启 \n unless process_match = ps_output.to_a.first # process not found \n # attempt to restart the process \n restart_output = <span class="comment">\#{restart_action} \n report[:alerts] << {:subject => "\#{process_to_monitor} is not running. Restart reported: \#{restart_output}"} \n else # process is running \n # if we wanted to parse fields we could: \n # fields = process_match.downcase.split \n report[:report][process_to_monitor] = 1 \n end \n #返回报告 \n return report \n rescue Exception \n { :error => { :subject => "Could not keep the process running.", \n :body => "An exception was thrown: \#{$!.message}" } } \n end \n end \n \n \n \n他采取的“Client Key”来做唯一性校验,也就是说,你必须获得这个“Client Key”,而这个将来可以成为其卖点(可行的方法是分级售卖,比如多少钱的帐号可以监控几个服务器之类的)。 \n仔细一想,这个Idea还真不赖,呵呵~ \n其他的参考资料: \n1、Scout主页:http://scoutapp.com/ \n2、插件编写手册:http://scoutapp.com/plugin_urls/static/creating_a_plugin \n3、rubyinside的报道:http://www.rubyinside.com/scout-a-ruby-powered-web-monitoring-and-reporting-service-825.html
Last week brought some exciting, highly requested new Amazon EC2 features to the community - Elastic IP Addresses, Availability Zones, and User Selectable Kernels.
Elastic IP addresses are static IP addresses designed for dynamic cloud computing. An Elastic IP address is associated with your account, not a particular instance, and you control that address until you choose to explicitly release it. Unlike traditional static IP addresses, however, Elastic IP addresses allow you to mask instance or availability zone failures by programmatically remapping your public IP addresses to any instance associated with your account. Rather than waiting on a data technician to reconfigure or replace your host, or waiting for DNS to propagate to all of your customers, Amazon EC2 enables you to engineer around problems with your instance or software by programmatically remapping your Elastic IP address to a replacement instance.
晚上写完手上的代码,正准备睡觉的时候,收到Amazon的一封mail,以为是S3或EC2的账单呢,打开一看,原来是EC2的好消息. \nGreetings AWS Developers, \n Last week brought some exciting, highly requested new Amazon EC2 features to the community - Elastic IP Addresses, Availability Zones, and User Selectable Kernels. \nwowo,真是个好东西,EC2一直以来都被人诟病之一的就是其IP地址的动态的,也就是当你重启您"镜像"后,你的IP地址会变化,也就是说,你的域名需要才信修改IP指向,或者采用一个老外写的一个插件(忘记脚啥名字了)来动态解析,比较不爽的很.现在EC2终于推出了"静态IP"功能,我粗略的看了下,其和账户是绑定的,也就是你重启自己的"镜像"后,并不失效. \n好东西,EC2会越来越好的... \n \n还是直接看英语的吧,呵呵: \nElastic IP addresses are static IP addresses designed for dynamic cloud computing. An Elastic IP address is associated with your account, not a particular instance, and you control that address until you choose to explicitly release it. Unlike traditional static IP addresses, however, Elastic IP addresses allow you to mask instance or availability zone failures by programmatically remapping your public IP addresses to any instance associated with your account. Rather than waiting on a data technician to reconfigure or replace your host, or waiting for DNS to propagate to all of your customers, Amazon EC2 enables you to engineer around problems with your instance or software by programmatically remapping your Elastic IP address to a replacement instance. \n详细情况请参考:http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1346
2.How to catch Timeout::ERROR ? : http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/170394
\n
3.Ruby's Thread#raise, Thread#kill, timeout.rb, and net/protocol.rb libraries are broken: http://headius.blogspot.com/2008/02/rubys-threadraise-threadkill-timeoutrb.html
\n
4.How to change the Timeout::Error threshold for open_uri : http://www.ruby-forum.com/topic/146676
1sters@IceskYsl:~/sources$ uname -a \nLinux taojer 2.6.18-xen #1 SMP Fri Nov 2 06:14:54 UTC 2007 x86_64 GNU/Linux
\n
然后使用“sudo apt-get install rar”,却发现出错,如下:
\n
\n
1sters@IceskYsl:~/sources$ sudo apt-get install rar \nPassword: \nReading package lists... Done \nBuilding dependency tree... Done \nPackage rar is not available, but is referred to by another package. \nThis may mean that the package is missing, has been obsoleted, or \nis only available from another source \nE: Package rar has no installation candidate
早在我开始使用Ubuntu的时候(7.04)就安装了linux下的rar,这几天在一台新的服务器上上安装的时候,竟然花了这么大的牛劲,呵呵。 \n 先看下版本,如下: \n1sters@IceskYsl:~/sources$ uname -a \nLinux taojer 2.6.18-xen #1 SMP Fri Nov 2 06:14:54 UTC 2007 x86_64 GNU/Linux \n然后使用“sudo apt-get install rar”,却发现出错,如下: \n \n1sters@IceskYsl:~/sources$ sudo apt-get install rar \nPassword: \nReading package lists... Done \nBuilding dependency tree... Done \nPackage rar is not available, but is referred to by another package. \nThis may mean that the package is missing, has been obsoleted, or \nis only available from another source \nE: Package rar has no installation candidate \n \n找不到相应的包,哦,因该是源的问题,查了下Google,很多人说是源的问题,于是乎,胡乱加了一大堆的源,试了下,貌似不好使,再查,找到相应的源,如下: \n \n \nShell代码 \n \n deb http://archive.ubuntu.com/ubuntu dapper universe multiverse; \n deb-src http://archive.ubuntu.com/ubuntu dapper universe multiverse; \n \n \n再使用: \n \nShell代码 \n \n sudo aptitude upgrade \n sudo aptitude install rar unrar \n \n \n \n然后就差不多OK了。 \n参考资料: \n1、http://ubuntuforums.org/showthread.php?t=571440
关于在RUby中调用系统的shell,大家可以参考如下文章( 6 Ways to Run Shell Commands in Ruby: http://pasadenarb.com/2007/03/ruby-shell-commands.html#comment-1886),我就不多废话了.直接看我的相关代码,如下:
\n
\n
\n
Ruby代码
\n\n
local_dir_name=1207667932_2
\n
logger.info("rar a \#{local_dir_name} \#{local_dir_name}")
\n
oo= %x{rar a \#{local_dir_name} \#{local_dir_name}}
尽管Google说会支持其他很多环境,但是现在还只支持python,毫无疑问,Google内部对python的喜爱已经毋庸置疑的。当然,我期待着哪天其可以支持ruby(rails框架或者其他);或者我该抽点时间去学学python了,呵呵。 \n看看他自己的说明: \nRun your web applications on Google's infrastructure. \nGoogle App Engine enables you to build web applications on the same scalable systems that power Google applications. \nNo assembly required. \nGoogle App Engine provides a fully-integrated application environment. \nIt's easy to scale. \nGoogle App Engine makes it easy to build scalable applications that grow from one user to millions of users without infrastructure headaches. \nIt's free to get started. \nEvery Google App Engine application can use up to 500MB of persistent storage and enough bandwidth and CPU for 5 million monthly page views.
早在几天前,就在Gseek上看到关于GoogleAppEngine的介绍,可惜当时去晚了,没有申请到试用帐号,只大略的看了下,发现其实好东西,今天在infoQ上再次看到这个东西的就介绍,再跑过去看看,下载了SDK并看了下他的guider,和演示代码,发现其真的很有前途,是个很有诱惑力的东西。 \n尽管Google说会支持其他很多环境,但是现在还只支持python,毫无疑问,Google内部对python的喜爱已经毋庸置疑的。当然,我期待着哪天其可以支持ruby(rails框架或者其他);或者我该抽点时间去学学python了,呵呵。 \n看看他自己的说明: \nRun your web applications on Google's infrastructure. \nGoogle App Engine enables you to build web applications on the same scalable systems that power Google applications. \nNo assembly required. \nGoogle App Engine provides a fully-integrated application environment. \nIt's easy to scale. \nGoogle App Engine makes it easy to build scalable applications that grow from one user to millions of users without infrastructure headaches. \nIt's free to get started. \nEvery Google App Engine application can use up to 500MB of persistent storage and enough bandwidth and CPU for 5 million monthly page views. \n毫无疑问,如果能大规模的推广开,将会带来很大的web开发热浪,同时Google将在这个里面得到更多的东西,不仅仅限于卖这个服务的费用,还会给google自己的其他份额应用更好的支撑。 \n同时,不可否认,会给亚马逊的S3,EC2,SQS等带来一些竞争,当然,这会使得这个领域更加合理和更多的选择。
"Last night Amazon announced persistent storage on EC2. Now you can create disks in S3 and attach them to EC2 instances. You want a terabyte of storage for your machine, just create it in S3 and mount it."
PS:这次公告中还提及一个新功能: \nAnother feature rolled out last night is snapshots. Need backup or the ability to rollback? Snapshot the instance and it’s on S3, ready to use. You can create new volumes from any particular snapshot. \n \nThese two features make Amazon’s grid computing platform a very nice place for startups to experiment, develop, and build out. All with little or no capital cost.
"Last night Amazon announced persistent storage on EC2. Now you can create disks in S3 and attach them to EC2 instances. You want a terabyte of storage for your machine, just create it in S3 and mount it." \n很多人应该记得,EC2才宣布支持静态IP没几天,今天就看到消息称EC2支持Persistent Storage了,大家应该还记得,EC2发布以来,虽然带给大家无数的方便和快捷,但是其中两个诟病一直被人提及,那就是“不支持固定IP地址”和“没有”Persistent Storage“,这两个诟病使得: \n1、一旦你重启了EC2,你的IP地址就会变化,这就意味着你花了几个小时才解析生效的DNS又无法解析。 \n2、一旦你的EC2重启,你必须及时的备份数据库和数据文件到S3上,以防止重启或者down机丢失数据。 \n而这两个问题,到现在为止,已经全部完善了,EC2基本上很成熟了,剩下一个让国内开发者认为不爽的是,在国内,访问的速度实在不咋地。希望亚马逊有改善的计划,到时,就不用自己买服务器,托管啥的啦,甚至VPS都得靠边站,呵呵,就像我以前说的《RubyOnRails + S3 + EC2 = ? 》,依然好戏。 \n或许是受到Google发布的Google App Engine的刺激,亚马逊才会在最近做这么大的动作,因为Google App Engine号称是亚马逊的EC2,S3,SQS以及SimpleDB的整体方案。对亚马逊有直接的竞争关系。 \n前面一篇文章《Google App Engine,前途无量,充满乐趣 》就说了,这样的竞争,会带来更多的好处,好戏还会有,下一个改进会是什么呢? \nPS:这次公告中还提及一个新功能: \nAnother feature rolled out last night is snapshots. Need backup or the ability to rollback? Snapshot the instance and it’s on S3, ready to use. You can create new volumes from any particular snapshot. \n \nThese two features make Amazon’s grid computing platform a very nice place for startups to experiment, develop, and build out. All with little or no capital cost.
A rails plugin to push things towards component-oriented architecture. Controller logic and views are encapsulated in lightweight cells and can be rendered like render_component.
由于打算将我的第一个开源项目1stlog重构和完善,看了下以前的实现方式,除了用到了很对rails2不支持的方法和插件外(正在着手修改),还用到了Rails中的component的。而这正是被很多railser们告诫要小心的地方,甚至有人说component是evil的,新版1stlog发布在即,我得好好了解下component为什么evil。 \n一、为什么当时选择component \n选择component是根据当时的设计需求来的,1stlog设计的时候是作为一个只有基本blog功能的大框架,而其他的一些个性化功能,需要由其他开发人员或者爱好者来按照一定的规范开发和编写,当时认为,使用component时自简单有效的策略,您可以参考我当时编写”1stlog插件开发指南“。 \n二、为什么说component是邪恶的 \n有人说Rails中的component是邪恶的,千万不要使用,原因呢,还真不清楚,看到有人这么写: \n \nUsing Components \n \n \n \n Components don’t belong in Rails. Don’t use them. They weren’t an \n \n extraction. They weren’t well planned. When you want to use a \n \n component it is probably because you misunderstand them or \n \n really want a partial. Rethink what you’re doing. \n \n The rest of the Rails world has written off components for a \n \n reason and they’ll probably be deprecated by 2.0. Resist. \n \n \n \n也有人拿typo中使用component导致响应很迟钝的数据说明,可以参考“Components may not be evil, but they sure can be slow”,再看看Rails的DHH咋说的呢?哦,他说”Why engines and components are not evil but distracting“ \n这么看来,component并不邪恶了,只是慢一点,有些小问题罢了。 \n三、还用不用? \n竟然大家都持谨慎态度,那么我们还用不用呢?用!但是或许得换个方式用。此话怎么讲?因为有一个既可以实现component功能,又不evil的东西出现了,那就是Cells,何谓Cells?还是看他的自白好了: \n \n \nA rails plugin to push things towards component-oriented architecture. Controller logic and views are encapsulated in lightweight cells and can be rendered like render_component. \n \n哦,看来是个好东西,还想多了解点,看看这些文章吧,"Cells: Bringing Components Back Into Rails 3"或者中文简要版本”插件Cells:把模块化带入Rails 应用中,组件导向轻量级的开发“,还可以看看道喜的简介”Rails框架:组件理念是否重返Rails框架“,或者看看中文的一个简单那的例子”有人用过cell么?“,如果想更深入的了解,可以看看”Ruby Component Web Frameworks“ \n四、还有更好的? \n我是不知道了,您要是知道的话,还请告诉我。 \n参考资料: \n1、http://glu.ttono.us/articles/2006/08/30/guide-things-you-shouldnt-be-doing-in-rails \n2、http://usurffx-gmail-com.javaeye.com/blog/176186 \n3、https://groups.google.com/group/ruby-component-web-frameworks \n4、http://chinaonrails.com/topic/view/1318/1.html \n5、http://www.lycom.de/past/2008/2/14/component-2008-02-14/#comments \n6、http://railsexpress.de/blog/articles/2005/11/18/components-may-not-be-evil-but-they-sure-can-be-slow \n7、http://weblog.rubyonrails.org/2005/11/11/why-engines-and-components-are-not-evil-but-distracting/ \n8、http://rubyforge.org/projects/cells/
\n", "_id"=>262}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"TibetIsXiZang,Tell this to all over the world,Tibet就是西藏!", "body"=>"
Amazon Simple Queue Service (Amazon SQS) offers a reliable, highly scalable, hosted queue for storing messages as they travel between computers. By using Amazon SQS, developers can simply move data between distributed components of their applications that perform different tasks, without losing messages or requiring each component to be always available.
Overview: What is Google Docs Offline? \n \nGoogle Docs now allows you to view and edit your documents offline, without an internet connection. To do all of this, Google Docs uses Google Gears, an open source browser extension that adds offline functionality directly to the browser. Google Docs can be accessed offline by typing http://docs.google.com into your browser or by clicking on the desktop shortcut that is downloaded during the installation process.
早就在Gseek看到GoogleDocs可以离线的消息,但是我的帐户里面一直还没有发现,好歹我也算Dcos的重度使用者,咋一直没看到这个功能呢? \n今天猛然发现,OK了,我等到了,呵呵。 \nOverview: What is Google Docs Offline? \n \nGoogle Docs now allows you to view and edit your documents offline, without an internet connection. To do all of this, Google Docs uses Google Gears, an open source browser extension that adds offline functionality directly to the browser. Google Docs can be accessed offline by typing http://docs.google.com into your browser or by clicking on the desktop shortcut that is downloaded during the installation process. \n挺好的,可以彻底不用Word和OpenOffice咯。三者比较下,我还是喜欢GoogleDocs的这个简洁和方便,不过不得不说几句,上次的改变,把那结果H1 H2 H3几个放到下拉菜单,不是好的用户体验,每次都多点一下,囧~ \n有了离线后,以后带着本本就不怕没网络咯,Good~
We've often told you that one of our goals is to drive down costs continuously and to pass those savings on to you. We have been able to reduce our costs for data transfer, so we're pleased to announce that we're lowering our pricing for data transfer, effective May 1, 2008. You'll notice below that we've reduced price at every existing usage tier of transfer out, as well as added an additional tier for the heaviest users.
\n
Current data transfer price (through April 30, 2008) \n$0.100 per GB - data transfer in \n$0.180 per GB - first 10 TB / month data transfer out \n$0.160 per GB - next 40 TB / month data transfer out \n$0.130 per GB - data transfer out / month over 50 TB
\n
Data transfer "in" and "out" refers to transfer into and out of the Amazon service. Data transferred between Amazon EC2 and Amazon S3-US, Amazon SimpleDB and Amazon SQS is free of charge (i.e., $0.00 per GB). Data transferred between Amazon EC2 and Amazon S3-Europe will be charged at regular rates.
\n
New data transfer price (effective May 1, 2008) \n$0.100 per GB - data transfer in \n$0.170 per GB - first 10 TB / month data transfer out \n$0.130 per GB - next 40 TB / month data transfer out \n$0.110 per GB - next 100 TB / month data transfer out \n$0.100 per GB - data transfer out / month over 150 TB
\n
Data transfer "in" and "out" refers to transfer into and out of the Amazon service. Data transferred between Amazon EC2 and Amazon S3-US, Amazon SimpleDB and Amazon SQS is free of charge (i.e., $0.00 per GB). Data transferred between Amazon EC2 and Amazon S3-Europe will be charged at regular rates.
\n
The result of this pricing change is that all customers will see a reduction in the price of transfer out. For example, a customer transferring 50TB a month will save 16% and a customer transferring 500TB a month will save 26% on transfer with the new pricing. Please see http://aws.amazon.com for full pricing information for each service.
晚上收到Amazon的AWS的邮件,说降价了,哈,真是好消息,前台在写<Google App Engine,前途无量,充满乐趣>的时候,还说到"同时,不可否认,会给亚马逊的S3,EC2,SQS等带来一些竞争,当然,这会使得这个领域更加合理和更多的选择。",不想到,这么快,Amazon就有动作了,真是好消息,直接看原文吧,总觉得用中文把E文再重复一遍挺浪费的,也比较别扭,总感觉有些外文不好使用中文表述出来,呵呵. \n=====================start=================== \n \nDear Amazon Web Services developers, \nWe've often told you that one of our goals is to drive down costs continuously and to pass those savings on to you. We have been able to reduce our costs for data transfer, so we're pleased to announce that we're lowering our pricing for data transfer, effective May 1, 2008. You'll notice below that we've reduced price at every existing usage tier of transfer out, as well as added an additional tier for the heaviest users. \nCurrent data transfer price (through April 30, 2008) \n$0.100 per GB - data transfer in \n$0.180 per GB - first 10 TB / month data transfer out \n$0.160 per GB - next 40 TB / month data transfer out \n$0.130 per GB - data transfer out / month over 50 TB \nData transfer "in" and "out" refers to transfer into and out of the Amazon service. Data transferred between Amazon EC2 and Amazon S3-US, Amazon SimpleDB and Amazon SQS is free of charge (i.e., $0.00 per GB). Data transferred between Amazon EC2 and Amazon S3-Europe will be charged at regular rates. \nNew data transfer price (effective May 1, 2008) \n$0.100 per GB - data transfer in \n$0.170 per GB - first 10 TB / month data transfer out \n$0.130 per GB - next 40 TB / month data transfer out \n$0.110 per GB - next 100 TB / month data transfer out \n$0.100 per GB - data transfer out / month over 150 TB \nData transfer "in" and "out" refers to transfer into and out of the Amazon service. Data transferred between Amazon EC2 and Amazon S3-US, Amazon SimpleDB and Amazon SQS is free of charge (i.e., $0.00 per GB). Data transferred between Amazon EC2 and Amazon S3-Europe will be charged at regular rates. \nThe result of this pricing change is that all customers will see a reduction in the price of transfer out. For example, a customer transferring 50TB a month will save 16% and a customer transferring 500TB a month will save 26% on transfer with the new pricing. Please see http://aws.amazon.com for full pricing information for each service. \nSincerely, \nThe Amazon Web Services Team \n================end-================== \n当然了,你也可以到Amazon官方网站上看到这个消息,"Announcement: Lower Data Transfer Costs" \nAWS越来越成熟,在继支持静态IP和固定存储后,这又是一个大的变化,如果啥时能使得国内的访问速度提上去的话,对国内的WEB人员将是最大的幸福了.继续期待... \n
在U盘价格卖到“白菜”一样的时候,你拿U盘来做什么,又可以做什么,你有想过把一个linux装到U盘里,打造一个随身携带的“生产环节”呢。 \n设想下这么个场景,你是公司业务人员,受客户邀请和上司器重,去一个你并不熟悉的客户环境中讲解客户需要的产品,当你兴致勃勃的到达客户处时,却发现无法联上演示离不开的互联网来连到您的DEMO服务器,或者网路相当糟糕,让你不得不点一个按钮就停下里尴尬的等待,或者其他等等等情况。 \n如果我告诉你,可以把Puppy Linux 4.00打造成这套演示环境(小生产环境)随手带在U盘里,随时随地的演示,你会不会心动? \nOk,先看看“随身系统——Puppy Linux 4.00 初体验”,如何,挺不错吧,想自己做一个么,看“将 Puppy Linux 4.00 安装在U盘里 打造随身系统”,还想了解更多,看“E-PUP Linux 中文项目(Puppy Linux 中文版)您高效实用的小型Linux发行版”和"Puppy Linux Discussion Forum“。 \n恩,差不多了,我想要的是一个带有Linux、Mysql,Ruby,Rails,gems,mogrels,nginx的小生产环境即可。至于开发环境下的JAVA,Netbeans等就无所谓了。有人能已经实践过了么,共享 :)
虽然在ubuntu上的rails里面使用过很多次的RMagick,但是却一直没有在单独的ruby \nscript中使用过,这次需要单独使用来画一些图片,于是写了一段代码,但是却跑不起来,老是报"LoadError: no such file to load -- RMagick "错误,查了些资料,搞清楚原因,记录如下: \n1.注意大小写敏感度 \n在windows或者mac上,不敏感大小写,可以:require 'rmagick'```</p> \n<p>但是在linux上,却不行,需要写:require 'RMagick'```</p> \n<p>````否则您可能得到如下错误:```</p> \n<p>```` MissingSourceFile: no such file to load -- rmagick```</p> \n<p><strong>2.单独ruby中需要引用````rubygems```</strong></p> \n<p>````require 'rubygems'<br /> \nrequire 'RMagick'```</p> \n<p>````如果不引用rubygems,可能会看到如下错误:</p> \n<p>require': no such file to load -- rmagick (LoadError)</p> \n<p>或者<br /> \n</p> \n<p>`require': no such file to load -- RMagick (LoadError)` \n参考文档: \n \n 在Ubuntu上安装RMagic:http://www.hhtong.com/blog1/articles/2006/11/11/ubuntu20061111-install-rmagic \n Ruby on Rails RMagic:http://www.mysmallventures.com/ruby-on-rails-rmagick-linux-issues/
看到http://chinaonrails.com/topic/view/1620.html上说DH已经采用了mod_rails(Passenger ),但是没看到效果,按照其介绍文章"Introducing Passenger for Ruby on Rails",登录我的DH帐户后,果然发现已经支持了,见我抓的图片。
Cross Site Reference Forgery works by including malicious code or a link in a page that accesses a web application that the user is believed to have authenticated. If the session for that web application has not timed out, an attacker may execute unauthorized commands. \n
This plugin works by extending all forms created with #form_tag (including #form_for, #form_remote_tag, and #remote_form_for) by adding a token unique to each session id. It also adds a filter that checks all non-GET requests for the existence of this token. This should ensure that all non-GET actions have been correctly submitted from a form on your site.```", "created_at"=>2008-05-22 13:28:39 UTC, "updated_at"=>2012-06-24 15:53:13 UTC, "body_html"=>"
前面一篇文章《CSRF: 不要低估了我的危害和攻击能力》说到了CSRF是相当恐怖的,前面也说了,在Rails2中可以设置安全码来进一步的防止,另外,今天给大家分享一个插件,是csrf_killer,详细的介绍请参考README。 \n<strong>CsrfKiller</strong><br />==========<br /><br />This plugin helps protect against possible CSRF attacks. If you don't know what a Cross Site Request Forgery attack is, check these links:<br /><br />* http://isc.sans.org/diary.html?storyid=1750<br />* http://en.wikipedia.org/wiki/Cross-site_request_forgery<br /><br />This plugin works by extending all forms created with #form_tag (including #form_for, #form_remote_tag, and #remote_form_for) by adding<br />a token unique to each session id. It also adds a filter that checks all non-GET requests for the existence of this token. This should<br />ensure that all non-GET actions have been correctly submitted from a form on your site.`
For use appcfg.pyto upload you app datas behind an HTTP proxy in Google App Engine \n,or use with gems, cpan,etc. Inside cmd.exe, typed: \n \nset HTTP_proxy=http://my.proxy.server:8000
For use appcfg.py to upload you app datas behind an HTTP proxy in Google App Engine \n,or use with gems, cpan,etc. Inside cmd.exe, typed: \n \nset HTTP_proxy=http://my.proxy.server:8000
WWW::Mechanize:The Mechanize library is used for automating interaction with websites. Mechanize automatically stores and sends cookies, follows redirects, can follow links, and submit forms. Form fields can be populated and submitted. Mechanize also keeps track of the sites that you have visited as a history.
有的时候需要去一个URL上取一些文字或者简介啥的下来,或者取一些自己需要的内容下来,这个时候虽然可以直接使用http-net连到URL上,取回内容,然后自己解析等,但是这在一定程度上算是网络爬虫的范畴。 \nWWW::Mechanize:The Mechanize library is used for automating interaction with websites. Mechanize automatically stores and sends cookies, follows redirects, can follow links, and submit forms. Form fields can be populated and submitted. Mechanize also keeps track of the sites that you have visited as a history. \n啊哈,貌似不错,在这个上面构建自己的爬虫应该简单的多了,可以使用它模拟浏览器的行为,但是需要注意的一点是,他模拟浏览器的时候会按照浏览器一样记住“历史”,如果你不设定历史条数,wowo,请留意你的内存吧,详细的请查看“ashchan”的文章”Mechanize的内存问题“。 \n再看段例子吧,真的很简单,他里面使用的是hpricot,大家都比较熟悉了,呵呵,看段代码,如下: \n \n \nGoogle \n \n require 'rubygems' \n require 'mechanize' \n \n agent = WWW::Mechanize.new \n agent.user_agent_alias = 'Mac Safari' \n page = agent.get("http://www.google.com/") \n search_form = page.forms.with.name("f").first \n search_form.q = "Hello" \n search_results = agent.submit(search_form) \n puts search_results.body \n \n \n简单吧,其他的请参考他的“EXAMPLES.txt”,其他信息请到其“Documentation”页面上查看吧。
恩,挺直接的,就是: \nALTER TABLE table_name ADD column_name ,貌似没啥问题,看来是MySQL的问题,和Rails无关,Google下资料,发现“change index or add column in a very big table”和我遇到的问题基本一致,但是其回复中并没有说道如何解决或者如何提升性能。 \n继续Google,找到“Why MySQL could be slow with large tables ?”这篇文章,谈到了为什么说MySQL在大表的时候会很慢,其观点是和表的结构设计有关。其有人回复说“I have a table with 35 mil records. When I wanted to add a column (alter table) I would take about 2 days.”,和我的问题一致,这个文章很好,建议各位有时间的仔细看看。 \n但是我的这个数据表结构并不复杂,如何能提升其速度呢,还在研究中,有了思路会再更新上来。 \n
项目使用Rails开发,DB采用的是MySQL,有一个不算复杂的表A,记录数差不多50W条数据,现在想增加一个列属性,于是很自然的想到Rails中的add_column,然后rake迁移数据,但是等了很久未见执行完毕,诡异。 \n初步判断是由于表里的记录太多了,查下add_column是怎杨的,如下: \n \nRuby代码 \n \n # File activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 121 \n 121: def add_column(table_name, column_name, type, options = {}) \n 122: add_column_sql = "ALTER TABLE \#{table_name} ADD \#{quote_column_name(column_name)} \#{type_to_sql(type, options[:limit], options[:precision], options[:scale])}" \n 123: add_column_options!(add_column_sql, options) \n 124: execute(add_column_sql) \n 125: end \n \n \n恩,挺直接的,就是: \nALTER TABLE table_name ADD column_name ,貌似没啥问题,看来是MySQL的问题,和Rails无关,Google下资料,发现“change index or add column in a very big table”和我遇到的问题基本一致,但是其回复中并没有说道如何解决或者如何提升性能。 \n继续Google,找到“Why MySQL could be slow with large tables ?”这篇文章,谈到了为什么说MySQL在大表的时候会很慢,其观点是和表的结构设计有关。其有人回复说“I have a table with 35 mil records. When I wanted to add a column (alter table) I would take about 2 days.”,和我的问题一致,这个文章很好,建议各位有时间的仔细看看。 \n但是我的这个数据表结构并不复杂,如何能提升其速度呢,还在研究中,有了思路会再更新上来。
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mys
\n\n
\n
ERROR: While executing gem ... (RuntimeError) ERROR: Failed to build gem native extension. Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mys```\n
解决方案 \n1.先运行
\n
\n\n
$ sudo apt-get install libmysqlclient15-dev
\n\n
\n
$ sudo apt-get install libmysqlclient15-dev```\n
注意上面安装的库名为libmysqlclient15-dev而非libmysqlclient5-dev \n \n2.再运行 \nsudo gem install mysql
昨天看到caiwangqin在CoR上发了一篇帖子说“RubyOnRails 2.1 what's new”这本书原文是葡萄牙的,由Brazilian社区翻译为英文,希望能有人组织翻译成中文版。 \n我向来希望把自己了解的东西写下里,记录成Doc文档分享给其他的人,如果你经常关注我的blog,应该了解;于是花了中午午休的时候,按照以往的经验做了一份协作约定文档《协作翻译: Ruby On Raisl 2.1新特性(第二版)》,然后翻译了索引篇《Ruby On Raisl 2.1新特性介绍》和第一章《第1章: 概述(Introduction)》,发布给其他成员。 \n紧接着我有挑选了几篇感兴趣的翻译,其他成员积极性相当高,仅仅一下午,所有14章全部领取完毕,晚上看GoogleDoc发现大家都在辛苦工作,实在感动,谢谢各位。 \n再次感受到社区的力量,很多朋友一般是不怎么联系的,但是这事情一发动就得到大家的积极响应,人多力量果然很大。 \n相信,这本书很快就可以和大家见面了,:) \n这是个不错的模式,希望以后还能有机会找到好资料,大家协作完成。
\n", "_id"=>316}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"install and configuration vsftpd ftp service on Ubuntu Linux", "body"=>"
Q. How do I install Ubuntu ftp service or server?
\n
A. Ubuntu Linux comes with various ftp servers to setup FTP service such as: \n=> proftpd - Versatile, virtual-hosting FTP daemon
\n
=> vsftpd - The Very Secure FTP Daemon
\n
=> ftpd - FTP server
\n
=> wu-ftpd - powerful and widely used FTP server
\n
=> wzdftpd - A portable, modular, small and efficient ftp server
\n
=> pure-ftpd - Pure-FTPd FTP server
\n
其中vsftpd相当优秀,其配置简单方便,且非常安全,如下是其主页上的说明:
\n
vsftpd is the Very Secure File Transfer Protocol Daemon. The server can be launched via a super-server such as inetd or xinetd. Alternatively, vsftpd can be launched in standalone mode, in which case vsftpd itself will listen on the network.
Type apt-get command to install vsftpd \n````$ sudo apt-get install vsftpd``` \nOutput:
\n
\n``Password: Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: vsftpd 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 121kB of archives. After unpacking 438kB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com edgy/main vsftpd 2.0.4-0ubuntu5 [121kB] Fetched 121kB in 0s (246kB/s) Selecting previously deselected package vsftpd. (Reading database ... 31396 files and directories currently installed.) Unpacking vsftpd (from .../vsftpd_2.0.4-0ubuntu5_amd64.deb) ... Setting up vsftpd (2.0.4-0ubuntu5) ... Adding system user `ftp' with uid 106... Adding new user `ftp' (106) with group `nogroup'. Not creating home directory `/home/ftp'. * Starting FTP server: vsftpd```\n
\n### Step # 2: Configure /etc/vsftpd.conf\n
The default vsftpd configuration file is /etc/vsftpd.conf. You need to edit this file using text editor such as vi: \n````$ sudo vi /etc/vsftpd.conf```
\n
Add the following line (uncomment line) to the vsftpd configuration file: \n````local_enable=YES``` \nAbove config directive will allow local users to log in via ftp
\n
If you would like to allow users to upload file, add the following to the file: \n````write_enable=YES```
\n
For security you may restrict local users to their home directories. Add the following to the file: \n````chroot_local_user=YES```
\n
Save and close the file.
\n### Step # 3: Restart vsftpd\n
To restart vsftpd type the command : \n````$ sudo /etc/init.d/vsftpd restart``` \nOutput:
\n``* Stopping FTP server: vsftpd [ ok ] * Starting FTP server: vsftpd [ ok ]
add following rules to your iptables script. Assuming that default incoming policy is drop. If protocol is TCP and destination port is 21 (ftp):
There are a large number of other configuration options available for vsftpd that can be used to fine tune ftp server. Read vsftpd.conf man page by typing following command: \n````$ man vsftpd.conf```
Q. How do I install Ubuntu ftp service or server? \nA. Ubuntu Linux comes with various ftp servers to setup FTP service such as: \n=> proftpd - Versatile, virtual-hosting FTP daemon \n=> vsftpd - The Very Secure FTP Daemon \n=> ftpd - FTP server \n=> wu-ftpd - powerful and widely used FTP server \n=> wzdftpd - A portable, modular, small and efficient ftp server \n=> pure-ftpd - Pure-FTPd FTP server \n其中vsftpd相当优秀,其配置简单方便,且非常安全,如下是其主页上的说明: \nvsftpd is the Very Secure File Transfer Protocol Daemon. The server can be launched via a super-server such as inetd or xinetd. Alternatively, vsftpd can be launched in standalone mode, in which case vsftpd itself will listen on the network. \n=> Default ftp port : 21 \n=> Default configuration file : /etc/vsftpd.conf \nQ:如何安装vsftpd \n很简单,即可搞,如下:
\n\n
Step # 1: Install vsftpd
\n\n
Type apt-get command to install vsftpd \n`$ sudo apt-get install vsftpd \nOutput: \n \nPassword:<br />Reading package lists... Done<br />Building dependency tree<br />Reading state information... Done<br />The following NEW packages will be installed:<br /> vsftpd<br />0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.<br />Need to get 121kB of archives.<br />After unpacking 438kB of additional disk space will be used.<br />Get:1 http://us.archive.ubuntu.com edgy/main vsftpd 2.0.4-0ubuntu5 [121kB]<br />Fetched 121kB in 0s (246kB/s)<br />Selecting previously deselected package vsftpd.<br />(Reading database ... 31396 files and directories currently installed.)<br />Unpacking vsftpd (from .../vsftpd_2.0.4-0ubuntu5_amd64.deb) ...<br />Setting up vsftpd (2.0.4-0ubuntu5) ...<br />Adding system user `ftp' with uid 106...<br />Adding new user `ftp' (106) with group `nogroup'.<br />Not creating home directory `/home/ftp'.<br /> * Starting FTP server: vsftpd`
\n\n
Step # 2: Configure /etc/vsftpd.conf
\n\n
The default vsftpd configuration file is /etc/vsftpd.conf. You need to edit this file using text editor such as vi: \n$ sudo vi /etc/vsftpd.conf```</strong></p> \n<p>Add the following line (uncomment line) to the vsftpd configuration file:<br /> \n<strong>local_enable=YES</strong><br /> \nAbove config directive will allow local users to log in via ftp</p> \n<p>If you would like to allow users to upload file, add the following to the file:<br /> \n<strong>write_enable=YES</strong></p> \n<p>For security you may restrict local users to their home directories. Add the following to the file:<br /> \n<strong>chroot_local_user=YES` \nSave and close the file.
\n\n
Step # 3: Restart vsftpd
\n\n
To restart vsftpd type the command : \n$ sudo /etc/init.d/vsftpd restart```</strong><br /> \nOutput:</p> \n``* Stopping FTP server: vsftpd [ ok ]<br /> * Starting FTP server: vsftpd [ ok ]<br /><br />add following rules to your iptables script. Assuming that default<br />incoming policy is drop. If protocol is TCP and destination port is 21<br />(ftp):<br /><br /><em>iptables -A INPUT -p tcp -m tcp --dport 21 -j ACCEPT</em><br /><br />See - <a href="http://www.cyberciti.biz/faq/iptables-open-ftp-port-21/">How do I open open ftp port 21 using iptables</a> for more information. \nThere are a large number of other configuration options available for vsftpd that can be used to fine tune ftp server. Read vsftpd.conf man page by typing following command: \n`$ man vsftpd.conf \n参考文档:<br />1、http://www.cyberciti.biz/faq/ubuntu-vsftpd-ftp-service-server/<br />2、http://school.cfan.com.cn/system/unix/2008-06-16/1213603744d188509.shtml`
有人问,如何在Rails的控制器中取得URL中的锚点的值,这个需求比较奇特,以前没搞过,于是google了一把,在“Getting the # value”这个帖子看到有人有类似的问题,他说出了在controller中直接取不到的原因是“For normal links/urls the #anchor is a client side feature and is often not even sent to the server as part of a request.”,恩,确实直接取不到,只能使用类似JS的方法来取了,因为其没有将URL全部提交到服务端,所以是无法取值的。
有人问,如何在Rails的控制器中取得URL中的锚点的值,这个需求比较奇特,以前没搞过,于是google了一把,在“Getting the # value”这个帖子看到有人有类似的问题,他说出了在controller中直接取不到的原因是“For normal links/urls the #anchor is a client side feature and is often not even sent to the server as part of a request.”,恩,确实直接取不到,只能使用类似JS的方法来取了,因为其没有将URL全部提交到服务端,所以是无法取值的。 \n另外,看了下Rails中生成anchor的方法比较简单,如下: \n \n \nRuby代码 \n \n <%= url_for(:action => 'play', :anchor => 'player') %> \n # => /messages/play/#player \n \n <%= url_for(:action => 'checkout', :anchor => 'tax&ship') %> \n # => /testing/jump/#tax&ship \n \n <%= url_for(:action => 'checkout', :anchor => 'tax&ship', :escape => false) %> \n # => /testing/jump/#tax&ship \n \n \n详细的请参考API:ActionView::Helpers::UrlHelper
\n", "_id"=>320}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["linux"], "comments_count"=>0, "category_id"=>7, "title"=>"linux下相关信息查看", "body"=>"有的时候需要对服务器信息做比较详细的了解,需要查看一些信息,整理如下:\r\n\r\n1、Java版本(JDK)\r\n\r\n$ java -version\r\njava version \"1.4.2_11\"\r\nJava(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_11-b06)\r\nJava HotSpot(TM) Client VM (build 1.4.2_11-b06, mixed mode)\r\n\r\n2、weblogic版本\r\n\r\n查看weblogic的版本信息,可以在bea\\logs目录下的log.txt中查到版本信息,如下:\r\n\r\n$ cat log.txt\r\n2004-10-20 15:00:58 -- install \"WebLogic Platform\" 8.1.3.0 at /opt/bea/weblogic81\r\nrelease 8.1.3.0 [Added]\r\n\r\n3、Oracle版本\r\n\r\n(1)用客户端连接到数据库,执行select * from v$instance查看version项\r\n(2)select * from product_component_version\r\n(3)或查询V$VERSION查看组件级信息\r\n\r\n4、内核\r\n
$ uname -a\r\nLinux oj-web03 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux
\r\n
[iceskysl@oj-web03 logs]$ cat /proc/version\r\nLinux version 2.4.21-27.ELsmp (bhcompile@bugs.build.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47)) #1 SMP Wed Dec 1 21:59:02 EST 20045、内存信息$ cat /proc/meminfo\r\n$ free -M6、CPU信息$cat /proc/cpuinfo7、硬盘信息\r\n$df\r\n\r\n
(1)用客户端连接到数据库,执行select * from v$instance查看version项 \n(2)select * from product_component_version \n(3)或查询V$VERSION查看组件级信息
\n\n
4、内核 \n$ uname -a \nLinux oj-web03 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux \n[iceskysl@oj-web03 logs]$ cat /proc/version \nLinux version 2.4.21-27.ELsmp (bhcompile@bugs.build.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47)) #1 SMP Wed Dec 1 21:59:02 EST 20045、内存信息$ cat /proc/meminfo \n$ free -M6、CPU信息$cat /proc/cpuinfo7、硬盘信息 \n$df
\n\n", "_id"=>321}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Security"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["ruby", "安全", "漏洞"], "comments_count"=>0, "category_id"=>8, "title"=>"Ruby暴出大量严重漏洞!", "body"=>"Drew Yao at Apple uncovered a handful of nasty security vulnerabilities affecting all current versions of Ruby. The details are still under wraps because an attacker can DoS you or possibly execute arbitrary code—holy crap! Better upgrade sooner than later.\n\nAccording to the official Ruby security advisory, the vulnerable Rubies are:\n\n* 1.8.4 and earlier\n* 1.8.5-p230 and earlier\n* 1.8.6-p229 and earlier\n* 1.8.7-p21 and earlier\n\nThose of us running Ruby 1.8.4 or earlier must upgrade to 1.8.5 or later for a fix. Those on 1.8.5-7 can grab the latest patchlevel release for a fix.\n\n(Please note: Ruby 1.8.7 breaks backward compatibility and is only compatible with Rails 2.1 and later, so don’t go overboard!)\n虽然暂时还没看到具体的细节公布出来,也没看到0day放出来,但是从其描述上不难看出,这些bug是ruby一致以来都有的,或许还有更多的bug,ruby走向成熟,离不开这样的检验。", "created_at"=>2008-06-25 06:05:42 UTC, "updated_at"=>2012-06-24 15:53:13 UTC, "body_html"=>"
Drew Yao at Apple uncovered a handful of nasty security vulnerabilities affecting all current versions of Ruby. The details are still under wraps because an attacker can DoS you or possibly execute arbitrary code—holy crap! Better upgrade sooner than later.
\n\n
According to the official Ruby security advisory, the vulnerable Rubies are:
\n\n
\n
1.8.4 and earlier
\n
1.8.5-p230 and earlier
\n
1.8.6-p229 and earlier
\n
1.8.7-p21 and earlier
\n
\n\n
Those of us running Ruby 1.8.4 or earlier must upgrade to 1.8.5 or later for a fix. Those on 1.8.5-7 can grab the latest patchlevel release for a fix.
\n\n
(Please note: Ruby 1.8.7 breaks backward compatibility and is only compatible with Rails 2.1 and later, so don’t go overboard!) \n虽然暂时还没看到具体的细节公布出来,也没看到0day放出来,但是从其描述上不难看出,这些bug是ruby一致以来都有的,或许还有更多的bug,ruby走向成熟,离不开这样的检验。
\n", "_id"=>323}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["rsync"], "comments_count"=>0, "category_id"=>9, "title"=>"同步利器rsync", "body"=>"rsync is a program that copies file from one location to another, with it you can make backups of your files, synchronize data on different locations and computers. It is commonly used by unix users to keep a safe backup of their files and is often recommended as the simplest solution for backups and safety copys.\r\n\r\n参考资料:\r\n\r\n1.rsync的安装和使用\r\n\r\n2. rsync", "created_at"=>2008-06-25 19:58:32 UTC, "updated_at"=>2012-06-24 15:53:13 UTC, "body_html"=>"
rsync is a program that copies file from one location to another, with it you can make backups of your files, synchronize data on different locations and computers. It is commonly used by unix users to keep a safe backup of their files and is often recommended as the simplest solution for backups and safety copys.
A gravatar, or globally recognized avatar, is quite simply an avatar image that follows you from weblog to weblog appearing beside your name when you comment on gravatar enabled sites. Avatars help identify your posts on web forums, so why not on weblogs?
\r\n看明白了么,就是一个你输入自己的Email,然后上传自己的图片标识,然后在其他支持 Gravatars的网站(blog居多)中发表评论的时候输入自己的Email地址,就可以在Gravatars上找到其对应的图片来显示了。\r\n\r\n这确实是个不错的Idea,相当简单,但是也做得有声有色的,有点意思。\r\n\r\n使用也很方便,其在“How the URL is constructed”上介绍了其URL的组成,中可以这么使用(来源Gravatars on Rails):\r\n\r\n\r\n\r\n1、首先在````application_helper.rb中增加一个helper方法```\r\n
这个世界有意思,多大的idea都可以做成网站,以前看过缩址的网站,现在有看到一个省份标识的网站, Gravatars,看他的介绍: \nA gravatar, or globally recognized avatar, is quite simply an avatar image that follows you from weblog to weblog appearing beside your name when you comment on gravatar enabled sites. Avatars help identify your posts on web forums, so why not on weblogs? \n看明白了么,就是一个你输入自己的Email,然后上传自己的图片标识,然后在其他支持 Gravatars的网站(blog居多)中发表评论的时候输入自己的Email地址,就可以在Gravatars上找到其对应的图片来显示了。
\n\n
这确实是个不错的Idea,相当简单,但是也做得有声有色的,有点意思。
\n\n
使用也很方便,其在“How the URL is constructed”上介绍了其URL的组成,中可以这么使用(来源Gravatars on Rails):
\n", "_id"=>333}])
+MONGODB iceylog_development['categories'].find({:_id=>3}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>3}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Rails: How to use helper inside a controller & model", "body"=>"前几天一个朋友问我如何在Controller中使用helper,我当时说helper是view层的东西,C层没法使用,当时有点忙,虽然知道这个说法也过得去,但是一棍子打死的说法肯定不对。\r\n\r\n今天另外一个朋友问我如何在Model里面使用helper,我开始也说没法使用,并说以前我都是直接在model里面在copy一遍helper的东西。然后还是觉得应该是可以使用的,于是google到一篇tips,但是其访问不了了,还好使用google caceh还是看到了其内容,现在记录如下:\r\n\r\nThis is an easy to use any helpers that rails provides in any other place besides views and view helpers\r\n
\r\n
Ruby代码
\r\n\r\n\t
# create a new file inside lib/ and call it helpers.rb
\r\n\t
# paste the following:
\r\n\t
\r\n\t
def help
\r\n\t
Helper.instance
\r\n\t
end
\r\n\t
\r\n\t
class Helper
\r\n\t
include Singleton
\r\n\t
# look inside ActionView::Helpers to include any other helpers that you might need
if Donkey.find_fit_donkeys.size == APP_SETTINGS['max_fit_donkeys']
\r\n\t
flash_error \"The maximum of \#{help.pluralize(APP_SETTINGS['max_fit_donkeys'], 'donkey')} has been reached.\"
\r\n\t
redirect_to_index
\r\n\t
end
\r\n\t
end
\r\n\r\n
\r\nPS:Don't use the method name \"helper\" because Rails already uses that. Just \"help\" works fine.", "created_at"=>2008-07-10 08:33:29 UTC, "updated_at"=>2012-06-24 15:53:13 UTC, "body_html"=>"
This is an easy to use any helpers that rails provides in any other place besides views and view helpers \n \nRuby代码 \n \n # create a new file inside lib/ and call it helpers.rb \n # paste the following: \n \n def help \n Helper.instance \n end \n \n class Helper \n include Singleton \n # look inside ActionView::Helpers to include any other helpers that you might need \n include ActionView::Helpers::DateHelper \n include ActionView::Helpers::TextHelper \n end \n \n # then in any model or controller: \n require 'lib/helpers' \n \n # to use: \n # help.name_of_helper \n # EX: help.pluralize 10, "person" \n \n \n然后又找到一篇类似的文档:http://snippets.dzone.com/posts/show/1799,摘个方法如下: \n \nRuby代码 \n \n def check_for_max_donkeys \n if Donkey.find_fit_donkeys.size == APP_SETTINGS['max_fit_donkeys'] \n flash_error "The maximum of \#{help.pluralize(APP_SETTINGS['max_fit_donkeys'], 'donkey')} has been reached." \n redirect_to_index \n end \n end \n \n \nPS:Don't use the method name "helper" because Rails already uses that. Just "help" works fine.
puts \"I am fun2 from Mixin1. I’ll call a member function of the class which includes me\"
\r\n\t
mem_fun
\r\n\t
end
\r\n\t
\r\n\t
def fun3
\r\n\t
puts \"I am fun3 from Mixin1. I’ll puts out a member variable of the class which includes me\"
\r\n\t
puts @mem_var
\r\n\t
end
\r\n\t
end
\r\n\t
\r\n\t
class A
\r\n\t
include Mixin1
\r\n\t
def mem_fun
\r\n\t
puts \"I am a member fun of class A\"
\r\n\t
end
\r\n\t
\r\n\t
def initialize
\r\n\t
@mem_var =\"I am a member varaible of class A\"
\r\n\t
end
\r\n\t
end
\r\n\r\n
\r\n调用一下试试看:\r\n
\r\n
Ruby代码
\r\n\r\n\t
a = A.new
\r\n\t
a.fun1
\r\n\t
a.fun2
\r\n\t
a.fun3
\r\n\r\n
\r\n结果如下:\r\nI am fun1 from Mixin1\r\nI am fun2 from Mixin1. I’ll call a member function of the class which includes me\r\nI am a member fun of class A\r\nI am fun3 from Mixin1. I’ll puts out a member variable of the class which includes me\r\nI am a member varaible of class A\r\n\r\n很明显了,不赘述。\r\n\r\n参考文档:\r\nhttp://thinkinginruby.javaeye.com/blog/148967\r\nhttp://my.donews.com/idlecat/2006/10/21/UDDxaYBkNCABNXNVgmIMuMwuKJMHiRXduBBu/\r\nhttp://www.juixe.com/techknow/index.php/2006/06/15/mixins-in-ruby/", "created_at"=>2008-07-10 10:01:42 UTC, "updated_at"=>2012-06-24 15:53:13 UTC, "body_html"=>"
在Ruby中,我们可以把一个模块混入(Mixin)到对象中,从而达到类似多重继承的效果。看几个例子: \n \nRuby代码 \n \n module Mixin1 \n def fun1 \n puts "I am fun1 from Mixin1" \n end \n \n def fun2 \n puts "I am fun2 from Mixin1. I’ll call a member function of the class which includes me" \n mem_fun \n end \n \n def fun3 \n puts "I am fun3 from Mixin1. I’ll puts out a member variable of the class which includes me" \n puts @mem_var \n end \n end \n \n class A \n include Mixin1 \n def mem_fun \n puts "I am a member fun of class A" \n end \n \n def initialize \n @mem_var ="I am a member varaible of class A" \n end \n end \n \n \n调用一下试试看: \n \nRuby代码 \n \n a = A.new \n a.fun1 \n a.fun2 \n a.fun3 \n \n \n结果如下: \nI am fun1 from Mixin1 \nI am fun2 from Mixin1. I’ll call a member function of the class which includes me \nI am a member fun of class A \nI am fun3 from Mixin1. I’ll puts out a member variable of the class which includes me \nI am a member varaible of class A
\n", "_id"=>336}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>9, "title"=>"Protocol Buffers:更简洁有效的数据交换格式!", "body"=>"“Protocol Buffers are a way of encoding structured data in an efficient yet extensible format. Google uses Protocol Buffers for almost all of its internal RPC protocols and file formats.”\r\n\r\nGoogle公司与本月初宣布其内部数据交换格式Protocol Buffers正式开源,基于Apache软件证书2.0发布,相关文档、实例和代码已经可以从Google Code上 访问到。\r\n\r\nProtocol Buffers被定义为一种数据描述语言(Data Description Language,DDL),广泛的应用于Google内部,用于结构化数据的描述、传输和存储。尽管其功能和用途与XML基本相似,但是 Protocol Buffers更为轻便。Google宣称其效率对于XML有很大提升,文本比XML要小3-10倍,而解析效率却提升至20-100倍。\r\n\r\n这真是和好消息,XML慢的诟病相比大家都非常清楚,JSON格式的又无法取代XML的强大地位,虽然Ruby中有Hpricot这样的XML解析利器,但是在大批量的解析中还是会有瓶颈出现,而Google此次放出的Protocol Buffers比XML小,且解析速度很快,足够引起广泛的关注了。\r\n\r\nInfoQ上有篇报道“Google开源数据交换格式Protocol Buffers”比较详细,你也可以在\"Protocol Buffers\"上查看。\r\n\r\n目前已经看到C++,Java,Python格式的API,但是没看到基于Ruby的API,何时会出现 ,应该很快就有了。", "created_at"=>2008-07-15 03:20:15 UTC, "updated_at"=>2012-06-24 15:53:13 UTC, "body_html"=>"
“Protocol Buffers are a way of encoding structured data in an efficient yet extensible format. Google uses Protocol Buffers for almost all of its internal RPC protocols and file formats.”
\n", "_id"=>341}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Starling: 消息队列服务器", "body"=>"Starling is a light-weight persistent queue server that speaks the MemCache protocol. It was built to drive Twitter's backend, and is in production across Twitter's cluster.\r\n\r\n参考文章:\r\n1、http://rubyforge.org/projects/starling/\r\n2、The complete guide to setting up Starling:http://rubypond.com/articles/2008/07/17/the-complete-guide-to-setting-up-starling/\r\n3、http://github.com/IceskYsl/starling/tree/master\r\n4、http://myspacesurfer.hee-ro.net/index.php?q=uggc%3A%2F%2Fjjj.eholvafvqr.pbz%2Ffgneyvat-naq-ehqrd-crefvfgrag-ehol-dhrhrf-958.ugzy", "created_at"=>2008-07-22 02:24:50 UTC, "updated_at"=>2012-06-24 15:53:13 UTC, "body_html"=>"
Starling is a light-weight persistent queue server that speaks the MemCache protocol. It was built to drive Twitter's backend, and is in production across Twitter's cluster.
\n", "_id"=>343}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Fleximage:Rails图片处理新选择", "body"=>"Fleximage is a Rails plugin that tries to make image uploading and rendering super easy.\r\nThere are 2 pieces involved in making Rails image handling easy.\r\n1. Image Uploads\r\n2. Image Rendering\r\n其使用的是Magick\r\n\r\n参考文档:\r\n1.让rails处理图片再简单一点\r\n2.fleximage", "created_at"=>2008-07-29 02:54:14 UTC, "updated_at"=>2012-06-24 15:53:13 UTC, "body_html"=>"
Fleximage is a Rails plugin that tries to make image uploading and rendering super easy. \nThere are 2 pieces involved in making Rails image handling easy. \n1. Image Uploads \n2. Image Rendering \n其使用的是Magick
在中国,电信,网通,联通等南北分化问题相当突出,电线的线路网通的访问可能会慢的无法忍受,解决这个问题的办法中,CDN比较靠谱,但是价格不是一般的贵,一般人玩不起,呵呵。一般会搞双线或者在每个网络中部署一套以提高用户体验。 \n而在页面上,一般来说,AJAX用的JS库表会比较大,这个时候就可以考虑直接使用Google或者Yahoo的JS库,Google的“AJAX Libraries API ”库包含了常见的jQuery, prototype, script.aculo.us, MooTools, and dojo.等等。 \n这样一来可以省去不少的网络流量,也提高了各地的速度。而且是免费的,何乐而不为呢? \n还有类似YUI的UI库,也可以这样考虑。可以提高不少性能。
\n", "_id"=>349}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Security"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>8, "title"=>"Apache Tomcat Directory Traversal Vulnerability", "body"=>"``Title: Apache Tomcat Directory Traversal VulnerabilityAuthor: Simon Ryeo(bar4mi (at) gmail.com, barami (at) ahnlab.com)Severity: HighImpact: Remote File DisclosureVulnerable Version: prior to 6.0.18Solution: - Best Choice: Upgrade to 6.0.18 (http://tomcat.apache.org) - Hot fix: Disable allowLinking or do not set URIencoding to utf8 in order to avoid this vulnerability. - Tomcat 5.5.x and 4.1.x Users: The fix will be included in the next releases. Please apply the hot fix until next release.References: - http://tomcat.apache.org/security.html - http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-2938History: - 07.17.2008: Initiate notify (To Apache Security Team) - 08.02.2008: Responsed this problem fixed and released new version - 08.05.2008: Notify disclosure (To Apache Tomcat Security Team) - 08.10.2008: Responsed with some suggestions.\r\n\r\nDescriptionAs Apache Security Team, this problem occurs because of JAVA side.If your context.xml or server.xml allows 'allowLinking'and 'URIencoding' as'UTF-8', an attacker can obtain your important system files.(e.g. /etc/passwd)\r\n\r\nExploitIf your webroot directory has three depth(e.g /usr/local/wwwroot), Anattacker can access arbitrary files as below. (Proof-of-concept)\r\n\r\nhttp://www.target.com/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/foo/bar\r\n\r\n# milw0rm.com [2008-08-11]```", "created_at"=>2008-08-11 09:51:56 UTC, "updated_at"=>2012-06-24 15:53:13 UTC, "body_html"=>"
``Title: Apache Tomcat Directory Traversal VulnerabilityAuthor: Simon Ryeo(bar4mi (at) gmail.com, barami (at) ahnlab.com)Severity: HighImpact: Remote File DisclosureVulnerable Version: prior to 6.0.18Solution: - Best Choice: Upgrade to 6.0.18 (http://tomcat.apache.org) - Hot fix: Disable allowLinking or do not set URIencoding to utf8 in order to avoid this vulnerability. - Tomcat 5.5.x and 4.1.x Users: The fix will be included in the next releases. Please apply the hot fix until next release.References: - http://tomcat.apache.org/security.html - http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-2938History: - 07.17.2008: Initiate notify (To Apache Security Team) - 08.02.2008: Responsed this problem fixed and released new version - 08.05.2008: Notify disclosure (To Apache Tomcat Security Team) - 08.10.2008: Responsed with some suggestions.
\n\n
DescriptionAs Apache Security Team, this problem occurs because of JAVA side.If your context.xml or server.xml allows 'allowLinking'and 'URIencoding' as'UTF-8', an attacker can obtain your important system files.(e.g. /etc/passwd)
\n\n
ExploitIf your webroot directory has three depth(e.g /usr/local/wwwroot), Anattacker can access arbitrary files as below. (Proof-of-concept)
有时间的看看其他人对中国网民的调查、分析、报告还是有好处的,至少可以让自己在一个宏观和趋势是了解中国网民在做什么和喜欢做什么,在08年1月的时候,在一篇《What Do Chinese Internet Users Do Online?》文章中看到《中国互联网络发展状况统计报告》,比较详细的说明了中国网民的构成,分布等等,非常不错。
\n\n
时隔半年,《TrendsSpotting Handbook Of Online China》这篇文章中又看到一个《Handbook of Online China》的PPT,该PPT分析了中国互联网用户的行为特征,从应用、搜索、web2等方面分析、比较了中国当下比较大的应用。
\n\n
在该报告中,我们可以看到,互联网应用中网络音乐,IM和在线视频,在线游戏都是热门,详细的可以进一步的查看该PPT。 \nHandbook of Online China \nView SlideShare presentation (tags: web trend trends powerpoint olympics) \n
The music API gives developers access to Yahoo!’s “catalog of artists, albums, tracks, videos, ratings and more,” according to the company. It allows developers to interface with Yahoo! Music’s database via “charts, search, similarities, genres, artists, and user recommendations and ratings.”\r\n\r\nThe REST-based API returns data in XML, JSON, and RSS and uses BBAuth to allow user authentication for Yahoo! Music users to access their personal data via external apps. Use of the API is currently limited to 5k queries per day.
\r\n采用REST格式的API,使用Ruby来调用非常简单,看一段代码:\r\n
\r\n
Ruby代码
\r\n\r\n\t
require 'yahoo-music'
\r\n\t
include Yahoo::Music
\r\n\t
Yahoo::Music.app_id = \"...\"# Put Your App ID Here
\r\n\t
artist = Artist.new(\"Beirut\") # Searches by name and uses first result
\r\n\t
album = artist.releases.detect{|r| r.title == \"Flying Club Cup\"}
在Last.fm宣布其开放API后,Yahoo! Music也宣布其开放API。直接看一段英文描述,不废话了,大家都看得懂,如下: \nThe music API gives developers access to Yahoo!’s “catalog of artists, albums, tracks, videos, ratings and more,” according to the company. It allows developers to interface with Yahoo! Music’s database via “charts, search, similarities, genres, artists, and user recommendations and ratings.”
\n\n
The REST-based API returns data in XML, JSON, and RSS and uses BBAuth to allow user authentication for Yahoo! Music users to access their personal data via external apps. Use of the API is currently limited to 5k queries per day. \n采用REST格式的API,使用Ruby来调用非常简单,看一段代码: \n \nRuby代码 \n \n require 'yahoo-music' \n include Yahoo::Music \n Yahoo::Music.app_id = "..." # Put Your App ID Here \n artist = Artist.new("Beirut") # Searches by name and uses first result \n album = artist.releases.detect{|r| r.title == "Flying Club Cup"} \n puts album.title \n puts album.artist \n puts "Release Date:" + album.released_on.strftime("%m/%d/%Y") \n puts \n puts "Tracks" \n artist.tracks.each_with_index do |track, i| \n puts "\\t%d %s \\t%2d:%2d" % [i, track.title, track.duration / 60, track.duration % 60] \n end \n \n \n详细资料,请参考:
正确的做法,应该是修改/etc/security/limits.conf \n里面有很详细的注释,比如 \n* soft nofile 2048 \n* hard nofile 32768
\n\n
检查: \n \nRuby代码 \n \n #check file descriptor \n \n echo \n echo "-----------------------------------------------" \n echo "Begin to check the file descriptor limit" \n fd=ulimit -n \n if [ $fd -lt 8192 ]; \n then \n echo "Fatal Error!" \n echo "The file descriptor limit is only '"$fd"'!" \n echo "Please make it more than 8192!" \n exit \n fi \n echo "OK, the file descriptor limit is" $fd \n echo "-----------------------------------------------" \n echo \n echo \n \n \n \n参考文章: \nhttp://blog.chinaunix.net/u2/64804/showart_1019246.html \nhttp://hi.baidu.com/leshy/blog/item/f57f4a903fb0898ea877a452.html
\n", "_id"=>356}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>3, "title"=>"查看MYSQL表占用空间状态", "body"=>"比如需要查询库占用的空间和索引占用的空间:\r\n\r\n查整个库的状态:\r\nselect concat(truncate(sum(data_length)/1024/1024,2),'MB') as data_size,\r\nconcat(truncate(sum(max_data_length)/1024/1024,2),'MB') as max_data_size,\r\nconcat(truncate(sum(data_free)/1024/1024,2),'MB') as data_free,\r\nconcat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size\r\nfrom information_schema.tables where TABLE_SCHEMA = 'databasename';\r\n\r\n查单表:\r\nselect concat(truncate(sum(data_length)/1024/1024,2),'MB') as data_size,\r\nconcat(truncate(sum(max_data_length)/1024/1024,2),'MB') as max_data_size,\r\nconcat(truncate(sum(data_free)/1024/1024,2),'MB') as data_free,\r\nconcat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size\r\nfrom information_schema.tables where TABLE_NAME = 'tablename';", "created_at"=>2008-08-19 09:08:34 UTC, "updated_at"=>2012-06-24 15:53:13 UTC, "body_html"=>"
比如需要查询库占用的空间和索引占用的空间:
\n\n
查整个库的状态: \nselect concat(truncate(sum(data_length)/1024/1024,2),'MB') as data_size, \nconcat(truncate(sum(max_data_length)/1024/1024,2),'MB') as max_data_size, \nconcat(truncate(sum(data_free)/1024/1024,2),'MB') as data_free, \nconcat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size \nfrom information_schema.tables where TABLE_SCHEMA = 'databasename';
\n\n
查单表: \nselect concat(truncate(sum(data_length)/1024/1024,2),'MB') as data_size, \nconcat(truncate(sum(max_data_length)/1024/1024,2),'MB') as max_data_size, \nconcat(truncate(sum(data_free)/1024/1024,2),'MB') as data_free, \nconcat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size \nfrom information_schema.tables where TABLE_NAME = 'tablename';
Prawn::Document.generate(\"utf8_text_flow.pdf\") do
\r\n\t
font \"\#{Prawn::BASEDIR}/data/fonts/simfang.ttf\"
\r\n\t
text \"我是中文,还有数字+yingwen+898\"* 2
\r\n\t
text \"This is a english text, and i will be here ...\"
\r\n\t
text \"This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,\"
\r\n\t
\r\n\t
font_size!(16)
\r\n\t
text \"At size 16\"
\r\n\t
\r\n\t
font_size!(16)
\r\n\t
text \"\\nIceskYsl@1sters!\"
\r\n\t
font_size!(10)
\r\n\t
text \"不考虑安全的开发过程就是不完整的过程,而我只是个懂点安全对于互联网充满期待的程序员…\"
\r\n\t
font_size!(12)
\r\n\t
text \"更可怕的是,同质化竞争对手可以按照URL中后面这个ID来遍历您的DB中的内容,写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事,这样的话,你就非常被动了。\"
\r\n4、其他\r\n\r\n上面说的那个Bug我已经提交给作者,详细的参考这里”chinese text can not flow well “,应该很快就可以修复和完善了;\r\n\r\n让我惊奇的是其主页 上竟然有 中文版页面,难道有国人参与?\r\n\r\n其代码库在:http://github.com/sandal/prawn/tree/master\r\n\r\n5、更新\r\n\r\n上面说到的一个对中文自动换行的BUG,提交给作者后,他就修复了,现在我测试的效果非常棒,是我见过的最棒的一个PDF生成类库了,如下是效果图,可以和上面的那个比较下。\r\n\r\n", "created_at"=>2008-08-20 03:39:42 UTC, "updated_at"=>2012-06-24 15:53:13 UTC, "body_html"=>"
比较简单,详细的参考其文档,我直接贴一段我测试用的代码,如下: \n \nRuby代码 \n \n # coding: utf-8 \n \n $LOADPATH << File.join(File.dirname(FILE_), '..', 'lib') \n require "prawn" \n start = Time.now \n Prawn::Document.generate("utf8_text_flow.pdf") do \n font "\#{Prawn::BASEDIR}/data/fonts/simfang.ttf" \n text "我是中文,还有数字+yingwen+898"* 2 \n text "This is a english text, and i will be here ..." \n text "This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ,This is a long text ," \n \n font_size!(16) \n text "At size 16" \n \n font_size!(16) \n text "\\nIceskYsl@1sters!" \n font_size!(10) \n text "不考虑安全的开发过程就是不完整的过程,而我只是个懂点安全对于互联网充满期待的程序员…" \n font_size!(12) \n text "更可怕的是,同质化竞争对手可以按照URL中后面这个ID来遍历您的DB中的内容,写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事,这样的话,你就非常被动了。" \n \n \n end \n puts "Spend \#{Time.now-start}s" \n \n \n \n \n \n生成的PDF效果还是比较让人满意的,如下是效果图:
BOSS (Build your Own Search Service) is Yahoo!'s open search web services platform. The goal of BOSS is simple: to foster innovation in the search industry. Developers, start-ups, and large Internet companies can use BOSS to build and launch web-scale search products that utilize the entire Yahoo! Search index. BOSS gives you access to Yahoo!'s investments in crawling and indexing, ranking and relevancy algorithms, and powerful infrastructure. By combining your unique assets and ideas with our search technology assets, BOSS is a platform for the next generation of search innovation, serving hundreds of millions of users across the Web.
yahoo的BOSS web服务比之前Yahoo! Search API更加方便灵活,取消了诸多限制,比如检索的次数等等,其介绍如下: \nBOSS (Build your Own Search Service) is Yahoo!'s open search web services platform. The goal of BOSS is simple: to foster innovation in the search industry. Developers, start-ups, and large Internet companies can use BOSS to build and launch web-scale search products that utilize the entire Yahoo! Search index. BOSS gives you access to Yahoo!'s investments in crawling and indexing, ranking and relevancy algorithms, and powerful infrastructure. By combining your unique assets and ideas with our search technology assets, BOSS is a platform for the next generation of search innovation, serving hundreds of millions of users across the Web. \n \nJay Pignata已经用Ruby写了一个类库BOSSMan,使用非常方便,步骤如下: \n1、安装gem \n \nRuby代码 \n \n gem sources -a http://gems.github.com \n gem install jpignata-bossman \n \n \n \n2、编写代码 \n \nRuby代码 \n \n require 'rubygems' \n require 'bossman' \n include BOSSMan \n \n BOSSMan.application_id = "Your Application ID here" \n \n news = BOSSMan::Search.news("IceskYsl", 0, 3) \n news.results.each do |result| \n puts "\#{result.title} [from \#{result.source}]" \n end \n \n \n参考文档: \nBOSSMan: Build Your Own Search Engine With Yahoo And Ruby: http://www.rubyinside.com/ruby-and-yahoo-boss-with-bossman-1047.html \n插件BOSSman:http://github.com/jpignata/bossman-gem/tree/master \n看视频介绍:http://developer.yahoo.com/search/boss/
Jul 30 17:36:15 www login(pam_unix)[11819]: session opened for user siteview by (uid=0) \r\nJul 30 17:36:15 www -- siteview[11819]: LOGIN ON pts/0 BY siteview FROM 192.168.168.42 \r\nJul 30 17:36:15 www login(pam_unix)[11819]: session closed for user siteview \r\nJul 30 17:47:17 www syslogd: /var/log/secure: No space left on device \r\nJul 30 19:11:58 www PAM-securetty[1611]: Couldn't open /etc/securetty
\r\n \r\n3、修改/etc/audit/audit.conf配置文件 \r\n可以通过修改audit.conf来配置,让其自动处理 \r\n1)修改为自动删除的: \r\nnotify = \"/usr/sbin/audbin -S /var/log/audit.d/save.%u -C -T 20% -N 'rm -f %f'\"; \r\n[The notify line as above should (according to the docs) remove old 'save' files when the filesystem comes within 20% of full (change the figure after -T to specify how close to full you want to start deleting old files).] \r\n \r\n2)修改为自动备份的:(/backup 是另外您想保存数据的分区)\r\n
God是一个使用Ruby写成的用于监视任务运行状态的可扩展框架,它的配置脚本采用Ruby来编写。因此,比起它的前辈Monit,God更为简单,灵活且易于扩展(尤其对于Ruby使用者),你可以很轻易的添加一些自定义规则。 \n \nRuby代码 \n \n MINIONS = [ \n { :rails_root => "/home/mycoolapp/staging/current", \n :mongrel_ports => [4001,4002,4003,4004,4005], \n :uid => 'mycoolapp', \n :gid => 'mycoolapp', \n :pid_path => '/home/mycoolapp/staging/shared/tmp/pids' } \n ] \n \n MINIONS.each do |minion| \n minion[:mongrel_ports].each do |port| \n God.watch do |w| \n w.name = "mongrel-\#{port}" \n w.uid = minion[:uid] \n w.gid = minion[:gid] \n w.interval = 30.seconds # default \n w.start = "mongrel_rails start -c \#{minion[:rails_root]} -p \#{port} </span> \n -P \#{minion[:pid_path]}/mongrel.\#{port}.pid -e production -d" \n w.stop = "mongrel_rails stop -P \#{minion[:pid_path]}/mongrel.\#{port}.pid" \n w.restart = "mongrel_rails restart -P \#{minion[:pid_path]}/mongrel.\#{port}.pid" \n w.start_grace = 10.seconds \n w.restart_grace = 10.seconds \n w.pid_file = "\#{minion[:pid_path]}/mongrel.\#{port}.pid" \n \n w.behavior(:clean_pid_file) \n \n w.start_if do |start| \n start.condition(:process_running) do |c| \n c.interval = 5.seconds \n c.running = false \n end \n end \n \n w.restart_if do |restart| \n restart.condition(:memory_usage) do |c| \n c.above = 150.megabytes \n c.times = [3, 5] # 3 out of 5 intervals \n end \n \n restart.condition(:cpu_usage) do |c| \n c.above = 50.percent \n c.times = 5 \n end \n end \n \n # lifecycle \n w.lifecycle do |on| \n on.condition(:flapping) do |c| \n c.to_state = [:start, :restart] \n c.times = 5 \n c.within = 5.minute \n c.transition = :unmonitored \n c.retry_in = 10.minutes \n c.retry_times = 5 \n c.retry_within = 2.hours \n end \n end \n end \n end \n end \n \n \n要了解更多资料,请参考如下文档: \nhttp://god.rubyforge.org/ \nhttp://ihower.idv.tw/blog/archives/1762 \nhttp://ezinearticles.com/?Why-Rails-Developers-Need-God&id=845672; \nhttp://www.letrails.cn/archives/46
\n", "_id"=>367}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>3, "title"=>"MySQL存储引擎选择和比较", "body"=>"大家都知道MYSQL有很多的存储引擎机制,有人曾说过“多个引擎说明这是MYSQL的软肋,它不能像oracle那样搞出一个通用的”,这句话的具体意思自己揣摩,我就不瞎解读了。\r\n\r\n今天看到一篇文章,是关于其存储引擎的,虽然不长,但是写的很不错,里面有些tips值得学习,不再翻译,其原文地址为《MySQL Storage Engines》。\r\n\r\n\r\n\r\nTip: A well designed MySQL-powered application will use different storage engines for different tables. If you're still stuck with all MyISAM tables, now may be a good time to revisit.", "created_at"=>2008-08-27 06:36:06 UTC, "updated_at"=>2012-06-24 15:53:13 UTC, "body_html"=>"
Tip: A well designed MySQL-powered application will use different storage engines for different tables. If you're still stuck with all MyISAM tables, now may be a good time to revisit.
The problems with PStore are significant enough to warrant a replacement default implementation.
\r\n\t
It’s a bad idea anyway to store sensitive information (like passwords) in the session. It doesn’t matter whether the session data can be seen by the client or not, it’s something nobody should ever do.
\r\n\t
Forging session data is only possible if cracking the secret is feasible.
\r\n\r\n文中,其针对Rails的采用CookieStore机制时,其针对“449fe2e7daee471bffae2fd8dc02313d”这样一个密码是,按照其机型:\r\n“My machine, an Intel Core 2 Duo T5300, can try 285840.1 passwords per second with 2 threads.”\r\n破解下来需要的时间是:\r\n``16^32/2 / 285840.1= 5.952*10^32 seconds= 1.886*10^25 years```\r\n这是个什么概念?\r\n\r\n但是其也提到了由于Rails采用的 Ruby’s CGI::Session的session Id生成器中存在一个缺陷,导致其算法是可以被破解的,不过“Update November 28: The key generation security problem has been fixed.”已经修复了。所以,我也认为基于CookieStore的session存储机制是安全可靠的。\r\n\r\n参考:\r\n
最近在看一本《The Rails way》的书,其中关于session存贮机制一章中,对基于CookieStore的session存储机制持否定态度,认为其存在被破解和Replay attack的可能。就我了解的信息来看,这个观点是不妥的。 \n最详细的一篇文章是写的laigongli写的这篇“Rails 2.0, cookie session store and security”,文章比较长,说的很详细,感兴趣的可以过去看看。其中主要观点为: \n \n The problems with PStore are significant enough to warrant a replacement default implementation. \n It’s a bad idea anyway to store sensitive information (like passwords) in the session. It doesn’t matter whether the session data can be seen by the client or not, it’s something nobody should ever do. \n Forging session data is only possible if cracking the secret is feasible. \n \n文中,其针对Rails的采用CookieStore机制时,其针对“449fe2e7daee471bffae2fd8dc02313d”这样一个密码是,按照其机型: \n“My machine, an Intel Core 2 Duo T5300, can try 285840.1 passwords per second with 2 threads.” \n破解下来需要的时间是: \n16^32/2 / 285840.1= 5.952*10^32 seconds= 1.886*10^25 years` \n这是个什么概念?
\n\n
但是其也提到了由于Rails采用的 Ruby’s CGI::Session的session Id生成器中存在一个缺陷,导致其算法是可以被破解的,不过“Update November 28: The key generation security problem has been fixed.”已经修复了。所以,我也认为基于CookieStore的session存储机制是安全可靠的。
\n\n
参考: \n \n Rails 2.0, cookie session store and security \n BustRailsCookie.rb
\n", "_id"=>369}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Thin: A fast and very simple Ruby web server", "body"=>"知道Thin这个东西很久了,记忆中的还是下面这张和mongrel的性能比较图片,但是一直没深入进去了解其到底如何。\r\n\r\n从图上可以看到,除了总体性能好于mongrel以外,最大的区别在于其在100个并发的时候还能保证高性能,而100个并发的时候mongrel的性能非常差(且消耗很多的资源,经常由此导致请求无法处理,而出现503)。\r\n今天花了点时间,把Thin从头到尾的看了一遍,然后连到一个服务器上试验了下,总体感觉如下:\r\n
\r\n详细的测试比较,请参考“File Uploads in Merb versus Rails”这里文章,其结论差不多是这样的“Merb’s average response time is 16 ms while Rails’s average is 205 ms (over 10x faster), yet the throughput is 3000 vs 2000 req/min (only 50% greater).”,针对其throughput提高不多的情况,merb的人给出的方案是add\":use_mutex: false\"in merb.yml,其原因说因为AR是非线程安全的才需要这个选项,设置成fasle后可以大大的提高性能。\r\n\r\n参考文章:\r\n
做Rails的应该知道,在Rails中处理大文件上传是很头疼的事情,比如你允许用户上传图片,那么其有的时候分辨率高的文件有1-2M的大小,这个时候rails的上传处理是很慢的,也不难理解,看段经典的上传代码: \n \nRails代码 \n \n def upload \n File.open(RAILS_ROOT+"/uploads/\#{params[:file].original_filename}.\#{next_count}”, “w”) { |f| f.write(params[:file].read) } \n render :action => ‘index’ \n end \n \n \n加上Rails是单线程的,这个时候处理大的IO非常慢,慢的后果是什么?拖死你的服务器,比如你使用mongrel,开了10个进程在跑,这个时候,用户上传一个文件要花2分钟,就会占着这个进程不放,导致其他的请求无法响应(好怀念weblogic的队列机制),所以你的系统抛给用户的可能就是503,504之类的错误。 \n有人推荐,这个情况下可以使用merb,这东西也不会很陌生,从rails大红大紫后,其一直在后面追赶,其基本特性就是线程安全的,所以对一个请求可以多线程处理,会加快处理速度,看段类似处理上传的代码: \n \nMerb代码 \n \n def upload \n FileUtils.mv params[:file][:tempfile].path, MERB_ROOT+”/uploads/\#{params[:file][:filename]}.\#{next_count}” \n render :action => ‘index’ \n end \n \n \n详细的测试比较,请参考“File Uploads in Merb versus Rails”这里文章,其结论差不多是这样的“Merb’s average response time is 16 ms while Rails’s average is 205 ms (over 10x faster), yet the throughput is 3000 vs 2000 req/min (only 50% greater).”,针对其throughput提高不多的情况,merb的人给出的方案是add":use_mutex: false"in merb.yml,其原因说因为AR是非线程安全的才需要这个选项,设置成fasle后可以大大的提高性能。
\n\n
参考文章: \n \n File Uploads in Merb versus Rails \n [Mongrel] Uploading Large (100mb+) files \n Taking Merb for a Spin \n Uploading large files to Rails with Merb
\n", "_id"=>371}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"NeverBlock: 非常值得期待的一组类库", "body"=>"\r\nNeverBlock is a Ruby library that allows developers to write non-blocking, concurrent code in a transparent manner. Meaning that you will keep coding in your traditional ways while you get the benefit of non-blocking IO operations.\r\n\r\nRuby的伪线程,Rails的非线程安全性导致其性能始终上不去,前端时间发布的ruby1.9有多处修改,后面的Rails2.2也号称要做线程安全了,如果以上两个条件都满足,Rails的性能将得到大幅的提高。\r\n\r\n由于Rails的AR是非线程安全的,导致其IO性能不是很好,其Mysql驱动一直是单线,不能很好的提高性能,做个Oracle的应该很怀念Oracle,weblogic中的线程池,java5中的concurrent包用来写同步等处理非常方便和高效。\r\n\r\n很高兴看到Ruby世界也有类似的东西出现了,他就是NeverBlock,在其放出PostgreSQL的适配驱动后,近日有发布了针对MYSQL的版本,名字为mysqlplus,非常值得期待。\r\n\r\n另外,关于“同步、异步、阻塞和非阻塞的概念”,请参考其链接上的文章。\r\n\r\n参考文章:\r\n\r\nhttp://chinaonrails.com/topic/view/1974.html\r\n\r\nhttp://www.espace.com.eg/neverblock/blog/2008/08/28/neverblock-mysql-support/\r\n\r\nhttp://github.com/espace/mysqlplus/tree/master\r\n\r\nhttp://zhanjun.net/?q=node/7\r\n\r\n ", "created_at"=>2008-08-30 11:16:35 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
NeverBlock is a Ruby library that allows developers to write non-blocking, concurrent code in a transparent manner. Meaning that you will keep coding in your traditional ways while you get the benefit of non-blocking IO operations.
另外,还有值得期待的就是Ruby的VM是否有改善?目前的GC还是问题大大的有,内存泄露也并不稀罕,希望有新的VM出来;另外,其Ruby的一些app服务器最近好像停止不前了,自从Zed A. Shaw闹脾气后,mongrel就很少有啥更新了,其maillist也冷冷清清的。thin还好,有些小的更新,这些server要针对Rails2.2和Ruby1.9做些大动作了。
SimpleConfig looks nice, but it definitely has a few differences from Configatron. The first big difference is that SimpleConfig is limited to use with Rails. Configatron can be used with any framework, any application, and any script. Configatron also seems a bit easier to use. There are no mixins needed to use it. The configatron method lives in Kernel, which means it’s available everywhere, no ‘configuration’ needed. Different strokes, eh? There are a few other configuration systems out there, I always encourage people to check out the options before they decide on a piece of software to use.
搞Java的人应该很习惯把一些配置(数据库连接、个性化配置等)写到配置文件中,一般会使用XML或者TXT文件中,在启动的时候读取配置,初始化等等。 \nRails中也可以实现类似的功能,虽然Rails提倡“零配置”,但有的时候开发一个系统,比如Blog系统等还是需要一些个性化的配置,我们原来的实现方式是:增加一个配置文件,启动的时候读取,并保存为全局变量,用的时候直接使用。也很方便。 \n其实还可以使用插件或者gem来做,Configatron就是这么一个gem,另外还有一个插件版的SimpleConfig,两者还是有些不同的,按照Configatron 作者的说法,其不同点在于: \nSimpleConfig looks nice, but it definitely has a few differences from Configatron. The first big difference is that SimpleConfig is limited to use with Rails. Configatron can be used with any framework, any application, and any script. Configatron also seems a bit easier to use. There are no mixins needed to use it. The configatron method lives in Kernel, which means it’s available everywhere, no ‘configuration’ needed. Different strokes, eh? There are a few other configuration systems out there, I always encourage people to check out the options before they decide on a piece of software to use. \n其实我们自己也可以写,只是没有必要再搞一套,功能上来说,上述这两个足够了,下面简单的看看Configatron 的用法: \n1、安装 \n$ sudo gem install configatron \n2、定义(支持namespace) \n \nRuby代码 \n \n configatron do |config| \n config.website_url = "http://www.1sters.com" \n config.namespace(:mems) do |mem| \n email.namespace(:iceskysl) do |iceskysl| \n iceskysl.email = "iceskysl@1sters.com" \n pop.blog_url = "http://iceskysl.1sters.com" \n # etc ... \n end \n email.namespace(:shine) do |shine| \n smtp.email = "shine@1sters.com" \n smtp.blog_url = "http://shine.1sters.com" \n # etc ... \n end \n end \n # etc... \n end \n \n \n3、使用 \n \nRuby代码 \n \n configatron.mems.iceskysl.email # => "iceskysl@1sters.com" \n configatron.mems.shine.blog_url # => "http://shine.1sters.com" \n configatron.website_url # => "http://www.1sters.com" \n \n \n4、重写 \n \nRuby代码 \n \n configatron do |config| \n config.website_url = "http://www.1sters.com/index" \n end \n \n \nPS: \n如果你是在自己的Rails里使用,可能simpleconfig会更加适合你,请参考其链接上的Readme。
Log4r is a comprehensive and flexible logging library written in Ruby for use in Ruby programs. It features a hierarchical logging system of any number of levels, custom level names, logger inheritance, multiple output destinations, execution tracing, custom formatting, thread safteyness, XML and YAML configuration, and more.
\r\n但是其从March 2004开始到现在都没人有维护和更新,看来需要寻找新的解决方案了。\r\n2、Logging\r\nLogging is a flexible logging library for use in Ruby programs based on the design of Java‘s log4j library. It features a hierarchical logging system, custom level names, multiple output destinations per log event, custom formatting, and more.\r\n关于Logging的详细API可以参考其doc文档,其详细的用法和注意事项,可以参考“HowtoConfigureLogging”,下面看个例子:\r\n
\r\n
Ruby代码
\r\n\r\n\t
require 'logging'
\r\n\t
\r\n\t
logger = Logging::Logger['example_logger']
\r\n\t
logger.add_appenders(
\r\n\t
Logging::Appender.stdout,
\r\n\t
Logging::Appenders::File.new('example.log')
\r\n\t
)
\r\n\t
logger.level = :info
\r\n\t
\r\n\t
logger.debug \"this debug message will not be output by the logger\"
Rail本身自带的logger虽然好用,但是还是有点太简易了,针对一些特殊的业务需求(比如需要记录一些业务日志供后续的报表系统分析、解析等)就显得有点力不从心了。这个时候可以找找其他的替代品。 \n1、log4r \n做java的应该对这样的名字相当熟悉,大名鼎鼎的log4j在java的世界里非常流行和实用,看这个log4r的名字就可以感受到其强大的功能。 \nLog4r is a comprehensive and flexible logging library written in Ruby for use in Ruby programs. It features a hierarchical logging system of any number of levels, custom level names, logger inheritance, multiple output destinations, execution tracing, custom formatting, thread safteyness, XML and YAML configuration, and more. \n但是截至到目前为止的其log4r-1.0.5版本中和Rails2的版本还存在一个冲突,详细的可以参考“Ticket #3512” (reopened defect)。 \nActionView::TemplateError (Expected kind of Outputter, got NilClass) c:/ruby/lib/ruby/gems/1.8/gems/log4r-1.0.5/src/log4r/logger.rb:115:in each' c:/ruby/lib/ruby/gems/1.8/gems/log4r-1.0.5/src/log4r/logger.rb:115:inadd' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:30:in benchmark' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/partials.rb:57:inrender_partial' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/base.rb:230:in `render' \n但是其从March 2004开始到现在都没人有维护和更新,看来需要寻找新的解决方案了。 \n2、Logging \nLogging is a flexible logging library for use in Ruby programs based on the design of Java‘s log4j library. It features a hierarchical logging system, custom level names, multiple output destinations per log event, custom formatting, and more. \n关于Logging的详细API可以参考其doc文档,其详细的用法和注意事项,可以参考“HowtoConfigureLogging”,下面看个例子: \n \nRuby代码 \n \n require 'logging' \n \n logger = Logging::Logger['example_logger'] \n logger.add_appenders( \n Logging::Appender.stdout, \n Logging::Appenders::File.new('example.log') \n ) \n logger.level = :info \n \n logger.debug "this debug message will not be output by the logger" \n logger.info "just some friendly advice" \n \n \n参考文章: \nhttp://wiki.rubyonrails.org/rails/pages/HowtoConfigureLogging \nhttp://logging.rubyforge.org/ \nhttp://log4r.sourceforge.net/index.html \nhttp://007surfing.com/index.php?hl=f5&q=uggc%3A%2F%2Fapupenvyf.oybtfcbg.pbz%2F2007%2F04%2Fybt.ugzy;
如果能把三种消息自动区分,使用各种的样式表,该多方便!确实,已经有人这么做了, Robby给出了一个plugin,“Flash Message Conductor”,看其介绍: \n``A simple pattern for managing flash messages in your Ruby on Rails application.
前面写过一篇《NeverBlock: 非常值得期待的一组类库》,其中说到了采用NeverBlock的non-blocking, concurrent机制,可以很大程度上提高mysql或者PostgreSQL的使用率,很多限度的提高性能。 \n但是没有给出具体的对比测试数据,今天看到有个哥们已经使用Thin,Rails和PostgreSQL做了一次对比测试,相关环境如下: \n \n服务器配置 \n \n 1 - 1 Thin server, normal postgreSQL Adapter \n 2 - 2 Thin servers (behind nginx), normal postgreSQL Adapter \n 3 - 4 Thin servers (behind nginx), normal postgreSQL Adapter \n 4 - 1 Thin server, neverblock postgreSQL Adapter \n \n \n \n压力配置 \n \n 1 - Very light work load, every 200 requests, one "select sleep(1)" would be issued \n 2 - Light work load, every 100 requests, one "select sleep(1)" would be issued \n 3 - Moderate work load, every 50 requests, one "select sleep(1)" would be issued \n 4 - Heavy work load, every 20 requests, one "select sleep(1)" would be issued \n 5 - Very heavy work load, every 10 requests, one "select sleep(1)" would be issued \n \n \n其结果对比如下:
前面有篇文章介绍了NeverBlock,其一篇是关于NeverBlock 原理介绍的,另外一篇是在ruby1.9下做的对比测试,当时我们说:接下来,,需要等待Ruby1.9和Rails2.2的到来,加上如上的测试对比,可以想象得到,Rails的性能会上很大一个台阶的。现在有个好消息是,NeverBlock支持了Ruby1.8(通过一些手法),这次看到其更新的特性如下: \n \n NeverBlock now supports Ruby1.8. \n NeverBlock support for Thin and Mongrel servers. \n NeverBlock now supports Ruby on Rails.on \n \n也就是说,现在NeverBlock支持Ruby1.8,支持Thin和mongrel服务器,另外支持Rails,测试方法很简单: \n1、安装需要的额外的系统类库 \n \nShell代码 \n \n apt-get install libmysql++-dev \n \n \n \n2、安装需要的gems \n下载这几个包,NeverBlock (zip|tar.gz), Mysqlplus (zip|tar.gz), EventMachine (zip|tar.gz), \n然后解压各自包;tar -zxvf (respective file name).tar.gz \n然后CD到各自目录中build成gem;gem build (respective file name).gemspec \n最后gen install;gem install (generated file name).gem \n3、修改environment.rb \nrequire 'never_block/frameworks/rails' \nrequire 'never_block/servers/thin'(如果是mongrel,则require 'never_block/servers/mongrel') \n4、修改database.yml \nadapter: neverblock_mysql (如果是postgresql,则为 adapter: neverblock_postgresql ) \nconnections: 12 # will spawn 12 connections instead of the defualt 4 #连接数 \n5、重启thin(mongrel即可)
\n\n
以上步骤没有问题,我已经测试过了。
\n\n
下面附几个别人做的对比测试: \n \n测试环境如下: \n \n Rails 2.1 \n Thin 0.82 \n Ruby 1.8.6 \n MySQL 5.0 \n A special build of EventMachine 0.12 \n \n \n \n系统负载构造: \n \n 1 - Moderate work load, one slow request for every 050 requests \n 2 - Heavy work load, one slow request for every 020 requests \n 3 - Very heavy work load, one slow request for every 010 requests \n \n \n \n结果如下:
\r\n详细参考:What's New in Edge Rails: Shallow Routes\r\n\r\n2、Mailer Layouts\r\n在Rails2.2中将加入Mailer布局模板,就像view-template一样,每个mailer可以有一个模板,其默认的是mailer加上_mailer后缀,比如下面:\r\n
\r\n参考:What's New in Edge Rails: Mailer Layouts\r\n\r\n3、Connection Pools\r\n前面说过,在Rails2.2中将会实现线程安全,如此以来,连接池的实现也就不在话下了,在Rails2.2中将增加连接池的特性,使用方法非常简单,直接在database.yml配置即可,如下:\r\n
\r\n``1sters@iceskysl:~> gnuplotset terminal pngset output \"http_benchmark.png\"set xlabel \"request\"set ylabel \"ms\"plot \"http_benchmark.txt\" using 7 with lines title \"ctime\", \\ \"http_benchmark.txt\" using 8 with lines title \"dtime\", \\ \"http_benchmark.txt\" using 9 with lines title \"ttime\", \\\"http_benchmark.txt\" using 10 with lines title \"wait\"\r\n\r\n结果类似:```\r\n\r\n
Apache的AB可以用来做一些性能测试,使用-g参数其结果可以输出到文件,然后使用gnuplot可以绘制相关图片,以更直观的显示。 \n \nab -h \n \n $ ab -h \n Usage: ab [options] [http://]hostname[:port]/path \n Options are: \n -n requests Number of requests to perform \n -c concurrency Number of multiple requests to make \n -t timelimit Seconds to max. wait for responses \n -p postfile File containing data to POST \n -T content-type Content-type header for POSTing \n -v verbosity How much troubleshooting info to print \n -w Print out results in HTML tables \n -i Use HEAD instead of GET \n -x attributes String to insert as table attributes \n -y attributes String to insert as tr attributes \n -z attributes String to insert as td or th attributes \n -C attribute Add cookie, eg. 'Apache=1234. (repeatable) \n -H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip' \n Inserted after all normal header lines. (repeatable) \n -A attribute Add Basic WWW Authentication, the attributes \n are a colon separated username and password. \n -P attribute Add Basic Proxy Authentication, the attributes \n are a colon separated username and password. \n -X proxy:port Proxyserver and port number to use \n -V Print version number and exit \n -k Use HTTP KeepAlive feature \n -d Do not show percentiles served table. \n -S Do not show confidence estimators and warnings. \n -g filename Output collected data to gnuplot format file. \n -e filename Output CSV file with percentages served \n -h Display usage information (this message) \n \n \n \n$ab -g http_benchmark.txt -n 1000 -c 100 http://1stlog.1sters.com/ \n \n \nhttp_benchmark.txt \n \n $ more http_benchmark.txt \n starttime seconds ctime dtime ttime wait \n Mon Sep 08 11:15:52 2008 1220843752427648 516 94524 95040 94521 \n Mon Sep 08 11:15:52 2008 1220843752944235 525 94500 95025 93995 \n Mon Sep 08 11:15:53 2008 1220843753469652 520 94491 95011 93475 \n Mon Sep 08 11:15:53 2008 1220843753990129 514 94478 94992 92960 \n Mon Sep 08 11:15:54 2008 1220843754505018 511 94471 94982 92449 \n Mon Sep 08 11:15:55 2008 1220843755016428 523 100439 100962 91925 \n \n \n \n \n``1sters@iceskysl:~> gnuplotset terminal pngset output "http_benchmark.png"set xlabel "request"set ylabel "ms"plot "http_benchmark.txt" using 7 with lines title "ctime", \\ "http_benchmark.txt" using 8 with lines title "dtime", \\ "http_benchmark.txt" using 9 with lines title "ttime", \\"http_benchmark.txt" using 10 with lines title "wait"
比如你的程序中写了这么一条语句:User.find(:all, :limit => params[:limit]),那么我们就可以构造这个params[:limit]为: "1 UNION (select 1,2,password,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,0 from users)",这句话什么意思?放到前面那个find后,就形成这样的语句: \n \nSQL代码 \n \n select * from users limit 1 UNION (select 1,username,password,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,0 from users) \n \n \n怎样?很邪恶吧,了解点安全的朋友都能看明白,不了解的我说半天还不如你去google下什么是union注射,呵呵。
\n\n
没升级到2.1.1的赶快升级或者按照如下方式修复吧,否则就有危险了。 \n \n Review your application whether you allow the user to control :limit or :offset \n If you are on Rails 2.1.0, please apply this patch or get Rails 2.1.1 \n If you are on the Rails 2.0 or 1.2 branch, apply this backport patch \n \n参考文档:http://www.rorsecurity.info/2008/09/08/sql-injection-issue-in-limit-and-offset-parameter/
\n", "_id"=>390}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"[Tips]自动填充测试需要的随机数据", "body"=>"经常遇到一些新功能开发完了,需要测试一些指标,比如性能测试等等,这个时候如果人工填充数据会非常囧的,你可以写rake来自己构造填充数据,你需要处理随机产生等情况,现在不必费心了,使用Faker Gem和populator可以快速的构造需要的数据。\r\n\r\nFaker\r\nA port of Perl‘s Data::Faker library that generates fake data.\r\n\r\nPopulator\r\nPopulate an Active Record database with mass insert.\r\n\r\n安装需要的gem:\r\n
Usage : haproxy -f <cfgfile> [ -vdVD ] [ -n <maxconn> ] [ -N <maxpconn> ] \n[ -p <pidfile> ] [ -m <max megs> ] \n-v displays version ; -vv shows known build options. \n-d enters debug mode ; -db only disables background mode. \n-V enters verbose mode (disables quiet mode) \n-D goes daemon ; implies -q \n-q quiet mode : don't display messages \n-c check mode : only check config file and exit \n-n sets the maximum total # of connections (2000) \n-m limits the usable amount of memory (in MB) \n-N sets the default, per-proxy maximum # of connections (2000) \n-p writes pids of all children to this file \n-de disables epoll() usage even when available \n-ds disables speculative epoll() usage even when available \n-dp disables poll() usage even when available \n-sf/-st [pid ]* finishes/terminates old pids. Must be last arguments.
晓得TDD,BDD,RSpec这些东西很久了,也看了不少的资料和教程,但总感觉还在门外徘徊,始终不得其要,真是怪异。应该是没在实际项目中实践过的缘故吧。 \n本文记录一些RSpec和BDD(Behaviour Driven Development )的资料和文档,给我自己也给各位路过者提供一些资料,感兴趣的仔细看看吧。 \n \n http://rspec.info/ \n Telling a good story - Rspec stories from the trenches \n Slides from RailsConf \n rspec plain text stories + webrat = chunky bacon! \n http://chinaonrails.com/topic/view/220.html \n Story Driven Development with Rails - Part I: Up and Running \n \n另外,http://rspec.info/documentation/rails/上的资料非常棒。有路过的,玩BDD的朋友还望多多指教,领我进门,多谢!
很早前我就说自我的blackberry8100跌坏以后,就一直没买手机,一直在正Google Android的发布,昨天早上(22号)看到chinaeconomicreview上的“T-Mobile’s Google phone on its way”,按照那个里面的图片,觉得非常不爽,整就一黑莓的造型嘛。于是打算入手黑莓8110.
\n", "_id"=>410}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>9, "title"=>"在Startups时就考虑Scalability", "body"=>"一般说来,项目初期的时候考虑更多的是功能的实现和可用性,而对Scalability考虑的并不是很多,从很多人的Scalability经验分享来看,大家比较认同的一条Scalability路线是基本上类似于:先DB和web server在一台机器上,再分割DB和web server,再集群,再cache,再系统分割,再水平、垂直扩展这样的路线。\r\n\r\n我一直不是很同意这个模式,因为当你有志把系统做大道一定规模的时候,为什么不先做一些Scalability的基础呢,比如功能的切割、子系统的划分等等,为什么非要等到系统压力上来了,再手忙脚乱的去重新规划呢。\r\n\r\n之所以这么说,是因为我做的项目预先会考虑好系统划分,做好接口定义,把不同的功能分割在封装成不同的子系统,子系统和子系统之间通过接口传递消息,而后期的Scalability则可以针对不同的子系统需要灵活选择,比如有的子系统需要较多的内存,而有的子系统CPU吃紧等等。\r\n\r\n今天看到Frank Mashraqi(Director of Business Operations & Technical Strategy for a top 50 website that delivers billions of page views per month.)写了一篇文章“Scalability for Startups: How to Grow Up without Blowing Up”,其“12 Tips for Building a Scalable Startup”列举了一些在Startups时就应该考虑的Scalability因素,值得阅读。其还有一个Doc版本,更加生动的说明了一些东西。\r\n\r\n如果你有类似的经验,欢迎和我讨论和分享。", "created_at"=>2008-10-07 02:28:16 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
今天看到Frank Mashraqi(Director of Business Operations & Technical Strategy for a top 50 website that delivers billions of page views per month.)写了一篇文章“Scalability for Startups: How to Grow Up without Blowing Up”,其“12 Tips for Building a Scalable Startup”列举了一些在Startups时就应该考虑的Scalability因素,值得阅读。其还有一个Doc版本,更加生动的说明了一些东西。
\n\n
如果你有类似的经验,欢迎和我讨论和分享。
\n", "_id"=>411}])
+MONGODB iceylog_development['categories'].find({:_id=>9}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>9}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>3, "title"=>"为Mysql选择更加合适的硬件环境", "body"=>"记得前段时间,博文的一个朋友做一本Mysql技术书籍时,将其策划的大纲给我看,我提出让他增加一章关于Mysql硬件选择的内容,因为Mysql的性能受硬件影响很大,如何选择一套比较合适的硬件环境相当重要,自然,他接受了我的建议。\r\n只是不知道他策划的这本书何时才能编写完成,不过在2008 MySQL Conference & Expo上,确实看到一篇“Scaling Out MySQL: Hardware Today and Tomorrow”,其Doc已经可以在scribd上看到了,嵌到这里。\r\n\r\n\r\n
记得前段时间,博文的一个朋友做一本Mysql技术书籍时,将其策划的大纲给我看,我提出让他增加一章关于Mysql硬件选择的内容,因为Mysql的性能受硬件影响很大,如何选择一套比较合适的硬件环境相当重要,自然,他接受了我的建议。 \n只是不知道他策划的这本书何时才能编写完成,不过在2008 MySQL Conference & Expo上,确实看到一篇“Scaling Out MySQL: Hardware Today and Tomorrow”,其Doc已经可以在scribd上看到了,嵌到这里。
\n\n
Scaling out MySQL - Hardware today and tomorrow - Upload a Document to Scribd \n其内容大致涉及到CPU,Mem,vendor,storage等方面的选择,摘取几条如下: \n \n CPU还是选64位的吧(为了支持更大的内存),Mysql在多核CPU上有些问题; \n 内存越大越好,反正很便宜,但是关于内存的配置使用还是很有学问的; \n 硬盘最后是选择15K而不是10K的,在这上面多花点钱是非常值得的; \n \n其他的大家看Doc里面的总结吧,总结好了别忘记share给我哈。
\n", "_id"=>412}])
+MONGODB iceylog_development['categories'].find({:_id=>3}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>3}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Thin"], "comments_count"=>0, "category_id"=>6, "title"=>"Thin version 1.0.0 is out!", "body"=>"Thin version 1.0.0 (codename That's What She Said) is out!\r\n\r\nYes 1.0! That doesn't mean it's bug free or anything. But, it does\r\nmean that it's been running on a number of servers and no show stopper\r\nbugs have been found since a while.\r\n\r\nAlso see http://macournoyer.wordpress.com/2008/09/30/thin-10/\r\n\r\n== What's new?\r\n\r\n* Fixed vlad.rake to allow TCP or socket [hellekin]\r\n* Updated Mack adapter to handle both <0.8.0 and >0.8.0 [Mark Bates]\r\n* rails rack adapter uses File.readable_real? so it recognizes ACL\r\npermissions [Ricardo Chimal]\r\n* Log a warning if Rack application returns nil body [Michael S.\r\nKlishin]\r\n* Handle nil and Time header values correctly [#76 state:resolved]\r\n[tmm1]\r\n* Add Content-Length header to response automatically when possible\r\n[#74 state:resolved] [dkubb]\r\n* Runner now remembers -r, -D and -V parameters so that clustered\r\nservers inherit those and\r\nkeep your parameters.\r\n* Make Set-Cookie header, in Rails adapter, compatible with current\r\nRack spec [Pedro Belo]\r\n[#73, state:resolved]\r\n* Add --no-epoll option to disable epoll usage on Linux [#61\r\nstate:resolved]\r\n* Add --force (-f) option to force stopping of a daemonized server\r\n[#72 state:resolved]\r\n* Update halycon adapter loader [mtodd]\r\n\r\n== Get it!\r\n\r\nInstall Thin from RubyForge:\r\n\r\ngem install thin\r\n\r\nOr using my mirror:\r\n\r\ngem install thin --source http://code.macournoyer.com\r\n\r\n参考文档:\r\nhttp://groups.google.com/group/thin-ruby/browse_thread/thread/402d51a6d9f2651d", "created_at"=>2008-10-07 09:56:27 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
Thin version 1.0.0 (codename That's What She Said) is out!
\n\n
Yes 1.0! That doesn't mean it's bug free or anything. But, it does \nmean that it's been running on a number of servers and no show stopper \nbugs have been found since a while.
\n", "_id"=>413}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"7 Top Tips for Coding With Currency", "body"=>"As anyone who’s ever made an e-commerce system knows, money is everything. No, really if you don’t get your financial sums right then you can’t hope to build a successful online business (and may find yourself creating potential legal issues with the tax man).\r\n\r\nSo here’s a rundown of the top tips I can give for making your financial calculations that bit easier.\r\n\r\nhttp://www.setfiremedia.com/blog/7-top-tips-for-coding-with-currency", "created_at"=>2008-10-08 09:05:08 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
As anyone who’s ever made an e-commerce system knows, money is everything. No, really if you don’t get your financial sums right then you can’t hope to build a successful online business (and may find yourself creating potential legal issues with the tax man).
\n\n
So here’s a rundown of the top tips I can give for making your financial calculations that bit easier.
Search directory arguments recursively for files to convert.
\r\n\t
-d or --delete
\r\n\t
delete input files after successful conversion. May not be safe yet!!!
\r\n\t
-v or --verbose
\r\n\t
makes sneetchalizer more chatty.
\r\n\t
-s or --show-output
\r\n\t
shows output from conversion tool.
\r\n\t
-p or --pretend
\r\n\t
don't convert anything. sneetchalizer will go through the motions and print out the commands it would run. Useful for preview- ing a complex command line to ensure it does what you intend. You should interpret this option's output with a grain of salt. For example, if you include the '--sanitize' option, the files will not really be renamed when using --pretend, and as such the command's output will not reflect that the filenames would be changed during an actual run.
\r\n\t
-t or --terminate
\r\n\t
terminate sneetchalizer options. This is useful if you have to convert '--coolDir' or '-groovySong.mp3'. This is the only option whose order on the command line is significant.
\r\n\t
-D ARG or --out-directory=ARG
\r\n\t
write all outfiles to a directory argument. This is useful if you want to (re)encode files directly to a mounted portable device.
\r\n\t
--strict and --pedantic
\r\n\t
many errors that sneetchalizer may encounter are recoverable, such as specifying a directory as argument that contains no files to convert, or conversion failures in general. By default the script will print an error message and move on to the next file. If you use '--strict' then sneetchalizer will bail out at the first sign of trouble except for tag errors. With '--pedantic' the script will stop even on tag errors.
\r\n\t
--stasis
\r\n\t
Preserve timestamp (mtime) of original file.
\r\n\t
--threads [N]
\r\n\t
Experimental. Use threads to create concurrent jobs. This option takes an optional integer argument which represents the number of threads to launch. The default is two. Preliminary tests suggest there is little advantage (and even diminishing returns) when setting this number greater than the number of cores/CPUs you have. Due to the asychronous nature of threads the --verbose and --show-output flags will be silently disabled and most screen output is supressed.
\r\n\t
--sanitize
\r\n\t
Removes ,, ;, :, ', \", %, @, #, and ` from filenames and tags.
\r\n\t
-n [FORMAT] or --rename[=FORMAT]
\r\n\t
rename all outfiles (and temporary wavs) according to FORMAT. FORMAT is a string with special designators to be pulled from the file tags. The following options are available:
\r\n\t
\r\n\t
* %t Song title
\r\n\t
* %b Album title
\r\n\t
* %n Track number
\r\n\t
* %a Artist name
\r\n\t
* %y Year
\r\n\t
* %g Genre
\r\n\t
* %c Comment field
\r\n\t
\r\n\t
Directories may be created with this command, as in \"%b/%n - %t\". The default value of FORMAT is \"%n %t\".
\r\n\t
\r\n\t
Bitrate/Quality/Compression options:
\r\n\t
\r\n\t
-b or --bitrate
\r\n\t
mp3/ogg/m4a bitrate.
\r\n\t
-q or --quality
\r\n\t
mp3/ogg quality.
\r\n\t
\r\n\t
quality and bitrate are passed directly to lame or oggenc depending on mp3 or ogg output format respectively. Both tools can handle either a bitrate or quality argument, so it is important to understand what values are valid for the underlying tool in your specific use case. faac will accept a bitrate argument, but not a quality argument. These options will be silently ignored for any output formats other than mp3, ogg or m4a. Make sure you know what you are doing if you decide to use both in one run, and read each tools manpage for valid values. If these options are omitted the tools builtin defaults are used (-q3 for oggenc and -q5 for lame).
\r\n\t
\r\n\t
-c or --compression
\r\n\t
flac/mac compression level.
\r\n\t
\r\n\t
this option allows you to pass a compression argument to flac and mac. See 'flac --help' and/or 'mac --help' if you don't know what this means.
\r\n\t
\r\n\t
Format Options:
\r\n\t
\r\n\t
--out=format
\r\n\t
output format. Default is wav.
\r\n\t
--in=format[,format..]
\r\n\t
input format(s). Default is wav.
\r\n\t
\r\n\t
Valid output formats are: \"aac\", \"aif\", \"aifc\", \"aiff\", \"aiffc\", \"ape\", \"au\", \"cdr\", \"cdda\", \"copy\", \"flac\", \"m4a\", \"m4b\", \"mpc\", \"mp4\", \"mpp\", \"mp3\", \"mp2\", \"ofr\", \"ofs\", \"ogg\", \"snd\", \"spx\", \"tta\", \"wav\", \"wv\". Valid input formats are all of the above plus \"wma\". You can specify multiple input formats using a comma: 'mp3,m4a,wma'. Input format is only neccesary when passing directory arguments, as file arguments are handled by context (read: file extension). The \"copy\" output option copies files directly, bypassing decoding/encoding steps (useful in conjunction with --rename).
\r\n\t
\r\n\t
Tagging Options:
\r\n\t
\r\n\t
--tt or --title
\r\n\t
Set 'title' tag.
\r\n\t
--ta or --artist
\r\n\t
Set 'artist' tag.
\r\n\t
--tl or --album
\r\n\t
Set 'album' tag.
\r\n\t
--ty or --year
\r\n\t
Set 'year' tag.
\r\n\t
--tc or --comment
\r\n\t
Set 'comment' tag.
\r\n\t
--tg or --genre
\r\n\t
Set 'genre' tag.
\r\n\t
--tn or --trackn
\r\n\t
Set 'track number' tag.
\r\n\t
\r\n\t
The short and long versions are different in an important way: Using the long version will clobber any existing tags. The short version will only set the tag if the existing tag has no value. Note that these tags will be placed in _every_ outfile during the run.
\r\n\t
\r\n\t
Alternative Encoder/Decoder Options:
\r\n\t
\r\n\t
--gogo
\r\n\t
use gogo to encode mp3 files.
\r\n\t
--bladeenc
\r\n\t
use bladeenc to encode mp3 files.
\r\n\t
\r\n\t
The default is still 'lame'. If 'lame' is not found, the script will search for one of these two encoders regardless if these options are passed or not.
\r\n\t
\r\n\t
Special Options:
\r\n\t
\r\n\t
--in-optionhook=ARG
\r\n\t
add ARG to infile conversion command. Possibly dangerous!
\r\n\t
--out-optionhook=ARG
\r\n\t
add ARG to outfile conversion command. Possibly dangerous!
Using the same --in and --out format allows us to resample/encode the file at a different bitrate or quality. Note that this will overwrite the original file so only do this on a copy, or use '-D' to write files to another directory.
直接下载其gz包,sneetchalizer-0.9.0是现在的最新版本。下载解包后可以看到: \n \nManifest: \n \n README - You're reading it now. \n LICENSE - A copy of the GPL, under which sneetchalizer is released. \n CHANGES - sneetchalizer's cvs/svn commit log. \n sneetchalizer - The script itself. \n sneetchalizer.1 - The manpage for sneetchalizer. \n sneetchalizer.desktop - A KDE service menu for converting with Konqueror. \n install.rb - A quick and dirty script to install the sneetchalizer. \n \n \n如果有root权限,可以直接运行install.rb,其会将sneetchalizer拷贝到/usr/bin下,将sneetchalizer.1拷贝到/usr/share/man/man1下。
\n\n
2、参数解释
\n\n
不翻译了,都挺简单明了的,如下: \n \nXML/HTML代码 \n \n General options: \n \n -h or --help \n Print quick or full usage details respectively. \n -r or --recursive \n Search directory arguments recursively for files to convert. \n -d or --delete \n delete input files after successful conversion. May not be safe yet!!! \n -v or --verbose \n makes sneetchalizer more chatty. \n -s or --show-output \n shows output from conversion tool. \n -p or --pretend \n don't convert anything. sneetchalizer will go through the motions and print out the commands it would run. Useful for preview- ing a complex command line to ensure it does what you intend. You should interpret this option's output with a grain of salt. For example, if you include the '--sanitize' option, the files will not really be renamed when using --pretend, and as such the command's output will not reflect that the filenames would be changed during an actual run. \n -t or --terminate \n terminate sneetchalizer options. This is useful if you have to convert '--coolDir' or '-groovySong.mp3'. This is the only option whose order on the command line is significant. \n -D ARG or --out-directory=ARG \n write all outfiles to a directory argument. This is useful if you want to (re)encode files directly to a mounted portable device. \n --strict and --pedantic \n many errors that sneetchalizer may encounter are recoverable, such as specifying a directory as argument that contains no files to convert, or conversion failures in general. By default the script will print an error message and move on to the next file. If you use '--strict' then sneetchalizer will bail out at the first sign of trouble except for tag errors. With '--pedantic' the script will stop even on tag errors. \n --stasis \n Preserve timestamp (mtime) of original file. \n --threads [N] \n Experimental. Use threads to create concurrent jobs. This option takes an optional integer argument which represents the number of threads to launch. The default is two. Preliminary tests suggest there is little advantage (and even diminishing returns) when setting this number greater than the number of cores/CPUs you have. Due to the asychronous nature of threads the --verbose and --show-output flags will be silently disabled and most screen output is supressed. \n --sanitize \n Removes ,, ;, :, ', ", %, @, #, and ` from filenames and tags. \n -n [FORMAT] or --rename[=FORMAT] \n rename all outfiles (and temporary wavs) according to FORMAT. FORMAT is a string with special designators to be pulled from the file tags. The following options are available: \n \n * %t Song title \n * %b Album title \n * %n Track number \n * %a Artist name \n * %y Year \n * %g Genre \n * %c Comment field \n \n Directories may be created with this command, as in "%b/%n - %t". The default value of FORMAT is "%n %t". \n \n Bitrate/Quality/Compression options: \n \n -b or --bitrate \n mp3/ogg/m4a bitrate. \n -q or --quality \n mp3/ogg quality. \n \n quality and bitrate are passed directly to lame or oggenc depending on mp3 or ogg output format respectively. Both tools can handle either a bitrate or quality argument, so it is important to understand what values are valid for the underlying tool in your specific use case. faac will accept a bitrate argument, but not a quality argument. These options will be silently ignored for any output formats other than mp3, ogg or m4a. Make sure you know what you are doing if you decide to use both in one run, and read each tools manpage for valid values. If these options are omitted the tools builtin defaults are used (-q3 for oggenc and -q5 for lame). \n \n -c or --compression \n flac/mac compression level. \n \n this option allows you to pass a compression argument to flac and mac. See 'flac --help' and/or 'mac --help' if you don't know what this means. \n \n Format Options: \n \n --out=format \n output format. Default is wav. \n --in=format[,format..] \n input format(s). Default is wav. \n \n Valid output formats are: "aac", "aif", "aifc", "aiff", "aiffc", "ape", "au", "cdr", "cdda", "copy", "flac", "m4a", "m4b", "mpc", "mp4", "mpp", "mp3", "mp2", "ofr", "ofs", "ogg", "snd", "spx", "tta", "wav", "wv". Valid input formats are all of the above plus "wma". You can specify multiple input formats using a comma: 'mp3,m4a,wma'. Input format is only neccesary when passing directory arguments, as file arguments are handled by context (read: file extension). The "copy" output option copies files directly, bypassing decoding/encoding steps (useful in conjunction with --rename). \n \n Tagging Options: \n \n --tt or --title \n Set 'title' tag. \n --ta or --artist \n Set 'artist' tag. \n --tl or --album \n Set 'album' tag. \n --ty or --year \n Set 'year' tag. \n --tc or --comment \n Set 'comment' tag. \n --tg or --genre \n Set 'genre' tag. \n --tn or --trackn \n Set 'track number' tag. \n \n The short and long versions are different in an important way: Using the long version will clobber any existing tags. The short version will only set the tag if the existing tag has no value. Note that these tags will be placed in _every_ outfile during the run. \n \n Alternative Encoder/Decoder Options: \n \n --gogo \n use gogo to encode mp3 files. \n --bladeenc \n use bladeenc to encode mp3 files. \n \n The default is still 'lame'. If 'lame' is not found, the script will search for one of these two encoders regardless if these options are passed or not. \n \n Special Options: \n \n --in-optionhook=ARG \n add ARG to infile conversion command. Possibly dangerous! \n --out-optionhook=ARG \n add ARG to outfile conversion command. Possibly dangerous! \n \n \n另外,你可以运行sneetchalizer -h看到简要的使用说明,也可以使用sneetchalizer --help看到详细的使用信息。
\n\n
3、使用示例
\n\n
如下简要的写几个使用的示例: \n \n使用示例: \n \n $ sneetchalizer song.mp3 \n \n The most simple possible example, creates 'song.wav'. \n \n $ sneetchalizer --out=ogg --in=flac -q5 /some/music/dir \n \n This example converts every flac file in '/some/music/dir' to ogg format at quality 5. \n \n $ sneetchalizer -d --out=mp3 --in=ogg,m4a,wma -b 160 . \n \n Converts every ogg, m4a, and wma file in the current directory to a 160 kbps constant bitrate mp3 file. The original files are deleted. \n \n $ sneetchalizer --out=mp3 --out-optionhook="--preset extreme" /some/wavs \n \n Here we encode every wav in '/some/wavs' to mp3 format passing '--preset extreme' directly to lame. \n \n $ sneetchalizer --in=ogg --out=ogg --quality=1 norvegianWood.ogg /some/more/oggs \n \n Using the same --in and --out format allows us to resample/encode the file at a different bitrate or quality. Note that this will overwrite the original file so only do this on a copy, or use '-D' to write files to another directory. \n \n $ sneetchalizer --in=ogg --out=m4a -D /mnt/ipod/ /some/oggs \n \n Here we re-encode some ogg files to m4a format and write them to our mounted iPod. \n \n \n4、注意事项
\n\n
本脚本只是粘合剂,其他的tool还是需要另外安装的。
\n\n
其他信息请参考其主页说明,如果您有这个方面的问题或经验,欢迎和我讨论。
\n\n\n
\n", "_id"=>415}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["架构"], "comments_count"=>0, "category_id"=>9, "title"=>"网站架构文章列表(持续更新中)", "body"=>"互联网越来越开放,技术人员也越来越乐于分享,分析构架、演变和遇到的问题,虽然说没有真正经历过,很多体验可能会没那么深,但是有些东西提前了解会有诸多好处。在很多地方看到类似的构架分析、分享的文章,统一收集整理如下,遇到其他的,我会持续更新,如果经历允许,我还会写一些读后感或者点评;如果你看到其他的类似文章或者点评,欢迎留言让我知道。\n\n对dbanotes等表示感谢。\n\nWikiPedia 技术架构学习分享\nhttp://www.dbanotes.net/opensource/wikipedia_arch.html\n\nYouTube 的架构扩展\nhttp://www.dbanotes.net/opensource/youtube_web_arch.html\n\nLinkedIn 架构笔记\nhttp://www.dbanotes.net/arch/linkedin.html\n\nLinkedIn 架构与开发过程\nhttp://www.dbanotes.net/arch/linkedin_soa.html\n\nInternet Archive 的海量存储浅析\nhttp://www.dbanotes.net/database/internet_archive_storage.html\n\nTailrank 网站架构\nhttp://www.dbanotes.net/review/tailrank_arch.html\n\nTwitter 的架构扩展: 100 倍性能提升\nhttp://www.dbanotes.net/arch/twitter_arch.html\n\n财帮子(caibangzi.com)网站架构\nhttp://www.dbanotes.net/arch/caibangzi_web_arch.html\n\nYupoo! 的网站技术架构\nhttp://www.dbanotes.net/arch/yupoo_arch.html\n\n37Signals 架构\nhttp://www.dbanotes.net/arch/37signals_arch.html\n\nFlickr 的访问统计实现以及其他\nhttp://www.dbanotes.net/arch/flickr_stats_and_dathan.html\n\nPlentyOfFish 网站架构学习\nhttp://www.dbanotes.net/arch/plentyoffish_arch.html\n\nYahoo!社区架构\nhttp://www.dbanotes.net/arch/yahoo_arch.html\n\n有关 Alexa 与 AOL 部署集群文件系统\nhttp://www.dbanotes.net/arch/alexa_ibrix_san_file_system.html\n\neBay 的存储一瞥\nhttp://www.dbanotes.net/arch/ebay_storage.html\n\neBay 的数据量\nhttp://www.dbanotes.net/database/ebay_storage.html\n\neBay 的数据库分布扩展架构\nhttp://www.dbanotes.net/database/ebay_database_scale_out.html\n\neBay 的数据层扩展经验\nhttp://www.dbanotes.net/arch/ebay_db_scale_out.html\n\neBay 的应用服务器规模\nhttp://www.dbanotes.net/web/ebay_application_server.html\n\n性能扩展问题要趁早\nhttp://www.dbanotes.net/arch/scaling_an_early_stage_startup.html\n\nScaling an early stage startup\nhttp://www.scribd.com/doc/429986/Scaling-an-early-stage-startup\n\nFacebook 的 PHP 性能与扩展性\nhttp://www.dbanotes.net/arch/facebook_php.html\n\nSkype 用 PostgreSQL 支撑海量用户\nhttp://www.dbanotes.net/arch/skype_postgresql.html\n\n闲谈 Web 图片服务器\nhttp://www.dbanotes.net/web/web_image_server.html\n\n说说北京奥运购票系统瘫痪这事儿\nhttp://www.dbanotes.net/review/beijing_olympic_ticketes_system_crash.html\n\nArchitectures You’ve Always Wondered About\nhttp://qcon.infoq.com/london-2008/tracks/show_track.jsp?trackOID=82\n\neBay’s Architectural Principles\nhttp://www.eos1.dk/qcon-london-2008/slides/RandyShoup_eBaysArchitecturalPrinciples.pdf\n\nBuilding a large scale SaaS app\nhttp://www.eos1.dk/qcon-london-2008/slides/Dan_Hanley_Building_a_large_scale_SaaS_app.pdf\n\nScaling an early stage startup\nhttp://www.scribd.com/doc/429986/Scaling-an-early-stage-startup\n\n互联星空播客架构(原文在张宴blog上,但是后来文章撤下,很可惜.此为转载)\nhttp://www.flashmov.com/blog_1632.html\n\nQQ游戏百万人同时在线服务器架构实现\nhttp://www.libing.net.cn/read.php?41\n\n大型Web2.0站点构建技术初探\nhttp://blog.csdn.net/heiyeshuwu/archive/2007/11/18/1890793.aspx\n\nWeb站点数据库分布存储浅谈\nhttp://blog.csdn.net/heiyeshuwu/archive/2007/11/18/1891639.aspx\n\nQQ的架构讨论\nhttp://groups.google.com/group/dev4server/browse_thread/thread/0d72668d11c4886b/a6d202489cabf285#a6d202489cabf285\n\nNotes from Scaling MySQL - Up or Out\nhttp://venublog.com/2008/04/16/notes-from-scaling-mysql-up-or-out/\n\nYapache-Yahoo! Apache 的秘密\nhttp://www.dbanotes.net/web/yapache_yahoo_apache.html\n\nScalability Best Practices: Lessons from eBay\nhttp://www.infoq.com/articles/ebay-scalability-best-practices", "created_at"=>2008-10-09 06:51:05 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
Google的产品很多都深得我心,一直在使用,整理整合了一些Gmail的快捷方式,备忘。 \n \n \n \n快捷键 \n定义 \n作用 \n \n \nc \nCompose \n撰写新邮件。“Shift+C”打开新窗口撰写新邮件 \n \n \n<tab> then <Enter> \nSend message \n新邮件撰写完后,先<tab>后<Enter>可发送邮件。(在Windows中,使用IE和Firefox有效) \n \n \nk \nMove to newer conversation \n在收件箱中,向上移动光标,按<Enter>查看邮件;在查看邮件时,打开下一封新邮件 \n \n \nj \nMove to older conversation \n在收件箱中,向下移动光标,按<Enter>查看邮件;在查看邮件时,打开下一封旧邮件 \n \n \nn \nNext message \n查看邮件时,定位光标到 \n \n \np \nPrevious message \n移动光标到前一个消息。<Enter>展开或折叠消息。(只在“会话模式”(Conversation View)中有效) \n \n \no or <Enter> \nOpen \n打开会话。在“Conversation View”中,也可用于打开消息。 \n \n \nu \nReturn to conversation list \n刷新页面、返回收件箱或返回会话列表 \n \n \ny \nArchive* \nRemove from current view \n \n删除会话或消息。 \n在收件箱中,<Y>可“存档”选中的会话
\n\n
在“已加星标示”中,<Y>可取消选中会话的星号; \n 在查看有标签的邮件时,<Y>可取消标签。 \n 在“垃圾邮件”、“已发邮件”和“所有邮件”中,<Y>没有作用 \n \n \n \n \nx \nSelect conversation \n选中会话,配合其他快捷键可为会话存档、添加标签或从下拉菜单中选择其他命令 \n \n \ns \nStar a message or conversation \n为会话或消息加星标。 \n \n \n! \nReport spam \n将消息标记为垃圾邮件并从会话中删除 \n \n \nr \nReply \n回复邮件或会话。“shift+r”可在新窗口中回复消息(只在“会话模式”中有效) \n \n \na \nReply all \n回复所有收件人。“Shift+a”可打开新窗口中回复。(PConline注:如果邮件有抄送地址,<r>回复发件人,<a>则回复所有抄送地址) \n \n \nf \nForward \n转发消息。“Shift+f”可打开新窗口转发。(只在“查看消息模式”(“Conversation View”)中有效) \n \n \n<Esc> \nEscape from input field \nRemoves the cursor from your current input field.(PConline注:在中文版Gmail中暂未有效果) \n \n \ny then o \nArchive and next \n存档选中的会话并打开下一个 \n \n \ng then a \nGo to 'All Mail' \n转到“所有邮件” \n \n \ng then s \nGo to 'Starred' \n转到“已加星标” \n \n \ng then c \nGo to 'Contacts' \n转到“通讯录” \n \n \ng then d \nGo to 'Drafts' \n转到“草稿” \n \n \ng then i \nGo to 'Inbox' \n转到“收件箱” \n \n \n/ \nSearch \n将光标定位到搜索栏中的输入框中 \n \n \n \n
\n", "_id"=>417}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["analyzer"], "comments_count"=>0, "category_id"=>7, "title"=>"Request-log-analyzer: Rails&Merb的日志分析", "body"=>"生产环境下,需要对环境持续监控以尽快的发现问题,找到耗费资源较多的地方加以改进,比较常见的做法是使用moint或者God实时监控;另外,还可以定期分析日志找到特定的请求,虽然可以是shell来做这件事,但是何必再造轮子呢,因为我们已经有了Request log analyzer :\r\n``简介:This is a simple command line tool to analyze request log files of both Rails andMerb. Its purpose is to find what actions are best candidates for optimization.This tool will parse all requests in the logfile and aggregate theinformation. Once it is finished parsing the log file, it will show therequests that take op most server time. Different metrics are used (cumulativetime, average time, blockers, DB time, etc)\r\n\r\n安装:gem sources -a http://gems.github.comsudo gem install wvanbergen-request-log-analyzer\r\n\r\n使用:Usage: request-log-analyzer [FILE] [OPTION]Analyze the given log FILE with the given OPTIONExample: request-log-analyzer mongrel.log\r\n\r\n --fast, -t: Only use completed requests --guess-database-time, -g: Guesses the database duration of requests if they are not in the log --output, -o: Comma-separated list of reports to show --amount, -c: Displays the top <amount> elements in the reports --colorize, -z: Fancy bash coloring\r\n\r\n示例:Note that this example was shortened for your viewing pleasure.$ request-log-analyzer /var/log/my_app.log\r\n\r\nRequest log analyzer, by Willem van Bergen and Bart ten Brinke\r\n\r\nProcessing all log lines...========================================================================Successfully analyzed 58908 requests from log file\r\n\r\nTimestamp first request: 2008-07-13T06:25:58+00:00Timestamp last request: 2008-07-20T06:18:53+00:00Total time analyzed: 7 daysMethods: DELETE (1%), GET (50%), POST (22%), PUT (25%).\r\n\r\nTop 10 most requested actions========================================================================/overview/:date/ : 19359 requests/overview/day/:date/ : 6365 requests/overview/:date/set/ : 5589 requests/overview/ : 3985 requests/clients/:id/ : 1976 requests........\r\n\r\nTop 10 actions by time - cumulative========================================================================/overview/:date/ : 9044.582s [19359 requests]/overview/ : 8478.767s [3985 requests]/overview/:date/set/ : 3309.041s [5589 requests]/clients/:id/products/:id/ : 1479.911s [924 requests]/clients/:id/ : 750.080s [1976 requests]........\r\n\r\nTop 10 actions by time - per request mean========================================================================/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]/clients/:id/ : 0.380s [1976 requests]........\r\n\r\nTop 10 worst DB offenders - cumulative time========================================================================/overview/:date/ : 8773.993s [19359 requests]/overview/ : 8394.754s [3985 requests]/overview/:date/set/ : 3307.928s [5589 requests]/clients/:id/products/:id/ : 1425.220s [924 requests]/clients/:id/ : 535.229s [1976 requests]........\r\n\r\nTop 10 worst DB offenders - mean time========================================================================/overview/:id/:id/:id/print/ : 6.994s [448 requests]/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]........\r\n\r\nMongrel process blockers (> 1.0 seconds)========================================================================/overview/:date/ : 7494.233s [3144 requests]/overview/ : 8320.293s [1549 requests]/overview/:date/set/ : 1149.235s [803 requests]/overview/:id/:id/:id/print/new/ : 613.693s [341 requests]/clients/:id/products/:id/ : 1370.693s [313 requests]........\r\n\r\nRequests graph - per hour======================================================================== ........ 7:00 - 2731 : XXXXXXX 8:00 - 6139 : XXXXXXXXXXXXXXXX 9:00 - 7465 : XXXXXXXXXXXXXXXXXXXX 10:00 - 7118 : XXXXXXXXXXXXXXXXXXX 11:00 - 7409 : XXXXXXXXXXXXXXXXXXX 12:00 - 6450 : XXXXXXXXXXXXXXXXX 13:00 - 5377 : XXXXXXXXXXXXXX 14:00 - 6058 : XXXXXXXXXXXXXXXX 15:00 - 4156 : XXXXXXXXXXX 16:00 - 2767 : XXXXXXX 17:00 - 1598 : XXXX 18:00 - 792 : XX ........\r\n\r\nErrors========================================================================ArgumentError: [237 requests] -> invalid dateStaleObjectError: [28 requests] -> Attempted to update a stale objectRuntimeError: [3 requests] -> Cannot destroy rule before it was createdStatementError: [2 requests] -> Mysql::Error: Deadlock found when trying to get lock; try restarting transactionNoMethodError: [1 requests] -> undefined method `code' for nil:NilClass```", "created_at"=>2008-10-13 08:45:11 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
生产环境下,需要对环境持续监控以尽快的发现问题,找到耗费资源较多的地方加以改进,比较常见的做法是使用moint或者God实时监控;另外,还可以定期分析日志找到特定的请求,虽然可以是shell来做这件事,但是何必再造轮子呢,因为我们已经有了Request log analyzer : \n``简介:This is a simple command line tool to analyze request log files of both Rails andMerb. Its purpose is to find what actions are best candidates for optimization.This tool will parse all requests in the logfile and aggregate theinformation. Once it is finished parsing the log file, it will show therequests that take op most server time. Different metrics are used (cumulativetime, average time, blockers, DB time, etc)
\n\n
安装:gem sources -a http://gems.github.comsudo gem install wvanbergen-request-log-analyzer
\n\n
使用:Usage: request-log-analyzer [FILE] [OPTION]Analyze the given log FILE with the given OPTIONExample: request-log-analyzer mongrel.log
\n\n
--fast, -t: Only use completed requests --guess-database-time, -g: Guesses the database duration of requests if they are not in the log --output, -o: Comma-separated list of reports to show --amount, -c: Displays the top <amount> elements in the reports --colorize, -z: Fancy bash coloring
\n\n
示例:Note that this example was shortened for your viewing pleasure.$ request-log-analyzer /var/log/my_app.log
\n\n
Request log analyzer, by Willem van Bergen and Bart ten Brinke
\n\n
Processing all log lines...========================================================================Successfully analyzed 58908 requests from log file
\n\n
Timestamp first request: 2008-07-13T06:25:58+00:00Timestamp last request: 2008-07-20T06:18:53+00:00Total time analyzed: 7 daysMethods: DELETE (1%), GET (50%), POST (22%), PUT (25%).
\n\n
Top 10 most requested actions========================================================================/overview/:date/ : 19359 requests/overview/day/:date/ : 6365 requests/overview/:date/set/ : 5589 requests/overview/ : 3985 requests/clients/:id/ : 1976 requests........
\n\n
Top 10 actions by time - cumulative========================================================================/overview/:date/ : 9044.582s [19359 requests]/overview/ : 8478.767s [3985 requests]/overview/:date/set/ : 3309.041s [5589 requests]/clients/:id/products/:id/ : 1479.911s [924 requests]/clients/:id/ : 750.080s [1976 requests]........
\n\n
Top 10 actions by time - per request mean========================================================================/overview/ : 2.128s [3985 requests]/clients/:id/products/:id/ : 1.602s [924 requests]/overview/:date/set/ : 0.592s [5589 requests]/overview/:date/ : 0.467s [19359 requests]/clients/:id/ : 0.380s [1976 requests]........
Errors========================================================================ArgumentError: [237 requests] -> invalid dateStaleObjectError: [28 requests] -> Attempted to update a stale objectRuntimeError: [3 requests] -> Cannot destroy rule before it was createdStatementError: [2 requests] -> Mysql::Error: Deadlock found when trying to get lock; try restarting transactionNoMethodError: [1 requests] -> undefined method code' for nil:NilClass``
Nginx有个Log Rotation模块,nginx will re-open it's logs in response to the USR1 signal.参考如下脚本: \n`$ mv access.log access.log.0$ kill -USR1cat master.nginx.pid`$ sleep 1$ gzip access.log.0 # do something with access.log.0
\r\n``2、Hpricot```Pros: Cool name, created by _why, faster than REXML, also does HTML, creative APICons: Not as fast as libxml-ruby, more of an HTML parser linguistically (ie: uses innerHTML instead of text or content, etc.)```\r\n
\r\n
Ruby代码
\r\n\r\n\t
%w[benchmark pp rubygems].each { |x| require x }
\r\n\t
gem 'hpricot', '>= 0.6'
\r\n\t
require 'hpricot'
\r\n\t
\r\n\t
##################################
\r\n\t
# Parsing Delicious API Response #
\r\n\t
##################################
\r\n\t
xml = File.read('posts.xml')
\r\n\t
puts Benchmark.measure {
\r\n\t
doc, posts = Hpricot::XML(xml), []
\r\n\t
(doc/:post).eachdo |p|
\r\n\t
posts << p.attributes
\r\n\t
end
\r\n\t
# pp posts
\r\n\t
}
\r\n\t
\r\n\t
################################
\r\n\t
# Parsing Twitter API Response #
\r\n\t
################################
\r\n\t
xml = File.read('timeline.xml')
\r\n\t
puts Benchmark.measure {
\r\n\t
doc, statuses = Hpricot::XML(xml), []
\r\n\t
(doc/:status).eachdo |s|
\r\n\t
h = {:user => {}}
\r\n\t
%w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].eachdo |a|
\r\n\t
h[a.intern] = s.at(a).innerHTML
\r\n\t
end
\r\n\t
%w[id name screen_name location description profile_image_url url protected followers_count].eachdo |a|
\r\n\t
h[:user][a.intern] = s.at('user').at(a).innerHTML
\r\n\t
end
\r\n\t
statuses << h
\r\n\t
end
\r\n\t
# pp statuses
\r\n\t
}
\r\n\r\n
\r\n3、libxml-ruby \r\n\r\nPros: Blistering fast\r\nCons: Hpricot has cooler name, REXML and Hpricot both feel easier to use out of the box\r\n
Ruby可以很方便的解析XML格式的文档,目前用的比较多的lib主要有三个,分别是:REXML, Hpricot, libxml-ruby,如下选取两个XML文档,分别使用这三个lib解析,感受下各自的速度和易用性。 \n一、原料 \n \n posts.xml – Uses xml element for object (post) and xml attributes for object attributes \n timeline.xml – Uses xml element for object (status) and child xml elements for attributes \n \n二、解析过程 \n1、REXML
\n\n
Pros: In the standard library \nCons: Slow, I don’t like the name \n \nRuby代码 \n \n %w[benchmark pp rexml/document].each { |x| require x } \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n doc, posts = REXML::Document.new(xml), [] \n doc.elements.each('posts/post') do |p| \n posts << p.attributes \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n doc, statuses = REXML::Document.new(xml), [] \n doc.elements.each('statuses/status') do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.elements[a].text \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.elements['user'].elements[a].text \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n<code class="ruby"><strong>2、Hpricot</strong><strong>Pros:</strong> Cool name, created by _why, faster than <span class="caps">REXML</span>, also does <span class="caps">HTML</span>, creative <span class="caps">API</span><strong>Cons:</strong> Not as fast as libxml-ruby, more of an <span class="caps">HTML</span> parser linguistically (ie: uses innerHTML instead of text or content, etc.)`` \n \nRuby代码 \n \n %w[benchmark pp rubygems].each { |x| require x } \n gem 'hpricot', '>= 0.6' \n require 'hpricot' \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n doc, posts = Hpricot::XML(xml), [] \n (doc/:post).each do |p| \n posts << p.attributes \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n doc, statuses = Hpricot::XML(xml), [] \n (doc/:status).each do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.at(a).innerHTML \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.at('user').at(a).innerHTML \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n3、libxml-ruby
\n\n
Pros: Blistering fast \nCons: Hpricot has cooler name, REXML and Hpricot both feel easier to use out of the box \n \nRuby代码 \n \n %w[benchmark pp rubygems].each { |x| require x } \n gem 'libxml-ruby', '>= 0.8.3' \n require 'xml' \n \n ################################## \n # Parsing Delicious API Response # \n ################################## \n xml = File.read('posts.xml') \n puts Benchmark.measure { \n parser, parser.string = XML::Parser.new, xml \n doc, posts = parser.parse, [] \n doc.find('//posts/post').each do |p| \n posts << p.attributes.inject({}) { |h, a| h[a.name] = a.value; h } \n end \n # pp posts \n } \n \n ################################ \n # Parsing Twitter API Response # \n ################################ \n xml = File.read('timeline.xml') \n puts Benchmark.measure { \n parser, parser.string = XML::Parser.new, xml \n doc, statuses = parser.parse, [] \n doc.find('//statuses/status').each do |s| \n h = {:user => {}} \n %w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a| \n h[a.intern] = s.find(a).first.content \n end \n %w[id name screen_name location description profile_image_url url protected followers_count].each do |a| \n h[:user][a.intern] = s.find('user').first.find(a).first.content \n end \n statuses << h \n end \n # pp statuses \n } \n \n \n<code class="ruby"><strong>三、结论</strong> \n<div class="codeText"> \n<div class="codeHead">结果如下:</div> \n<ol class="dp-xml" start="1"> \n <li class="alt"><span><span>=rexml </span></span></li> \n <li><span>delicious 0.020000 0.000000 0.020000 ( 0.021139) </span></li> \n <li class="alt"><span>twitter 0.940000 0.020000 0.960000 ( 0.988666) </span></li> \n <li><span> </span></li> \n <li class="alt"><span>=hpricot </span></li> \n <li><span>delicious 0.010000 0.000000 0.010000 ( 0.005548) </span></li> \n <li class="alt"><span>twitter 0.250000 0.010000 0.260000 ( 0.258320) </span></li> \n <li><span> </span></li> \n <li class="alt"><span>=libxml-ruby </span></li> \n <li><span>delicious 0.000000 0.000000 0.000000 ( 0.007829) </span></li> \n <li class="alt"><span>twitter 0.030000 0.010000 0.040000 ( 0.034040) </span></li> \n</ol> \n</div> \n``<code class="ruby">参考文档:http://railstips.org/2008/8/12/parsing-xml-with-ruby``
\n", "_id"=>421}])
+MONGODB iceylog_development['categories'].find({:_id=>4}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>4}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Tips"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["oauth"], "comments_count"=>0, "category_id"=>4, "title"=>"初识oauth: 为API访问授权提供一个开放的标准", "body"=>"最近在准备一些API设计开发工作,初步了解了下oauth,OAuth是由Blaine Cook、Chris Messina、Larry Halff 及David Recordon共同发起的,目的在于为API访问授权提供一个开放的标准。\r\noauth目前看来进展比较顺利,可以看到其有主流语言的lib(Java、C#、Objective-C、Perl、PHP及Ruby语言),目前支持oauth的API有twitter,douban等应用。\r\n\r\nOAuth is the great new standard allowing your users to use your application to talk to their accounts on other applications. I won’t go more into it here as it’s pretty well covered on the OAuth site.\r\n\r\nOAuth’s Goal\r\nWebsite X can access your protected data at API Y\r\n
\r\n\t
All without sharing your password off-site
\r\n\t
especially when there isn’t one like with OpenID
\r\n
\r\n其基本流程为:\r\n\r\n\t
Register your consumer application with the OAuth compliant service to receive your Consumer Credentials (This is only done once)
\r\n\t
You initiate the OAuth Token exchange process for a user by requesting a RequestToken from the Service
\r\n\t
You store the RequestToken in your database or in the users session object
\r\n\t
You redirect your user to the service providers authorize_url with the RequestToken’s key appended
\r\n\t
Your user is asked by the service provider to authorize your RequestToken
\r\n\t
Your user clicks yes and is redirected to your CallBack URL
OAuth is the great new standard allowing your users to use your application to talk to their accounts on other applications. I won’t go more into it here as it’s pretty well covered on the OAuth site. \n \nOAuth’s Goal \nWebsite X can access your protected data at API Y \n \n All without sharing your password off-site \n especially when there isn’t one like with OpenID \n \n其基本流程为: \n \n Register your consumer application with the OAuth compliant service to receive your Consumer Credentials (This is only done once) \n You initiate the OAuth Token exchange process for a user by requesting a RequestToken from the Service \n You store the RequestToken in your database or in the users session object \n You redirect your user to the service providers authorize_url with the RequestToken’s key appended \n Your user is asked by the service provider to authorize your RequestToken \n Your user clicks yes and is redirected to your CallBack URL \n Your callback action exchanges the RequestToken for an AccessToken \n Now you can access your users data by performing http requests signed by your consumer credentials and the AccessToken. \n ???? \n PROFIT!!! \n \n如果你想了解,请参考如下文档,如果你有经验,请分享,谢谢! \n \n参考文档: \n \n Developing OAuth clients in Ruby \n How to turn your rails site into an OAuth Provider \n OAuth不断获得动力 \n Rails plugin for OAuth \n OAuth implementation for Ruby \n 豆瓣 API 认证授权说明 \n The How of OAuth --这个PPT挺不错 \n
\n", "_id"=>425}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>7, "title"=>"在crontab中调用rake task定时跑job", "body"=>"在Rails中可以使用很大插件来实现后台定时JOB,但是最环保的应该是使用crontab来调用rake,也很简单,基本上分成如下几步:\r\n\r\nin the root of my app i have notify_answerers.sh\r\n``#!/bin/shexport PATH='/usr/local/ruby/bin':$PATH cd /opt/dev/Monier/usr/local/ruby/bin/rake nginx:fetch_status RAILS_ENV=production```\r\nin myapp/lib/tasks i have myapp.rake\r\n``namespace :nginx do desc \"Notify answerers of new questions\" task :fetch_status => :environment do Nginx.find(:all).each do |nginx| puts \"nginx=\#{nginx.name}\" nginx.do_fetch_nginx_status_job nginx.update_attribute(:updated_at,Time.now) end endend```\r\nIn my cron file i have:\r\n``*/2 * * * * /bin/sh /opt/dev/Monier/lib/crontabs/fetch_nginx_status.sh```\r\n(use \"crotab -e\" on the server to edit this file)", "created_at"=>2008-10-24 16:51:45 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
in the root of my app i have notify_answerers.sh \n#!/bin/shexport PATH='/usr/local/ruby/bin':$PATH cd /opt/dev/Monier/usr/local/ruby/bin/rake nginx:fetch_status RAILS_ENV=production \nin myapp/lib/tasks i have myapp.rake \nnamespace :nginx do desc "Notify answerers of new questions" task :fetch_status => :environment do Nginx.find(:all).each do |nginx| puts "nginx=\#{nginx.name}" nginx.do_fetch_nginx_status_job nginx.update_attribute(:updated_at,Time.now) end endend \nIn my cron file i have: \n*/2 * * * * /bin/sh /opt/dev/Monier/lib/crontabs/fetch_nginx_status.sh``` \n(use "crotab -e" on the server to edit this file)
merb的1.0终于出来了,等的实在不易,1.0版的merb已经足够完善了,可以拿来做一些production的东西了,例如以前说到的代替rails做上传文件等等。 \nrubyinsite已经发了一篇参考资源文件,感兴趣的可以过去瞧瞧,地址如下:Merb 1.0 Released So Here’s 44 Links and Resources To Get You Going。
Q:how to get distance between two GeoPoints in sdk 1.0 ? MapPoint.distanceSquared(MapPoint) is gone \nthaks!! \n
\n
A:you'll need to brush up on your trigonometry, and first compute the Haversine function (this is the standard way of doing it). In order to use the Java trig functions, you'll have to first convert all your angles from degrees to radians. \nGiven two longitude/latitude pairs, and the earth's average radius (assume 6356.78km for your calculations), \nyou can calculate the distance between the 2 points via this Java code: \n \n \tdouble EarthRad = 6356.78;\t// in km ! \n// first convert to radians... \ndouble geo1_lat = geo1.getLatitude()*java.lang.Math.PI/360; \ndouble geo1_lng = geo1.getLongitude()*java.lang.Math.PI/360; \ndouble geo2_lat = geo2.getLatitude()*java.lang.Math.PI/360; \ndouble geo2_lng = geo2.getLongitude()*java.lang.Math.PI/360; \n \ndouble deltaLat = java.lang.Math.abs(java.lang.Math.abs(geo2_lat) - java.lang.Math.abs(geo1_lat)); \ndouble deltaLng = java.lang.Math.abs(java.lang.Math.abs(geo2_lng) - java.lang.Math.abs(geo1_lng)); \n \ndouble dist = 2*EarthRad*java.lang.Math.asin(java.lang.Math.sqrt(haversine(deltaLat) \n+ java.lang.Math.cos(pair1_lat) \n*java.lang.Math.cos(pair1_lng)*haversine(deltaLng))); \n \nWhere "dist" now contains the distance between along the earth's surface. \nYou can find the Haversine function trig equation by Googling it, then construct a method that returns the appropriate value.
\n
Computing the speed is straightforward: you know your sampling frequency, and you now know the distance between the most recent two points, so, employee speed = distance / sampling interval
Q:how to get distance between two GeoPoints in sdk 1.0 ? MapPoint.distanceSquared(MapPoint) is gone \nthaks!! \n \nA:you'll need to brush up on your trigonometry, and first compute the Haversine function (this is the standard way of doing it). In order to use the Java trig functions, you'll have to first convert all your angles from degrees to radians. \nGiven two longitude/latitude pairs, and the earth's average radius (assume 6356.78km for your calculations), \nyou can calculate the distance between the 2 points via this Java code: \n \n double EarthRad = 6356.78; // in km ! \n// first convert to radians... \ndouble geo1_lat = geo1.getLatitude()*java.lang.Math.PI/360; \ndouble geo1_lng = geo1.getLongitude()*java.lang.Math.PI/360; \ndouble geo2_lat = geo2.getLatitude()*java.lang.Math.PI/360; \ndouble geo2_lng = geo2.getLongitude()*java.lang.Math.PI/360; \n \ndouble deltaLat = java.lang.Math.abs(java.lang.Math.abs(geo2_lat) - java.lang.Math.abs(geo1_lat)); \ndouble deltaLng = java.lang.Math.abs(java.lang.Math.abs(geo2_lng) - java.lang.Math.abs(geo1_lng)); \n \ndouble dist = 2*EarthRad*java.lang.Math.asin(java.lang.Math.sqrt(haversine(deltaLat) \n+ java.lang.Math.cos(pair1_lat) \n*java.lang.Math.cos(pair1_lng)*haversine(deltaLng))); \n \nWhere "dist" now contains the distance between along the earth's surface. \nYou can find the Haversine function trig equation by Googling it, then construct a method that returns the appropriate value. \nComputing the speed is straightforward: you know your sampling frequency, and you now know the distance between the most recent two points, so, employee speed = distance / sampling interval \n参考:http://www.anddev.org/distance_between_two_geopoints_in_sdk10-t4195.html \nhttp://www.anddev.org/calculating_distance_between_two_gps_points-t3708.html \n
\n", "_id"=>450}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Ruby&Rails", "to_xml"], "comments_count"=>0, "category_id"=>11, "title"=>"Rails: Disabling XML character escaping for to_xml & xml builder", "body"=>"
In my case, I had to genarate the xml view for api render,but in rails, i got a &XXX format string for non englisg, it also appears to_xml will automatically escape any entities into their corresponding &XXX representation. There's a piece in the documentation that says "If $KCODE is set to u and encoding set to UTF8, then escaping will NOT be performed." \n \nUnfortunately, this doesn't appear to be the case. Even after following the docs and ensuring that default_charset is indeed UTF-8 (actually the default for Rails nowadays), we still get encoded characters in to_xml output. \n \nSince our client is UTF-8 aware, we need to pass thru the UTF-8 data intact. The only way we've found to do this is thru the following horrible monkey-patch:
\n
\n
Ruby代码
\n\n
module Builder
\n
class XmlBase
\n
def _escape(text)
\n
text
\n
end
\n
end
\n
end
\n\n
\n
\nWhat's the proper way to do this? \n \nPS: \nsomebody say that to "set $KCODE='UTF8' in config/environment.rb can solve this issue." but it's not for me. \n \nmore infos: \nhttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2c13ad7c0f8c0781
In my case, I had to genarate the xml view for api render,but in rails, i got a &XXX format string for non englisg, it also appears to_xml will automatically escape any entities into their corresponding &XXX representation. There's a piece in the documentation that says "If $KCODE is set to u and encoding set to UTF8, then escaping will NOT be performed." \n \nUnfortunately, this doesn't appear to be the case. Even after following the docs and ensuring that default_charset is indeed UTF-8 (actually the default for Rails nowadays), we still get encoded characters in to_xml output. \n \nSince our client is UTF-8 aware, we need to pass thru the UTF-8 data intact. The only way we've found to do this is thru the following horrible monkey-patch: \n \nRuby代码 \n \n module Builder \n class XmlBase \n def _escape(text) \n text \n end \n end \n end \n \n \n \nWhat's the proper way to do this? \n \nPS: \nsomebody say that to "set $KCODE='UTF8' in config/environment.rb can solve this issue." but it's not for me. \n \nmore infos: \nhttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2c13ad7c0f8c0781 \n
\n", "_id"=>451}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["random", "ruby"], "comments_count"=>0, "category_id"=>11, "title"=>"Generate a random string", "body"=>"Generates a random string of lowercase letters. Great for email verification codes or user password salt....\n
Some tips for mount&umount ,maybe give you some help..
\n
cdrom: \n# mount -t is09660 /dev/cdrom /mnt/cdrom \n# umount /mnt/cdrom \n \nfloppy: \n# mount /dev/fd0 /mnt/floppy \n#umount /mnt/floppy \n \nusb: \n1.use 'fdisk -l' to show the usb nums,something like '/dev/sda'; \n2.then use 'mkdir /mnt/usb' to create a dir for mount this usb; \n3.at last,use '# mount -t msdos /dev/sda1 /mnt/usb" to mount it. \n4.#umount /mnt/usb \n \nhda: \n1.use 'fdisk -l' to show the disk nums,like '/dev/hda1'; \n2.then use 'make /mnt/vfat' to create a mount point; \n3.at last,use '# mount -t vfat /dev/hda1 /mnt/vfat'to mount it.. \n4.#umount /mnt/vfat
Some tips for mount&umount ,maybe give you some help.. \ncdrom:
\n\n
mount -t is09660 /dev/cdrom /mnt/cdrom
\n\n
umount /mnt/cdrom
\n\n
floppy:
\n\n
mount /dev/fd0 /mnt/floppy
\n\n
umount /mnt/floppy
\n\n
usb: \n1.use 'fdisk -l' to show the usb nums,something like '/dev/sda'; \n2.then use 'mkdir /mnt/usb' to create a dir for mount this usb; \n3.at last,use '# mount -t msdos /dev/sda1 /mnt/usb" to mount it. \n4.#umount /mnt/usb \n \nhda: \n1.use 'fdisk -l' to show the disk nums,like '/dev/hda1'; \n2.then use 'make /mnt/vfat' to create a mount point; \n3.at last,use '# mount -t vfat /dev/hda1 /mnt/vfat'to mount it.. \n4.#umount /mnt/vfat \nand some usefull resource links and docs here: \nhttp://unix-cd.com/unixcd12/article_3967.html \nhttp://blog.oracle.com.cn/index.php/121320/viewspace-6733.html
In my case, I need do send big files to users, yes, you can do it with nginx,just like others static files,but i need some control for the request action,The delivery of a static file which depends on an application header is known as the X-Sendfile feature. \nLighttpd has this feature and there is a mod_xsendfile for Apache2. \nNginx also has this feature, but implemented a little bit differently. In Nginx this feature is called X-Accel-Redirect. \nThere are two main differences:
\n\n
The header must contain a URI
\n
The location should be defined as internal; to prevent the client going directly to the URI
\n\n
\n
\n
Ruby代码
\n\n
location /files {
\n
root /var/www;
\n
internal;
\n
}
\n\n
\n
\n
Ruby代码
\n\n
// Get requested file name
\n
path = @params["path"]
\n
\n
# ...
\n
# Perform any required security checks, validation
In my case, I need do send big files to users, yes, you can do it with nginx,just like others static files,but i need some control for the request action,The delivery of a static file which depends on an application header is known as the X-Sendfile feature. \nLighttpd has this feature and there is a mod_xsendfile for Apache2. \nNginx also has this feature, but implemented a little bit differently. In Nginx this feature is called X-Accel-Redirect. \nThere are two main differences: \n \n The header must contain a URI \n The location should be defined as internal; to prevent the client going directly to the URI \n \n \n \nRuby代码 \n \n location /files { \n root /var/www; \n internal; \n } \n \n \n \nRuby代码 \n \n // Get requested file name \n path = @params["path"] \n \n # ... \n # Perform any required security checks, validation \n # and/or stats accounting \n # ... \n \n # And redirect user to internal location \n response.headers['X-Accel-Redirect'] = "/files/" + path \n \n \n \nsome userfull link resource come here: \n \n http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/ \n http://wiki.codemongers.com/NginxXSendfile \n http://www.motionstandingstill.com/using-nginx-to-send-files-with-x-accel-redirect/2008-09-03/ \n \n
I store user sessions in memcache,and then i want do share theres sessions with sub domains,but i notice some strange things when i put session into memcached,there are: \n1. In my older website(rails 2.0),It genenrated sessions key for memcached as \#{namespace}-\#{RAILS_ENV}:"session:\#{id}"; \n2.In my newer website(reails 2.3),It generated seesions key for memcached just as "\#{namespace}:\#{id}"; \n \nso,i can not get the same seesion datas with diff session keys. i do have spend lots of time for sove this , i do have some userfull dis, \n \n1. In rails2.3 ,it's vendor memcache-client-1.5.0.5 in ruby\\lib\\ruby\\gems\\1.8\\gems\\activesupport-2.3.0\\lib\\active_support\\vendor; \n2. you can config namespace in you environment.rb file like " ActionController::Base.session_options[:namespace] = 'session'" \n3. In rails2.0,when you use memcached,you will use cached_fu and act_as_cache plugins,and you may have a config file in your config dir named memcached.yml, and in this file,you can config defaults,production,test and developer..with lots of filed,like namespace,servers etc.. \n4. you will notice it generate memcached key as mentioned above. \n \nI track it,and got this:
I store user sessions in memcache,and then i want do share theres sessions with sub domains,but i notice some strange things when i put session into memcached,there are: \n1. In my older website(rails 2.0),It genenrated sessions key for memcached as \#{namespace}-\#{RAILS_ENV}:"session:\#{id}"; \n2.In my newer website(reails 2.3),It generated seesions key for memcached just as "\#{namespace}:\#{id}"; \n \nso,i can not get the same seesion datas with diff session keys. i do have spend lots of time for sove this , i do have some userfull dis, \n \n1. In rails2.3 ,it's vendor memcache-client-1.5.0.5 in ruby\\lib\\ruby\\gems\\1.8\\gems\\activesupport-2.3.0\\lib\\active_support\\vendor; \n2. you can config namespace in you environment.rb file like " ActionController::Base.session_options[:namespace] = 'session'" \n3. In rails2.0,when you use memcached,you will use cached_fu and act_as_cache plugins,and you may have a config file in your config dir named memcached.yml, and in this file,you can config defaults,production,test and developer..with lots of filed,like namespace,servers etc.. \n4. you will notice it generate memcached key as mentioned above. \n \nI track it,and got this: \n \nRuby代码 \n \n def setup_memcache(config) \n config[:namespace] << "-\#{RAILS_ENV}" \n \n silence_warnings do \n Object.const_set :CACHE, memcache_klass.new(config) \n end \n \n CACHE.servers = Array(config.delete(:servers)) \n \n setup_session_store if config[:sessions] \n setup_fragment_store! if config[:fragments] \n setup_fast_hash! if config[:fast_hash] \n setup_fastest_hash! if config[:fastest_hash] \n \n CACHE \n end \n \n \nshit,it append RAILS_ENV to namespace with "-",that's it...I hate some hardcode config in plugin,blalal.... \nsome userfull link resources... \n \n http://errtheblog.com/posts/22-sessions-n-such \n http://www.raecoo.com/2008/10/25/rails-store-format-in-memcache/ \n http://www.scribd.com/doc/2203398/Scaling-Rails-with-memcached \n http://railscasts.com/episodes/115-caching-in-rails-2-1
In some case,you may want do get Uniquely Identifying for a 'real' android phone,and you can do it like this:
\n
In Android.Provider.Settings.System we have some interesting values that could be of use, one specifically is “Android_ID”. From the documentation it is the following;
\n
\n
String \tANDROID_ID \tThe Android ID (a unique 64-bit value) as a hex string. \t“android_id”
\nAlso, note that in an emulator this will return “null”, though a real device will return an actual value. The nice thing about this tid-bit of code is that you are not required any special permissions to call it, since it’s essentially a passive call to get information. No write access is (obviously) required.\n
Garry Tan, cofounder of Posterous, lists 12 lessons for scaling that apply to more than just Rails,and i mark some word below. \n \nUse cloud storage for static files. --S3,I do not care it 's fine in china. \nUse HTTP Cache Control to tell the browser what it can cache. --this is true,etag is great. \nUse Sphinx for text search. --sometimes,you do have others chose. \nUse InnoDB for more crash resistant and faster writes. --maybe it's right. \nDon't use textbook Rails ActiveRecord objects. Use New Relic to find exactly what is slow in your system. --yep \nUse memcache later so you find your database bottlenecks now. --this is very important. \nUse mongrel proctitle to find your slow queries. You are only as fast as your slowest queries. -maybe mongrel is not only chose,think about thin,ok? \nUse asynchronous job queuing to do work in parallel. --yes,but sometimes crontab is enough. \nUse monitoring so you'll know when your site went down and why. --that's it,just do it. \nLearn by reading the source code, fixing problems, and submitting them back to the community. --very userfull when you got some strange questions.. \nUse new plugins. Old plugins can't be trusted. --and check chang histroy carefully. \nUse new information. Old information can't be trusted. --and what's this? \n \ngo to http://axonflux.com/building-and-scaling-a-startup for more infos.
When it asks for driver location choose the unzipped folderand install the driver for it.
\n
You'll see sth like "HTC Dream Composite ADB Interface" on success
\n
(Re)Start Eclipse
\n
Your G1 should now be listed in the DDMS-Perspective under Devices
\n
Go to the AndroidManifest.xml of your App and modify it to containandroid:debuggable="true"in the <application ... >-Tag,look like this:<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
\n
Go Debug as usual. \n
\n\nps: I do not upload the zip file here,you can find it via the link above,but if you can not download it,you can mail me to fetch one.
I konw,you can dev app and test it on the simulator,but if you had a real driver,G1,you can do debug on it,very great,here is the tips for this: \n \n On your G1, go to Settings Applications Development [X] USB debugging \n Download this file: android_usb_windows.zip \n Unzip it to a folder \n Connect your G1 with your PC \n When it asks for driver location choose the unzipped folder and install the driver for it. \n You'll see sth like "HTC Dream Composite ADB Interface" on success \n (Re)Start Eclipse \n Your G1 should now be listed in the DDMS-Perspective under Devices \n Go to the AndroidManifest.xml of your App and modify it to contain android:debuggable="true" in the <application ... >-Tag ,look like this:<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> \n Go Debug as usual. \n \n \nps: I do not upload the zip file here,you can find it via the link above,but if you can not download it,you can mail me to fetch one. \nBtw: \nYou can now install (signed)APKs via USB: \nD:\\dev\\Android\\android-sdk-windows-1.0_r1\\tools>adb -d install D:\\Workspace\\keytools\\AndNav_signed.apk \n1305 KB/s (1975987 bytes in 1.478s) \npkg: /data/local/tmp/AndNav_signed.apk \nSuccess \n \n \nAnd uninstall them: \nD:\\dev\\Android\\android-sdk-windows-1.0_r1\\tools>adb uninstall org.andnav \nSuccess \n \n
In some case,you may want do get Uniquely Identifying for a 'real' android phone,such as IMEI code,SimOperator etc, and we all kown ,the IMEI like ID card,and you can use TelephonyManager to get it,some usefull codes like this :
Apr 1 01:47:49 garden kernel: Linux version 2.6.18-92.1.17.el5 (mockbuild@builder10.centos.org) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)) #1 SMP Tue Nov 4 13:43:30 EST 2008
\n
\n \nlooks like something wrong about "ip_conntrack",and i do some check like this: \n\n
Installing ri documentation for fastercsv-1.4.0...
\n
Installing RDoc documentation for fastercsv-1.4.0...
\n
iceskysl ~/webroot: cd ..
\n\n
\nand do not forget to add "require 'fastercsv'" in your class file.", "created_at"=>2009-04-22 17:12:15 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
some tips is here. \n \nRuby代码 \n \n def self.imp_init_owner_data \n fp = "\#{RAILS_ROOT}/datas/inumbers/ini_owner.csv" \n FasterCSV.open(fp, "w") do |csv| \n InumberCate.find_all_by_typee("owner").each do |owner| \n csv << [owner.name,owner.id] \n end \n end \n end \n \n \ninstall fastercsv gems like this.. \n \n \n \nRuby代码 \n \n iceskysl ~/webroot: gem install fastercsv \n Successfully installed fastercsv-1.4.0 \n 1 gem installed \n Installing ri documentation for fastercsv-1.4.0... \n Installing RDoc documentation for fastercsv-1.4.0... \n iceskysl ~/webroot: cd .. \n \n \nand do not forget to add "require 'fastercsv'" in your class file.
you can use apt-spy to update sources.list ,here is some step and tips. \n1.open /etc/apt/sources.list and add this \ndeb http://http.us.debian.org/debian/ stable main \n2.do "apt-get update" \n3.then "apt-get install apt-spy" \n4.then "apt-spy update" \n5.last,"apt-spy -d unstable -a asia -t 5" \n \nref: \nhttp://http.us.debian.org/debian/README.mirrors.txt
you can use apt-spy to update sources.list ,here is some step and tips. \n1.open /etc/apt/sources.list and add this \ndeb http://http.us.debian.org/debian/ stable main \n2.do "apt-get update" \n3.then "apt-get install apt-spy" \n4.then "apt-spy update" \n5.last,"apt-spy -d unstable -a asia -t 5" \n \nref: \nhttp://http.us.debian.org/debian/README.mirrors.txt
\n", "_id"=>466}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["iowait"], "comments_count"=>0, "category_id"=>11, "title"=>"How can I find out what is generating iowait on my server?", "body"=>"
A question I’m asked daily is “How can I find out what is generating iowait on my server?” Sure, you can dig through pages of lsof output, restart services, or run strace, but it can be a frustrating process. I saw a process on this blog post, and a guy changed the regexes to fit Red Hat and CentOS systems a bit better: \n
A question I’m asked daily is “How can I find out what is generating iowait on my server?” Sure, you can dig through pages of lsof output, restart services, or run strace, but it can be a frustrating process. I saw a process on this blog post, and a guy changed the regexes to fit Red Hat and CentOS systems a bit better: \n \nRuby代码 \n \n [root@5-3 ~]# /etc/init.d/syslog stop \n Shutting down kernel logger: [ OK ] \n Shutting down system logger: [ OK ] \n [root@5-3 ~]# echo 1 > /proc/sys/vm/block_dump \n [root@5-3 ~]# dmesg | egrep "READ|WRITE|dirtied" | egrep -o '([a-zA-Z]*)' | sort | uniq -c | sort -rn | head \n 202 kjournald \n 16 egrep \n 9 irqbalance \n 9 bash \n 2 java \n 1 sda \n 1 mailserver \n [root@5-3 ~]# echo 0 > /proc/sys/vm/block_dump \n [root@5-3 ~]# /etc/init.d/syslog start \n Starting system logger: [ OK ] \n Starting kernel logger: [ OK ] \n \n \nIn my specific situation, it looks like kjournald is the biggest abuser of my disk. \nDon’t forget to set things back to their normal state when you’re done! \n \nXML/HTML代码 \n \n # echo 0 > /proc/sys/vm/block_dump \n # /etc/init.d/syslog start \n \n \n \n \nref: \nhttp://rackerhacker.com/2008/03/11/hunting-down-elusive-sources-of-iowait/ \nhttp://blog.eikke.com/index.php/ikke/2007/03/22/who_s_abusing_my_sata_controller \nhttp://hi.baidu.com/dipsey/blog/item/900bbbaf3e46dcc97cd92aba.html \nhttp://www.ducea.com/2009/03/11/howto-install-iotop-on-debian-etch/ \n \nhttp://www.cppblog.com/go-benny/archive/2008/04/23/47908.html \n
--attach PID Quit god when the attached process dies
\n
--no-events Disable the event system
\n
--bleakhouse Enable bleakhouse profiling
\n
[iceskysl@ws_api]#
\n\n
\n1.DYNAMICALLY LOADING CONFIG FILES INTO AN ALREADY RUNNING GOD\n
\n
God allows you to load or reload configurations into an already running instance. There are a few things to consider when doing this:
\n
\n
Existng Watches with the samename```as the incoming Watches will be overidden by the new config.
\n
All paths must be either absolute or relative to the path from which god was started.
\n
\n
To load a config into a running god, issue the following command:
\n
$ sudo god load path/to/config.god # god load /data/www/api/config/config_thin_api.god```\n
Config files that are loaded dynamically can contain anything that a normal config file contains, however, global options such asGod.pid_file_directory```blocks will be ignored (and produce a warning in the logs).
\n
\n
2.show logs
\n
\n
\n
XML/HTML代码
\n\n
[iceskysl@ws_api]# god log thin-thin-7514
\n
I, [2009-04-28T08:24:16.705870 #23174] INFO -- : thin-thin-7514 moved 'up' to 'up'
\n
I, [2009-04-28T08:24:16.706346 #23174] INFO -- : thin-thin-7514 [trigger] process is not running (ProcessRunning)
\n
I, [2009-04-28T08:24:16.888477 #23174] INFO -- : thin-thin-7514 sent email to iceskysl@gmail.com (Email)
\n
I, [2009-04-28T08:24:16.888642 #23174] INFO -- : thin-thin-7514 move 'up' to 'start'
\n
I, [2009-04-28T08:24:16.888976 #23174] INFO -- : thin-thin-7514 before_start: no pid file to delete (CleanPidFile)
\n
I, [2009-04-28T08:24:16.889109 #23174] INFO -- : thin-thin-7514 start: thin start -C /data/www/web/current/config/thin.yml -o 7514
some days before,i posted a article 《God: 比Monit更好用的monitoring》,today,i will post more useful tips for God. \n \n \nRuby代码 \n \n [iceskysl@ws_api]# god --help \n Usage: \n Starting: \n god [-c <config file>] [-p <port> | -b] [-P <file>] [-l <file>] [-D] \n \n Querying: \n god <command> <argument> [-p <port>] \n god <command> [-p <port>] \n god -v \n god -V (must be run as root to be accurate on Linux) \n \n Commands: \n start <task or group name> start task or group \n restart <task or group name> restart task or group \n stop <task or group name> stop task or group \n monitor <task or group name> monitor task or group \n unmonitor <task or group name> unmonitor task or group \n remove <task or group name> remove task or group from god \n load <file> load a config into a running god \n log <task name> show realtime log for given task \n status show status of each task \n quit stop god \n terminate stop god and all tasks \n check run self diagnostic \n \n Options: \n -c, --config-file CONFIG Configuration file \n -p, --port PORT Communications port (default 17165) \n -b, --auto-bind Auto-bind to an unused port number \n -P, --pid FILE Where to write the PID file \n -l, --log FILE Where to write the log file \n -D, --no-daemonize Don't daemonize \n -v, --version Print the version number and exit \n -V Print extended version and build information \n --log-level LEVEL Log level [debug|info|warn|error|fatal] \n --no-syslog Disable output to syslog \n --attach PID Quit god when the attached process dies \n --no-events Disable the event system \n --bleakhouse Enable bleakhouse profiling \n [iceskysl@ws_api]# \n \n \n1.DYNAMICALLY LOADING CONFIG FILES INTO AN ALREADY RUNNING GOD \n \nGod allows you to load or reload configurations into an already running instance. There are a few things to consider when doing this: \n \n Existng Watches with the same name<span class="Apple-converted-space"> </span>as the incoming Watches will be overidden by the new config.</li> \n <li style="margin: 0px; font-size: 13px;">All paths must be either absolute or relative to the path from which god was started.</li> \n</ul> \n<p style="margin: 0px 0px 1em; font-size: 13px;">To load a config into a running god, issue the following command:</p> \n<pre style="border: 1px solid rgb(204, 204, 204); margin: 1em 0px; padding: 1em; font-size: 10px; line-height: 1.3; background-color: rgb(239, 239, 239);">$ sudo god load path/to/config.god<br /># god load /data/www/api/config/config_thin_api.god \nConfig files that are loaded dynamically can contain anything that a normal config file contains, however, global options such as God.pid_file_directory``` blocks will be ignored (and produce a warning in the logs). \n \n2.show logs \n \n \nXML/HTML代码 \n \n [iceskysl@ws_api]# god log thin-thin-7514 \n I, [2009-04-28T08:24:16.705870 #23174] INFO -- : thin-thin-7514 moved 'up' to 'up' \n I, [2009-04-28T08:24:16.706346 #23174] INFO -- : thin-thin-7514 [trigger] process is not running (ProcessRunning) \n I, [2009-04-28T08:24:16.888477 #23174] INFO -- : thin-thin-7514 sent email to iceskysl@gmail.com (Email) \n I, [2009-04-28T08:24:16.888642 #23174] INFO -- : thin-thin-7514 move 'up' to 'start' \n I, [2009-04-28T08:24:16.888976 #23174] INFO -- : thin-thin-7514 before_start: no pid file to delete (CleanPidFile) \n I, [2009-04-28T08:24:16.889109 #23174] INFO -- : thin-thin-7514 start: thin start -C /data/www/web/current/config/thin.yml -o 7514 \n \n \n \nresource links: \nhttp://god.rubyforge.org/ \n
If you have recently updated to Rails 2.2.2, you may encounter this error when you want to start your application: \n \n/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in \n`load_missing_constant': uninitialized constant Inflector (NameError) \n \nthe usage of Inflector class is changed a bit. You can see the difference when you compare the inflections.rb files. Path of the file is yourApp/config/initializers/inflections.rb \n \n
\n
inflections.rb (Rails 2.1.0)
\n\n
\n
\n
Inflector.inflections do |inflect|
\n
.
\n
.
\n
.
\n
end
\n\n
\n \n
\n
inflections.rb (Rails 2.2.2)
\n\n
ActiveSupport::Inflector.inflections do |inflect|
\n
.
\n
.
\n
.
\n
end
\n\n
\nthe situation changing Inflector to ActiveSupport::Inflector was enough to solve the problem.", "created_at"=>2009-05-05 13:37:01 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
If you have recently updated to Rails 2.2.2, you may encounter this error when you want to start your application: \n \n/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in \n`load_missing_constant': uninitialized constant Inflector (NameError) \n \nthe usage of Inflector class is changed a bit. You can see the difference when you compare the inflections.rb files. Path of the file is yourApp/config/initializers/inflections.rb \n \n \ninflections.rb (Rails 2.1.0) \n \n \n \n Inflector.inflections do |inflect| \n . \n . \n . \n end \n \n \n \n \ninflections.rb (Rails 2.2.2) \n \n ActiveSupport::Inflector.inflections do |inflect| \n . \n . \n . \n end \n \n \nthe situation changing Inflector to ActiveSupport::Inflector was enough to solve the problem.
\n", "_id"=>470}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["God", "ruby", "Ruby&Rails"], "comments_count"=>0, "category_id"=>11, "title"=>"Socket Errno::EAFNOSUPPORT with God in ruby", "body"=>"
when i start god.sh,then give some error msg like this:
\n
\n
\n
XML/HTML代码
\n\n
I [2009-05-16 21:25:41] INFO: Using pid file directory: /var/run/god
\n
/usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `initialize': Address family not supported by protocol - socket(2) (Errno::EAFNOSUPPORT)
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `open'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in `open_server_inaddr_any'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:863:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:759:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in `each'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in `open_server'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1340:in `initialize'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in `new'
\n
from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in `start_service'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:78:in `start'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:43:in `initialize'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in `new'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in `start'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:633:in `at_exit'
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:666
\n
from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/cli/run.rb:87
\n\n
\nok,then i find some userful messsage,like here:\n
Errno::EAFNOSUPPORT - the specifiedsockaddrisnot a valid address for the family of the callingsocket
\n
and here, i notice where is the problen,the god find hostname,name map it to ip address,then create some sockets on the ip,and the error point is here,so i nano my /etc/hosts file,and add map for hostname and 127.0.0.1,that's it! \n
when i start god.sh,then give some error msg like this: \n \n \nXML/HTML代码 \n \n I [2009-05-16 21:25:41] INFO: Using pid file directory: /var/run/god \n /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in initialize': Address family not supported by protocol - socket(2) (Errno::EAFNOSUPPORT) </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in open' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:850:in open_server_inaddr_any' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:863:in open_server' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:759:in open_server' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in each' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:757:in open_server' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1340:in initialize' \n from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in new' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/1.8/drb/drb.rb:1628:in start_service' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:78:in start' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/socket.rb:43:in initialize' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in new' </span></li> \n <li class="alt"><span> from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:607:in start' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:633:in `at_exit' \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god.rb:666 \n from /usr/local/ruby/lib/ruby/gems/1.8/gems/god-0.7.13/bin/../lib/god/cli/run.rb:87 \n \n \nok,then i find some userful messsage,like here: \nErrno::EAFNOSUPPORT - the specified sockaddr isnot a valid address for the family of the calling socket \nand here, i notice where is the problen,the god find hostname,name map it to ip address,then create some sockets on the ip,and the error point is here,so i nano my /etc/hosts file,and add map for hostname and 127.0.0.1,that's it!
\n", "_id"=>471}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["书"], "comments_count"=>0, "category_id"=>6, "title"=>"我写的书:《Google Android开发入门与实战》等即将上市.", "body"=>"这篇文章是非技术性的,所以使用中文写,免得写了大家看不懂,呵呵。\r\n\r\n写书不是第一次,出版却是第一本,至于原因,就不详述了,去年9月开始参与一些图书的翻译和撰写中,截至到目前,这段时间一共参与了三本书,按照参与的先后顺序,分别是《The Rails Way》,《Google API 编程.开发.实例》以及《Google Android开发入门与实战》。\r\n\r\n其中《The Rails Way》是做为译者参与,其他翻译者都是国内第一批Rails技术人员,分散在全国各地,还有一名译者在加拿大,我一共翻译了5章内容,分别是第2章“Working_with_Controllers”,第10章“ActionView”,第13章“Session__Session_Management”,第15章“XML_and_ActiveResource”和第16章“ActionMailer”,翻译很早前就结束了,目前好像还在审稿、校核工作,由YiTan在跟,至于何时出版,我还真不知道。\r\n\r\n《Google API 编程.开发.实例》我是从去年9月份介入,开始参与选题和策划,截至撰写相关内容,因为我自身是Google重度使用者,平时也比较多的使用和了解GoogleAPI,所以写起来得心应手,一共写了“Google Account Authentication”,“Google AJAX Language API”,“Google Chart API”,“Blogger Data API”,“Feedburner API”,“Google Code Search Data API”和“Google Book Search Book Viewability API”这些章节,前前后后也花了不少零碎的时间。其他作者大多都Google内部的同学,本书已经进入出版流程,由博文视点出版社策划出版,应该在6.5号Google开发者大会上可以看到,如下是本书第一版封面。\r\n\r\n\r\n\r\n本书特点:本书覆盖了Google绝大多数的API,其中针对每个API就其原理、用法做了详细说明,最后基本上都有实际的例子演示如何使用。\r\n\r\n《Google Android开发入门与实战》是08年11月份开始撰写的,和另外一个朋友一起,两个人陆续的差不多用了半年时间,在09年4月份差不多全部写完,后面主要是都在校核和审稿,由人民邮电出版社出版,5月底6月初即可上市,封面如下:\r\n\r\n\r\n\r\n \r\n
《Google API 编程.开发.实例》我是从去年9月份介入,开始参与选题和策划,截至撰写相关内容,因为我自身是Google重度使用者,平时也比较多的使用和了解GoogleAPI,所以写起来得心应手,一共写了“Google Account Authentication”,“Google AJAX Language API”,“Google Chart API”,“Blogger Data API”,“Feedburner API”,“Google Code Search Data API”和“Google Book Search Book Viewability API”这些章节,前前后后也花了不少零碎的时间。其他作者大多都Google内部的同学,本书已经进入出版流程,由博文视点出版社策划出版,应该在6.5号Google开发者大会上可以看到,如下是本书第一版封面。
and now,you can open a cmd shell,and input sqlite3 like this: \n
\n
C:\\Documents and Settings\\Administrator>sqlite3 \nSQLite version 3.5.9 \nEnter ".help" for instructions
\n
and some help infos is here:
\n
sqlite> .help \n.bail ON|OFF Stop after hitting an error. Default OFF \n.databases List names and files of attached databases \n.dump ?TABLE? ... Dump the database in an SQL text format \n.echo ON|OFF Turn command echo on or off \n.exit Exit this program \n.explain ON|OFF Turn output mode suitable for EXPLAIN on or off. \n.header(s) ON|OFF Turn display of headers on or off \n.help Show this message \n.import FILE TABLE Import data from FILE into TABLE \n.indices TABLE Show names of all indices on TABLE \n.load FILE ?ENTRY? Load an extension library \n.mode MODE ?TABLE? Set output mode where MODE is one of: \n csv Comma-separated values \n column Left-aligned columns. (See .width) \n html HTML <table> code \n insert SQL insert statements for TABLE \n line One value per line \n list Values delimited by .separator string \n tabs Tab-separated values \n tcl TCL list elements \n.nullvalue STRING Print STRING in place of NULL values \n.output FILENAME Send output to FILENAME \n.output stdout Send output to the screen \n.prompt MAIN CONTINUE Replace the standard prompts \n.quit Exit this program \n.read FILENAME Execute SQL in FILENAME \n.schema ?TABLE? Show the CREATE statements \n.separator STRING Change separator used by output mode and .import \n.show Show the current values for various settings \n.tables ?PATTERN? List names of tables matching a LIKE pattern \n.timeout MS Try opening locked tables for MS milliseconds \n.width NUM NUM ... Set column widths for "column" mode
Install SQLite3 for Windows by downloading the following 2 zip files and unzipping them into /WINDOWS/system32 \nhttp://www.sqlite.org/sqlite-3_6_14_1.zip \nhttp://www.sqlite.org/sqlitedll-3_6_14_1.zip \nIf those don't work try the official download site here \nand now,you can open a cmd shell,and input sqlite3 like this: \n \nC:\\Documents and Settings\\Administrator>sqlite3 \nSQLite version 3.5.9 \nEnter ".help" for instructions \nand some help infos is here: \nsqlite> .help \n.bail ON|OFF Stop after hitting an error. Default OFF \n.databases List names and files of attached databases \n.dump ?TABLE? ... Dump the database in an SQL text format \n.echo ON|OFF Turn command echo on or off \n.exit Exit this program \n.explain ON|OFF Turn output mode suitable for EXPLAIN on or off. \n.header(s) ON|OFF Turn display of headers on or off \n.help Show this message \n.import FILE TABLE Import data from FILE into TABLE \n.indices TABLE Show names of all indices on TABLE \n.load FILE ?ENTRY? Load an extension library \n.mode MODE ?TABLE? Set output mode where MODE is one of: \n csv Comma-separated values \n column Left-aligned columns. (See .width) \n html HTML <table> code \n insert SQL insert statements for TABLE \n line One value per line \n list Values delimited by .separator string \n tabs Tab-separated values \n tcl TCL list elements \n.nullvalue STRING Print STRING in place of NULL values \n.output FILENAME Send output to FILENAME \n.output stdout Send output to the screen \n.prompt MAIN CONTINUE Replace the standard prompts \n.quit Exit this program \n.read FILENAME Execute SQL in FILENAME \n.schema ?TABLE? Show the CREATE statements \n.separator STRING Change separator used by output mode and .import \n.show Show the current values for various settings \n.tables ?PATTERN? List names of tables matching a LIKE pattern \n.timeout MS Try opening locked tables for MS milliseconds \n.width NUM NUM ... Set column widths for "column" mode
add this line into /etc/lftp.conf \nset net:limit-rate 10240000,40960 \n \nthat's limit upload rate to 10M,and download to 40K \n \nsome useful resource:
when i ssh to a server,i get some message like this: \nAddress 192.168.5.12 maps to localhost, but this does not map back to the address - POSSIBLE BREAKIN ATTEMPT! \nSolution: \nModify the "/etc/ssh/ssh_config" file at localhost \n GSSAPIAuthentication no \nexp: \nssh 192.168.1.110时报错上述错,本地是192.168.1.20 ,则修改本地192.168.1.20中的/etc/ssh/ssh_config,把参数GSSAPIAuthentication no修改就可以了。。或者修改服务器端192.168.1.110上的/etc/ssh/sshd_config ,把参数GSSAPIAuthentication no改了也可以。要注意的是/etc/ssh/ssh_config和/etc/ssh/sshd_confg的区别。
\ncURL figures out which protocol to use from the URL you provide, and when \"http:\" is specified will, unless otherwise instructed (using -0), default to using HTTP 1.1. The first argument, -u, instructs cURL to use the next two parameters (separated by a colon) as the account name and password for basic authentication. The next argument, -d, specifies the data (maximum 140 characters) to be sent via a POST request.\n\nOf course what cURL expects is a response to the POST request so the result will be the requested page (update.xml) sent to stdout. This page will be encoded according to the file type used in the request, thus as we just requested update.xml we’ll get XML-formatted data. The alternatives are JSON (JavaScript Object Notation), RSS and Atom formats.\n\nfrom:\nhttp://www.networkworld.com/columnists/2008/052108-gearhead.html?page=2", "created_at"=>2009-09-27 18:26:17 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
curl -u email:passw -d status="text" http://twitter.com/statuses/update.xml \ncURL figures out which protocol to use from the URL you provide, and when "http:" is specified will, unless otherwise instructed (using -0), default to using HTTP 1.1. The first argument, -u, instructs cURL to use the next two parameters (separated by a colon) as the account name and password for basic authentication. The next argument, -d, specifies the data (maximum 140 characters) to be sent via a POST request.
\n\n
Of course what cURL expects is a response to the POST request so the result will be the requested page (update.xml) sent to stdout. This page will be encoded according to the file type used in the request, thus as we just requested update.xml we’ll get XML-formatted data. The alternatives are JSON (JavaScript Object Notation), RSS and Atom formats.
I like Unicorn because it's Unix \n RailsConf 2009: powered by OMG UNICORNS!!!! \n
\n", "_id"=>487}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"01. 视觉观察 | Observe"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["rails", "rails-2.3.4"], "comments_count"=>0, "category_id"=>6, "title"=>"rails-2.3.4 发布了", "body"=>"Ruby on Rails 2.3.4, this release fixes bugs and introduces a few minor features. Due to the inclusion of two security fixes, all users of the 2.3 series are recommended to upgrade as soon as possible.\n\nC:\\Documents and Settings\\Administrator>gem install rails\nSuccessfully installed activesupport-2.3.4\nSuccessfully installed activerecord-2.3.4\nSuccessfully installed actionpack-2.3.4\nSuccessfully installed actionmailer-2.3.4\nSuccessfully installed activeresource-2.3.4\nSuccessfully installed rails-2.3.4\n6 gems installed\nInstalling ri documentation for activesupport-2.3.4...\nInstalling ri documentation for activerecord-2.3.4...\nInstalling ri documentation for actionpack-2.3.4...\nInstalling ri documentation for actionmailer-2.3.4...\nInstalling ri documentation for activeresource-2.3.4...\nInstalling RDoc documentation for activesupport-2.3.4...\nInstalling RDoc documentation for activerecord-2.3.4...\nInstalling RDoc documentation for actionpack-2.3.4...\nInstalling RDoc documentation for actionmailer-2.3.4...\nInstalling RDoc documentation for activeresource-2.3.4...\n\n详细信息:\n\nhttp://weblog.rubyonrails.org/2009/9/4/ruby-on-rails-2-3-4", "created_at"=>2009-10-14 07:47:04 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
Ruby on Rails 2.3.4, this release fixes bugs and introduces a few minor features. Due to the inclusion of two security fixes, all users of the 2.3 series are recommended to upgrade as soon as possible.
\n\n
C:\\Documents and Settings\\Administrator>gem install rails \nSuccessfully installed activesupport-2.3.4 \nSuccessfully installed activerecord-2.3.4 \nSuccessfully installed actionpack-2.3.4 \nSuccessfully installed actionmailer-2.3.4 \nSuccessfully installed activeresource-2.3.4 \nSuccessfully installed rails-2.3.4 \n6 gems installed \nInstalling ri documentation for activesupport-2.3.4... \nInstalling ri documentation for activerecord-2.3.4... \nInstalling ri documentation for actionpack-2.3.4... \nInstalling ri documentation for actionmailer-2.3.4... \nInstalling ri documentation for activeresource-2.3.4... \nInstalling RDoc documentation for activesupport-2.3.4... \nInstalling RDoc documentation for activerecord-2.3.4... \nInstalling RDoc documentation for actionpack-2.3.4... \nInstalling RDoc documentation for actionmailer-2.3.4... \nInstalling RDoc documentation for activeresource-2.3.4...
\nany hg command fails with:\nValueError: unknown locale: UTF-8\n\nThis is mercurial 1.3.1and Python 2.6.1, but its seem that its caused by Leopard’s Term.app not setting the local encoding correctly. To resolve this, add the following to .profile:\n
This is mercurial 1.3.1and Python 2.6.1, but its seem that its caused by Leopard’s Term.app not setting the local encoding correctly. To resolve this, add the following to .profile: \nexport LC_ALL=en_US.UTF-8 \nexport LANG=en_US.UTF-8 \nthen i clone the code for Go Programming Language \neoe:system IceskYsl$ printenv LANG \neoe:system IceskYsl$ export LC_ALL=en_US.UTF-8 \neoe:system IceskYsl$ export LANG=en_US.UTF-8 \neoe:system IceskYsl$ hg clone -r release https://go.googlecode.com/hg/ go \nrequesting all changes \nadding changesets \nadding manifests \nadding file changes \nadded 3976 changesets with 16799 changes to 2931 files \nupdating working directory \n1640 files updated, 0 files merged, 0 files removed, 0 files unresolved \nhttp://www.ibm.com/developerworks/cn/opensource/os-cn-mercurial/
\n", "_id"=>493}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>11, "title"=>"how to avoid Net::SMTPFatalError (555 5.5.2 Syntax error.", "body"=>"i can not get notify email from my ExceptionNotifier in rails project,i notice some useful msg in the production logs:\n
@from = \"\#{sender}\"\n If I submit an email id, It is giving error as\n (Net::SMTPFatalError) \"555 5.5.2 Syntax error. d29sm1994943and.38\\n\"\n\nThe from line is the problem. The Net::SMTP library was recently changed\nso it adds angle brackets to your sender, so you cannot have any in your\nstring. Try this as a workaround:\n@from = \"a...@xxxxxxx\"
\n\nso,just fix it like this:\nExceptionNotifier.sender_address = %(\"iceskysl\" )\nto\nExceptionNotifier.sender_address = %(iceskysl@eoemobile.com)", "created_at"=>2009-11-12 19:58:54 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
i can not get notify email from my ExceptionNotifier in rails project,i notice some useful msg in the production logs: \nNet::SMTPFatalError (555 5.5.2 Syntax error. b17sm72261fka.43
\n\n
google.... \n@from = "\#{sender}a...@xxxxxxx" \n If I submit an email id, It is giving error as \n (Net::SMTPFatalError) "555 5.5.2 Syntax error. d29sm1994943and.38\\n"
\n\n
The from line is the problem. The Net::SMTP library was recently changed \nso it adds angle brackets to your sender, so you cannot have any in your \nstring. Try this as a workaround: \n@from = "a...@xxxxxxx"
\n\n
so,just fix it like this: \nExceptionNotifier.sender_address = %("iceskysl" iceskysl@eoemobile.com) \nto \nExceptionNotifier.sender_address = %(iceskysl@eoemobile.com)
\n", "_id"=>495}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["package", "ubuntu", "uninstall"], "comments_count"=>0, "category_id"=>7, "title"=>"Uninstall / Delete / Remove Package", "body"=>"Just use the following syntax:\n\nsudo apt-get remove {package-name}\n\nFor example remove package called mplayer, enter:\n$ sudo apt-get remove mplayer\n\nRemove package called lighttpd along with all configuration files, enter:\n$ sudo apt-get --purge remove lighttpd\n\nTo list all installed package, enter:\\\ndpkg --list\ndpkg --list | less\ndpkg --list | grep -i 'http'", "created_at"=>2009-11-22 18:48:23 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
Just use the following syntax:
\n\n
sudo apt-get remove {package-name}
\n\n
For example remove package called mplayer, enter: \n$ sudo apt-get remove mplayer
\n\n
Remove package called lighttpd along with all configuration files, enter: \n$ sudo apt-get --purge remove lighttpd
\n\n
To list all installed package, enter:\\ \ndpkg --list \ndpkg --list | less \ndpkg --list | grep -i 'http'
\n", "_id"=>496}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["delegate", "ImageMagick"], "comments_count"=>0, "category_id"=>7, "title"=>"ImageMagick够折腾得,no decode delegate", "body"=>"估计RP出问题了,以前安装和今天在mac上安装都很顺利,但是在服务器上装得时候,出现一大堆得问题,极度诡异,最后查了N多资料,改了N多东西,也不晓得最后是哪个生效了,终于折腾好了.\n记录下我参考过得资料:\nhttp://www.imagemagick.org/script/command-line-processing.php\nhttp://wanguan2000.blog.ubuntu.org.cn/2009/01/04/ubuntu-下rmagick的安装/\nhttp://infrastacks.com/?p=57\nhttp://hi.baidu.com/yttxuehui/blog/item/9f1a21978d6fa96a55fb96d5.html\nhttp://www.blogjava.net/fl1429/archive/2009/06/17/282895.html\nhttp://hi.baidu.com/countryroadtao/blog/item/225c72dad2adc16cd0164e97.html\nhttp://www.cnscn.org/htm_data/602/0705/8717.html\nhttp://stackoverflow.com/questions/1483968/imagemagick-convert-error-wrong-jpeg-library-version-library-is-62-caller-expe\n我读最后一个问题印象深刻\n\"Looks like it is reading the wrong jpeg ibrary, but I have jpeg 7 installed. How do i tell ImageMagick to look up the right JPEG library version(I don't care 62 or 70 as long as it works).\"\nroot@li84-64:/data/soft/ImageMagick-6.5.7-9# convert -list format | grep JPEG\n see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS),\n and supplement 61 which adds JPEG-2000 encoding.\n JNG* PNG rw- JPEG Network Graphics\n JP2* JP2 rw- JPEG-2000 File Format Syntax\n JPC* JPC rw- JPEG-2000 Code Stream Syntax\n JPEG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n JPG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n JPX* JPX rw- JPEG-2000 File Format Syntax\n PGX* PGX r-- JPEG-2000 VM Format\n PJPEG* JPEG rw- Joint Photographic Experts Group JFIF format (70)\n\n看到其需要得JPEG得lib是70,但是我装得是\n\nroot@li84-64:/data/soft/ImageMagick-6.5.7-9# dpkg --list | grep \"magick\"\nrc imagemagick 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation programs\nii libmagick++10 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library\nii libmagick++9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library - develop\nii libmagick10 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library\nii libmagick9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library - development fil\nii libmagickcore1 7:6.4.5.4.dfsg1-1ubuntu3.1 low-level image manipulation library\nii libmagickwand1 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation library\nii librmagick-ruby 1.15.11-1ubuntu1 ImageMagick API for Ruby\nii librmagick-ruby1.8 1.15.11-1ubuntu1 ImageMagick API for Ruby", "created_at"=>2009-11-22 20:30:32 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
root@li84-64:/data/soft/ImageMagick-6.5.7-9# dpkg --list | grep "magick" \nrc imagemagick 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation programs \nii libmagick++10 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library \nii libmagick++9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 C++ API to the ImageMagick library - develop \nii libmagick10 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library \nii libmagick9-dev 7:6.3.7.9.dfsg1-2ubuntu1.1 image manipulation library - development fil \nii libmagickcore1 7:6.4.5.4.dfsg1-1ubuntu3.1 low-level image manipulation library \nii libmagickwand1 7:6.4.5.4.dfsg1-1ubuntu3.1 image manipulation library \nii librmagick-ruby 1.15.11-1ubuntu1 ImageMagick API for Ruby \nii librmagick-ruby1.8 1.15.11-1ubuntu1 ImageMagick API for Ruby
\n", "_id"=>497}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["find", "inject", "rails", "ruby", "select"], "comments_count"=>0, "category_id"=>5, "title"=>"用Ruby在已知数组中找到和目标最匹配得元素", "body"=>"有个需求,给定一个数组,然后给出一个变量,需要在这个数组中找到和这个变量得值最接近得那个元素,开始用find或者select都不是很合适,最后找到inject,很好得解决了这个需求,现在记录下:\n首先看下inject这个函数\n````\nenum.inject(initial) {| memo, obj | block } => obj\nenum.inject {| memo, obj | block } => obj\nCombines the elements of enum by applying the block to an accumulator value (memo) and each element in turn. At each step, memo is set to the value returned by the block. The first form lets you supply an initial value for memo. The second form uses the first element of the collection as a the initial value (and skips that element while iterating).\n\n # Sum some numbers\n (5..10).inject {|sum, n| sum + n } #=> 45\n # Multiply some numbers\n (5..10).inject(1) {|product, n| product * n } #=> 151200\n\n # find the longest word\n longest = %w{ cat sheep bear }.inject do |memo,word|\n memo.length > word.length ? memo : word\n end\n longest #=> \"sheep\"\n\n # find the length of the longest word\n longest = %w{ cat sheep bear }.inject(0) do |memo,word|\n memo >= word.length ? memo : word.length\n end\n longest #=> 5\n```\n\n然后根据我得需求,写出一个函数如下:\n````\n # find the min abs size\n def self.select_h(h)\n if ALL_FORMATS.include?(h)\n return h\n else\n ok_size = ALL_FORMATS.inject do |i,j|\n (i-h).abs < (j-h).abs ? i : j\n end\n return ok_size\n end\n end\n```\n首先看是否包含这个变量,如果又,直接返回,如果没有就inject来取一个最合适得。", "created_at"=>2009-11-24 08:06:13 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
有个需求,给定一个数组,然后给出一个变量,需要在这个数组中找到和这个变量得值最接近得那个元素,开始用find或者select都不是很合适,最后找到inject,很好得解决了这个需求,现在记录下: \n首先看下inject这个函数 \n```` \nenum.inject(initial) {| memo, obj | block } => obj \nenum.inject {| memo, obj | block } => obj \nCombines the elements of enum by applying the block to an accumulator value (memo) and each element in turn. At each step, memo is set to the value returned by the block. The first form lets you supply an initial value for memo. The second form uses the first element of the collection as a the initial value (and skips that element while iterating).
\n\n
# Sum some numbers \n (5..10).inject {|sum, n| sum + n } #=> 45 \n # Multiply some numbers \n (5..10).inject(1) {|product, n| product * n } #=> 151200
\n\n
# find the longest word \n longest = %w{ cat sheep bear }.inject do |memo,word| \n memo.length > word.length ? memo : word \n end \n longest #=> "sheep"
\n\n
# find the length of the longest word \n longest = %w{ cat sheep bear }.inject(0) do |memo,word| \n memo >= word.length ? memo : word.length \n end \n longest #=> 5 \n```
\n\n
然后根据我得需求,写出一个函数如下: \n` \n # find the min abs size \n def self.select_h(h) \n if ALL_FORMATS.include?(h) \n return h \n else \n ok_size = ALL_FORMATS.inject do |i,j| \n (i-h).abs < (j-h).abs ? i : j \n end \n return ok_size \n end \n end \n \n首先看是否包含这个变量,如果又,直接返回,如果没有就inject来取一个最合适得。
\n", "_id"=>498}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Facebooker error UnableToLoadAdapter", "body"=>"If you see an error that looks like\n
\nIts because you haven’t configured config/facebooker.yml file correctly, or at all. (Most tutorials etc. have you creating and editing this file after you install facebooker)", "created_at"=>2009-11-26 13:31:29 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
If you see an error that looks like \n/home/brickfactor/facebooker_tutorial/vendor/plugins/facebooker/lib/facebooker \n/adapters/adapter_base.rb:43:in load_adapter': Facebooker::AdapterBase::UnableToLoadAdapter (Facebooker::AdapterBase::UnableToLoadAdapter) \n/RAILS_APP/vendor/plugins/facebooker/lib/facebooker/adapters/adapter_base.rb:43:inload_adapter': Facebooker::AdapterBase::UnableToLoadAdapter (Facebooker::AdapterBase::UnableToLoadAdapter) \nfrom /RAILS_APP/vendor/plugins/facebooker/lib/facebooker.rb:121:in load_adapter' \nfrom /RAILS_APP/vendor/plugins/facebooker/lib/facebooker.rb:65:inapply_configuration' \nfrom /RAILS_APP/vendor/plugins/facebooker/lib/facebooker.rb:45:in `load_configuration' \nfrom /RAILS_APP/vendor/plugins/facebooker/rails/../init.rb:6 \nIts because you haven’t configured config/facebooker.yml file correctly, or at all. (Most tutorials etc. have you creating and editing this file after you install facebooker)
\n", "_id"=>502}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["GD", "php", "ubuntu"], "comments_count"=>0, "category_id"=>7, "title"=>"Install GD Support for PHP in Ubuntu", "body"=>"I am in the process of building my blog using wordpress ,then i install SI CAPTCHA Anti-Spam ,but it's say i didn’t have GD support for PHP5 installed on my server. so i need to do:\n\nOpen terminal and type in the following command:\n
\n\nThere you go, you now have GD Support for PHP5 in Ubuntu. Get your Drupal on!", "created_at"=>2010-01-13 02:25:36 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
I am in the process of building my blog using wordpress ,then i install SI CAPTCHA Anti-Spam ,but it's say i didn’t have GD support for PHP5 installed on my server. so i need to do:
\n\n
Open terminal and type in the following command: \n$ sudo apt-get install php5-gd
\n\n
Now restart Apache \n# sudo /etc/init.d/apache2 restart
\n\n
or restart spawn-fcgi \n/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9100 -u www-data -g www-data -f /usr/bin/php-cgi -C 10
\n\n
There you go, you now have GD Support for PHP5 in Ubuntu. Get your Drupal on!
\n", "_id"=>503}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>7, "title"=>"Fixing Ruby no such file to load readline error in centOS", "body"=>"Does this error message look familar when you script/console?\n````[iceskysl@li1248 current]$ ./script/console production\nLoading production environment (Rails 2.3.5)\n/usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load -- readline (LoadError)\n from /usr/local/lib/ruby/1.8/irb/completion.rb:10\n from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `require'\n from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `load_modules'\n from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `each'\n from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `load_modules'\n from /usr/local/lib/ruby/1.8/irb/init.rb:21:in `setup'\n from /usr/local/lib/ruby/1.8/irb.rb:54:in `start'\n from /usr/local/bin/irb:13```\nthis happens when readline is somehow different than your current version of ruby or corrupted. The quick fix is to recompile readline. To do it in CentOS with yum:\n````$> yum install readline-devel -y\n$> cd /root/src/ruby-1.8.6-p114/ext/readline/\n$> ruby extconf.rb\n$> make\n$> sudo make install ```\nNow you should have script/console working.", "created_at"=>2010-01-19 21:46:28 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
Does this error message look familar when you script/console? \n[iceskysl@li1248 current]$ ./script/console production \nLoading production environment (Rails 2.3.5) \n/usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load -- readline (LoadError) \n from /usr/local/lib/ruby/1.8/irb/completion.rb:10 \n from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `require' \n from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `load_modules' \n from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `each' \n from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `load_modules' \n from /usr/local/lib/ruby/1.8/irb/init.rb:21:in `setup' \n from /usr/local/lib/ruby/1.8/irb.rb:54:in `start' \n from /usr/local/bin/irb:13``` \nthis happens when readline is somehow different than your current version of ruby or corrupted. The quick fix is to recompile readline. To do it in CentOS with yum: \n$> yum install readline-devel -y \n$> cd /root/src/ruby-1.8.6-p114/ext/readline/ \n$> ruby extconf.rb \n$> make \n$> sudo make install ``` \nNow you should have script/console working.
\n", "_id"=>504}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["centOS", "Swap"], "comments_count"=>0, "category_id"=>7, "title"=>"Swap Space in centOS", "body"=>"Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.\n\nSwap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.\n\nSwap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.\n\nSo, if:\n\nM = Amount of RAM in GB, and S = Amount of swap in GB, then\n
If M < 2\n\tS = M *2\nElse\n\tS = M + 2
\nUsing this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.\n\nFor systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).\n\nsource:http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-swapspace.html", "created_at"=>2010-01-21 02:01:34 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.
\n\n
Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
\n\n
Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.
\n\n
So, if:
\n\n
M = Amount of RAM in GB, and S = Amount of swap in GB, then \nIf M < 2 \n S = M *2 \nElse \n S = M + 2 \nUsing this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.
\n\n
For systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).
\n", "_id"=>505}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"04. 无心呢喃 | Buzz"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["劫持", "电信"], "comments_count"=>0, "category_id"=>5, "title"=>"深圳电信耍流氓,劫持浏览器", "body"=>"今天无意发现在浏览器的左下角经常出现一个页面无法打开的提示,如下\nThe webpage at http://121.15.207.133:4022/logo.jpg?p=undefined|778|1276|24|800|1280might be temporarily down or it may have moved permanently to a new web address.\n\n看其样式是请求了一个121.15.207.133上的一个logo图片,然后传入了几个参数,但是这个图片的服务器貌似除了电问题,导致请求不到。\n无缘无故的,咋会去请求这个玩意呢,查了吓这个IP归属,属于:\n
\n", "_id"=>506}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["C", "ruby", "RubyInline"], "comments_count"=>0, "category_id"=>2, "title"=>"RubyInline, Making Making Things Faster Easier", "body"=>"发现一篇好文,讲的是如何使用RubyInline,在Ruby中直接嵌入C并运行,相比之前些lib,要方便的多,由于这个文章在墙外,就转了一份过来,可以翻墙的可以去看原文\nhttp://on-ruby.blogspot.com/2006/07/rubyinline-making-making-things-faster.html\n\nToday on ruby-talk, I caught a thread called \"For Performance, Write it in C\". I'd like to present a slight amendment to that thesis. Let me explain.\n\nIt all started with an email at work. Someone was passing around a bunch of prime number printers in various languages (C, Java, C#, Perl, and Python). They all used the same (ugly) algorithm, and were supposed to show just how 'performant the languages were. Since I'm the local Ruby evangelist, I was asked to write a Ruby version. Here's what I came up with (warning, ugly algorithm ahead):\n\n#!/usr/bin/ruby\n\nfor num in 1..10_000 do\nis_prime = 1\nfor x in 2..(num - 1) do\nif (num % x == 0)\nis_prime = x\nbreak\nend\nend\nif is_prime == 1\nputs \"\#{num} is a prime number\"\nelse\nputs \"\#{num} equals \#{is_prime} * \#{num/is_prime}\"\nend\nend\nHow fast is it? Well, time says:\n\n$ time ./primes.rb > /dev/null\n\nreal 0m2.905s\nuser 0m2.716s\nsys 0m0.004s\n$\n\nCertainly, nothing to write home about, but not too far from Perl or Python either.\nWanting to improve it, and not being able to touch the algorithm (we want to be comparing apples to quinces after all, not apples to oranges). I know my only hope is to find the bottleneck(s) and rewrite it (them?) in C. My first step is to grab Ruby's profiler and see what it says (oh, by the way, I reduced the value of num to 100 so that this would complete in my lifetime ... the profiler is slow).\n\n$ ruby -rprofile primes.rb > /dev/null\n% cumulative self self total\ntime seconds seconds calls ms/call ms/call name\n63.64 0.14 0.14 101 1.39 3.56 Range#each\n13.64 0.17 0.03 1133 0.03 0.03 Fixnum#%\n9.09 0.19 0.02 1233 0.02 0.02 Fixnum#==\n4.55 0.20 0.01 100 0.10 0.20 Kernel.puts\n4.55 0.21 0.01 200 0.05 0.05 IO#write\n4.55 0.22 0.01 248 0.04 0.04 Fixnum#to_s\n0.00 0.22 0.00 74 0.00 0.00 Fixnum#/\n0.00 0.22 0.00 100 0.00 0.00 Fixnum#-\n0.00 0.22 0.00 1 0.00 220.00 #toplevel\n$\n\nWhich tells me that most of my time is spent in each (well, it's actually spent in the block I sent to each. It's taking a whopping 1.39 msec per call, compared to .0X msec for everything else. What would happen if I rewrote just that block?\nEnter RubyInline (A great tool written by zenspider and Eric Hodel). I'm not a C wiz by any stretch of the imagination, but this stuff is pretty easy to bang out. My new code looks like this:\n\n#!/usr/bin/ruby\n\nrequire \"rubygems\"\nrequire \"inline\"\n\nclass Primes\ninline do |builder|\nbuilder.c '\nint prime(int num) {\nint x;\nfor (x = 2; x < (num - 1) ; x++) { if (num == 2) { return 1; } if (num % x == 0) { return x; } } return 1; }' end end p = Primes.new for num in 2..10_000 do is_prime = p.prime(num) if is_prime == 1 puts \"\#{num} is a prime number\" else puts \"\#{num} equals \#{is_prime} * \#{num/is_prime}\" end end Not too ugly. At least I can still see what's happening. The main loop being in Ruby helps a lot too (especially if this were a much bigger program). How much of a difference does it make? time says: $ time ./cprimes.rb > /dev/null\n\nreal 0m0.328s\nuser 0m0.288s\nsys 0m0.020s\n\nAn order of magnitude improvement. Not too shabby.\nWhat's the lesson here? Optimize what you need to (and only what you need to), profile find out what that is (it may be slow, but profiling is your friend), and use the right tools (rewriting a bit of code with RubyInline is way better than rewriting the whole app in C).", "created_at"=>2010-01-24 10:51:47 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
Today on ruby-talk, I caught a thread called "For Performance, Write it in C". I'd like to present a slight amendment to that thesis. Let me explain.
\n\n
It all started with an email at work. Someone was passing around a bunch of prime number printers in various languages (C, Java, C#, Perl, and Python). They all used the same (ugly) algorithm, and were supposed to show just how 'performant the languages were. Since I'm the local Ruby evangelist, I was asked to write a Ruby version. Here's what I came up with (warning, ugly algorithm ahead):
\n\n
!/usr/bin/ruby
\n\n
for num in 1..10_000 do \nis_prime = 1 \nfor x in 2..(num - 1) do \nif (num % x == 0) \nis_prime = x \nbreak \nend \nend \nif is_prime == 1 \nputs "\#{num} is a prime number" \nelse \nputs "\#{num} equals \#{is_prime} * \#{num/is_prime}" \nend \nend \nHow fast is it? Well, time says:
\n\n
$ time ./primes.rb > /dev/null
\n\n
real 0m2.905s \nuser 0m2.716s \nsys 0m0.004s \n$
\n\n
Certainly, nothing to write home about, but not too far from Perl or Python either. \nWanting to improve it, and not being able to touch the algorithm (we want to be comparing apples to quinces after all, not apples to oranges). I know my only hope is to find the bottleneck(s) and rewrite it (them?) in C. My first step is to grab Ruby's profiler and see what it says (oh, by the way, I reduced the value of num to 100 so that this would complete in my lifetime ... the profiler is slow).
Which tells me that most of my time is spent in each (well, it's actually spent in the block I sent to each. It's taking a whopping 1.39 msec per call, compared to .0X msec for everything else. What would happen if I rewrote just that block? \nEnter RubyInline (A great tool written by zenspider and Eric Hodel). I'm not a C wiz by any stretch of the imagination, but this stuff is pretty easy to bang out. My new code looks like this:
\n\n
!/usr/bin/ruby
\n\n
require "rubygems" \nrequire "inline"
\n\n
class Primes \ninline do |builder| \nbuilder.c ' \nint prime(int num) { \nint x; \nfor (x = 2; x < (num - 1) ; x++) { if (num == 2) { return 1; } if (num % x == 0) { return x; } } return 1; }' end end p = Primes.new for num in 2..10_000 do is_prime = p.prime(num) if is_prime == 1 puts "\#{num} is a prime number" else puts "\#{num} equals \#{is_prime} * \#{num/is_prime}" end end Not too ugly. At least I can still see what's happening. The main loop being in Ruby helps a lot too (especially if this were a much bigger program). How much of a difference does it make? time says: $ time ./cprimes.rb > /dev/null
\n\n
real 0m0.328s \nuser 0m0.288s \nsys 0m0.020s
\n\n
An order of magnitude improvement. Not too shabby. \nWhat's the lesson here? Optimize what you need to (and only what you need to), profile find out what that is (it may be slow, but profiling is your friend), and use the right tools (rewriting a bit of code with RubyInline is way better than rewriting the whole app in C).
\n# Example MySQL config file for large systems.\n#\n# This is for a large system with memory = 512M where the system runs mainly\n# MySQL.\n#\n# You can copy this file to\n# /etc/my.cnf to set global options,\n# mysql-data-dir/my.cnf to set server-specific options (in this\n# installation this directory is /var/lib/mysql) or\n# ~/.my.cnf to set user-specific options.\n#\n# In this file, you can use all long options that a program supports.\n# If you want to know which options a program supports, run the program\n# with the \"--help\" option.\n\n# The following options will be passed to all MySQL clients\n[client]\nport = 3306\nsocket = /var/lib/mysql/mysql.sock\n\n# Here follows entries for some specific programs\n\n# The MySQL server\n[mysqld]\ndatadir=/var/lib/mysql\nsocket=/var/lib/mysql/mysql.sock\nuser=mysql\nskip-locking\n\n# By default, the wait_timeout value is 28800. Unless you want MySQL to keep waiting for 28800 seconds (480 minutes or 8 hours),\n# please decrease its value according to your application needs.\nwait_timeout=60\n# Increase connect_timeout from 5 to 10\nconnect_timeout=10\n# Decrease interactive_timeout from 28800 to 100\ninteractive_timeout=120\n# Increase join_buffer_size from 131072 to 1M\njoin_buffer_size=1M\n# Increase query_cache_size from 0 to 128M\nquery_cache_size=32M\n# Increase query cache limit from 1048576 to 2M\nquery_cache_limit=2M\n# Increase max allowed packet size from 1M to 16M\nmax_allowed_packet=2M\n# Increase table cache cache from 256 to 1024\ntable_cache=1024\n# Increase sort buffer size from 1M\nsort_buffer_size=2M\n# Increase read buffer size from 1M\nread_buffer_size=2M\n# Increase read_rnd_buffer_size to 4M\nread_rnd_buffer_size=4M\n\n#Other settings\nsort_buffer_size=8M\nkey_buffer = 256M\nkey_buffer_size=64M\nmyisam_sort_buffer_size = 64M\nthread_cache_size = 8\n# Try number of CPU's*2 for thread_concurrency\nthread_concurrency = 2\n\n\n# Don't listen on a TCP/IP port at all. This can be a security enhancement,\n# if all processes that need to connect to mysqld run on the same host.\n# All interaction with mysqld must be made via Unix sockets or named pipes.\n# Note that using this option without enabling named pipes on Windows\n# (via the \"enable-named-pipe\" option) will render mysqld useless!\n#\n#skip-networking\n\n# Disable Federated by default\nskip-federated\n\nold_passwords=1\n\n#for slow queries\nlog-slow-queries = /var/log/mysql-slow.log\nlong_query_time = 3\n\n[mysqldump]\nquick\nmax_allowed_packet = 16M\n\n[mysql]\nno-auto-rehash\n# Remove the next comment character if you are not familiar with SQL\n#safe-updates\n\n[isamchk]\nkey_buffer = 128M\nsort_buffer_size = 128M\nread_buffer = 2M\nwrite_buffer = 2M\n\n[myisamchk]\nkey_buffer = 128M\nsort_buffer_size = 128M\nread_buffer = 2M\nwrite_buffer = 2M\n\n[mysqlhotcopy]\ninteractive-timeout\n\n[mysqld_safe]\nlog-error=/var/log/mysqld.log\npid-file=/var/run/mysqld/mysqld.pid\n
mysql> SHOW VARIABLES like \"%sort%\";\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| max_length_for_sort_data | 1024 |\n| max_sort_length | 1024 |\n| myisam_max_sort_file_size | 2146435072 |\n| myisam_sort_buffer_size | 67108864 |\n| sort_buffer_size | 8388608 |\n+---------------------------+------------+\n5 rows in set (0.00 sec)
\n\n不晓得是做啥用的,查了下资料:\n
http://forge.mysql.com/wiki/MySQL_Internals_Algorithms\n\nUsing the modified filesort algorithm, the tuples are longer than the pairs used in the original method, and fewer of them fit in the sort buffer (the size of which is given by sort_buffer_size). As a result, it is possible for the extra I/O to make the modified approach slower, not faster. To avoid a slowdown, the optimization is used only if the total size of the extra columns in the sort tuple does not exceed the value of the max_length_for_sort_data system variable. (A symptom of setting the value of this variable too high is that you should see high disk activity and low CPU activity.)
Using the modified filesort algorithm, the tuples are longer than the pairs used in the original method, and fewer of them fit in the sort buffer (the size of which is given by sort_buffer_size). As a result, it is possible for the extra I/O to make the modified approach slower, not faster. To avoid a slowdown, the optimization is used only if the total size of the extra columns in the sort tuple does not exceed the value of the max_length_for_sort_data system variable. (A symptom of setting the value of this variable too high is that you should see high disk activity and low CPU activity.)
\n", "_id"=>513}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "filesort"], "comments_count"=>0, "category_id"=>11, "title"=>"What does Using filesort mean in MySQL?", "body"=>"一直以来,只要我看到explain出来的结果有“Using filesort ”,我就要想方设法的优化和改善,因为我以前以为这个的意思就是使用文件系统来排序(那该多慢呀!),其实不是这样的。\n在mysqlperformanceblog上看到一篇文章《What does Using filesort mean in MySQL?》其中作者说自己每次面世的时候都会问“what does Using filesort mean in EXPLAIN,” 结果没有一个人回答的是对的,结果让其比较郁闷,就写了这个文章说明:\n
The usual answer is something like “rows are being placed into a temporary table which is too big to fit in memory, so it gets sorted on disk.” Unfortunately, this is not the same thing. First of all, this is Using temporary. Secondly, temporary tables may go to disk if they are too big, but EXPLAIN doesn’t show that. (If I interview you, I might ask you what “too big” means, or I might ask you the other reason temporary tables go to disk!)
The truth is, filesort is badly named. Anytime a sort can’t be performed from an index, it’s a filesort. It has nothing to do with files. Filesort should be called “sort.” It is quicksort at heart.
\n正解是,filesort这个名字有问题,容易给人误解,在mysql中,任何不能通过index进行的sort都称之为filesort,这里的filesort和文件没有任何关系,应该称之为“sort”而不是“filesort”,它的内部实现就是快速排序。\n\n参考资料:\nWhat does Using filesort mean in MySQL?\nhttp://www.mysqlperformanceblog.com/2009/03/05/what-does-using-filesort-mean-in-mysql/\n\nHow MySQL executes ORDER BY\nhttp://s.petrunia.net/blog/?p=24", "created_at"=>2010-02-03 03:51:36 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
一直以来,只要我看到explain出来的结果有“Using filesort ”,我就要想方设法的优化和改善,因为我以前以为这个的意思就是使用文件系统来排序(那该多慢呀!),其实不是这样的。 \n在mysqlperformanceblog上看到一篇文章《What does Using filesort mean in MySQL?》其中作者说自己每次面世的时候都会问“what does Using filesort mean in EXPLAIN,” 结果没有一个人回答的是对的,结果让其比较郁闷,就写了这个文章说明: \nThe usual answer is something like “rows are being placed into a temporary table which is too big to fit in memory, so it gets sorted on disk.” Unfortunately, this is not the same thing. First of all, this is Using temporary. Secondly, temporary tables may go to disk if they are too big, but EXPLAIN doesn’t show that. (If I interview you, I might ask you what “too big” means, or I might ask you the other reason temporary tables go to disk!) \n通常的解释是:选择出来的记录太多了,需要排序时内存中放不下了,所以会存储在磁盘中,并通过操作磁盘的文件的方式来排序。但是呢,这是不对的。
\n\n
The truth is, filesort is badly named. Anytime a sort can’t be performed from an index, it’s a filesort. It has nothing to do with files. Filesort should be called “sort.” It is quicksort at heart. \n正解是,filesort这个名字有问题,容易给人误解,在mysql中,任何不能通过index进行的sort都称之为filesort,这里的filesort和文件没有任何关系,应该称之为“sort”而不是“filesort”,它的内部实现就是快速排序。
\n", "_id"=>514}])
+MONGODB iceylog_development['categories'].find({:_id=>11}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>11}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"03. 技术归总 | Technic"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "variables"], "comments_count"=>0, "category_id"=>11, "title"=>"Mysql动态修改参数", "body"=>"mysql数据库也像ORACLE数据库一样,可以动态的修改参数,可以修改会话级变量只对当前会话产生影响;也可以修改全局变量,对所有新连接的会话都产生影响。\n\n修改会话级变量\n用show variables 命令查看当前参数的值,like 'pattern'用于模式匹配,查找指定的参数\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n用set SESSION命令设置会话级变量的新值\n\nmysql> set SESSION sort_buffer_size=7000000;\nQuery OK, 0 rows affected (0.00 sec)\n\n--修改会话级变量对当前会话来说立刻生效\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 7000000 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\nmysql> exit\nBye\n退出重新连接后,此参数恢复原值\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 40 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n修改全局变量\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 40 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n\n用set GLOBAL 命令设置全局变量\n\nmysql> set GLOBAL sort_buffer_size = 7000000;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 6291448 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n当前此参数的值并不发生变化,先退出,然后重新连进去\nmysql> exit\nBye\n[root@devdbc_stb root]# mysql\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 41 to server version: 5.0.37-log\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n\nmysql> show variables like '%sort_buffer_size%';\n+---------------------------+------------+\n| Variable_name | Value |\n+---------------------------+------------+\n| sort_buffer_size | 7000000 |\n+---------------------------+------------+\n1 rows in set (0.00 sec)\n新的参数值生效", "created_at"=>2010-02-03 04:00:12 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
--修改会话级变量对当前会话来说立刻生效 \nmysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 7000000 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
mysql> exit \nBye \n退出重新连接后,此参数恢复原值 \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 40 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
修改全局变量 \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 40 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec)
\n\n
用set GLOBAL 命令设置全局变量
\n\n
mysql> set GLOBAL sort_buffer_size = 7000000; \nQuery OK, 0 rows affected (0.00 sec)
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 6291448 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec) \n当前此参数的值并不发生变化,先退出,然后重新连进去 \nmysql> exit \nBye \n[root@devdbc_stb root]# mysql \nWelcome to the MySQL monitor. Commands end with ; or \\g. \nYour MySQL connection id is 41 to server version: 5.0.37-log
\n\n
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
\n\n
mysql> show variables like '%sort_buffer_size%'; \n+---------------------------+------------+ \n| Variable_name | Value | \n+---------------------------+------------+ \n| sort_buffer_size | 7000000 | \n+---------------------------+------------+ \n1 rows in set (0.00 sec) \n新的参数值生效
\n", "_id"=>516}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Tips"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Textmate", "theme"], "comments_count"=>0, "category_id"=>4, "title"=>"Installing a New Textmate Theme", "body"=>"To install a new theme, select one of the .tmTheme links listed below, download it to your desktop and double-click on the file. This will place it in ~/Library/Application Support/TextMate/Themes, at which point the new theme will appear in the list found in Preferences → Fonts & Colors. This will also set it as the active theme. (Once the theme is installed, you may remove the .tmTheme from your desktop.)\n\nRails Envy TextMate Theme\n http://railsenvy.com/2008/9/18/rails-envy-textmate-theme\n\nUser Submitted Themes\n http://wiki.macromates.com/Themes/UserSubmittedThemes", "created_at"=>2010-02-04 18:24:02 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
To install a new theme, select one of the .tmTheme links listed below, download it to your desktop and double-click on the file. This will place it in ~/Library/Application Support/TextMate/Themes, at which point the new theme will appear in the list found in Preferences → Fonts & Colors. This will also set it as the active theme. (Once the theme is installed, you may remove the .tmTheme from your desktop.)
\n\nrestart teatmate and it's done!\n\nIn the TextMate preferences, advanced tab, shell variables, set the TM_GIT variable to point to your installation of git (ie /usr/local/bin/git)\nMany shortcuts are available from the Git-shortcut (Ctrl-Shift-G). Subversion commands are Command-Option-g. Less frequent commands are accessed via the menu.\nUpdate your bundle by running the “Update Git Bundle” command.", "created_at"=>2010-02-04 23:39:24 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
In the TextMate preferences, advanced tab, shell variables, set the TM_GIT variable to point to your installation of git (ie /usr/local/bin/git) \nMany shortcuts are available from the Git-shortcut (Ctrl-Shift-G). Subversion commands are Command-Option-g. Less frequent commands are accessed via the menu. \nUpdate your bundle by running the “Update Git Bundle” command.
SIMBL (SIMple Bundle Loader) - pronounced like \"symbol\" or \"cymbal\" - enables hacks and plugins. For instance, SIMBL enables PithHelmet to enhance Safari.
Install SIMBL and make sure you have latest SIMBL 0.9.x\nPlace Visor.bundle into ~/Library/Application Support/SIMBL/Plugins (create this directory if it does not exist)\nRelaunch Terminal.app - You should now see the Visor Status Menu Item\nConfigure your keyboard trigger by selecting the Visor Status Menu Item -> Visor Preferences ... and edit your keyboard hot-key\nYou can now trigger Visor with your hot-key from any application to get an instant terminal session.\n\nTo hide Visor, you can either:\nre-trigger with your key-combo\noptionally you can click off of the Visor window
如果你和我一样经常使用终端程序,这个小程序一定可以帮到你。他能将终端窗口变成类似雷神或CS那样的下拉窗口,非常酷。 \n可以从这里下载 http://visor.binaryage.com/ \n这个软件需要SIMBL ,如果你没有安装,要先安装这个。 \nhttp://www.culater.net/software/SIMBL/SIMBL.php \nSIMBL (SIMple Bundle Loader) - pronounced like "symbol" or "cymbal" - enables hacks and plugins. For instance, SIMBL enables PithHelmet to enhance Safari. \n之后将下载下来的文件解压,将解压后的文件拷贝至/Library/Application Support/SIMBL/Plugins,之后再重新启动你的终端你就可以看到效果了。 默认的快捷启动键是Ctrl+` \nvisor: http://visor.binaryage.com/
\n\n
Installation
\n\n
Install SIMBL and make sure you have latest SIMBL 0.9.x \nPlace Visor.bundle into ~/Library/Application Support/SIMBL/Plugins (create this directory if it does not exist) \nRelaunch Terminal.app - You should now see the Visor Status Menu Item \nConfigure your keyboard trigger by selecting the Visor Status Menu Item -> Visor Preferences ... and edit your keyboard hot-key \nYou can now trigger Visor with your hot-key from any application to get an instant terminal session.
\n\n
To hide Visor, you can either: \nre-trigger with your key-combo \noptionally you can click off of the Visor window
前段时间写了一篇《实例优化mysql配置文件my.cnf》,这几天看到效果非常明显,别的不说,单mysql cache_hits就很不错(之前竟然没注意到这个参数) \n# Increase query_cache_size from 0 to 128M \nquery_cache_size=128M
Rails 3 in Action by Yehuda Katz and Mike Gunderloy. Currently available is their Early Access Edition, which gives you access to chapters as they are written.
\n\t
Beginning Rails 3 by Jeffrey Allan Hardy , Cloves Carneiro Jr. & Rida Al Barazi
这次升级需要新装很多的gem,如下: \ngem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n \ngem install rails --pre \n期间遇到一个错误: \nDue to a rubygems bug, you must uninstall all older versions of bundler for 0.9 to work \n然后这边有N多关于Rails3的资料供参考:
\n\n
Rails 3 Tutorials & Blog Posts
\n\n
Edging your way towards Ruby 1.9.1 and Rails 3.0pre \n Unobtrusive JavaScript in Rails 3 by Zach Carter \n A Fresh Cup: Seed Data in Rails 3 tutorial – feature summary + code example by Mike Gunderloy. \n Rails3: Stepping off of the golden path slides by Matt Aimonetti \n Rails Magazine – RailsConf 2009 Edition page 5 has a section called The Unofficial Guide to What’s New in Rails 3 by Rupak Ganguly \n Jason Ting’s RailsConf 2009 Notes includes some basic notes about Rails 3 \n Noel Rappin: Railsconf 09 – After the RailsConfening article \n Yehuda Katz: Railsconf Wrapup blog – contains links to jQuery talk by Katz at RailsConf 09 \n How to Begin Playing With Rails 3 by Oscar Del Ben \n My Five Favorite Things About Rails 3 by Yehuda Katz \n Rails 3: The Great Decoupling by Yehuda Katz \n Rails Edge Architecture by Yehuda Katz \n How to Build Sinatra on Rails 3 by Yehuda Katz
\n\n
Rails 3 Presentations & Conference Talks
\n\n
Yehuda: What to Expect in Rails 3.0 webcast recording \n Scotland on Rails: Yehuda on Rails & Merb Merge video. For more Scotland on Rails videos, check out this Ruby Inside post. \n Yehuda Katz on Rails 3 and beyond interview by Mark Coleman \n RailsConf: Yehuda – The Russian Doll Pattern video \n RailsConf 09: DHH Keynote video – DHH previews unobtrusive javascript, default escaping & more.
\n\n
Rails 3 Books
\n\n
Rails 3 in Action by Yehuda Katz and Mike Gunderloy. Currently available is their Early Access Edition, which gives you access to chapters as they are written. \n Beginning Rails 3 by Jeffrey Allan Hardy , Cloves Carneiro Jr. & Rida Al Barazi
\n\n
Rails 3 Commentary
\n\n
Internet News: Rails 3 Gets Supersized With Merb \n eWeek: Rubyists Unite Ruby on Rails and Merb to Merge in Rails 3 \n CIO: Rails 3 to add security enhancement \n Yehuda Katz: Rails and Merb Merge \n RubyOnRails.org: Rails + Merb Merge Announcement
\n", "_id"=>521}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"02. 产品设计 | PM"}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['$cmd'].find({"count"=>"categories", "query"=>{:name=>"02. 产品设计 | PM"}, "fields"=>nil}).limit(-1)
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"categories"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['categories'].insert([{"sort"=>0, "posts_count"=>0, "name"=>"02. 产品设计 | PM", "updated_at"=>2012-06-24 15:53:14 UTC, "created_at"=>2012-06-24 15:53:14 UTC, "_id"=>13}])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Axure", "Balsamiq Mockups", "原型设计"], "comments_count"=>0, "category_id"=>13, "title"=>"Balsamiq Mockups,理想的原型设计工具", "body"=>"由于经常要讨论产品,包括web和手机(\bAandroid,Iphone)的产品原型设计,尝试过很多的原型设计工具,例如Axure等,后来换了mac book,就一直找不到合适的原型设计工具,就一直在Google Doc中直接draw,其做了很多无用功。\n比较偶然的机会看到Balsamiq Mockups这个软件,和Pixelmator一样,是个人开发者(意大利人Peldi)开发的产品,其地址为http://www.balsamiq.com/ ,在其提供的demo页面上试了下http://www.balsamiq.com/demos/mockups/Mockups.html,效果很好,符合我的预期。\n虽然是由个人设计的,但功能却一点不弱于其他大牌的原型设计工具:\n操作方面,拖拽,控件分组,甚至元素之间的对齐都做得很贴心;\n预制了很多界面元素,从简单的输入框,下拉框,浏览器主要元素,到经常用得到的导航条,日历,表格,到复杂的Tag Cloud,Cover Flow, 地图,WYSWYG的格式工具栏等,有了这些不用从头画起,往往比用白板都快;\n界面元素的修改很简单,比如导航条的几个标签页的label,就是用逗号分隔的文字,下拉框的选项就是分行的文字;\n使用xml语言来记录和保存界面元素和布局,\n这使得每个设计都能被很好得放进SVN,Git,和CVS等工具中进行管理和跟踪;\n可以设计复杂的界面元素,保存后,以后可以重复使用(包括修改);\n可以将设计导出成PNG格式的图片;\n可以用命令行进行导出操作,这样就能让我写个脚本,从svn里checkout某个目录下的所有设计文件后,导出图片,打包后用邮件发到项目经理,工程师甚至客户那;\n跨平台,Balsamiq Mokups是用Flex和Air实现的,所以在Mac OS, Linux和Windows下都能使用;\n不仅仅有桌面版本,还有能集成在Confluence,JIRA,和XWiki中的版本,使得异地在线协作更方便有效。\n\n以下是关于Balsamiq Mockups的一些特点:\n易操作:从 Balsamiq Mockups 自带的元素里可以很方便地拖拽,效果图轻易形成;元素对齐很贴心;\n可偷懒:根据 Balsamiq Mockups 提供的 Wiki 风格的代码规则,画图时可以「偷懒」,输入文本符号则能生成图标。因此相比其它繁琐的软件操作,Balsamiq Mockups 也能更快地完成画图任务。\n控件足:Balsamiq Mockups 软件包括 50 多个控件, 70 多个图标。基本自带了所有常用的小控件,并在导航处进行分类;图标设计赏心悦目。要是 Balsamiq Mockups 允许用户导入自定义的控件就更好了,当然现有的也足够了 -\n新风格:让人眼前一亮的涂鸦风格,很能还原手绘效果;\n可中文:在菜单栏 View 里将 Use System Fonts 勾上,就能完美支持中文输入(注:非 Balsamiq Mockups 中文版);\n其它点:Balsamiq Mockups 使用 xml 记录,方便移植、二次利用;可导出为 png 格式图片。\n\n另外还有跨平台与多版本两个优点:\n跨平台:Balsamiq Mockups 基于 Air ,因此能同时在 Windows、Mac OS 及 Linux 下使用;\n多版本:包括桌面版本,以及集成于 Confluence、JIRA、XWiki、FogBugz 中的版本\n\n软件可以从其网站上下载,其中桌面版本售价是$79。但作者非常厚道,提供了几种免费使用的方式:http://www.balsamiq.com/products/mockups/desktop\n\nYou can download Mockups for Desktop for free. Some of the features of the app, like saving and loading multiple mockups or linking mockups together can only get unlocked using a license key.\n", "created_at"=>2010-02-21 18:39:26 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
You can download Mockups for Desktop for free. Some of the features of the app, like saving and loading multiple mockups or linking mockups together can only get unlocked using a license key.
\n", "_id"=>522}])
+MONGODB iceylog_development['categories'].find({:_id=>13}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>13}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Database", "socket"], "comments_count"=>0, "category_id"=>3, "title"=>"Can’t connect to local MySQL server through socket 解决办法", "body"=>"Rails启动后报错,ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/temp/mysql.sock’ (2)\n\n1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.\n另外看看是不是权限问题.\n\n2、确定你的mysql.sock是不是在那个位置,\nmysql -u 你的mysql用户名 -p -S /var/lib/mysql/mysql.sock\n\n3、试试:service mysqld start\n\n4、如果是权限问题,则先改变权限 #chown -R mysql:mysql /var/lib/mysql\n\n[root@localhost ~]# /etc/init.d/mysqld start\n启动 MySQL: [ 确定 ]\n[root@localhost ~]# mysql -uroot -p", "created_at"=>2010-02-23 21:24:14 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
Rails启动后报错,ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/temp/mysql.sock’ (2)
\n\n
1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动. \n另外看看是不是权限问题.
\n", "_id"=>523}])
+MONGODB iceylog_development['categories'].find({:_id=>3}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>3}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Passenger", "REE"], "comments_count"=>0, "category_id"=>2, "title"=>"Download Ruby Enterprise Edition(REE)", "body"=>"前段时间用上了Passenger ,尔后就看到很多的人推荐使用Ruby Enterprise Edition(REE),今天得闲,试了一把。\nStep 1: Download\nSource code: version 1.8.7-2010.01\nStep 2: Install\nExtract it:\ntar xzvf ruby-enterprise-X.X.X.tar.gz\nRun the installer (completely safe, none of your system files will be touched!):\n./ruby-enterprise-X.X.X/installer\n
Welcome to the Ruby Enterprise Edition installer
\n
This installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.
\n
Don't worry, none of your system files will be touched if you don't want them
\n
to, so there is no risk that things will screw up.
\n
You can expect this from the installation process:
\n
1. Ruby Enterprise Edition will be compiled and optimized for speed for this
\n
system.
\n
2. Ruby on Rails will be installed for Ruby Enterprise Edition.
\n
3. You will learn how to tell Phusion Passenger to use Ruby Enterprise
\n
Edition instead of regular Ruby.
\n
Press Enter to continue, or Ctrl-C to abort.
\n
Welcome to the Ruby Enterprise Edition installerThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.Don't worry, none of your system files will be touched if you don't want themto, so there is no risk that things will screw up.\nYou can expect this from the installation process:\n1. Ruby Enterprise Edition will be compiled and optimized for speed for this system.\n\n2. Ruby on Rails will be installed for Ruby Enterprise Edition.\n\n3. You will learn how to tell Phusion Passenger to use Ruby Enterprise Edition instead of regular Ruby.\nPress Enter to continue, or Ctrl-C to abort.
\nStep 3: Make Phusion Passenger use Ruby Enterprise Edition instead of regular Ruby\nFollow the instructions that the Ruby Enterprise Edition installer gave you.", "created_at"=>2010-03-03 16:53:29 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
前段时间用上了Passenger ,尔后就看到很多的人推荐使用Ruby Enterprise Edition(REE),今天得闲,试了一把。 \nStep 1: Download \nSource code: version 1.8.7-2010.01 \nStep 2: Install \nExtract it: \ntar xzvf ruby-enterprise-X.X.X.tar.gz \nRun the installer (completely safe, none of your system files will be touched!): \n./ruby-enterprise-X.X.X/installer \nWelcome to the Ruby Enterprise Edition installer \nThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01. \nDon't worry, none of your system files will be touched if you don't want them \nto, so there is no risk that things will screw up. \nYou can expect this from the installation process: \n1. Ruby Enterprise Edition will be compiled and optimized for speed for this \nsystem. \n2. Ruby on Rails will be installed for Ruby Enterprise Edition. \n3. You will learn how to tell Phusion Passenger to use Ruby Enterprise \nEdition instead of regular Ruby. \nPress Enter to continue, or Ctrl-C to abort. \nWelcome to the Ruby Enterprise Edition installerThis installer will help you install Ruby Enterprise Edition 1.8.7-2010.01.Don't worry, none of your system files will be touched if you don't want themto, so there is no risk that things will screw up. \nYou can expect this from the installation process: \n1. Ruby Enterprise Edition will be compiled and optimized for speed for this system.
\n\n\n
Ruby on Rails will be installed for Ruby Enterprise Edition.
\n
You will learn how to tell Phusion Passenger to use Ruby Enterprise Edition instead of regular Ruby. \nPress Enter to continue, or Ctrl-C to abort. \nStep 3: Make Phusion Passenger use Ruby Enterprise Edition instead of regular Ruby \nFollow the instructions that the Ruby Enterprise Edition installer gave you.
\n\n", "_id"=>524}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"02. 产品设计 | PM"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Border-radius", "css3"], "comments_count"=>0, "category_id"=>13, "title"=>"Border-radius: create rounded corners with CSS!", "body"=>"W3C has offered some new options for borders in CSS3, of which one is border-radius. Both Mozila/Firefox and Safari 3 have implemented this function, which allows you to create round corners on box-items. This is an example:\n\nMozilla/Firefox and Safari 3 users should see a nicely rounded box, with a nicely rounded border.\nThe code for this example above is actually quite simple:\n\nThese different corners can also each be handled on their own, Mozilla has other names for the feature than the spec says it should have though, as it has f.i. -moz-border-radius-topright as opposed to -webkit-border-top-right-radius:\n\nMozilla/Firefox and Safari 3 users should see a box with a rounded left upper corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded right upper corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded left lower corner.\nMozilla/Firefox and Safari 3 users should see a box with a rounded right lower corner.\nThese are handled by / should be handled by:\n\n````-moz-border-radius-topleft / -webkit-border-top-left-radius\n-moz-border-radius-topright / -webkit-border-top-right-radius\n-moz-border-radius-bottomleft / -webkit-border-bottom-left-radius\n-moz-border-radius-bottomright / -webkit-border-bottom-right-radius```", "created_at"=>2010-03-05 10:38:13 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
W3C has offered some new options for borders in CSS3, of which one is border-radius. Both Mozila/Firefox and Safari 3 have implemented this function, which allows you to create round corners on box-items. This is an example:
\n\n
Mozilla/Firefox and Safari 3 users should see a nicely rounded box, with a nicely rounded border. \nThe code for this example above is actually quite simple: \n \nThese different corners can also each be handled on their own, Mozilla has other names for the feature than the spec says it should have though, as it has f.i. -moz-border-radius-topright as opposed to -webkit-border-top-right-radius:
\n\n
Mozilla/Firefox and Safari 3 users should see a box with a rounded left upper corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded right upper corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded left lower corner. \nMozilla/Firefox and Safari 3 users should see a box with a rounded right lower corner. \nThese are handled by / should be handled by:
\n", "_id"=>527}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["action_mailer_optional_tls", "Gmail", "Redmine"], "comments_count"=>0, "category_id"=>2, "title"=>"Setup Redmine to send email using GMail", "body"=>"Redmine是用Rails写的一套很不错的项目管理系统,其提供了诸多很方便实用的功能,诸如里程碑管理,BUG跟踪,代码库变更管理等等。\n搭建以后在管理面板中测试邮件不通,主要原因是由于采用的Gmail的邮箱,于是找到一些解决方案,如下:\n1. Install the action_mailer_optional_tls plugin\nThe action_mailer_optional_tls_plugin adds a TLS option to Redmine's emailing library, ActionMailer. TLS is a version of SSL which is required by GMail in order to send email.\n\nTo install this plugin, use the script/plugin command in your Redmine directory:\n ./script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git\n\n2. Configure your email.yml\n# File: config/email.yml\nproduction:\n delivery_method: :smtp\n smtp_settings:\n tls: true\n address: \"smtp.gmail.com\"\n port: 587\n domain: \"www.YOURDOAMIN.com\" # 'your.domain.com' for GoogleApps\n authentication: :plain\n user_name: \"username@youdomain.com\"\n password: \"password\"\n\n3. Start up Redmine and test your Email\nNext it's time to start up Redmine and to send a test email. Make sure that you start Redmine in the same mode as you configured above (e.g. production). To send a test email:\nLogin as an administrator\nGo to the Administration panel\nGo into the Settings and select the \"Email notifications\" tab\nIn the bottom right, click the link to \"Send a test email\"", "created_at"=>2010-03-14 18:31:57 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
Redmine是用Rails写的一套很不错的项目管理系统,其提供了诸多很方便实用的功能,诸如里程碑管理,BUG跟踪,代码库变更管理等等。 \n搭建以后在管理面板中测试邮件不通,主要原因是由于采用的Gmail的邮箱,于是找到一些解决方案,如下: \n1. Install the action_mailer_optional_tls plugin \nThe action_mailer_optional_tls_plugin adds a TLS option to Redmine's emailing library, ActionMailer. TLS is a version of SSL which is required by GMail in order to send email.
\n\n
To install this plugin, use the script/plugin command in your Redmine directory: \n ./script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git
3. Start up Redmine and test your Email \nNext it's time to start up Redmine and to send a test email. Make sure that you start Redmine in the same mode as you configured above (e.g. production). To send a test email: \nLogin as an administrator \nGo to the Administration panel \nGo into the Settings and select the "Email notifications" tab \nIn the bottom right, click the link to "Send a test email"
\n", "_id"=>529}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["concat", "Database"], "comments_count"=>0, "category_id"=>3, "title"=>"MySQL CONCAT", "body"=>"MySQL CONCAT function is used to concatenate two strings to form a single string. Try out following example:\nmysql> SELECT CONCAT('FIRST ', 'SECOND');\n+----------------------------+\n| CONCAT('FIRST ', 'SECOND') |\n+----------------------------+\n| FIRST SECOND |\n+----------------------------+\n1 row in set (0.00 sec)\n\nie.\nmysql -u eoewallpapers -p123456123 wallpapers -e 'set names 'utf8'; select CONCAT(base_url,\"400\",title) from photos where state > 10 ' > photos_400.txt", "created_at"=>2010-03-19 20:34:34 UTC, "updated_at"=>2012-06-24 15:53:14 UTC, "body_html"=>"
MySQL CONCAT function is used to concatenate two strings to form a single string. Try out following example: \nmysql> SELECT CONCAT('FIRST ', 'SECOND'); \n+----------------------------+ \n| CONCAT('FIRST ', 'SECOND') | \n+----------------------------+ \n| FIRST SECOND | \n+----------------------------+ \n1 row in set (0.00 sec)
\n\n
ie. \nmysql -u eoewallpapers -p123456123 wallpapers -e 'set names 'utf8'; select CONCAT(base_url,"400",title) from photos where state > 10 ' > photos_400.txt
alias ls=”ls -G”是给”ls -G”起了一个别名,当执行ls时,就相当于执行了ls -G。
\n\n
CLICOLOR是用来设置是否进行颜色的显示。CLI是Command Line Interface的缩写。 \nLSCOLORS是用来设置当CLICOLOR被启用后,各种文件类型的颜色。LSCOLORS的值中每两个字母为一组,分别设置某个文件类型的文字颜色和背景颜色。LSCOLORS中一共11组颜色设置,按照先后顺序,分别对以下的文件类型进行设置:
\n\n
directory \nsymbolic link \nsocket \npipe \nexecutable \nblock special \ncharacter special \nexecutable with setuid bit set \nexecutable with setgid bit set \ndirectory writable to others, with sticky bit \ndirectory writable to others, without sticky bit \nLSCOLORS中,字母代表的颜色如下:
\n", "_id"=>535}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["10.6.3", "rails3", "railties"], "comments_count"=>0, "category_id"=>7, "title"=>"解决升级mac OS 10.6.3后rails3无法启动的问题", "body"=>"昨晚看hero的时候顺带update到mac OS 10.6.3,早上重启机器安装成功,发现rails3无法启动,报:\n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception)\nfrom /usr/bin/rails:19\n\n这个错误我之前安装rails3的时候遇到过,解决如下:\n1.先尝试下重新安装rails\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install rails --pre\nPassword:\nSuccessfully installed treetop-1.4.5\n1 gem installed\nInstalling ri documentation for treetop-1.4.5...\nInstalling RDoc documentation for treetop-1.4.5..\n发现多了个treetop的gem,查查是啥:\n
Treetop is a language for describing languages. Combining the elegance of Ruby with cutting-edge parsing expression grammars, it helps you analyze syntax with revolutionarily ease.
\n\n再次执行rails,发现\n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception)\n from /usr/bin/rails:19\n\n还是不行,那就是railties的问题了,重新装下\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install railties --pre\nSuccessfully installed railties-3.0.0.beta\n1 gem installed\nInstalling ri documentation for railties-3.0.0.beta...\nInstalling RDoc documentation for railties-3.0.0.beta...\nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ rails -v\nRails 3.0.0.beta\n\nOK,可以了~", "created_at"=>2010-03-31 22:01:38 UTC, "updated_at"=>2012-06-24 15:53:15 UTC, "body_html"=>"
昨晚看hero的时候顺带update到mac OS 10.6.3,早上重启机器安装成功,发现rails3无法启动,报: \n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception) \nfrom /usr/bin/rails:19
\n\n
这个错误我之前安装rails3的时候遇到过,解决如下: \n1.先尝试下重新安装rails \nIceskYsl@eoe /svnroot/eoe/dev/rails/eoelogs $ sudo gem install rails --pre \nPassword: \nSuccessfully installed treetop-1.4.5 \n1 gem installed \nInstalling ri documentation for treetop-1.4.5... \nInstalling RDoc documentation for treetop-1.4.5.. \n发现多了个treetop的gem,查查是啥: \nTreetop is a language for describing languages. Combining the elegance of Ruby with cutting-edge parsing expression grammars, it helps you analyze syntax with revolutionarily ease.
\n\n
再次执行rails,发现 \n/Library/Ruby/Site/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception) \n from /usr/bin/rails:19
\nThis Rails plugin allows users to take advantage of nginx's X-Accel-Redirect header, similar to X-Send-File.```\n
== Install\nYou should install it as a plugin, running this command on your projects root directory:\n $ script/plugin install git://github.com/goncalossilva/X-Accel-Redirect.git```\n
== Usage\nX-Accel-Redirect has an equivalent method to Rails <i>send_file</i>, called <b>x_accel_redirect</b>. Using is as easy as:\n x_accel_redirect \"/path/to/file\", :filename => \"filename\"\nAll <i>send_file</i> options are available using this method. Now you can even let your old <b>:x_sendfile</b> option since the plugin will discard it.```\n```\n
于是聪明的人们就想,可以使用app server处理业务逻辑,然后再让web server来接管处理剩下的文件发送,所以就有了mod_xsendfile for Apache2和Lighttp中提供的X-Sendfile功能,Nginx自然也有类似的功能,只是其名字不叫X-Sendfile,而是叫X-Accel-Redirect(这个名字好像更容易理解)。 这里主要说Nginx,Apache的自行查阅资料,先了解下原理: \n \n The header must contain a URI \n The location should be defined as internal; to prevent the client going directly to the URI \n \n定义一段配置: \n<a href="/NginxHttpCoreModule#location">location</a> /protected/ { \n <a href="/NginxHttpCoreModule#internal">internal</a>; \n <a href="/NginxHttpCoreModule#root">root</a> /some/path; \n} \n然后在你的应用中: \n \nadd_header("X-Accel-Redirect: /protected/iso.img"); \n然后Nginx就接管了你的请求,发送<strong>/some/path/protected/iso.img</strong>这个文件。 \n原理了解了,看看如何使用更快捷,自然是用插件,有人写出了一个插件:X-Accel-Redirect \n`` \n<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;"> \n<div id="_mcePaste">= X-Accel-Redirect</div> \nThis Rails plugin allows users to take advantage of nginx's X-Accel-Redirect header, similar to X-Send-File. \n== Install \nYou should install it as a plugin, running this command on your projects root directory: \n $ script/plugin install git://github.com/goncalossilva/X-Accel-Redirect.git \n<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;">== Usage \nX-Accel-Redirect has an equivalent method to Rails <i>send_file</i>, called <b>x_accel_redirect</b>. Using is as easy as: \n x_accel_redirect "/path/to/file", :filename => "filename" \nAll <i>send_file</i> options are available using this method. Now you can even let your old <b>:x_sendfile</b> option since the plugin will discard it. \n \n<div id="_mcePaste"><strong>参考:</strong></div> \n \nwiki.nginx.org/NginxXSendfile \n``<span style="font-family: Georgia, Times, 'Times New Roman', serif; line-height: 21px; white-space: normal; color: #21211e; font-size: 13px;"> \n<h1 class="entry-title" style="outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; font-weight: bold; clear: both; text-transform: uppercase; letter-spacing: 2px; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;"><a href="http://www.motionstandingstill.com/using-nginx-to-send-files-with-x-accel-redirect/2008-09-03/">USING NGINX TO SEND FILES WITH X-ACCEL-REDIRECT</a></h1> \n</span> \nThe complete nginx solution to sending flowers and files with rails \n``<a href="http://bianbian.org/technology/linux/154.html">[译]利用Nginx的X-Accel-Redirect头实现下载控制(附带php和rails实例)</a>
\n", "_id"=>538}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"publish a rails plugin:Nginx-X-Accel-Redirect", "body"=>"前面2个文章说到了在Rails中使用send_file实现断点续传《在rails下实现多线程下载和断点续传》和利用Nginx的X-Accel-Redirect实现发送大文件《使用Nginx的X-Accel-Redirect在Rails中发送文件》,项目中需要两个功能,就把他整合起来,同时发布到github上了,Nginx-X-Accel-Redirect。\n\n简介:\nThis Rails plugin allows users to take advantage of nginx’s X-Accel-Redirect header, similar to X-Send-File and Content-Range.\n\n安装:\n$ script/plugin install git://github.com/IceskYsl/Nginx-X-Accel-Redirect.git\n\n使用:\nx_accel_redirect \"/path/to/file\", :filename => \"filename\",:root=>\"/path/to/root\"\n\n详细信息:github.com/IceskYsl/Nginx-X-Accel-Redirect", "created_at"=>2010-04-17 21:37:59 UTC, "updated_at"=>2012-06-24 15:53:15 UTC, "body_html"=>"
\n", "_id"=>547}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>3, "title"=>"TEXT fields in MySQL", "body"=>"MySQL TEXT fields have a limit of 65,000 bytes. If you insert anything larger than that in to a normal TEXT field mySQL will silently truncate your data without telling you (meaning software checks are probably a good idea). MEDIUMTEXT will store 16 million characters and LONGTEXT can handle over 4 trillion, but this information does not appear to be readily available in the online mySQL manual (although it is hinted at in this table). Something to bare in mind when designing database applications.\n\nMyISAM tables in MySQL have a maximum size of a row of 65,535 bytes, so all the data in a row must fit within that limit. However, the TEXT types are stored outside the table itself and only contribute 9 to 12 bytes towards that limit. (For more information about this refer to the MySQL Manual - Data Storage Requirements chapter).\n\nref::http://www.electrictoolbox.com/maximum-length-mysql-text-field-types/\nTEXT data types are also able to store much more data than VARCHAR and CHAR text types so TEXT types are what you need to use when storing web page or similar content in a database.\n\nThe maximum amount of data that can be stored in each data type is as follows:\n\nTINYTEXT\t256 bytes\nTEXT\t65,535 bytes\t~64kb\nMEDIUMTEXT\t 16,777,215 bytes\t~16MB\nBIGTEXT\t4,294,967,295 bytes\t~4GB\nIn most circumstances the TEXT type is probably sufficient, but if you are coding a content management system it's probably best to use the MEDIUMTEXT type for longer pages to ensure there are no issues with data size limits.", "created_at"=>2010-06-27 20:56:02 UTC, "updated_at"=>2012-06-24 15:53:15 UTC, "body_html"=>"
MySQL TEXT fields have a limit of 65,000 bytes. If you insert anything larger than that in to a normal TEXT field mySQL will silently truncate your data without telling you (meaning software checks are probably a good idea). MEDIUMTEXT will store 16 million characters and LONGTEXT can handle over 4 trillion, but this information does not appear to be readily available in the online mySQL manual (although it is hinted at in this table). Something to bare in mind when designing database applications.
\n\n
MyISAM tables in MySQL have a maximum size of a row of 65,535 bytes, so all the data in a row must fit within that limit. However, the TEXT types are stored outside the table itself and only contribute 9 to 12 bytes towards that limit. (For more information about this refer to the MySQL Manual - Data Storage Requirements chapter).
The maximum amount of data that can be stored in each data type is as follows:
\n\n
TINYTEXT 256 bytes \nTEXT 65,535 bytes ~64kb \nMEDIUMTEXT 16,777,215 bytes ~16MB \nBIGTEXT 4,294,967,295 bytes ~4GB \nIn most circumstances the TEXT type is probably sufficient, but if you are coding a content management system it's probably best to use the MEDIUMTEXT type for longer pages to ensure there are no issues with data size limits.
做移动互联网的过程中,有这样一些词是必须知道的,如MO,MT,GSM,LINKID \n上行(MO)上行的意思就是短信发送到服务器端 MO又称 Mobile Original \n下行(MT)下行的意思就是短信从服务器端发回到手机上,MT又称Mobile Terminated \n简单的说,从手机发起一个的过程叫上行(MO),到手机结束的过程叫下行(MT),比如,平时给你的朋友发送一条短信,对你来说就是上行(MO),而对你的朋友来说,就是下行(MT)。在企业、行业应用中,从系统给手机发送信息的过程叫下行(MT),而手机发送信息给系统的过程叫上行(MO)。
\n", "_id"=>554}])
+MONGODB iceylog_development['categories'].find({:_id=>6}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>6}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["log", "rails3", "slice_before"], "comments_count"=>0, "category_id"=>2, "title"=>"Parse Rails 3 log file using Enumerable#slice_before", "body"=>"``def parse_rails_log_file(file)\n # Remove all empty lines\n lines = file.each_line.map(&:strip).reject(&:empty?)\n\n # Use +Enumerable#slice_before+ to slice log file into sections for each request\n lines.slice_before(/Started (GET|POST|PUT|DELETE)/).each_with_object({}) do |request_log, totals|\n # Only include successfully finished actions in report\n if duration = request_log.last[/Completed 200 OK in (?<duration>\\d+)ms/, :duration]\n action_name = request_log.first[/Started (GET|POST|PUT|DELETE) \"(?<action>.+?)\" for/, :action]\n totals[action_name] ||= 0\n totals[action_name] += duration.to_i\n end\n end\nend\n\nif __FILE__ == $PROGRAM_NAME\n require \"pp\"\n puts \"Parsing Rails 3 log file (extracting cumulative running time per request path):\"\n puts \"=================\"\n\n log_file = <<-LOG_FILE\n Started GET \"/index\" for 192.168.74.1 at 2010-03-09 11:37:40\n Processing by UpdatesController#index as HTML\n Update Load (0.5ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (16.7ms)\n Completed 200 OK in 71ms (Views: 44.3ms | ActiveRecord: 0.5ms)\n\n Started POST \"/updates\" for 192.168.74.1 at 2010-03-09 11:37:43\n Processing by UpdatesController#create as HTML\n Parameters: {\"commit\"=>\"Save changes\"}\n Update Load (0.4ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (1.3ms)\n Completed 200 OK in 60ms (Views: 32.1ms | ActiveRecord: 0.4ms)\n\n Started GET \"/updates\" for 192.168.74.1 at 2010-03-09 11:45:51\n Processing by UpdatesController#index as HTML\n\n TypeError (exception class/object expected):\n app/controllers/updates_controller.rb:3:in `raise'\n app/controllers/updates_controller.rb:3:in `index'\n\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.6ms)\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.9ms)\n Rendered /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within /usr/local/rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb (23.9ms)\n\n Started GET \"/updates\" for 192.168.74.1 at 2010-03-09 11:45:58\n Processing by UpdatesController#index as HTML\n Update Load (0.3ms) SELECT `updates`.* FROM `updates` ORDER BY created_at DESC\n Rendered updates/index.html.erb (1.1ms)\n Completed 200 OK in 100ms (Views: 29.3ms | ActiveRecord: 0.3ms)\n LOG_FILE\n\n pp parse_rails_log_file(log_file) # => {\"/index\"=>71, \"/updates\"=>160}\nend```", "created_at"=>2010-07-26 21:42:33 UTC, "updated_at"=>2012-06-24 15:53:15 UTC, "body_html"=>"
# Use +Enumerable#slice_before+ to slice log file into sections for each request \n lines.slice_before(/Started (GET|POST|PUT|DELETE)/).each_with_object({}) do |request_log, totals| \n # Only include successfully finished actions in report \n if duration = request_log.last[/Completed 200 OK in (?<duration>\\d+)ms/, :duration] \n action_name = request_log.first[/Started (GET|POST|PUT|DELETE) "(?<action>.+?)" for/, :action] \n totals[action_name] ||= 0 \n totals[action_name] += duration.to_i \n end \n end \nend
\n\n
if FILE == $PROGRAM_NAME \n require "pp" \n puts "Parsing Rails 3 log file (extracting cumulative running time per request path):" \n puts "================="
\n\n
log_file = <<-LOG_FILE \n Started GET "/index" for 192.168.74.1 at 2010-03-09 11:37:40 \n Processing by UpdatesController#index as HTML \n Update Load (0.5ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (16.7ms) \n Completed 200 OK in 71ms (Views: 44.3ms | ActiveRecord: 0.5ms)
\n\n
Started POST "/updates" for 192.168.74.1 at 2010-03-09 11:37:43 \n Processing by UpdatesController#create as HTML \n Parameters: {"commit"=>"Save changes"} \n Update Load (0.4ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (1.3ms) \n Completed 200 OK in 60ms (Views: 32.1ms | ActiveRecord: 0.4ms)
\n\n
Started GET "/updates" for 192.168.74.1 at 2010-03-09 11:45:51 \n Processing by UpdatesController#index as HTML
Started GET "/updates" for 192.168.74.1 at 2010-03-09 11:45:58 \n Processing by UpdatesController#index as HTML \n Update Load (0.3ms) SELECT updates.* FROM updates ORDER BY created_at DESC \n Rendered updates/index.html.erb (1.1ms) \n Completed 200 OK in 100ms (Views: 29.3ms | ActiveRecord: 0.3ms) \n LOG_FILE
\n写完申明后,去看消息出处看到其竟然做了修改,我早料到其会做相关的行为,所有早些时候截了屏幕如下:\n\n\n\n而现在的文章被修改为:\n\n\n\n看我用鼠标标识的地方,对关键信息进行了修改,感兴趣的人可以去 http://mobile.venturebeat.com/2010/07/28/android-wallpaper-app-that-steals-your-data-was-downloaded-by-millions/ 查看原文,对于这种标题党用子虚乌有的事情炒作,等消息传播后再修改自己的内容算什么行为!而对国内部分媒体在传播时不但不对真实性进行验证,还添油加醋,歪曲意思的报道,我非常无奈(看到有人还说可以获取信用卡信息,还加密传输,我实在无语)。\n\n按照我个人的感觉,他们应该紧接着要开始拿这个事件来炒作自己的产品了,我个人懒得去关注,如果有人发现有人借此炒作自己的产品,请帮忙分析分析,看看到底是什么人用这样手法。\n\n再次update!!!\n\n通过email和mylookout的人取得联系,说明我取得诸如设备号,手机屏幕大小是为了更智能的给设备适配图片,而获取部分的sim卡号是后来用户反馈说自己换了手机还想使用之前的收藏记录才使用的,这些信息只在该应用中使用,并没提供给任何第三方!\n\n同时让其确认venturebeat上文章中说到的获取浏览器历史,短信息,密码等高敏感性信息是否是他们说的还是写文章的人自己写的(Lots of my users send me the email ask me why I collect their text message and voicemail passward, I just want to make sure whether you and your ceo said that I collected browsing history,text message ,voicemail passward during the meeting.)。\n\n其cto给我回复说他们没有说过我的应用获取过诸如text messages or browsing history这些信息( We never stated that the wallpaper applications gathered users text messages or browsing history.),是媒体在撰写和传播的时候错误报道了(A member of the press misreported our research and he has since corrected it. )。\n\n我非常无语~\n\n2010年8月4日第二次次update!\n\n多谢这些天很多朋友的关心,我很好,谢谢!这些天和google android组,lookout公司和venturebeat的作者,以及国内外很多媒体,博客们,记者们都有很多的接触。\n\n1. google就前段时间将应用暂停和我一起分析了这个应用,今天发来调查的结果:\n\nOur investigation has concluded that there's no obvious malicious code in your apps, though the implementation accesses data that it doesn't need to. We've restored your apps (and they'll be available on Market again once you publish them), and are looking forward to seeing them updated to use ANDROID_ID. We are likely to make a statement about this issue this week--I'll let you know.\n\n我早就说过,我配合调查,我把代码提供给他们,google也做出了公正的评判,另外也给我提了一些建议(ANDROID_ID)。\n\n2. 当时写这篇报道的venturebeat记者Dean Takahashi发来了mail,为自己犯的错误道歉,并道歉该事带来的恶劣影响,会再写一篇文章澄清这个事情以消除影响。\n\n3. 那个安全公司lookout的人写邮件来要于我一起“ We wanted to coordinate with you to prevent further misunderstandings. ”。\n\n4.好几个不认识的国外记者很负责任,发邮件和gt和我交流询问事情的真相,并帮我喊冤,谢谢这些有职业精神的记者们。\n\n这个事情到这差不多就结束了,其中看到很多假丑恶,也看到很多真善美!谢谢所有帮助过我的人(很多很多,就不一一列举)。", "created_at"=>2010-07-29 08:41:39 UTC, "updated_at"=>2012-06-24 15:53:15 UTC, "body_html"=>"
同时让其确认venturebeat上文章中说到的获取浏览器历史,短信息,密码等高敏感性信息是否是他们说的还是写文章的人自己写的(Lots of my users send me the email ask me why I collect their text message and voicemail passward, I just want to make sure whether you and your ceo said that I collected browsing history,text message ,voicemail passward during the meeting.)。
\n\n
其cto给我回复说他们没有说过我的应用获取过诸如text messages or browsing history这些信息( We never stated that the wallpaper applications gathered users text messages or browsing history.),是媒体在撰写和传播的时候错误报道了(A member of the press misreported our research and he has since corrected it. )。
Our investigation has concluded that there's no obvious malicious code in your apps, though the implementation accesses data that it doesn't need to. We've restored your apps (and they'll be available on Market again once you publish them), and are looking forward to seeing them updated to use ANDROID_ID. We are likely to make a statement about this issue this week--I'll let you know.
\n", "_id"=>556}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Munin", "netstat", "passive"], "comments_count"=>0, "category_id"=>7, "title"=>"Fix the passive netstat connections in Munin", "body"=>"\n\nIf your running Munin in WHM they you may have noticed the passive netstat connections have been rising steadily over the last couple of weeks. This isn't a problem with your server, its a Munin bug that can be easily fixed.\n\n\n\n\n\nApparently the problem stemms from Munin counting the passive connections rejected. You can fix this problem quite easily by following the instructions below\n\nEdit the following file:\n/usr/share/munin/plugins/netstat\n\nand change the line\n
If your running Munin in WHM they you may have noticed the passive netstat connections have been rising steadily over the last couple of weeks. This isn't a problem with your server, its a Munin bug that can be easily fixed.
\n\n\n\n
Apparently the problem stemms from Munin counting the passive connections rejected. You can fix this problem quite easily by following the instructions below
\n\n
Edit the following file: \n/usr/share/munin/plugins/netstat
\n", "_id"=>557}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["Charts", "Highcharts", "rails"], "comments_count"=>0, "category_id"=>2, "title"=>"ChartsOnRails", "body"=>"这几天需要找到漂亮的Charts类库,找了几个,发现一个很不粗的,mark下待使用,介绍如下:\n\nHighcharts is a charting library written in pure JavaScript, offering an easy way of adding interactive charts to your web site or web application. Highcharts currently supports line, spline, area, areaspline, column, bar, pie and scatter chart types.\n\n有兴趣的可以参考如下连接去看看:\n\nhttp://highcharts.com/\n\nhttp://railscasts.com/episodes/223-charts\n\nhttp://www.spritle.com/blogs/?p=859", "created_at"=>2010-08-20 21:48:59 UTC, "updated_at"=>2012-06-24 15:53:15 UTC, "body_html"=>"
这几天需要找到漂亮的Charts类库,找了几个,发现一个很不粗的,mark下待使用,介绍如下:
\n\n
Highcharts is a charting library written in pure JavaScript, offering an easy way of adding interactive charts to your web site or web application. Highcharts currently supports line, spline, area, areaspline, column, bar, pie and scatter chart types.
\n", "_id"=>558}])
+MONGODB iceylog_development['categories'].find({:_id=>2}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>2}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"malformed format string on rails~", "body"=>"在rails中使用find进行模糊查询时,出现了malformedformat string(输入为字符)或非法字符(输入为数字)的提示。\n(1) @vendors = Vendor.find(:all,:conditions=>[@sql])\n(2) @vendors = Vendor.find_by_sql(\"select * from vendor where \"+@sql)\n错误发生在按(1)方式查询过程中,采用(2)方式可以避免这个错误,这间接说明了find_by_sql确实相当不安全。\n查阅了一下资料,对于这个问题的说法如下:Rails uses sprintf (%) on the inside. So, Escape your % with %,因此只要将模糊查询的地方一个百分号全部换成两个便可以解决问题。", "created_at"=>2010-09-03 16:39:58 UTC, "updated_at"=>2012-06-24 15:53:15 UTC, "body_html"=>"
在rails中使用find进行模糊查询时,出现了malformed format string(输入为字符)或非法字符(输入为数字)的提示。 \n(1) @vendors = Vendor.find(:all,:conditions=>[@sql]) \n(2) @vendors = Vendor.find_by_sql("select * from vendor where "+@sql) \n错误发生在按(1)方式查询过程中,采用(2)方式可以避免这个错误,这间接说明了find_by_sql确实相当不安全。 \n查阅了一下资料,对于这个问题的说法如下:Rails uses sprintf (%) on the inside. So, Escape your % with %,因此只要将模糊查询的地方一个百分号全部换成两个便可以解决问题。
\n", "_id"=>563}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Ruby & Rails"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>2, "title"=>"Using the Rails logger outside of models and controllers", "body"=>"You can use the Rails logger outside of Rails models in at least version 2.3.X and up of Rails. You might be used to doing the following in your models or controllers:\n\nlogger.info \"Some debugging info I want to see in my development log.\"\n\nIf you make a regular model that doesn’t inherit from ActiveRecord, though, you may see the following error:\n\nundefined local variable or method `logger' for #<Class:0x42fd77c>\n\nThe solution is to call Rails.logger.info (or debug, or warn) as follows:\n\nRails.logger.info \"Some debugging info I want to see in my development log.\"\n\nI hope that helps someone.", "created_at"=>2010-09-17 01:50:49 UTC, "updated_at"=>2012-06-24 15:53:15 UTC, "body_html"=>"
<!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px} -->You can use the Rails logger outside of Rails models in at least version 2.3.X and up of Rails. You might be used to doing the following in your models or controllers:
\n\n
logger.info "Some debugging info I want to see in my development log."
\n\n
If you make a regular model that doesn’t inherit from ActiveRecord, though, you may see the following error:
\n\n
undefined local variable or method `logger' for #<Class:0x42fd77c>
\n\n
The solution is to call Rails.logger.info (or debug, or warn) as follows:
\n\n
Rails.logger.info "Some debugging info I want to see in my development log."
svn remove log/* \nsvn commit -m"removing log files" \nsvn propset svn:ignore ".log" log/ \nsvn update log/ \nsvn commit -m 'Ignoring all files in /log/ ending in .log' \nsvn move config/database.yml config/database.example \nsvn commit -m 'Moving database.yml to database.example to provide a template for anyone who checks out the code' \nsvn propset svn:ignore "database.yml" config/ \nsvn update config/ \nsvn commit -m 'Ignoring database.yml' \nsvn remove tmp/ \nsvn propset svn:ignore "*" tmp/ \nsvn update tmp/ \nsvn commit -m "ignore tmp/ content from now" \nsvn propset svn:ignore ".htaccess" config/ \nsvn update config/ \nsvn commit -m 'Ignoring .htaccess' \nsvn propset svn:ignore "dispatch.fcgi" config/ \nsvn update config/ \nsvn commit -m 'Ignoring dispatch.fcgi'
\n", "_id"=>566}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Database"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>[], "comments_count"=>0, "category_id"=>3, "title"=>"delete & not exists in Mysql", "body"=>"This works\n\nselect * from tb_patient p where not exists (select col_patient_id from tb_payment where col_patient_id = p.col_unid);\n\nHowever, this does NOT work\n\ndelete from tb_patient p where not exists (select col_patient_id from tb_payment where col_patient_id = p.col_unid);\n\nwhy? Because of the alias p!!! Table alias is not allowed in not exists subquery!! Instead, you have to use the full table name~~~~ faint!\n\nCorrect code\n delete from tb_patient where not exists (select col_patient_id from tb_payment where col_patient_id = tb_patient.col_unid);", "created_at"=>2010-10-04 06:49:42 UTC, "updated_at"=>2012-06-24 15:53:15 UTC, "body_html"=>"
This works
\n\n
select * from tb_patient p where not exists (select col_patient_id from tb_payment where col_patient_id = p.col_unid);
\n\n
However, this does NOT work
\n\n
delete from tb_patient p where not exists (select col_patient_id from tb_payment where col_patient_id = p.col_unid);
\n\n
why? Because of the alias p!!! Table alias is not allowed in not exists subquery!! Instead, you have to use the full table name~~~~ faint!
\n\n
Correct code \n delete from tb_patient where not exists (select col_patient_id from tb_payment where col_patient_id = tb_patient.col_unid);
/var/run/sshd must be owned by root and not group or world-writable.
\n
root@e:/home/iceskysl# chmod 600 /var/run/sshd
\nroot@e:/home/iceskysl# /etc/init.d/ssh restart/var/run/sshd must be owned by root and not group or world-writable.root@li84-64:/home/iceskysl# chmod 600 /var/run/sshd", "created_at"=>2010-10-18 18:45:27 UTC, "updated_at"=>2012-06-24 15:53:15 UTC, "body_html"=>"
于是偶chmod 600 /etc/ssh/*,然后再次重启了ssh。 \nroot@e:/home/iceskysl# /etc/init.d/ssh restart \n/var/run/sshd must be owned by root and not group or world-writable. \nroot@e:/home/iceskysl# chmod 600 /var/run/sshd \nroot@e:/home/iceskysl# /etc/init.d/ssh restart/var/run/sshd must be owned by root and not group or world-writable.root@li84-64:/home/iceskysl# chmod 600 /var/run/sshd
\n", "_id"=>568}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Android & Java"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["certificate"], "comments_count"=>0, "category_id"=>12, "title"=>"“Debug certificate expired” error in eclipse android plugins", "body"=>"I am using eclipse android plugins to build a project, But i am getting this error in the console window:\n\n[2010-02-03 10:31:14 - androidVNC]Error generating final archive:\nDebug certificate expired on 1/30/10 2:35 PM!\n\nIceskYsl@eoe ~/.android $ pwd\n/Users/IceskYsl/.android\nIceskYsl@eoe ~/.android $ ll\ntotal 48\ndrwxr-xr-x 9 IceskYsl staff 306 Nov 17 2009 .\ndrwxr-xr-x+ 62 IceskYsl staff 2108 Nov 30 13:51 ..\n-rw-r--r-- 1 IceskYsl staff 123 Sep 30 15:42 adb_usb.ini\n-rw-r--r-- 1 IceskYsl staff 204 Dec 1 00:52 androidtool.cfg\ndrwxr-xr-x 6 IceskYsl staff 204 Oct 16 16:17 avd\n-rw-r--r-- 1 IceskYsl staff 1393 Dec 1 00:37 ddms.cfg\n-rw-r--r-- 1 IceskYsl staff 1267 Nov 17 2009 debug.keystore\n-rw-r--r-- 1 IceskYsl staff 759 Nov 17 2009 default.keyset\n-rw-r--r-- 1 IceskYsl staff 78 Dec 1 00:52 repositories.cfg\n\nDelete your debug certificate under ~/.android/debug.keystore (on Linux and Mac OS X); the directory is something like %USERHOME%/.androidon Windows.\n\nThe Eclipse plugin should then generate a new certificate when you next try to build a debug package.", "created_at"=>2010-11-30 09:10:04 UTC, "updated_at"=>2012-06-24 15:53:15 UTC, "body_html"=>"
I am using eclipse android plugins to build a project, But i am getting this error in the console window:
\n\n
[2010-02-03 10:31:14 - androidVNC]Error generating final archive: \nDebug certificate expired on 1/30/10 2:35 PM!
\n", "_id"=>574}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["brew"], "comments_count"=>0, "category_id"=>7, "title"=>"Installs Homebrew to /usr/local so you don't need sudo to `brew install`", "body"=>"$ curl https://raw.github.com/gist/323731/install_homebrew.rb -o /tmp/install_homebrew.rb\n % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n100 4569 100 4569 0 0 1605 0 0:00:02 0:00:02 --:--:-- 2346\n\n $ ruby /tmp/install_homebrew.rb\n==> This script will install:\n/usr/local/bin/brew\n/usr/local/Library/Formula/...\n/usr/local/Library/Homebrew/...\n==> The following directories will be made group writable:\n/usr/local/.\n/usr/local/bin\n==> The following directories will have their group set to admin:\n/usr/local/.\n/usr/local/bin\n\nPress enter to continue\n==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin\n==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin\n==> Downloading and Installing Homebrew...\nWarning: The following *evil* dylibs exist in /usr/local/lib\nThey may break builds or worse. You should consider deleting them:\n/usr/local/lib/libevent-1.4.2.1.3.dylib\n/usr/local/lib/libevent_core-1.4.2.1.3.dylib\n/usr/local/lib/libevent_extra-1.4.2.1.3.dylib\n/usr/local/lib/libkyotocabinet.4.8.0.dylib\n/usr/local/lib/libprotobuf-lite.6.dylib\n/usr/local/lib/libprotobuf.6.dylib\n/usr/local/lib/libprotoc.6.dylib\n==> Installation successful!\nNow type: brew help\n\n参考:https://gist.github.com/323731", "created_at"=>2011-09-03 08:29:42 UTC, "updated_at"=>2012-06-24 15:53:15 UTC, "body_html"=>"
$ curl https://raw.github.com/gist/323731/install_homebrew.rb -o /tmp/install_homebrew.rb \n % Total % Received % Xferd Average Speed Time Time Time Current \n Dload Upload Total Spent Left Speed \n100 4569 100 4569 0 0 1605 0 0:00:02 0:00:02 --:--:-- 2346
\n\n
$ ruby /tmp/install_homebrew.rb \n==> This script will install: \n/usr/local/bin/brew \n/usr/local/Library/Formula/... \n/usr/local/Library/Homebrew/... \n==> The following directories will be made group writable: \n/usr/local/. \n/usr/local/bin \n==> The following directories will have their group set to admin: \n/usr/local/. \n/usr/local/bin
\n\n
Press enter to continue \n==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin \n==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin \n==> Downloading and Installing Homebrew... \nWarning: The following evil dylibs exist in /usr/local/lib \nThey may break builds or worse. You should consider deleting them: \n/usr/local/lib/libevent-1.4.2.1.3.dylib \n/usr/local/lib/libevent_core-1.4.2.1.3.dylib \n/usr/local/lib/libevent_extra-1.4.2.1.3.dylib \n/usr/local/lib/libkyotocabinet.4.8.0.dylib \n/usr/local/lib/libprotobuf-lite.6.dylib \n/usr/local/lib/libprotobuf.6.dylib \n/usr/local/lib/libprotoc.6.dylib \n==> Installation successful! \nNow type: brew help
\n", "_id"=>576}])
+MONGODB iceylog_development['categories'].find({:_id=>5}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>5}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Mac & *UNIX"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["perl", "Twig", "xml"], "comments_count"=>0, "category_id"=>7, "title"=>"install perl module for XML-Twig in RHEL-Red Hat/Fedora Linux?", "body"=>"This module provides a way to process XML documents. It is build on top of XML::Parser. XML::Twig offers a tree interface to the document, while allowing you to output the parts of it that have been completely processed. It allows minimal resource (CPU and memory) usage by building the tree only for the parts of the documents that need actual processing, through the use of the twig_roots and twig_print_outside_roots options.(as pointed by yum info)\r\n\r\nLet’s first search for the package\r\n$ yum search perl-XML-Twig\r\nperl-XML-Twig.noarch : A perl module for processing huge XML documents in tree\r\n\r\nNote that you must be the root/administrator to install the package. To install this package in Red Hat/Fedora Linux.\r\n$ yum install perl-XML-Twig.noarch\r\n\r\nYou can check the details of this package perl-XML-Twig\r\n$ yum info perl-XML-Twig.noarch\r\n\r\n或者:\r\nperl -MCPAN -e 'install XML::Twig'", "created_at"=>2011-12-10 10:53:02 UTC, "updated_at"=>2012-06-24 15:53:15 UTC, "body_html"=>"
This module provides a way to process XML documents. It is build on top of XML::Parser. XML::Twig offers a tree interface to the document, while allowing you to output the parts of it that have been completely processed. It allows minimal resource (CPU and memory) usage by building the tree only for the parts of the documents that need actual processing, through the use of the twig_roots and twig_print_outside_roots options.(as pointed by yum info)
\n\n
Let’s first search for the package \n$ yum search perl-XML-Twig \nperl-XML-Twig.noarch : A perl module for processing huge XML documents in tree
\n\n
Note that you must be the root/administrator to install the package. To install this package in Red Hat/Fedora Linux. \n$ yum install perl-XML-Twig.noarch
\n\n
You can check the details of this package perl-XML-Twig \n$ yum info perl-XML-Twig.noarch
\r\n#Add this gem to your Gemfile:\r\ngem 'ruby-akismet', :require => 'akismet'\r\n```\r\n\r\n\r\n#Create an initializer file like config/initializers/akismet.rb with your configuration:\r\n
\n", "_id"=>580}])
+MONGODB iceylog_development['categories'].find({:_id=>7}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>7}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Architecture"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["nginx", "statistics", "upstream"], "comments_count"=>0, "category_id"=>9, "title"=>"NGINX upstream statistics", "body"=>"使用过nginx的应该都都晓得upstream,前面一篇文章说到《nginx upstream的5种配置方式》,例如如下是很常见的一段配置\r\n\r\n#create by ice 2011.12.22\r\nupstream unicon_v2_www {\r\n# This is the socket we configured in unicorn.rb\r\nserver unix:/var/www/v2/tmp/sockets/unicorn.sock backup;\r\nserver 192.168.0.1:5000 weight=9 max_fails=2 fail_timeout=30s;\r\nserver 192.168.0.2:5000 weight=3 max_fails=2 fail_timeout=30s;\r\n}\r\nserver {\r\nlisten 80;\r\nserver_name www.iceskysl.com;\r\nerror_log /opt/nginx/logs/error/error_v2_www.log;\r\naccess_log /opt/nginx/logs/access/access_v2_www.log main;\r\n\r\nroot /var/www/v2/public/;\r\nindex index.html index.htm;\r\n\r\nlocation / {\r\nproxy_redirect off;\r\nproxy_set_header X-Real-IP $remote_addr;\r\nproxy_set_header Host $host;\r\nproxy_set_header Content-Length $content_length;\r\nproxy_set_header X-Forwarded-For $remote_addr;\r\nclient_max_body_size 10m;\r\nclient_body_buffer_size 128k;\r\nproxy_connect_timeout 90;\r\nproxy_send_timeout 90;\r\nproxy_read_timeout 90;\r\nproxy_buffer_size 4k;\r\nproxy_buffers 4 32k;\r\nproxy_busy_buffers_size 64k;\r\nproxy_temp_file_write_size 64k;\r\nchunked_transfer_encoding off;\r\nproxy_pass http://unicon_v2_www/;\r\n}\r\n}\r\n\r\n其中upstream的这段配置:\r\nupstream unicon_v2_www {\r\n# This is the socket we configured in unicorn.rb\r\nserver unix:/var/www/v2/tmp/sockets/unicorn.sock backup;\r\nserver 192.168.0.1:5000 weight=9 max_fails=2 fail_timeout=30s;\r\nserver 192.168.0.2:5000 weight=3 max_fails=2 fail_timeout=30s;\r\n}\r\n\r\n我们了解到socket模式的这个是backup,其他两个机器分别weight=3和weight=9,于是我们想监控下upstream每个后端具体处理了多少请求,有没有问题等,这个好像就不好监控了,nginx自带的status模块只能监控总的请求数,无法区分每个upstream的具体情况。\r\n找到一个ustats(http://code.google.com/p/ustats/),其介绍是:NGINX basic upstream statistics module,具体的如下:\r\n
USTATS module provides basic statistics for each backend in nginx upstreams:\r\n\r\nNumber of requests\r\nHttp 499/500/503 errors count\r\nTcp errors\r\nHttp read/write timeouts\r\nFail timeout\r\nMax fails count\r\nLast failed access time\r\nTotal fails count\r\nBlacklisted backend highlighting\r\nDown backends highlighting\r\nThe module allows you to sort values in some columns for each separate upstream. The data can be retrieved as JSON by appending \"?json\" to the end of location on which the module was set to work on (see configuration instructions below).
我们了解到socket模式的这个是backup,其他两个机器分别weight=3和weight=9,于是我们想监控下upstream每个后端具体处理了多少请求,有没有问题等,这个好像就不好监控了,nginx自带的status模块只能监控总的请求数,无法区分每个upstream的具体情况。 \n找到一个ustats(http://code.google.com/p/ustats/),其介绍是:NGINX basic upstream statistics module,具体的如下:<!--more--> \nUSTATS module provides basic statistics for each backend in nginx upstreams:
\n\n
Number of requests \nHttp 499/500/503 errors count \nTcp errors \nHttp read/write timeouts \nFail timeout \nMax fails count \nLast failed access time \nTotal fails count \nBlacklisted backend highlighting \nDown backends highlighting \nThe module allows you to sort values in some columns for each separate upstream. The data can be retrieved as JSON by appending "?json" to the end of location on which the module was set to work on (see configuration instructions below). \n看上去正是我需要的,有时间试试看~(为啥nginx不学haproxy官方自带一个详细statistics的页面呢~haproxy那个statistics很详细很好用~) \n详细使用指南:http://code.google.com/p/ustats/
\r\nThe reason is simple. I installed an extension called SEO Site Tools which installs an icon on the right of the address bar. When you click the button, on the window displayed there is the option “Show no follo” which is an option for displaying links that have the value nofollow for the attribute rel of an HTML element.\r\n\r\nThis attribute instructs some search engines that a hyperlink should not influence the link target’s ranking in the search engine’s index. (Source: wikipedia.org)\r\n
\r\n\r\n修复的方法很简单,去掉“Show no follo”的勾选就好了~\r\n", "created_at"=>2012-01-28 01:48:36 UTC, "updated_at"=>2012-06-24 15:53:15 UTC, "body_html"=>"
经过检查(Library/Application Support/Google/Chrome/Default/User StyleSheets/Custom.css),发现不是本地的css配置,最后找到是一个叫“SEO Site Tools”导致的,具体原因是: \n \nThe reason is simple. I installed an extension called SEO Site Tools which installs an icon on the right of the address bar. When you click the button, on the window displayed there is the option “Show no follo” which is an option for displaying links that have the value nofollow for the attribute rel of an HTML element.
\n\n
This attribute instructs some search engines that a hyperlink should not influence the link target’s ranking in the search engine’s index. (Source: wikipedia.org)
\n\n
修复的方法很简单,去掉“Show no follo”的勾选就好了~
\n", "_id"=>589}])
+MONGODB iceylog_development['categories'].find({:_id=>10}).limit(-1).sort([[:_id, :asc]])
+MONGODB iceylog_development['categories'].update({"_id"=>10}, {"$inc"=>{"posts_count"=>1}})
+MONGODB iceylog_development['categories'].find({:name=>"Html/css/js"}).limit(-1).sort([[:_id, :asc]])
+WARNING: Can't mass-assign protected attributes: state
+MONGODB iceylog_development['$cmd'].find({:findandmodify=>"mongoid.auto_increment_ids", :query=>{:_id=>"posts"}, :update=>{:$inc=>{:c=>1}}, :new=>true, :upsert=>true}).limit(-1)
+MONGODB iceylog_development['posts'].insert([{"state"=>1, "tags"=>["CoffeeScript", "Connect", "Express", "jade", "JavaScript", "Node.js", "npm"], "comments_count"=>0, "category_id"=>10, "title"=>"CoffeeScript解决JavaScript不美,Node.js潜力巨大", "body"=>"如果你对JavaScript感兴趣,但是不喜欢写一大堆一大堆的JavaScript代码,那真的不是你的错,因为很多人都说JavaScript不美,究其原因,可以归纳为:JavaScript的诞生是个悲剧. 它是函数式+动态语言的优秀内核, 却硬被绑上了C/Java的语法。\r\n\r\n如果你真的喜欢JavaScript,那么你可以尝试了解更多~比如CoffeeScript,再比如Node.js,再比如Connect,再比如Express,再再比如jade,再再再比如npm等等,于是我们从安装npm(a package manager for node)开始~\r\n\r\n#装npm\r\nice@mac:~ > curl http://npmjs.org/install.sh | sh\r\n % Total % Received % Xferd Average Speed Time Time Time Current\r\n Dload Upload Total Spent Left Speed\r\n100 7881 100 7881 0 0 3664 0 0:00:02 0:00:02 --:--:-- 8584\r\ntar=/usr/bin/tar\r\nversion:\r\nbsdtar 2.8.3 - libarchive 2.8.3\r\ninstall npm@1.1\r\nfetching: http://registry.npmjs.org/npm/-/npm-1.1.0-3.tgz\r\n0.6.2\r\n1.1.0-3\r\ncleanup prefix=/usr/local\r\n\r\nAll clean!\r\n/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js\r\nnpm@1.1.0-3 /usr/local/lib/node_modules/npm\r\nIt worked\r\n\r\n#看看怎么用\r\nice@mac:~ > npm help\r\n\r\nUsage: npm \r\n\r\nwhere is one of:\r\n adduser, apihelp, author, bin, bugs, c, cache, completion,\r\n config, deprecate, docs, edit, explore, faq, find, get,\r\n help, help-search, home, i, info, init, install, la, link,\r\n list, ll, ln, login, ls, outdated, owner, pack, prefix,\r\n prune, publish, r, rb, rebuild, remove, restart, rm, root,\r\n run-script, s, se, search, set, show, star, start, stop,\r\n submodule, tag, test, un, uninstall, unlink, unpublish,\r\n unstar, up, update, version, view, whoami\r\n\r\nnpm -h quick help on \r\nnpm -l display full usage info\r\nnpm faq commonly asked questions\r\nnpm help search for help on \r\nnpm help npm involved overview\r\n\r\nSpecify configs in the ini-formatted file:\r\n /Users/ice/.npmrc\r\nor on the command line via: npm --key value\r\nConfig info can be viewed via: npm help config\r\n\r\nnpm@1.1.0-3 /usr/local/lib/node_modules/npm\r\n\r\n#用npm装connect\r\nice@mac:~ > npm install connect\r\nnpm http GET https://registry.npmjs.org/connect\r\nnpm http 200 https://registry.npmjs.org/connect\r\nnpm http GET https://registry.npmjs.org/connect/-/connect-1.8.5.tgz\r\nnpm http 200 https://registry.npmjs.org/connect/-/connect-1.8.5.tgz\r\nnpm http GET https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/mime\r\nnpm http GET https://registry.npmjs.org/formidable\r\nnpm http 200 https://registry.npmjs.org/formidable\r\nnpm http 200 https://registry.npmjs.org/mime\r\nnpm http 200 https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/formidable/-/formidable-1.0.8.tgz\r\nnpm http GET https://registry.npmjs.org/mime/-/mime-1.2.4.tgz\r\nnpm http GET https://registry.npmjs.org/qs/-/qs-0.4.1.tgz\r\nnpm http 200 https://registry.npmjs.org/mime/-/mime-1.2.4.tgz\r\nnpm http 200 https://registry.npmjs.org/formidable/-/formidable-1.0.8.tgz\r\nnpm http 200 https://registry.npmjs.org/qs/-/qs-0.4.1.tgz\r\nconnect@1.8.5 ./node_modules/connect \r\n├── mime@1.2.4\r\n├── qs@0.4.1\r\n└── formidable@1.0.8\r\n\r\n#用npm装express\r\nice@mac:~ > npm install express\r\nnpm http GET https://registry.npmjs.org/express\r\nnpm http 200 https://registry.npmjs.org/express\r\nnpm http GET https://registry.npmjs.org/express/-/express-2.5.6.tgz\r\nnpm http 200 https://registry.npmjs.org/express/-/express-2.5.6.tgz\r\nnpm http GET https://registry.npmjs.org/mime\r\nnpm http GET https://registry.npmjs.org/qs\r\nnpm http GET https://registry.npmjs.org/mkdirp/0.0.7\r\nnpm http 304 https://registry.npmjs.org/qs\r\nnpm http 304 https://registry.npmjs.org/mime\r\nnpm http 200 https://registry.npmjs.org/mkdirp/0.0.7\r\nnpm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.0.7.tgz\r\nnpm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.0.7.tgz\r\nexpress@2.5.6 ./node_modules/express \r\n├── mkdirp@0.0.7\r\n├── mime@1.2.4\r\n└── qs@0.4.1\r\n\r\n#用npm装jade\r\nice@mac:~ > npm install jade\r\nnpm http GET https://registry.npmjs.org/jade\r\nnpm http 200 https://registry.npmjs.org/jade\r\nnpm http GET https://registry.npmjs.org/jade/-/jade-0.20.0.tgz\r\nnpm http 200 https://registry.npmjs.org/jade/-/jade-0.20.0.tgz\r\nnpm http GET https://registry.npmjs.org/commander\r\nnpm http GET https://registry.npmjs.org/mkdirp\r\nnpm http 200 https://registry.npmjs.org/mkdirp\r\nnpm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz\r\nnpm http 200 https://registry.npmjs.org/commander\r\nnpm http GET https://registry.npmjs.org/commander/-/commander-0.2.1.tgz\r\nnpm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz\r\nnpm http 200 https://registry.npmjs.org/commander/-/commander-0.2.1.tgz\r\njade@0.20.0 ./node_modules/jade \r\n├── commander@0.2.1\r\n└── mkdirp@0.3.0\r\n\r\n好了,你入门了,更多资料,请自行查看如下链接的资料吧~\r\n\r\n相关资料\r\n\r\nCoffeeScript: CoffeeScript is a little language that compiles into JavaScript\r\nhttp://coffeescript.org/\r\n\r\n为什么CoffeeScript这么美?\r\nhttp://cnodejs.org/blog/?p=1584\r\n\r\nCoffeeScript: The beautiful way to write JavaScript\r\nhttp://amix.dk/blog/post/19612\r\n\r\n10个让朋友对你刮目相看的CoffeeScript单行代码绝技\r\nhttp://heikezhi.com/2011/06/08/10-coffeescript-one-liners-to-impress-your-friends/\r\n\r\nnpm: a package manager for node\r\nhttps://github.com/isaacs/npm\r\n\r\nExpress:http://expressjs.com/\r\nHigh performance, high class web development for Node.js\r\n\r\nConnect: Connect is a middleware layer for Node.js\r\nhttp://www.senchalabs.org/connect/\r\n\r\njade: http://jade-lang.com/\r\nNode Template Engine\r\n\r\ncoffee-box: Blog engine for fashionable developers. Built upon Node.js, Express, MongoDB and CoffeeScript.\r\nhttps://github.com/qiao/coffee-box", "created_at"=>2012-01-28 14:57:06 UTC, "updated_at"=>2012-06-24 15:53:15 UTC, "body_html"=>"
如果你真的喜欢JavaScript,那么你可以尝试了解更多~比如CoffeeScript,再比如Node.js,再比如Connect,再比如Express,再再比如jade,再再再比如npm等等,于是我们从安装npm(a package manager for node)开始~
\n\n
#装npm \nice@mac:~ > curl http://npmjs.org/install.sh | sh \n % Total % Received % Xferd Average Speed Time Time Time Current \n Dload Upload Total Spent Left Speed \n100 7881 100 7881 0 0 3664 0 0:00:02 0:00:02 --:--:-- 8584 \ntar=/usr/bin/tar \nversion: \nbsdtar 2.8.3 - libarchive 2.8.3 \ninstall npm@1.1 \nfetching: http://registry.npmjs.org/npm/-/npm-1.1.0-3.tgz \n0.6.2 \n1.1.0-3 \ncleanup prefix=/usr/local
\n\n
All clean! \n/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js \nnpm@1.1.0-3 /usr/local/lib/node_modules/npm \nIt worked \n<!--more-->
npm -h quick help on \nnpm -l display full usage info \nnpm faq commonly asked questions \nnpm help search for help on \nnpm help npm involved overview
\n\n
Specify configs in the ini-formatted file: \n /Users/ice/.npmrc \nor on the command line via: npm --key value \nConfig info can be viewed via: npm help config
首先安装Graphviz \n% brew install cairo pango graphviz # Homebrew on Mac OS X \n% sudo port install graphviz # Macports on Mac OS X \n% sudo aptitude install graphviz # Debian and Ubuntu
更多信息参考:http://rails-erd.rubyforge.org/ \n<!--more--> \n附:常见错误处理: \nCould not find gem 'choice (~> 0.1.4) ruby', which is required by gem 'rails-erd (>= 0) ruby', in any of the sources.
\n\n
原因是rails-erd依赖choice这个gem,装下 \nice@mac:/www/trunk > sudo gem install choice \nPassword: \nSuccessfully installed choice-0.1.4 \n1 gem installed \nInstalling ri documentation for choice-0.1.4... \nInstalling RDoc documentation for choice-0.1.4...
\r\n其实比较成熟的标记语言还是有不少的,比如wiki format,又比如今天要讲的Markdown,甚至还有国内bbs喜欢用的bbcode都还是不错的标记语言,这里主要讲的是Markdown和Mou。\r\n\r\nhttp://apple4.us/上有篇文章写的不错《为什么作家应该用 Markdown 保存自己的文稿》,其中说了为什么作家需要用Markdown保存自己的文稿,其实对技术人员也一样有用,大家可以仔细看看~同时被介绍的还有Mou(Mou The missing Markdown editor for web developers)。\r\n\r\nMou真是个不错的东西,让不会编程的人也很快接收其用法,当你已经熟练掌握其语法后,其实也可以不用Mou,比如技术人员一般直接在textmate里写或者直接写都还蛮不错的。\r\n\r\n大概汇总下用 Markdown 有如下好处:\r\n\r\n\t
http://apple4.us/上有篇文章写的不错《为什么作家应该用 Markdown 保存自己的文稿》,其中说了为什么作家需要用Markdown保存自己的文稿,其实对技术人员也一样有用,大家可以仔细看看~同时被介绍的还有Mou(Mou The missing Markdown editor for web developers)。