站务

帮你检查网站相应速度和提供如何改善建议的在线工具

帮你检查网站相应速度和提供如何改善建议的在线工具
http://www.websiteoptimization.com/services/analyze/
有帮助。

backup database on nearlyfreespeech.net

backup database on nearlyfreespeech.net

  mysqldump -u jsmith -p -h tingda.db pengyou > backup/pydb

-u username
-p passwrd, don't enter passowrd here
-h host. usually in the form of someting.db

pengyou > backup/pydb

save database pengyou to backup directory with filename pydb

reference: http://www.modwest.com/help/kb6-241.html

import database

 mysql -h localhost DATABASE < YOURFILE.sql

在不支持ssh key登录的站点也实现自动登录,就是用户不如输入密码

要解决问题

有些站点不提供sshkey登录,只让你用密码登录。因为ssh命令不让在命令行直接明文你给密码,所以每次登录要输入密码很不方便。

解决方法

受到这篇文章启发: http://linuxtoy.org/archives/sshpass.html , 用sshpass可以解决。请阅读该文行。

更新我 .bash_alias 下面内容

以前是:
alias sshsrv01='ssh 404@某服务器ip -p端口号'
这样输入 sshsrv01(就是ssh到sever01的简写 :),实际运行一个ssh登录命令,但需要输入密码才能登入。因为ssh命令不让你直接在命令行输入密码。

现在该行更新为:

  alias sshsrv01='sshpass -p 'ssh登录密码' ssh 404@某服务器ip -p端口号'

sshpass -p 可以让你在后面直接跟登录密码,密码要放在英文单引号中。

现在再次输入 sshsrv01, 直接就登录到server01上了,无须输入密码。和使用sshkey达到的效果一样。

注意

  • alias命令整体要放在英文单引号中。所以,命令中有2对单引号。**
  • 在登录时,sshpass让你觉得和用sshkey登录一样,但安全性上,passwd-based和key-based是不一样的。当然key-based安全!
  • 是否能运用到scp和rsync中我还没有试验。谁用了请说明。

让drupal的统计模块(statistics)将记录保留更长的时间。可以设置为永久保留

需要解决的问题

durpal代码让你保留统计信息,比如最近点击、访问来源等信息,最长保留时间是16周。我想让它保留更长时间的信息。搜索了一下,决定直接改代码。

方法

因为我使用drupal 6。以下修改都是针对drupal 6的代码。

需要修改的文件是 modules/statistics/statistics.admin.inc

编辑该文件,查找 3600 这个关键词,会看到这行

'#description' => t('Log each page access. Required for referrer statistics\
.'));
$period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172\
800, 259200, 604800, 1209600, 2419200, 4838400, 9676800,3600000000), 'format_in\
terval')
;

其中 $period 后面是默认的保存时间,以秒来计算。诉一3600就是一个小时。10800是一天。你要保留多少天直接用 天数 x 24 x 3600 就是添上去的秒数。

我图省事。直接加了 3600000000 ,就是1000000个一小时。:)

修改好了,保存。

回到管理页面。 /admin/reports/settings

在“Discard access logs older than:”中现在可以选择的时间断中赫然出现 114 years 这个选项。原来1000000个小时就是114年啊。足够长了。:)

可惜114年太长。drupal不同意。最后我删除了2个零。改为1年零7周。

参考文章:
http://api.drupal.org/api/function/statistics_access_logging_settings/6
需要修改的代码片段就在上面链接页面中。

解释statistics模块是干嘛的。http://drupal.org/node/297

我为了解决这个问题进行的关键词搜索

修改显示参数,让每页显示超过30条信息

我只想每页多显示些referrers条目,比如显示200条

第一步:让每次查询数据库的时候多查一些,而不是默认的30条

还是在 modules/statistics/statistics.admin.inc 搜索一下

  $result = pager_query($sql, 30);

之类的看看。修改30为400,就是每次查询400条。

第二步:修改输出查询条目的参数

参考源代码: http://api.drupal.org/api/function/statistics_top_referrers。这是修改referrer的,修改hits和top pages, top visits一样道理。

最简单的方法,就是搜索关键词“30”,看到默认output是30,直接改为100就好了或任何你想要的数字就好了。

注意

按我的方法直接改动核心代码的好处是方便。增加几个字符,就好了。

坏处是下次升级的时候,你还要记得修改相同的地方,不然你的修改就被覆盖了。所有,有些麻烦。

drupal模板:在聚合页不显示文章正文

自己老文章重读
http://pengyou.rijiben.org/node/2032
在node.tp.php中用

就是如果这个node是单独的一个page,那么打印$content。也就是说,如果不是单独的,就不打印。成功了。:)

顺便在聚合页也不显示作者了

   <?php if ($page == 1)print $submitted ?>
   <?php if ($page == 1)print $submitted ?>

大家举一反三去。哈哈。

    <?php if ($page == 0): ?>

一次 untar 多个文件

我现在用的方法

我今天自己想到了用这个

  for f in *.gz; do tar xvzf $f;done 

用了一个 for ; do ; done 的bash循环。我喜欢用这个。

看到别人的方法

一次 untar 多個files
find [folder] -iname "*.tar" -exec tar xvfz {} \;
我現在多是用到sites/all/modules 用 wget 更新模組的
http://www.joetsuihk.com/node/117

不但解决了我的问题,而且都是为了解决同一个问题,更快速地升级drupal模块!

每次我升级ddrupal的时候都在想,如果不是drupal支持多站点,我每个站点升级一次,那是多么痛苦啊。幸好支持多站点的软件,只要升级同一个系统,所有站点都升级了。

nearlyfreespeech.net上计算流量费用的页面

nearlyfreespeech.net上计算流量费用的页面
https://www.nearlyfreespeech.net/services/bwcalc.php

因为这个网站服务商的原则是用的流量越多越便宜
https://www.nearlyfreespeech.net/services/hosting.php#pricing

我多个站点在上面,流量在每个月3g-5g之间,现在费用是每月3美元左右。

我计算了一下,按现在流量再用一年应该便宜到每月2美元不到。:)

帮助朋友上传他设计的图标到 archive.org

好处: http://www.archive.org 致力于存档事业。常年来服务稳定。

方法,提示自己。登录后,点upload,选择多余10个文件,或者大于100mb等,这样可以不用web界面传,而用ftp传。建立一个item的名字,这个名字是出现在 archive.org/details/项目名字。所以,我用gaolewen,传完后,地址就应该是 http://www.archive.org/details/gaolewen 。网站给了我ftp的地址。用lftp登录。本地到我要上传的目录。lftp下命令前加英文惊叹好表示在本地执行该命令。所以改变本地目录是 !cd,浏览本地目录是!ls。到了要上传的目录,用

                                                                    mirror -R . 

就可以了。这是我2年前读lftp的man的收获。:) mirror就是镜像。通常都是镜像远端服务器到本地,参数 -R 是说 Reverse,就是反过来。那么它会镜像本地目录到远端服务器。英文句号 . 表示是镜像当前目录到远端。

似乎今天上传速度很慢。

以前都能达到200k以上,开多个lftp,能达到数个200k以上。现在单位对网速做了限制。:(

让drupal运行在cherokee网页服务器上

让drupal运行在cherokee网页服务器上的菜谱
http://svn.cherokee-project.com/browser/cherokee/trunk/doc/c...

cherokke号称最快的web server
http://www.cherokee-project.com/

决定在自己的桌面机试验一下。

暂时用处不大。因为除非自己用虚拟服务器,不然各大虚拟主机提供商都是apache。

如何在你的网站引用picasa相册上的照片幻灯片

答案在这里
http://picasa.google.com/support/bin/answer.py?hl=en&answer=...

以前用过,操作链接位置变了。

简单说就是

This feature is currently only available in English.

You can embed a Flash slideshow of any web album. It'll be automatically updated when you make changes to your album. Follow these steps to embed a slideshow:

  1. On the My Photos page, click your album.
  2. Click Link to this album on the right-hand side.
  3. Click Embed Slideshow.
  4. Choose your slideshow settings, such as image size, captions, and autoplay.
  5. Once you've chosen your settings, copy the resulting HTML code (Ctrl-C).
  6. Paste the HTML in the source code for your site (Ctrl-V).

Once the slideshow is embedded in your site, people who click your slideshow will be taken to view your album in Picasa Web Albums.

只有帐号在英文界面下才能用。所以,自己看英文吧。:)

你可临时把帐号界面切换到英文使用这个功能。

你的gmail地址其实有无数个关联地址

你gmail帐户名后跟 英文加号 + 后面随便写,这些地址都是你帐号的alias。非常有用

参考了这篇文章: http://proofgroup.com/blog/2008/dec/gmail_aliases_testing_mu...

就是说,你的email是 zhangsan@gmail.com,那么 zhangsan+1@gmail.com zhangsan+2@gmail.com zhangsan+lisi@gmail.com zhangsan+lisi+wangwu@gmail.com 这些地址都是发给zhangsan@gmail.com的。

有什么好处?参考文章中主要用来在同一测试站点注册多个帐号。

lvcha认为方便在同一论坛注册多个帐号。

我有其他用处。:)

我以后给人留email坚持手写,对于我想看看他到底是有心联系我还是留个地址将来发广告用的测试一下。我会在加号后面写一堆随机的字母
pengyou.rijiben.org+l;fajdfahsfdauw;ersdflljasl;jkfipeq.cm.cxdjlsafhasdasd@gmail.com

还有一种玩法,就是这么留email,手写,随便写。对方会很惊讶:“啊,你email地址这么复杂,你竟然能记得住”。你可淡淡一笑,说,熟了,就好了。记忆力一直不错。给您背一段圆周率的前100位?

圆周率用希腊字母pai4来表示。这是 π Π 的小写和大写?输入方法是在scim的中文输入中按ixila,只后选择该字母,用加号翻页。

gmail用户名中的英文点是可有可无的

比如 pengyou.rijbien.org和pengyourijibenorg和p.en.g.y.o.u.rijiben.o.r.g是一样的。这主要是为了防止有人用英文的点来冒充你,算是对你帐号的一种保护。

比如你的邮件是 zhangsan@gmail.com 如果没有这种保护措施,有人冒充你注册了 zhang.san@gmail.com 的邮件发给你联系人,很少有人会注意到两个地址的区别的。我用zhangsan举例你可能觉得这有什么,想象看如果是 customerservice@gmail.comcusomer.service@gmail.com 呢,或者是 bankofchina 与 bank.of.china 。 不管哪个,都不要在emial中写自己的银行卡和重要私人信息!! :P

这不是bug,这是feature

开发人员有这个需要,所以提供这个功能。
英文加号因为在注册帐号时是禁用的,所以很方便在编辑配置程序的时候,让它看到英文加号,就知道后面的东西是什么无所谓,都关联为加号前的帐号就可以了,所以所有信都还是会投递到你的信箱。

升级ubuntu gnu/linux 服务器版本

方法在这里:
https://help.ubuntu.com/community/HardyUpgrades

ubuntu.cn99.com的源不能用了。这是不好。我这里联它很快的。改用cn.archive那个了。慢!

update 200902: cn99的源重新可以使用了。

这里看都有哪些源可以用: http://wiki.ubuntu.org.cn/index.php?title=Template:6.06sourc...

找了一个,http://ftp.sjtu.edu.cn/ubuntu/ 很快。

Ubuntu 6.06 to Ubuntu 8.04 Upgrade (Server)

I verified that my current install was completely up to date:

sudo aptitude update
sudo aptitude upgrade
sudo aptitude dist-upgrade

http://ubuntu-tutorials.com/2008/04/03/dapper-to-hardy-direc...

照片程序比较

http://en.wikipedia.org/wiki/Comparison_of_photo_gallery_software

cameralife这个项目让我很有兴趣。因为它可以把照片存在amazon s3,或者从flickr上直接抓图片。
http://fdcl.sourceforge.net/
该项目和gallery比较 http://fdcl.sourceforge.net/ourcompetition.php

留着以后研究一下。

gallery1和2两个系列我都用过。很不错。但我承受不了自己租用服务器上放太多照片(关闭朋友日记本的相册时候上面有了20多照片了,这还是在大家都没尽兴传的情况下),太贵。存到s3便宜,但gallery暂时不支持。

当然flickr最方便和最便宜!:)

archive.org更便宜(免费!!)但没那么方便。

还有一个项目看着不错
Naig - NotAnotherImageGallery
http://naig.sourceforge.net/

firefox的扩展stylish帮我选择和定制不同网页样

我用这个样式
http://userstyles.org/styles/1635
http://userstyles.org/styles/1635

让wikipedia的左侧工具栏到下面去,把更多屏幕留给文章内容

http://userstyles.org/styles/258
Description:
This style sheet moves the navigation section below the article at the Wikipedia (English) Web site.

http://userstyles.org/styles/8743

minilist slashdot

http://userstyles.org/styles/344

all styles with minimalist in their names

http://userstyles.org/styles/search/minimalist

bbc

http://userstyles.org/styles/1598

google reader mobile

http://userstyles.org/styles/4400
http://userstyles.org/styles/4200

linux.com

http://userstyles.org/styles/5298

minimalist templete

http://userstyles.org/styles/5244
Template - Minimalistic
Template - Minimalistic
5944
By IsaacG
Last updated Jul 04 2008
0 installs this week, 24 total.

A generic template.
Use for minimalistic:
- Article (and comments) only
- Full width
- Size 12 font
- Justified
- No background

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document domain("") {

body {
background-image: url() !important;
/* background-color: white !important; */
}

#primaryContent
{
/* ******************************************************
* To resize the column, change the width
* on the line below.
* Set margin-left to 0 to prevent centering of the
* article.
* ******************************************************/
width: 96% !important;
margin-left: auto !important;
margin-right: auto !important;

 padding: 2% !important;
 text-align: justify !important;
 font-size: 12pt !important;
 font-family: arial, sans-serif !important;
 max-width: none !important;

/*
position: absolute !important;
left: 0 !important;
*/
}

#hide
{ display: none !important; }

#upper_level_containers
{
width: 100% !important;
max-width: none !important;
margin: 0 !important;
padding: 0 !important;
float: none !important;
}

}

youtube minimalist

http://userstyles.org/styles/4806

gamil 无法去掉所有广告

http://userstyles.org/styles/713

douban;把右边栏放到下面去增大正文空间

http://userstyles.org/styles/4452

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document domain("people.com.cn") {

@-moz-document url-prefix(http://) {
:link, :visited {font-size:12px !important; font-weight:bold !important; text-decoration: none ! important ; border-style:none !important; background:white !important;}
:link:hover, :visited:hover {font-size:12px !important; font-weight:bolder !important; text-decoration: underline ! important; color:black !important; background:white !important;}
img {display:none !important; font-size:12px !important;display:none ! important; background:white !important;}
embed{font-size:12px !important;display:none !important; background:white !important;}
p {font-size:1em !important; border-width: 0px !important; border-style: none!important; background:white !important;}

软件开发的新理念:Da-Back

各种软件开发理念
http://en.wikipedia.org/wiki/List_of_software_development_philosophies

我自己想了一个开发方式,起名字叫:dabac:development aided byaudio comments,发音是Da-Back。:)就是很多人不愿意写注释,自己一步步干嘛呢。让大家在写完代码后,一行行的说自己的意图,就是解释代码和思路。说比写快,而且下一个人也不用老看屏幕,散步的时候听都可以。也许和我更喜欢和习惯从听中接受信息有关,所以我想尝试这个方法。

关键是觉得我这个么名字想得也不错。:)

gedit之类工具本身就能通过ssh协议去编辑其它机器上的文件

简单解决了直接ssh到服务器编辑文件无法输入中文的问题。还没有试验呢。因为很少上去。服务很稳啊。:)

Comment by andresj: (1 day ago)
You don't need X11 forwarding to edit the files in Gedit nor Kate.

For Gedit, just click on "Places > Connect to server...", select SSH
from the list, write in the information, and click on Connect. Add a
bookmark if you want, it will appear in the same list as Home folder,
Pictures, etc. Double click on your files or File > Open inside
Gedit.

Comment by freedom: (6 weeks ago)
While i'm not against this feature i will not vote for it as i believe
that it can be accomplished easier. On GNU/Linux systems you can
already mount the ssh partition and then edit files with the local
graphical editor if you so wish. On Gnome nautilus allows you to do
that even if you don't really know what you are doing, if you aren't
using gnome look at sshfs package.

https://members.nearlyfreespeech.net/jsmith/support/voting?i...

wordpress我用到的扩展

为朋友装和管理一个wordpress的站点,做校友联系用。

wordpress中显示作者信息

和author相关的帮助
http://codex.wordpress.org/Template_Tags#Author_tags

特别是这个:
http://codex.wordpress.org/Template_Tags/wp_list_authors

在index.php中添加上述代码

wordpress的super cache扩展

Author: Donncha O Caoimh

This plugin generates static html files from your dynamic WordPress blog. After a html file is generated your webserver will serve that file instead of processing the comparatively heavier and more expensive WordPress PHP scripts.
http://wordpress.org/extend/plugins/wp-super-cache/

需要php中safe mode是on。

wordpress在侧栏显示新留言的扩展get recent comments

Author: Krischan Jodies

This plugin shows excerpts of the latest comments and/or trackbacks in your sidebar. You have comprehensive control about their appearance. This ranges from the number of comments, the length of the excerpts up to the html layout. You can let the plugin order the comments by the corresponding post, or simply order them by date. The plugin can (optionally) separate the trackbacks/pingbacks from the comments. It can ignore comments to certain categories, and it offers support for gravatars. It only gives extra work to the database, when actually a new comment arrived. You can filter out unwanted pingbacks, which originate from your own blog. And it is a widget.
http://wordpress.org/extend/plugins/get-recent-comments/

openID

http://wordpress.org/extend/plugins/openid/

wordpress中注释掉sidebar的一些内容需要用html的注释语法

  <!-- 中间这些字是看不到的 -->

如果是多行,我现在的方法就是统一插入的后缀

emacs中区块操作。选中区域后,让光标在这些行的第一个字符,之后c-x r t插入 就可以了

wordpress安装记录

给朋友装了个wordpress,记录下

自由软件wp的下载和安装说明都在:
http://wordpress.org/

中文汉化包
http://codex.wordpress.org/WordPress_Localization#Chinese_-.E4.B8.AD.E6.96.87.28zh_CN.29

中文文档: http://codex.wordpress.org.cn/

给你的 Wordpress 添加 Google 自定义搜索
http://www.wopus.org/google-custom-search-for-wordpress.html

google的搜索比自带的好。

从RSS Feeds中排除特定分类的四种方法
http://www.wopus.org/four-way-remove-special-cat-from-rssfee...

文章提到了插件。修改模板代码是最简洁的。可这解修改代码不等于rss地址下次要变化了?!比如现在隐藏分类2。以后加一个隐藏分类4。那么,以前订阅了的人还是会看到分类4,因为人家订阅的rss地址中只隐藏了分类2,你后来修改rss地址,人家没有重新订阅的。

drupal在这点有多种方法了。

禁用并删除 Wordpress 文章修订记录
http://www.wopus.org/deeactivate-and-del-post-revisions.html

我倒是喜欢有修订记录

今天发现单位一个内部网站在用blogger,非常感动啊

blogger是个好东西。我在严重考虑把一些站点转到blogger平台。简单,省心,用它来写和发布,map到自己的域名,发布到ftp,当人们浏览的时候是看得静态页面。

blogger没有在国内火起来只要是长年对它的封锁,让上面的用户都走了。还好,现在解封锁已经有一年多了吧,一直比较稳定。

可惜blogger不能定制每篇文章url的规则,就是自己建立一个有规律的简洁链接规则有。一个work around就是先写你希望的url到标题中,写完正文后发表文章。此时文章的url就是你当前的题目。再编辑文章,比文章标题改为你想要的中文。
via: http://www.sinoblog.org/2008/08/google-blogger-title-seo.html

例子:

文章标题是:blogger是个好东西
先用“blogger-is-good”做为标题发布
这样文章url就是 site/blogger-is-good.html
只后再编辑文章把题目改一下
我不需要英文,我一般是把url改为全是数字的
比如 site/12.html 这样。

和squid类似的反响代理varnish

项目在: http://varnish.projects.linpro.no/

今天看到有人用这个在drupal前面跑效果不错。

如何在mysql中把表user中的status字段设置为1

如何在mysql中把表user中的status字段设置为1

小拉给了答案

UPDATE 表的名字 set
user table

id status
user1 0
user2 1
user3 0

我又忘了那条命令了。似乎是 set status = 1 where

安装适合drupal运行的主机

安装适合drupal运行的主机

Installing a dedicated server or a VPS with Ubuntu Server 8.04 LTS (Hardy Heron) for Drupal 6.x

http://2bits.com/articles/installing-a-dedicated-server-or-a...

memcache

http://2bits.com/articles/installing-memcached-125-and-memca...

why ubuntu

http://2bits.com/news/wikimedia-standardizes-400-servers-ubu...

将多个drupal站点的数据库合并到一个数据库中

将多个drupal站点的数据库合并到一个数据库中

先看到这篇。用emacs查找替换。
http://www.opensourcery.com/blog/jonathan-hedstrom/merging-t...
从上篇留言中看到这篇,更简洁,提到了注意事项。用vim查找替换。
http://niebegeg.net/blog/changing-of-the-dbprefix-of-the-dru...

pyzh: Python localization package for zh (China/Chinese); 聚合国内python人的力量,建立一整套python的中

pyzh: Python localization package for zh (China/Chinese); 聚合国内python人的力量,建立一整套python的中文本地化工具包。

我喜欢并想用其中的汉子到拼音转换功能。

http://code.google.com/p/pyzh/

a set of localization tools to make python support Chinese and Chinese culture better.

Contact me (panjy at zopen dot cn) if you want to contribute.

聚合国内python人的力量,建立一整套python的中文本地化工具包。

gb18030的python-codec是韩国人帮咱们写的,这个有些汗了。自己的事情,还是应该由咱们自己来完成!

典型的是:

  1. 汉字 -> 拼音 转换

  2. 中英文字数统计

  3. 公历 -> 阴历 转换

  4. 中文分词

  5. 中英文文本折行

  6. 繁簡中文轉換, 支援多種編碼方式

如何下载163相册

如何下载163相册

最好的方法:)

http://163.zpoo.com/help.htm

有个图片地址,我就用wget。

其他方法

http://zhidao.baidu.com/question/7421888.html?fr=qrl
这个方法请lvcha试验并解释一下?

http://zhidao.baidu.com/question/40576318.html?fr=qrl
常见推荐方法

http://mozilla.sociz.com/viewthread.php?tid=8951
firefox插件
但需要论坛用户才能下载。不选择

我也想做这样的drupal hosted service服务

我也想做这样的drupal hosted service服务

http://bryght.com/cn/

google为非盈利性机构准备的工具和服务

google为非盈利性机构准备的工具和服务

http://www.google.com/nonprofits/

drupal做sns站点

drupal做sns站点
介绍: http://drupal.org/node/300255

站点: http://drupalsn.com/
使用的模块: http://drupalsn.com/modules_used.php

我没搞明白我如何发文章。还是sns都是互相留言形式。

Syndicate content