shitou's blog 
Home About Feed | MIX BOY 塌客

Tags "tips"

10
Jul

在cron中执行一个控制器的action by shitou

0
一些任务需要放在linux的cron中定期执行:
#under RAILS_ROOT
$./script/runner -e production \
 "ActionController::Integration::Session.new.get '/users/refresh/2?long=true'"
Tags: tips

2009-07-10 15:35:13, 221 reviews

send to mailbox

Your email:

09
Jun

在一个controller中调用另一个controller的方法 by shitou

0
遇到了比较特殊的情况,目前进行代码整合会比较麻烦,所以需要在一个controller A中调用controller B的action, 这里不是简简单单的redirect或者是render, 只是在逻辑上需要执行controller B的action代码,view还是由A来render, 并且A中所有的全局变量也继承到B中, 下面是解决办法:
  def exeRedirect (options={})
    params.merge!(options)
    c = ActionController.const_get(Inflector.classify("#{params[:controller]}_controller")).new
    c.process(request,response)

    #如果需要当前的实例变量也由B来覆盖,那么开启下面一行, 并且在执行后需要调用return
    #c.instance_variables.each {|v| self.instance_variable_set(v,c.instance_variable_get(v))}
  end


  #在controlelr A中定义上面的方法然后调用:
  exeRedirect :controller => controllerB, :action => actionB

 

Tags: tips

2009-06-09 10:55:31, 313 reviews

send to mailbox

Your email:

06
Feb

Media change: please insert the disc labeled by shitou

0

在Debian中使用apt-get安装软件包时经常会提示让你插入netinst的光盘:

Media change: please insert the disc labeled

当没有时就无法进行安装了, 这时可以打开文件/etc/apt/sources.list文件,注释掉cdrom那一行,然后再执行apt-get update更新下deb仓库, 这样以后再使用apt-get安装时就不会再搜寻cdrom了

Tags: debian,tips

2009-02-06 11:17:57, 667 reviews

send to mailbox

Your email:

05
Feb

shell小技巧 by shitou

0

有时我们会进入一个很深层次的目录,同时需要进入其他目录,这时来回切换就显得非常繁琐,这时你可以使用:

 

#cd -

 

或者history, 然后! 数字 来执行历史命令, 当然也可以用向上箭头翻出历史命令, 不过当你不是一条命令进入上一目录时就用cd - 是最方便的了

Tags: tips,shell

2009-02-05 13:50:55, 394 reviews

send to mailbox

Your email:

30
Oct

Performance Tuning for Linux Servers书笔记-Chap1 by shitou

0

要学的东西实在是多啊, 抽时间看<Performance Tuning for Linux Servers>这本电子书, 这本书内容比较深, 里面的内容大都为tips, Linux的知识还得继续补充,计划每天一章, 共14章, 每天一次笔记

 

Chapter1

 

1. Linux分区的顺序一直都没怎么注意, 现在才知道, 分区的顺序对磁盘的性能也是有影响的, 经常要读写的数据分区要放在靠前的柱面里, 如/var, /usr, swap分区, /分区可以放在后面

 

2. hdparm -Tt /dev/hda; #测试硬盘的读写速度

hdparm -d /dev/hda; #查看硬盘的DMA功能是否打开

hdparm -c /dev/hda; #查看硬盘的32-bit传输功能是否开启

hdparm -d1c1 /dev/hda; #开启硬盘的DMA, 32-bit功能, 0为关闭

 

3. 对IO读取比较频繁的server, 可以在修改Kernel(2.6.*)的IO的默认等待方式, 默认的为anticipatory, 可以修改成deadline,  方法是在grub的引导参数上添加 elevator = deadline

 

 

 

Tags: tips

2008-10-30 15:24:32, 391 reviews

send to mailbox

Your email:

24
Oct

几个rails tips by shitou

0
  • 在views和tests中都要使用helper的方法

  • 不要使用小的RJS文件,你可以把它直接放在controller中

  • 如果你使用RESTful的架构,不要在随便在你的action中使用respond_to来render xml,除非你真的使用了API

  • 如果你使用了在线支付和交易,不要存储它们在数据库中,直接把表单提交到支付网关

  • 在大多数情况下has_many :through比has_and_belongs_to_many要更好(shitou: 这样的话你就可以在关联表中添加更多的数据)

  • 你可以在model中通过关联来定义方法, e.g., has_many :visits do {define custom find here} end

  • 如果你的一个页面大部分都可以cached, 只是因为要显示登陆用户的用户名, 那么你可以直接使用page cache, 然后再用javascript来替换掉显示用户名的部分

  • 关掉不需要session的controller或者是action

  • decode一个session文件可以: Marsha1.load(File.read("/tmp/sessions/filename"))

 

翻译自: Tips from the Advanced Rails Studio

 

 

 

Tags: tips

2008-10-24 10:19:16, 305 reviews

send to mailbox

Your email:

Tags

U-ka saegusa IN db command Mai Kuraki Norah Jones log iPhoneException ACG Mac Safari objective-c CouchDB LVS AJAX debian 推荐 AMQP google mail bug gettext Erlang 北京 iptables 架构 tips mysql backup function 我看 postfix 监控 SEO cache Etag memcache thread 进程 线程 无锡 yield file column mixboy xml rss gems ruby shitou shell lighttpd 安全 csrf 公司 nginx linux 模块 apache webserver 朋友 大学 生活 尼古拉斯凯奇 movie 文件同步 笑笑 歌词 auto complete plugin rails music ubuntu blog

Category

  • iPhone[17]
  • Erlang[4]
  • google[8]
  • 生活[38]
  • 音乐[11]
  • 电影[11]
  • linux[20]
  • web server[6]
  • mail server[3]
  • cluster[1]
  • system manage[5]
  • ruby[18]
  • ruby on rails[27]
  • 开源[3]

Episode

  • iPhoneException
  • shell
  • thread
  • memcache

Recent Comments

  • comment6, viagra bez receptu, revelation, ambie...
  • comment5, http://www.freecodesource.com/user/pr...
  • comment4, meridia medicine, :-<>], plavix clopi...
  • comment2, viagra calgary, resin, paxil vs wellb...
  • comment2, codeine promethazine, conclusion, buy...
  • comment2, clomid ovarian cysts, fronted, oxycod...
  • comment2, http://www.freecodesource.com/user/pr...
  • comment3, cipro allergy, :-E, weed and hydrocod...
  • comment2, http://www.freecodesource.com/user/pr...
  • comment4, vicodin cr, chocolate, premarin cance...

Popular Posts

  • MySQL Innodb备份
  • 准备开始学习Erlang了(恶狼, 二郎..)
  • Lighttpd配置参数
  • iPhone上的HelloWorld终于跑起来了
  • Etag和Expire

Recommended Posts

  • Mai Kuraki -永远より ながく
  • U-ka saegusa IN db Final Best
  • Heaven Can Wait - Charlotte Gainsbou
  • Ruby遍历MemCached的key
  • Norah Jones - The fall
  • 请记得仰望梦想的姿势
  • Shell: 统计MySQL InnoDB表的大小
  • Rails Benchmark
  • 发送异常到邮箱
  • I Miss Nobody
  • Music4u, Vol. 1
  • my macbook
  • Mai Kuraki-Beautiful
  • 10首最伤情英文歌曲精选
  • Mai Kuraki - PUZZLE/Revive

Friends' blogs

  • levy
  • sphance
  • andreas

Login

   注册

留言 查看留言

留言

   取消

留言 查看留言


Statistics

  • 访问次数: 51143
  • 今天访问: 7
  • 日志: 172
  • 评论: 124
  • 音乐: 9
  • 用户: 148


 

just DO NOT support IE

close