Monthly Archive四月 2007
Database & 技术 26 Apr 2007 11:14 am
mysql 中取指定范围随机数
Returns a random floating-point value v between 0 and 1 inclusive (that is, in the range 0 <= v <= 1.0). If an integer argument N is specified, it is used as the seed value, which produces a repeatable sequence.
mysql> SELECT RAND();
-> 0.9233482386203
mysql> SELECT RAND(20);
-> 0.15888261251047
mysql> SELECT RAND(20);
-> 0.15888261251047
mysql> SELECT RAND();
-> 0.63553050033332
mysql> SELECT RAND();
-> 0.70100469486881
mysql> SELECT RAND(20);
-> 0.15888261251047
To obtain a random integer R in the range i <= R <= j, use the expression FLOOR(i + RAND() * (j – i). For example, to obtain a random integer in the range of 7 to 12 inclusive, you could use the following statement:
SELECT FLOOR(7 + (RAND() * 5));
将discuz论坛中所有贴子的浏览数改为13~93之间
update cdb_threads set views=FLOOR( 13+(RAND() * 80));
wamp windows 下gd模块失效
用wamp自带的工具配置失效,因为他显示的php.ini和实际使用的是两个文件。
应当使用wamp\php\下的php.ini
LINUX & 技术 17 Apr 2007 11:48 am
linux 批量删除文件
find ../shanghai/ -name “*.html” -exec rm -f {} \;
在命令行可执行在shell里报错
find: missing argument to `-exec’
换用
find ../shanghai/ -name “*.html”|xargs rm -rf
在命令行可执行在shell里报错
rm:无效选项 —
请尝试执行‘rm –help’来获取更多信息。
给shell加上#!/bin/bash
报错
: bad interpreter: 没有那个文件或目录sh
由于shell是在windows下写的,估计是换行的问题.
系统没装dos2unix,所以在linux下重写一遍,成功。
LINUX & 技术 17 Apr 2007 10:54 am
find命令中*号的疑惑
当前目录下有abc.html,def.html,ghi.html
使用find . -name *.html会报 “path must precede expression”错误
因为find -name 后面只能指定一個 name,执行上面的命令会解析成
-name abc.html,def.html,ghi.html 所以就会报错
可以使用 find . -name “*.html” 来解决
HTML/XHTML/CSS & 技术 16 Apr 2007 01:11 pm
li标签的间距问题
- body{font-size:12px;margin:0}
- ul{list-style:none;margin:0;padding:0;}
- ul li{background:green;height:20px;width:120px;vertical-align: bottom;}
- ul li a{color:#fff;padding:0 0 0 10px;}
1.解决li在IE5下产生空白行距的方法:如果li定义了宽度,那么需要在li里面再定义vertical-align: bottom;
2.宽度最好不要定义在UL,定义在LI或者UL外层的DIV里面
3. 书写LI的最佳方式,li里面要书写高度和宽度,以及vertical-align: bottom;(for ie5/win bug),或者在ul外面加上一层div,并定义宽度,那么在li里面不用定义宽度和vertical-align: bottom;,也显示正常(IE5下不会产生空白行距),不过高度还是要定义一下的。
HTML/XHTML/CSS & 技术 10 Apr 2007 10:34 am
css display属性小记
visibility属性用来确定元素是显示还是隐藏,这用visibility=”visible|hidden”来表示,visible表示显示,hidden表示隐藏。
当visibility被设置为”hidden”的时候,元素虽然被隐藏了,但它仍然占据它原来所在的位置。
table的display为’table’时在ie下会出错,ff下没事,干脆显示时用display=”;
用pear::pager产生html翻页
网站需要使用全静态页面进行翻页。
只需修改pager类的fileName和append两个option就可以实现
将list.php?page=2改为list_2.html
- fileName [string]
- name of the page, with a "%d" if append == TRUE.
- fixFileName [boolean]
- If set to FALSE, the fileName option is not overridden. Use at your own risk.
- append [boolean]
- If TRUE pageID is appended as GET value to the URL. If FALSE it is embedded in the URL according to fileName specs.
pear::pager文档
http://pear.php.net/manual/en/package.html.pager.factory.php
以下为函数
- /**
- * 获得html分页对象
- *
- * @param int $limit 每页显示数目
- * @param int $cnt 总数
- * @param int $filename 文件名格式
- * @return object
- */
- function get_html_pager($limit, $cnt,$filename='list_%d.html') {
- include_once('Pager/Pager.php');
- $options = array(
- 'perPage' => $limit,
- 'delta' => 10,
- 'url' => '',
- 'clearIfVoid' => true,
- 'urlVar' => 'Page',
- 'mode' => 'Jumping',
- 'totalItems' => $cnt,
- 'prevImg' => '上一页',
- 'nextImg' => '下一页',
- 'firstPageText' => '首页',
- 'lastPageText' => '末页',
- 'linkClass' => '',
- 'curPageLinkClassName' => 'strong',
- 'excludeVars' => array('Flush'),
- 'path' => './',
- 'fileName' => $filename,
- 'append' => false,
- //'spacesAfterSeparator' => 1,
- );
- $pager = Pager::factory($options);
- return $pager;
- }
LINUX & 技术 06 Apr 2007 04:35 pm
lsof常用技巧
1) lsof abc.txt 显示开启文件abc.txt的进程
2) lsof -i :22 知道22端口现在运行什么程序
3) lsof -c nsd 显示nsd进程现在打开的文件
4) lsof -g gid 显示归属gid的进程情况
5) lsof +d /usr/local/ 显示/usr/local目录下被进程开启的文件
6) lsof +D /usr/local/ 同上,但是会搜索目录下的目录,时间较长
7) lsof -d 4 显示使用fd为4的进程
lsof -i [i] 用以显示符合条件的进程情况
语法: lsof -i[46] [protocol][@hostname|hostaddr][:service|port]
46 –> IPv4 or IPv6
protocol –> TCP or UDP
hostname –> Internet host name
hostaddr –> IPv4位置
service –> /etc/service中的 service name (可以不只一个)
port –> 端口号 (可以不只一个)
例子: TCP:25 - TCP and port 25
@1.2.3.4 - Internet IPv4 host address 1.2.3.4
tcp@ohaha.ks.edu.tw:ftp - TCP protocol host:ohaha.ks.edu.tw service name:ftp
9) lsof -n 不将IP转换为hostname,缺省是不加上-n参数
例子: lsof -i tcp@ohaha.ks.edu.tw:ftp -n
10) lsof -p 12 看进程号为12的进程打开了哪些文件
11) lsof +|-r [t] 控制lsof不断重复执行,缺省是15s刷新
-r,lsof会永远不断的执行,直到收到中断信号
+r,lsof会一直执行,直到没有档案被显示
例子:不断查看目前ftp连接的情况:lsof -i tcp@ohaha.ks.edu.tw:ftp -r
12) lsof -s 列出打开文件的大小,如果没有大小,则留下空白
13) lsof -u username 以UID,列出打开的文件