SH获取昨天日期
Tue, 02 Feb 2010 02:15:06 +0800

区别于bash的sh获取昨天的日期

bash里使用 date -d "yesterday"就可以了,但sh里不行

我们用变换时区的办法获取:

> d=`TZ=$TZ+24 date "+%Y/%m/%d"`

> echo $d

2010/02/01

-----

但是,建议还是看一下date的用法。不同的环境可能有更好的办法

我在freebsd下,

date的用法如下

usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]
---

其中,参数-v可以进行这样的操作

> date -v-1d +%Y%m%d

20100201

> date -v-2d +%Y%m%d

20100131

评论(0) | 阅读
FreeBSD安装Nginx+PHP+Mysql
Thu, 03 Dec 2009 15:26:58 +0800

首先,需要强调的是,用ports安装,避免叮叮当当的许多问题。

FB 7.0 -RELEASE

之前的版本了,所以更新一下ports

portsnap fetch extract update

 

安装MySQL

cd /usr/ports/databases/mysql51-server/
make WITH_CHARSET=utf-8 WITH_XCHARSET=all WITH_PROC_SCOPE_PTH=yes BUILD_OPTIMIZED=yes BUILD_STATIC=yes SKIP_DNS_CHECK=yes WITHOUT_INNODB=yes install clean
cp /usr/local/share/mysql/my-small.cnf /etc/my.cnf
 
/usr/local/bin/mysql_install_db --user=mysql
mysqladmin -u root password 'new_password' //root的新密码

 

安装 PHP 及其扩展

cd /usr/ports/lang/php5
make install clean
cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini
cd /usr/ports/lang/php5-extensions/
make install clean

安装Nginx

cd /usr/ports/www/nginx/
make install clean

开机启动

vi /etc/rc.conf
mysql_enable="YES"
nginx_enable="YES"
/usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -C 4 -f /usr/local/bin/php-cgi

评论(0) | 阅读
为PHP打上fpm的支持
Thu, 03 Dec 2009 00:19:10 +0800

php-fpm是PHP的FastCGI Process Manager,我们可以在这里获取:www.php-fpm.org

那里通常有最新版本的patch,下载一个下来,比如php-fpm-0.6-103~5.3.1.tar.gz,这个对应的是PHP-5.3.1版本的fpm patch

tar zxf php-fpm-0.6-103~5.3.1.tar.gz

php-fpm-0.6-103~5.3.1/generate-patch  (这里会产生一个fpm.patch的文件)

cd php-5.3.1

patch -p1 < ../fpm.patch

----------------

OK,打上fpm了,编译PHP前,先

./buildconf --force

不然,configure不认--with-fastcgi这个选项

./configure ...........

即可

评论(0) | 阅读
Godaddy域名注册优惠码
Fri, 06 Nov 2009 11:24:57 +0800

Godaddy域名注册优惠码

优惠码: cjc695dom
说明: $7.49 .COM 注册
有效期: N/A

优惠码: cjctld749
说明: $7.49 .NET 注册
有效期: N/A

优惠码: cjctld749
说明: $7.49 .ORG 注册
有效期: N/A

评论(0) | 阅读
GODADDY主机产品优惠码
Fri, 06 Nov 2009 11:19:38 +0800

Godaddy主机优惠码(通用)

优惠券: cjcshare20
购买所有主机产品优惠20%.  (独立主机例外)
有效期: 无限制

优惠券:cjc20hun 
购买100$及以上可以优惠20$
有效期: 无限制

优惠码: cjctenoff
购买50$及以上可以优惠10$
有效期:无限制

优惠码: cjcsave
购买30$及以上可以优惠 5$
有效期:无限制

优惠码:cjcdeal 购买75$以上优惠15%

评论(0) | 阅读
Win7来了,我的64位时代也来了
Sun, 25 Oct 2009 15:33:43 +0800

前几天,MS发布了Windows7,我也装了个,还是64位的,一进去,多数软件还是32位,找64位的软件还是挺辛苦的。

以后都用64位了。

下面是截图,够眩的。

评论(0) | 阅读
删除多余的备份
Sat, 19 Sep 2009 01:38:55 +0800

当初的server-backup.pl不太完善,因为不会自动删除已经备份的文件,所以日积月累会很多多余的文件。现在改进一下。

#now, we delete the file created at 7 days ago.
($sec,$min,$hour,$mday,$mon,$year,
          $wday,$yday,$isdst) = localtime(time()-7*24*60*60);
$bto = sprintf("/data/backup/%4d%02d%02d.tar.gz", $year+1900, $mon+1, $mday);
system("rm -f ".$bto);
system("echo \"".localtime(time)." delete $bto OK.\" >> /data/log/backup.log");

这样,就会删除7天以前的备份档了。

评论(0) | 阅读
SQL之JOIN结构简单理解
Fri, 18 Sep 2009 23:30:52 +0800

以前写JOIN的时候都是这样:

select * from a join b on a.xx=b.yy where a.zz=ww

现在遇到了多表联合了,一下连join几个都不对,其实,可以这样理解,SELECT 就是从某个源取得数据的,所以应该这样:

select * from (((a join b on a.xx=b.yy) join c on c.zz=a.ww) join d on d.kk=c.ii .....)......

括号内的是表联合后构成的数据源

评论(0) | 阅读
Alma
Fri, 04 Sep 2009 22:56:16 +0800

来自Nacho Sotomayor的La Roca CD1/1994中的音轨1,Alma

-----一朝步入画卷,一日梦回千年 

评论(0) | 阅读
Techniques To Manage Procrastination (SELECT)
Mon, 31 Aug 2009 00:25:49 +0800

Set Priorities.
Not: I don't know where to begin, so I can't begin at all.
Not: I have to do EVERYTHING! Nothing less will do.
Instead: The most important step is to pick one project to focus on.


Break the Task Down into Little Pieces
Not: There's so much to do, and it's so complicated. I'm overwhelmed by my English term paper.
Instead: I don't have to do the whole project at once. There are separate small steps I can take one at a time to begin researching and drafting my paper.


Set Up Small, Specific Goals.
Not: I have to write my thesis within two months.
Instead: If I write 2 pages per day, Monday-Friday, I can finish a 1st draft in 1 month. I'll have a revised final draft in 2 months.


Take One Small Step at a Time.
Not: It's too much. I'll never get it all done
Instead: What is the one next step on my list? I'll concentrate on that step for right now


Reward Yourself Right Away When You Accomplish a Small Goal.
Not: I can't take any time out until I'm completely finished.
Instead: I spent an hour working. Now I'll call a friend.

 
Use a Time Schedule.
Not: I must devote the whole week to this project
Instead: I can use these times this week to work on my project:
Monday 7-8; Tuesday 7-9; Saturday 10-12.

 
Learn How to Tell Time.
Not: Sorting through these papers and reorganizing my file cabinet will be a snap. It won't take me more than an hour, so I can do it any time.
Instead: Sorting papers always takes longer than I expect, so I'll start tonight. I'll spend 1 hour filing 1 stack of papers.

 
Optimize Your Chances for Success.
Not: I'll do my writing this weekend at home.
Instead: I'll write during the week in a library. (Choose whatever conditions are optimal for you to get work done.)

 
Delegate, if Possible.
Not: I am the only person in the world who can do this.
Instead: I don't have to do this all by myself. I can ask someone else to do part of the job and still feel a sense of accomplishment.

 
Just Get Started.
Not: I can't write this speech until inspiration hits.
Instead: I'll write what first comes to mind, then improve it later.

 
Look at What You Have Accomplished.
Not: I have hardly made a dent in all there is to do.
Instead: I have reviewed my lecture notes and read 3 chapters. That won't guarentee me an "A", but it's more than I did yesterday.

 
Be Realistic!
Not: I should be able to work full-time, take 4 classes, be president of the Esperanto Club, spend more time with friends, and play tennis 2 hours a day with no trouble at all.
Instead: I have limits. I can take on fewer responsibilities and still like myself.

评论(0) | 阅读
标签
最近发表
最新评论
连接
版权说明
任何转载,无需经过许可,但必须注明来源地址。如有任何建议或意见,请联系
Copyright©2007-2009 lewphee.com All rights reserved.