Jump to navigation

You are currently browsing the monthly archives for April 2010

一般人都回答不上来的几个问题,你想来试试吗?

  • Posted on April 30, 2010 at 8:53 am

初中物理三年
高中物理三年
大学物理二年

问题一:
地球为什么会自转?

问题二:
地球为什么会绕着太阳公转?

问题三:
月球和女人monthly circle的关系。

学了8年物理,一般人都回答不来这三个问题。

Ubuntu 10.04 RC发布

  • Posted on April 26, 2010 at 11:29 am

24日发布
代号:Lucid Lynx
Ubuntu 10.04
RC的意思是: Release Candidate

The Ubuntu team is pleased to announce
the Release Candidate for Ubuntu 10.04 LTS (Long-Term Support)
Desktop and Server editions and Ubuntu 10.04 …….

传说系统启动时间接近10秒。

discuz中添加新的论坛动态

  • Posted on April 25, 2010 at 7:12 pm

discuz 7.2 gbk版
discuz 有一个论坛动态的功能,就是一些feeds,比如某人等级提升啦,某人的贴子被置顶啦,某人的贴子回复数超过1000啦之类的。

为了活跃论坛气氛,我们决定加入一个新的动态:某人回复了某个贴子。

先来看一下添加feed的函数:
include/global.func.php

function add_feed($arg, $data, $template = '') {
	global $tablepre, $db, $timestamp;
	...
 
	$db->query("INSERT INTO {$tablepre}feeds (type, fid, typeid, sortid, appid, uid, username, data, template, dateline)VALUES ('$type', '$fid', '$typeid', '$sortid', '$appid', '$uid', '$username', '".addslashes(serialize($data))."', '".addslashes(serialize($template))."', '$timestamp')");
	return $db->insert_id();

数据结构:
mysql> desc cdb_feeds;
+———-+———————–+——+—–+———+—————-+
| Field | Type | Null | Key | Default | Extra |
+———-+———————–+——+—–+———+—————-+
| feed_id | mediumint(8) unsigned | NO | PRI | NULL | auto_increment |
| type | varchar(255) | NO | MUL | default | |
| fid | smallint(6) unsigned | NO | | 0 | |
| typeid | smallint(6) unsigned | NO | | 0 | |
| sortid | smallint(6) unsigned | NO | | 0 | |
| appid | varchar(30) | NO | MUL | | |
| uid | mediumint(8) unsigned | NO | MUL | 0 | |
| username | varchar(15) | NO | | | |
| data | text | NO | | NULL | |
| template | text | NO | | NULL | |
| dateline | int(10) unsigned | NO | MUL | 0 | |
+———-+———————–+——+—–+———+—————-+

mysql> select * from cdb_feeds limit 1 \G
*************************** 1. row ***************************
feed_id: 2696
type: user_usergroup
fid: 0
typeid: 0
sortid: 0
appid:
uid: 129385
username: wogksthrPth
data: a:1:{s:5:”title”;a:2:{s:5:”actor”;s:62:”wogksthrPth“;s:9:”usergroup”;s:82:”秀才“;}}
template: s:0:”";
dateline: 1271894327

fid typeid sortid 都是主题相关的参数
appid 可能是应用相关的参数

如果template为空字符串的话,在显示feed的时候,就会去templates/default/dz_feeds.lang.php加载 ‘feed_$template’ 模板。

修改feed的模板文件:
templates/default/dz_feeds.lang.php
添加一行:

'feed_new_reply_title'=> '{actor} 回复了贴子:{subject}',

然后在include/newreply.inc.php中添加feed

                if (1)
                {
                        $arg = $data = array();
                        $arg['type'] = 'new_reply';
                        $arg['fid'] = $thread['fid'];
                        $arg['typeid'] = $thread['typeid'];
                        $arg['sortid'] = $thread['sortid'];
                        $arg['uid'] = $discuz_uid;
                        $arg['username'] = $discuz_userss;
                        $data['title']['actor'] = "<a href=\"space.php?uid={$discuz_uid}\" target=\"_blank\">{$discz_userss}</a>" ;u
                        $data['title']['subject'] = "<a href=\"viewthread.php?tid={$thread[tid]}\" target=\"_blank\">{$thread[subject]}</a>";                  
                        add_feed($arg, $data);
                }

再创建 images/feeds/new_reply.gif

更新缓存即可。

drupal_goto 函数详解

  • Posted on April 24, 2010 at 2:51 pm

drupal 6:

drupal_goto($path = '', $query = NULL, $fragment = NULL, $http_response_code = 302);

主要作用是从当前页跳转到另外一个页面。

Drupal will ensure that messages set by drupal_set_message() and other session data are written to the database before the user is redirected.
使用这个函数的时候不必担心 drupal_set_message()会失效,drupal会保证在跳转之前把message写到数据库里。

btw:
drupal会对path进行编码(encode),保证URL的正常。

Parameters
参数:
$path A Drupal path or a full URL.
$path: drupal路径,或者是一个完整的url
$query A query string component, if any.
$query: url中的参数部分。比如 a=1&b=1&c=1
$fragment A destination fragment identifier (named anchor).
$fragement #xxxx 锚点
$http_response_code Valid values for an actual “goto” as per RFC 2616 section 10.3 are:
$http_response_code HTTP CODE
301 Moved Permanently (the recommended value for most redirects)
302 Found (default in Drupal and PHP, sometimes used for spamming search engines)
303 See Other
304 Not Modified
305 Use Proxy
307 Temporary Redirect (alternative to “503 Site Down for Maintenance”)
Note: Other values are defined by RFC 2616, but are rarely used and poorly supported.

举例:
假设我们要跳转到
/my_page?sex=1&country=BE
正确:

drupal_goto("my_page", "sex=1&country=BE");

错误:

drupal_goto("my_page?sex=1&country=BE");

这样会跳转到 my_page%3Fsex%3D1%2526country%3DBE

freebsd下查看cpu信息

  • Posted on April 23, 2010 at 3:53 pm

freebsd下没有 /proc 文件系统,就更加没有 /proc/cpuinfo 了。
据说国内某公司申请了 /proc 文件系统的专利?

[root@super ~]# sysctl -a | egrep -i ‘hw.machine|hw.model|hw.ncpu’
hw.machine: i386
hw.model: Intel(R) Xeon(R) CPU 5110 @ 1.60GHz
hw.ncpu: 2
hw.machine_arch: i386

[root@super ~]# grep -i cpu /var/run/dmesg.boot
CPU: Intel(R) Xeon(R) CPU 5110 @ 1.60GHz (1595.94-MHz 686-class CPU)
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
cpu0 (BSP): APIC ID: 0
cpu1 (AP): APIC ID: 1
cpu0: on acpi0
ACPI Error (psparse-0626): Method parse/execution failed [\\_PR_.CPU1._PDC] (Node 0xc63172a0), AE_BAD_SIGNATURE
p4tcc0: on cpu0
cpu1: on acpi0
ACPI Error (psparse-0626): Method parse/execution failed [\\_PR_.CPU2._PDC] (Node 0xc63171a0), AE_BAD_SIGNATURE
p4tcc1: on cpu1
SMP: AP CPU #1 Launched!

#sysctl -a | grep -i cpu | less

yahoo 买下 me.me 作为微博新域名

  • Posted on April 22, 2010 at 4:33 pm

又是一个类似twitter的网站,yahoo称它为meme. 所以me.me这个域名再好不过了。

具体金额没有透露出来。估计总要几万刀吧
官方称这次购买行为是”an essential component of our online branding strategy”.

国内访问不了,翻墙.

ps:
.me域名是Montenegro这个国家的。黑山共和国。

btw:
对于这种好域名,有个英文组合词可以用来形容: oh-so-clever
the oh-so-clever domain name.

爱心汇青海,携手抗震灾(转载)

  • Posted on April 21, 2010 at 10:13 am

爱心汇青海,携手抗震灾

青海玉树地震牵动了全中国网民的心,让我们用实际行动,支援灾区、为玉树祈福。

腾讯公益慈善基金会执行理事长、腾讯公司首席行政官陈一丹呼吁亿万网友,
以实际行动投入到全国上下同心协力的青海抗震救灾行动中去,携手同胞,战胜天灾,重建家园。

腾讯网捐赠网址:

http://gongyi.qq.com/qinghai/

本人晚上闲着无聊,收集了几个淘宝店铺,都是热心捐款的好掌柜。如果您的淘宝店也在搞捐款捐物的话动,那么联系我吧,也让您的店榜上有名。

===========================================================================
惠峰鞋城

http://shop60739173.taobao.com/

掌柜的话:
情系玉树!
此义卖每笔交易将有1元捐给慈善机构!友情捐助爱心不打折!
评论:
要是打折就更好了。

===========================================================================

爱国T恤店

http://shop61144752.taobao.com/

掌柜的话:
每售出一件爱心T恤,掌柜就捐款10.01元。
评论:
这个掌柜最大方了,有魄力。

===========================================================================

linlin韓流{品牌服飾〓時尚女包}贵族旂艦店

http://844816098.taobao.com/

掌柜的话:
(部分宝贝)每售出一件,为玉树捐款成交金额的10%.
评论:
一看到这个店名,就知道是90后的妹妹们开的店啦。

===========================================================================

YAN SHOP≮晏乐嘉品≯ 淘宝天下推荐 女装女鞋一站式购物

http://piaopiaohu.taobao.com/

掌柜的话:
(部分宝贝)每售出一件,宝贝成交金额的1元会自动捐赠给慈善机构。
评论:
1块钱太少了吧。

===========================================================================
新疆莫合烟特产卷土从来

http://yaolinai.taobao.com/

掌柜的话:
当我看这篇文章的时候我真的在哭,
我是个新疆人没办法了解的更多但是亲爱的朋友们,
有多少孩子在饿肚子,有多少孩子还在寒风中。
我们能给他们一个在大灾难后的无助吗?
做为一个中国人我们不能,
我们要伸出援助之手帮助我们的兄弟姐妹。
请大家购买我的捐助产品。
我将我虽得得百分之90捐助给这些孩子(运费除外)
我将低于成本卖给大家。
评论:
为新疆人而感动。
===========================================================================

时尚联盟☆向1981衣神君伟服饰探索者学习

http://sisang.taobao.com/

掌柜的话:
本店部分商品已设置按商品加运费10%比率捐款给玉树灾区,
另外每单由掌柜捐赠五元到上面图片捐款通道,并把捐赠截图公布,以你我微薄之力,温暖灾区人民!
评论:
有图有真相!

===========================================================================

百年制桶

http://bainianzhitong.taobao.com/

掌柜的话:
从5月13日起至6月13日,所有在本店购买橡木桶、橡木工艺酒具系列产品,只要您购买任何一件,我们都将向灾区捐款5元,多买多捐!早一点到达,多一分希望,尽我们微薄之力,支持灾区重建!!!
评论:
等等,这个估计是汶川地震时候的。

===========================================================================

chrome浏览器下discuz ajaxget函数中的问题

  • Posted on April 20, 2010 at 2:54 pm

discuz7.2 gbk版
经过测试发现:
/include/js/common.js:

function ajaxget(url, showid, waitid, loading, display, recall)

使用此函数以ajax的GET方式从url取到html代码,并且通过ajaxinnerhtml()把代码填充到某个页面元素(比如div)里面。
如果取到的html代码中含有

<script src='http://xxxx.com/xxxx.php?a=xx&b=xxx'></script>

或者类似的代码,
在chrome和firefox浏览器里面,页面会跳转到

http://xxxx.com/xxxx.php?a=xx&b=xxx

而浏览器地址栏的地址却是正确的。

IE没有问题。

另外在使用chrome逛天涯论坛的时候,偶尔也会出现类似情况:
点击某个版块之后,比如“ 天涯摄影”, 然后整个页面变成空白,
只显示一个120×600的google图片广告,
此时地址栏中的地址是“天涯摄影”的地址,
刷新即恢复正常。
tianya_google

drupal6 hook_schema中的自增字段

  • Posted on April 19, 2010 at 1:53 pm

假设模块为 abc
在文件abc.install中我们可以实现abc_install和abc_uninstall函数,
用来在模块安装/反安装过程中做一些事情,比如自动生成/删除数据表之类的。

function abc_install() {
    // Use schema API to create database table.
    drupal_install_schema('abc');
}
function abc_schema()
{
    $schema['abc_db_table'] = array(
              'field'=>array(
			'id'=>array(
				'type'=>'serial',
				'not null'=>TRUE,
				'description'=>t('xxx.'),
				),
			'title'=>array(
				'type'=>'char',
				'length'=>'255',
				'not null'=>TRUE,
				'default'=>'',
				'description'=>t('title'),
				),
			'flag'=>array(
				'type'=>'int',
				'size'=>'small',
				'not null'=>TRUE,
				'default'=>0,
				'description'=>t('flag'),
				),
              ),
		'primary key'=>array(
			'id',
		),
    );
}

这样就可以创建一张数据表: abc_db_table
它有一个主键id , ‘type’=>’serial’, 相当于 unsigned int auto_increment.

ps: text类型的字段(column),不能设置默认值(default value).

btw: 在hook_schema函数中, char类型的字段(column),有一个’length’属性,表示 char(xx) 。
int 类型的字段,有一个’size’属性,表示smallint, bigint, tinyint之类的。
text类型的字段,也有一个’size’属性,bigtext之类的意思。

神奇的诺基亚nokia手机

  • Posted on April 18, 2010 at 1:36 pm

最近在用一台nokia 1110还是1200,
有手电筒的那个。
似乎是前二年花200块钱买的。
平时主要是用它来看看农历,顺便当个闹钟使。

前几天某个晚上,女人发飙,用力把它扔地板上摔烂,
拼起来之后,竟然还能用,完全正常!

感谢神奇的诺基亚。

Top