`
jacky
  • 浏览: 25328 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论
文章列表
1. To search a string from the content of files.    E.g. Search 'logo.gif' from all jsp,html and xsl files under current folder find . \( -name '*.jsp' -o -name '*.html' -o -name '*.xsl' \) -exec grep -l logo.gif {} \; 2. To get lines in a certain range from file which is huge    E.g. Get the line ...

UNIX: DOS To UNIX

Features: 1. Convert window format to UNIX format 2. Keep the last modify date of file unchanged if [ $# -ne 1 ];then echo echo "USAGE: $0 fileName" echo exit -1 fi file=$1 tr -d '\r' <$file >$file.tmp touch -r $file $file.tmp mv $file.tmp $file chmod 777 $fi ...
Here is a real practice: House keep log files which have been out of date for N days. if [ $# -ne 2 ];then echo "Usage: $0 [develop|uat|prod] [ N days ago ]" exit -1 fi ENV=$1 N_DAYS_AGO=$2 function getDays { _thisMon=$1 _thisYear=`date +%Y` _div4=`expr $_thisYear \% 4 ...
环境如下: ubuntu server v8 lighttpd-1.5.0-r1992 ruby 1.8.6 (2007-09-24 patchlevel 111) fcgi-2.4.0 ruby-fcgi-0.8.7.tar apt-get了libfcgi0,libfcgi-dev 单独启动spawn-fcgi的脚本lighttpd DISPATCH_PATH=/home/www/www.jk.com/public/dispatch.fcgi SOCKET_PATH=/tmp/ RAILS_ENV=production export $RAILS_ENV case &qu ...
数据库中有表categories,想做个admin后台来进行维护操作,这时候,map.namespace 就能帮助我们省却很多功夫。 步骤如下: 1. Generate categories controller ruby script/generate scaffold Category category_name:string category_name_md5:string sequence:int 2. 创建 controllers\admin\categories_controller.rb class Admin::CategoriesController < Ap ...
http://www.aidanf.net/adding-a-rich-text-editor-to-your-rails-application 推荐两款for rails的rich editor. 今日尝试了一下以前在java里使用过的TinyMCE。 引用ruby script/plugin install hxxp://secure.near-time.com/svn/plugins/trunk/tiny_mce/ 引用rake tiny_mce:scripts:install 在controller里配置editor的属性: class UsersController < ...
gregg的这两篇文章详细的描述了如何应用page cache和action cache : http://www.railsenvy.com/2007/2/28/rails-caching-tutorial http://www.railsenvy.com/2007/3/20/ruby-on-rails-caching-tutorial-part-2 那Rails2.1结合Will-pagination是如何使用的呢? routes.rb map.connect 'users/page/:page', :controller => 'users', :a ...
1. Ruby DBI launch operation in Mysql with conditions as follow:       a) The Character encoding of MYSQL table is UTF-8    b) If the encoding of Ruby file is "UTF-8" without BOM, then we need to convert the Chinese character using    name="你好" name = Iconv.new("GB ...
引用 Problem 中国为了防御敌国的导弹袭击,发展出一种导弹拦截系统。但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够达到任意的高度,但是以后每一发炮弹都不能高于前一发的高度。某天,雷达捕捉到敌国的导弹来袭。由于该系统还在使用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹。 Input 最多20个整数,分别表示导弹依次飞来的高度(雷达给出高度数据是不大于30000的正整数) Output 两个整数M和N。表示:这套系统最多能拦截 M 枚导弹,如果要拦截所有导弹最少要配备 N 套这种导弹系统。 Sample Input 300 250 275 252 200 138 2 ...
引用 背景 很久以前,迷宫里住着一个恶魔。一天,我们伟大的英雄Jacky无意中踏入了这个迷宫。不幸的是,他被困在这个迷 宫当中了。恶魔在迷宫中召唤出了许多怪物,想要阻止Jacky逃脱。在迷宫中,Jacky遇到一个一位巫师。他给了 Jacky迷宫的地图,并告诉他迷宫的入口很快会关闭。Jacky必须以非常快的速度到达入口,并且有足够的力气推开挡 在入口的岩石。于是,Jacky带着地图一路向着出口走去…… 问题 给出Jacky和各怪物的能量, 攻击力, 防御力,和迷宫的地图,请你计算一下 能量/耗时 的最大值。 当Jacky走到有怪物的地方时,Jacky会先进行攻击,然后怪物攻击,然 ...

猪的安家

引用 Jacky和Mary养了很多猪。他们想要给猪安家。但是Jacky没有足够的猪圈,很多猪只能够在一个猪圈安家。举个例子,假如有16头猪,Jacky建了3个猪圈,为了保证公平,剩下1头猪就没有地方安家了。Mary生气了,骂Jacky没有脑子,并让他重新建立猪圈。这回Jacky建造了5个猪圈,但是仍然有1头猪没有地方去,然后Jacky又建造了7个猪圈,但是还有2头没有地方去。Jacky都快疯了。你对这个事情感兴趣起来,你想通过Jacky建造猪圈的过程,知道Jacky家至少养了多少头猪。 输入 输入包含多组测试数据。每组数据第一行包含一个整数n (n <= 10) – Jacky建立猪圈 ...
4张任意的扑克牌,用+,-,*,/,(,) 计算总合等于24的方法。 缺点:没有过滤重复的算法,比如 24=(4+(10+(11-1)))和24=(4+(-1)+(10+11))原本是一样的。 # # count 4 random numbers(1-13) to 24 by using +,-,*,/,(,) # # require 'mathn' beginTime = Time.now $opers = ['+','-','*','/'] def count24(total,data,str) lack = getSymmetry(str) lac ...
最近写了个java操作visio文档的小工具.使用了javacom & jacob,参考了c++操作visio的com技术,并请教了javacom的作者Miika. 这里同大家分享一下. java 代码  /**  * @author:Jacky Huang  * @date 2007-8-23  */ public class JVisio {           private static Log log = LogFactory.getLog(JVisio.class);           /**   ...
Hibernate3.2Rc4,遇到java.lang.NoSuchFieldError: tokenTypeToASTClassMap这样的错误,反复check代码和文件都找不出原因,Google也没有相应解答。分析了一下,是语法分析器的错误,更换ANTLR到antlr-2.7.6.jar,问题解决。  
Global site tag (gtag.js) - Google Analytics