个人在平时使用google.com是总结出来的常见google搜索技巧:
1,简单数学计算
1.23 * 20
2,查看天气预报
beijing weather
3,查看时间
beijing time
4,搜索文件,指定格式
rails filetype:ppt5,查找指定站点
rails site:wxianfeng.com6,排除站点查找
rails -site:wxianfeng.com7,查找外链
link:www.dhgate.com8,查找相似网站
related:www.dhgate.com9,查看google收录数
site:wxianfeng.com10,搜索手机号码归属地(g.cn)
1388888888811,搜索指定的词组
"ruby on rails"12,排除关键字搜索
-rails site:wxianfeng.com13,指定多个关键字
ruby || rails
ruby OR rails 14,查询汇率
1 dollars in RMB
15,查询网站title中含有指定关键字
intitle:wxianfeng16,查询url含有指定关键字的
inurl:wxianfeng17,网页内容包含的关键词
intext:wxianfenggo on ………….
SEE:
http://dongxi.net/b00rT
http://www.williamlong.info/archives/728.html
Rails社区核心人物之一Katz今天离开了engineyard,离开了rails社区,有点遗憾,这个人我想rails社区的fans都应该知道,katz在kungfurails的时候来过中国,并且作了rails3的演讲,视频见此:
http://v.youku.com/v_show/id_XMTI4NDQ2OTIw.html,katz做过很多我们耳熟能详的项目,Rails,Merb,jQuery,datamapper 等等,并且最近刚发布的rails3主要贡献者就是katz,把merb的想法带入了rails,Yehuda Katz 在blog里说明离开的原因和去向,并且说明了未来三年的计划,他的去向是去开发 sproutcore了,sproutcore是apple公司开源出来的,然而sproutcore的创造者在今年7月8日离开了apple公司,创办了自己的公司,依据sproutcore开发更好的桌面体验般的webapp,sproutcore创始人准备将sproutcore打造为html5的框架,为移动互联网,IPAD等提供良好的应用体验,看来HTML5也是大势所趋啊….
无论怎样,Good luck Katz,必定你为rails社区贡献了很多,katz承诺虽然离开了engineyard,但是rails3.1的开发工作还将由他主导,说不定也因为他rails+sproutcore会很好的结合起来呢,over。。。
叽歪一下祝贺Katz进入HTML5 team
See:
http://www.javaeye.com/news/17731-yehuda-kats-leave-engine-yard
不幸,宿舍的电脑又挂掉了,这次装了个win 7,win 7 果然气质不凡,概念版的QQ很炫的说,不过跑起来有点卡,还是XP下的qq跑得流畅,郁闷的是qq2010,安装上运行不起来,抱错,这不是必win 7 用概念版的吗~!..切入正题:
最终环境:win 7 + ruby 1.9.2 + rails 3.0.0.rc2 + mysql 5.1
目前rails3的demo跑起来了,由于以前的项目都是跑在2.x系列的,所以以后还要折腾………….
1,安装 ruby 1.9.2 and install
http://rubyforge.org/frs/download.php/72170/rubyinstaller-1.9.2-p0.exe
注意安装上ruby 1.9.2 就不需要再安装rubygems了,这个和以前ruby 1.8.X 的有区别,ruby 1.9.2 已经自带rubygems了,可以>gem -v 查看
2,安装rails
F:\>gem install rails --pre --no-ri --no-rdoc ERROR: Error installing rails: activemodel requires builder (~> 2.1.2, runtime)
接下来你只需要运行gem install rails —pre —no-ri —no-rdoc 即可,缺少什么装什么,一直装到gem install rails —pre —no-ri —no-rdoc 成功即可,例如上面错误,继续安装缺少的依赖的库,如果某个gem安装不上了,去rubygems.org上下载下来手动安装上,再继续,如果加上 —pre 参数安装的不是最新的rails版本,那么把 —pre 参数去掉试试
F:\>gem install builder --no-ri --no-rdoc
为什么要用—no-ri —no-rdoc 参数,因为加上去安装实在是慢,反正装了也不用,还不如不装rdoc!
3,新建rails3 project
>rails new rails3 -d mysql
4,修改database.yml
5,创建数据库
>rake db:create RAILS_ENV=development
6,启动rails3 server
>rails server
你会发现报如下错误:
E:\Rubyproject\rails3>rails server Could not find gem 'mysql2 (>= 0, runtime)' in any of the gem sources. Try running `bundle install`.
发现rails3.0连接mysql的adapter不再是mysql了,是mysql2,这个好办,我们还用之前的mysql但是建议用mysql2,mysql2性能上有很大提高,gem install mysql2 即可
修改项目下Gemfile
gem ‘mysql2’ 改为 gem ‘mysql’
同理修改config下的database.yml mysql2 → mysql
7,ok,你的demo已经可以跑起来了
如果你的mysql还是连不上,可能是libmysql.dll 问题,see: http://wxianfeng.com/2010/06/23/windows-xp-ruby-on-rails-mysql
除此之外,还有一种更简单的方法,安装devkit,但是我没有成功,gem install rails —pre 安装失败,see : http://skim.la/2010/08/21/rails-3-rc-on-windows-using-rubyinstaller-192/
see:
http://skim.la/2010/02/07/rails-3-beta-on-windows-using-rubyinstaller-187-rc2/
http://osdir.com/ml/RubyonRailsTalk/2010-09/msg00480.html
最近blog换了皮肤,以前是最大宽度,现在宽度限制死了,有的图片超过了宽度,很丑陋,于是用minimagick对所有的图片统一缩放了下,这下图片的大小刚刚好,缩放比resize的效果要好,图片不会扭曲难看,
minimagick和rmagick都是调用imagemagick的ruby接口,使用起来很方便。。。。
1,缩放 (也就是我用来处理我blog里图片的脚本)
require 'rubygems' require 'mini_magick' # path = "E:/Rubyproject/wxianfeng_com/public/files/" # windows路径 path = "/usr/local/system/www/wxianfeng_com/shared/public/files/" files = Dir.open(path).to_a.select{|x| x != '.' && x!= '..' && x != '.svn' && x != 'Thumbs.db'} imgs = files.select { |f| f !~ /^(thumb_|middle_)/ } imgs.each do |ele| p ele img_path = path + ele img = MiniMagick::Image.from_file(img_path) w,h = img[:width],img[:height] percent = ((480/w.to_f) * 100).to_i img.combine_options do |c| c.sample "#{percent}%" # 缩放 end img.write(img_path) end
2,resize
image = MiniMagick::Image.from_file("input.jpg") # or MiniMagick::Image.new("input.jpg") image.resize "100x100" # or image.thumbnail "100x100" image.write("output.jpg")
3,裁剪
require ‘mini_magick’ img = MiniMagick::Image.from_file “1.jpg” #取得宽度和高度 w,h = img[:width],img[:height] #=> [2048, 1536] shaved_off = ((w-h)/2).round #=> 256 img.shave “#{shaved_off}x0″ #此处表示宽度上左右各截取256个像素,高度上截取0像素 img.write “2.jpg”
4,旋转
image = MiniMagick::Image.from_file("input.jpg") image.combine_options do |c| c.rotate "-90>" # 旋转 90 度 end image.write("input.jpg") # 同名 替换掉原来的
SEE:
http://github.com/probablycorey/mini_magick
http://www.blogkid.net/archives/2154.html















