ITeye博客

2008 年文章归档

共 11 篇文章

当你linux设置了时间,但是显示不正确的时候

计算机系统有两个时钟,一个是 BIOS,或者CMOS,或者说“硬件时钟”,还有一个就是“系统(操作系统)时钟”,如果这两个时钟的设置上有问题,或者Linux 的时钟配置文件不正确的话,就会产生系统时钟差 8 小时的问题。 让我们先查看 /etc/sysconfig/clock 的内容: [root@www /root]# cat /etc/sysconfig/clock ZONE=Asia/Shanghai ;/usr/share/zoneinfo 下面的文件。 UTC=false ; 硬件时钟是否为 UTC 或者说 GMT 时钟。 ARC=false ;如果是在 Alpha 机器上,则设置…

2008-12-31 10:24

修改 Linux 系统时区

1. 查看当前时区 # vi /etc/sysconfig/clock 2. 修改设置时区 方法(1) # tzselect 方法(2 仅限于RedHat Linux 和 CentOS) # timeconfig 3. 复制相应的时区文件,替换系统默认时区 # cp /usr/share/zoneinfo/$主时区/$次时区 /etc/localtime 对于中国服务器则执行: # cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 4. 将当前时间写入BIOS永久生效(避免重启后失效) # hwclock

2008-12-30 16:23

rake migrate 调用fixture

require 'rake' rake = Rake::Application.new ENV['FIXTURES'] = "roles,static_permissions,roles_static_permissions" Rake::Task["db:YAML:delete"].invoke Rake::Task["db:YAML:restore"].invoke class InitConfig < ActiveRecord::Migration def self.up require 'rake' rake = Rake::Application.new ENV['FIXTURES…

2008-12-30 11:58

Ruby Rails 系统调用Ping的使用

想用RoR下调用系统命令,一般exec和system 和syscall 想使用在Rails下,调用ping命令 最常见的是ruby支持的Ping用法如下: Ping contains routines to test for the reachability of remote hosts. Currently the only routine implemented is pingecho(). Ping.pingecho uses a TCP echo (not an ICMP echo) to determine if the remote host is reachable. Thi…

2008-12-24 08:48

MySql Root 用户远程登录的解决

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'youpassword' WITH GRANT OPTION; grant all on depot_development.* to 'david'@'localhost' identified by 'lovelove'; 要开启远程连接的权限才行,比如grant all on *.* on remote@'你的ip或%' identified by 'pass' WITH GRANT OPTION; 这样就开了一个名为remote密码为pass的远程用户,他可以对所有的数据…

2008-12-10 08:28 · Mysql

Rails 下拉菜单

资源列表: http://www.ibm.com/developerworks/cn/xml/x-introajaxrails/ http://wiki.rubyonrails.com/rails/pages/HowtoUseFormOptionHelpers 有几种不同的写法,支持的功能不一样,保存下来 <%= select 'post', 'type_id', Type.find(:all).map {|x| [x.name, x.id]} %> <%= collection_select :Job, :client_id, Client.find(:all), :id, :name %…

2008-11-21 17:07

在Win32下Ruby连接Mysql

我看到论坛上的那个有点老了 1.首先安装好MySql 最新的应该是5.0 2.使用“gem install mysql”命令远程安装mysql的ruby驱动,但是可惜的是,不要以为大功告成了,这样的情况下你依然很有可能连不上mysql的。 3.把mysql安装目录bin下的libmysql.dll拷贝到ruby的bin目录. Ok! require "mysql" begin dbh = Mysql.real_connect("localhost", "root", "abc123", "test") res = dbh.query("SELECT NAME FROM test") whil…

2008-06-04 17:56

使用Ruby读取excel文件的简单例子

本篇文章已经比较老,全新的导入导出处理见 这里 Rails 的 Wiki 上有講到幾個方法可以直接用 Ruby 寫 Excel file: 1. office 2003 之後有支援以 xml 做為儲存格式。只要符合schema 的 XML file 就會被正確解讀成 Excel file。這樣產生出來的文件只有 office 2003 以後才能讀取 2. 用 Jakarta POI 的 Ruby Binding 3. 用 spreadsheet 4. 最後是用 CSV Reading An Excel File With Ruby Jump to Comments This tutorial…

2008-06-04 17:50 · RubyOnRails

关于Rails的用户认证

最近对于用户认证研究了一下,有点心得 把资源顺便整理一下,以备后用 http://notahat.com/posts/19 http://onrails.org/articles/2006/02/18/auto-login The "remember me" checkbox 2 months ago Here's a nifty solution that I came up with for implementing the "remember me" checkbox on login forms in Rails. First you'll need this extension t…

2008-05-16 14:52

让will_paginate的分页支持ajax

让will_paginate的分页支持ajax 关于will_paginate插件,请看这个帖子: http://mmm.iteye.com/blog/116931。 文/陈刚 (www.chengang.com.cn) 但一直搜不到它支持ajax分面的方法 ,于是我参考它分页方法的源代码(位于:vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb),稍微改写,变成了一个支持ajax的分页方法。以下代码复制到application_helper里即可。 #---------------------------------…

2008-05-10 13:37

[Rails 常用插件简介]will_paginate

Rails2.0中原pagination将被移出作为插件classic_pagination,will_paginate是个非常不错的替代方案 一:安装 [Copy to clipboard] [ - ] CODE: view plain copy to clipboard print ? ruby script/plugin install svn://errtheblog.com/svn/plugins/will_paginate ruby script/plugin install svn://errtheblog.com/svn/plugins/will_paginate 二:使用 …

2008-05-10 13:34