自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(60)
  • 收藏
  • 关注

rjcop处理图片上传时截取

http://github.com/jschwindt/rjcrop/

2009-12-21 02:11:34 120

原创 由于页面中对代码加亮的JS

http://alexgorbatchev.com/wiki/SyntaxHighlighter

2009-11-05 12:57:01 84

git server+continuouse integrity

gem install integrity #安装Integrity gem integrity install --passenger | --thin Install_PATH #在指点的地点安装integrity程序,passenger及thin是看你的WEB服务器使用哪种 然后去Install_PATH中编辑config.yml 主要是看使用何种DB integrity ...

2009-10-28 15:12:26 131

升级到snow 10.6 ROR的解决

http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard 叁照些文章安装,不过特别要注意的是,要重新编译ruby,因为原来的ruby是32位的,如果你mysql改用64位后,需要编译msyql gem为64位,而此gem是用ruby来跑,所以ruby必须要在新的环境下重新编译一次即可。...

2009-10-13 23:25:35 87

mac os snow 10.6下反安装mysql

Open Terminal sudo nano /etc/hostconfig Enter your password if you’re not authed yet. Delete the following line: “MYSQLCOM=-YES-” CTRL+X (This is the command for closing NANO, Enter the “Y” key to...

2009-10-13 22:16:50 87

原创 ruby console plugin

前几天在看 screencasts,发现一好插件:Hirb 。这是个扩展命令行的插件,可以以更加易读的形式展现方法返回的内容(比如以 mysql 输出的形式展现 ActiveRecord 实例)   gem install cldwalker-hirb --source http://gems.github.com/ # Append the following lines into...

2009-10-12 11:09:49 126

原创 Centos5.3源

CentOS的网络源配置文件是: /etc/yum.repos.d/ 下的 CentOS-Base.repo 配置方法一般是: 1.终端下 vi /etc/yum.repos.d/CentOS-Base.repo ,删除里面原来的所有内容,然后用下面的相应内容替换。 2.把下面相应内容,保存为:CentOS-Base.repo ,然后用mv命令,替换旧的“/etc/yum.re...

2009-09-24 19:36:20 122

restful_authentication的site_key问题

好久没来写东西了,最近项目太忙,也懒的写啥。不过今天花了两个小时解决了一个很无聊的问题,记一下。 restful_authentication是采用随机生成的site_key来加密密码,我们项目在开发过程中经常采用svn加capistrano来修改加部署,这样的话,每次部署后,为了图省事,我们一般用capistrano自动rake auth:gen:site_key,而此时生成的site_key...

2009-08-17 02:56:57 139

centos+rails+php+lighttpd

php:   ./configure \ --enable-fastcgi \ --enable-force-cgi-redirect \   其他配置信息,待空闲后,稍后补充      

2008-12-28 16:13:08 80

capistrano2.5使用

gem install capistrano 到项目目录中运行 capify  . 会自动产生  ./Capfile ./config/deploy.rb   #主配置文件   set :application, "numed_collection" set :repository, "svn://×.×.×.×/numed_collection" set :deploy_to, "/data/w...

2008-12-10 10:48:12 75

ubuntu下rmagick快速安装(备忘)

sudo apt- get install libmagick9- dev ruby1.8 - dev sudo gem install rmagick sudo apt-get install imagemagick sudo gem install rmagick

2008-12-09 21:54:33 112

关于rails的route的性能

今天跟蛋黄讨论关于route的性能问题,经过跟踪调试发现,具名路由的实现相当简单,并且性能也相当好。 在服务器启动时, map.resources会生成相应的路由的对象,比如 map.resources    :blogs 会生成若干个named  routes地址的对象 比如:    edit_blog,对象类型是ActionController::Routing::Route,其中有个to_s...

2008-12-05 12:20:10 142

原创 ubuntu8.10 dpkg备份和恢复安装包列表

1. 执行备份操作:dpkg --get-selections > installed-software.log,这将当前系统中已安装的软件保存到 installed-software.log 中。 2. 在还原时使用 dpkg --set-selections < installed-software.log 导入软件列表,再利用 dselect 工具安装软件。 ...

2008-12-04 15:46:55 424

原创 sphinx在ubuntu8.1下安装与使用

参考 dlee 的  http://www.iteye.com/topic/200065 在安装mmseg的过程中出错的解决办法以及自己整理一下在ubuntu8.1下的完整安装与使用   g++更换到4.1版本,python使用2.5编译coreseek通过 李沫南还开发了一个支持中文全文检索的Sphinx定制版本——Coreseek,除了支持中文的全文检索外,Coreseek最大的特点是支...

2008-12-03 21:40:52 133

private的一个问题

首先,要明白这几个ruby的原理1、默认(包括你所用的定义方法)在顶层定义的都是private的实例方法2、private方法是不允许指明接收者的,其接收者只能是隐含的selfdef x11puts "in x11"enddef x11=(t) puts tend x11self.x11="ddd"当前定义了两个方法,都是private的,可以puts self.private_methods.s...

2008-07-03 15:34:02 93

rails1.2.3的在rubyforge更新到1.0.0以后产生的问题解决

运行时提示已active0.4.5.不能active1.0.0,那直接删除0.4.5的gem就行了。

2008-06-17 17:38:17 65

Ruby中闭包与block

转道友Blog中的一小段code说明ruby中的闭包 procs = [] (1..3).each do |i| procs << lambda { puts i } end procs.each { |p| p.call } # Output: # 1 # 2 # 3 ########################...

2008-06-17 08:01:26 123

截取中文

  def trc_utf8(text, length = 40, t_string = "...")        l=0        char_array=text.unpack("U*")        char_array.each_with_index do |c,i|          l = l+ (c<127 ? 0.5 : 1)          if l&gt...

2008-06-13 21:45:26 98

提升mysql性能(转)

 TCMalloc(Thread-Caching Malloc)是google开发的开源工具──“google-perftools”中的成员。与标准的glibc库的malloc相比,TCMalloc在内存的分配上效率和速度要高得多,可以在很大程度上提高MySQL服务器在高并发情况下的性能,降低系统负载。  TCMalloc的实现原理和测试报告请见一篇文章:《TCMalloc:线程缓存的Malloc...

2008-06-07 09:15:57 163

用ruby抓取gzip网页

require 'net/http'require 'uri'module Net  class HTTP    def HTTP.get_with_headers(uri,headers=nil)      uri=URI.parse(uri) if uri.respond_to? :to_str      start(uri.host,uri.port) do |http|        re...

2008-05-26 19:42:41 162

抓取网页时转换字符集出现问题(问题已解决)

用ruby写个网页抓取的小东东,遇到问题: 环境:ubuntu8.04+netbeans6.1+ruby1.8.6 在ruby中使用Net::HTTP.get_response抓取一个GB2312编码的网页后转换成utf8全是乱码,主要代码部分如下 resp=Net::HTTP.get_response(URL,URI) body=resp.body[0,resp.size-1] r=Iconv....

2008-05-26 16:21:33 138

让url更人性化_acts_as_slugable

== Installation<tt>./script/plugin install http://code.dunae.ca/acts_as_slugable</tt>== Usage examplesIn your target table, add a column to hold the URL slug.=== With scope  class Page &lt...

2008-05-26 09:29:11 64

在ror项目中使用paypal

http://www.codyfauser.com/2008/1/17/paypal-express-payments-with-activemerchant

2008-05-21 18:18:41 59

全国省市县三级数据库

中国省,市,县(区)三级数据信息,已转换成mysql的dump文件

2008-05-12 22:41:03 208

memcached+libmemcached+memcache_client

ubuntu下安装memcached非常简单 运行也很简单 ./memcached -d -m 2048 -l 10.0.0.40 -p 11211 如果要使用caffeine,请参考 http://blog.methodmissing.com/2007/6/4/get-your-caffeine-on/ 本人是使用的 memcache-client gem install memcache-c...

2008-05-02 16:33:01 148

acts_as_taggable_on_steroids代替原acts_as_taggable

1、安装 ruby script/plugin install http://svn.viney.net.nz/things/rails/plugins/acts_as_taggable_on_steroids 2、 class Post < ActiveRecord::Base acts_as_taggable end 3、 p = Post.find(:...

2008-04-23 09:45:31 99

ferret+acts_as_ferret+RMMSeg全文索引+中文分词的使用

首先,在ubuntu下要安装 atp-get install build-essential  zlib1g-dev ruby需要安装dev包 1、安装ferret sudo gem install ferret 2、安装acts_as_ferret 可用gem sudo gem install acts_as_ferret 或用plugins svn://projects.jkraemer.ne...

2008-04-22 13:21:26 151

rails测试驱动开发中的一些知识点滴

def setup @controller=***.new @request=ActionController::TestRequest.new @response=ActionController::TestResponse.new end  assert_template 测试是否装载了正确的view assert_tag 'form',:attributes=>{:acti...

2008-04-21 19:28:59 97

又一个处理图片的插件

http://fleximage.rubyforge.org/examples/   Home: http://fleximage.rubyforge.org/ Repository: svn://rubyforge.org/var/svn/fleximage Effect examples: http://fleximage.rubyforge.org/examples resi...

2007-08-30 17:14:12 173

routes笔记

例: ruby 代码map.admin_report 'report/:year',                     :controller => 'admin',                     :action => 'report'   Having this named route in routes.rb tells Rails to create two ne...

2007-08-28 15:22:15 97

validations常用方法

ruby 代码 validates_inclusion_of :class_level,          :in => %w( Freshmen Sophomore Junior Senior),         :message=>"must be: Freshmen, Sophomore, Junior, or Senior"     r...

2007-08-25 16:00:33 236

activescaffold插件的基本使用(爆爽的东东)

http://www.activescaffold.com/ 三步曲 1、Install the latest version of the plugin: ruby 代码 ./script/plugin install http://activescaffold.googlecode.com/svn/tags/active_scaffold   2、Add this to ...

2007-08-13 10:29:22 178

rails中使用tzinfo-timezone实现各时区时间转换

结合http://marklunds.com/articles/one/311 和手册,完整的一个实现各时区时间转换的一个例子: 首先保证服务器安装tzinfo插件  gem install  tzinfo 1、配置环境 ruby 代码 ActiveRecord::Base.default_timezone = :utc    2、相应的类中 ruby 代码 require 't...

2007-08-11 14:48:01 540

dhtml日历插件和show flash messages on cached pages

Show flash messages on cached pages ruby 代码ruby script/plugin install svn://rubyforge.org/var/svn/pivotalrb/cacheable_flash/trunk  时间日历插件http://dry.4thebusiness.com/info/dhtml_calendarruby 代码ruby scr...

2007-08-11 14:47:25 167

ruby中rmgaick给图片加版权信息和水印(中文水印)

根据imagemagick和一些网站的资料,总结了常用的加水印(特别是中文)的代码。 require 'rubygems' require 'RMagick' #在图片中嵌入中文文字 ruby 代码 def   t1       img=Magick::Image.read('path\read_image1.jpg').first    #图片路径,用相对路径即...

2007-07-30 19:30:26 402

ror中文截取乱码解决

puts "在要城在".scan(/./)[0, 6].join('') 注意,用utf-8编码,一个汉字三个字节

2007-07-12 16:17:20 91

migration的外键支持

migration默认是不支持外键的,原因是一部分数据库如MySQL ISAM和SQLite不支持外键,同时外键也会给Rails的test fixture导入数据造成麻烦(这个好像有个很麻烦的解决办法)。不过还是有个插件提供了外键的导出(rake db:schema:dump)和导入(rake db:schema:load)(可惜migration中无法正常使用)。 <o:p><...

2007-07-06 15:39:06 417

小技巧

1、<%=select :news,:news_types_id,NewsType.find(:all).map{|c|[c.typename,c.typeid]}%> 实现关联的内容建立选择框,如建新闻的时候把新闻类型取出来,供选择。 2、flash[:error][email protected]_messages.join('<br/>')  ,把型的错误记...

2007-07-04 08:19:21 37

ruby on rails报告

nubyonrails.com/pages/gruff ruby 代码   sudo gem install gruff         # Install the plugin   ./script/plugin install http://topfunky.net/svn/plugins/gruff      # Make a ...

2007-07-03 08:42:19 63

form_tag的小问题

<%form_tag ({:action => 'update',:id => @photo}, :multipart=> true ) do %> 要加上小括号,和大括号,否则,处理有错,另外参数顺序不能错了。,原因在于形参是*方式接受。唉,有时语言太灵活了也痛苦 呀,呵呵。虽然这很简单,手册中也有详细的信息。但还是记下来,因为,ruby/rails中经常因此产生...

2007-06-30 20:18:28 270

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除