This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// 根据好与不好的支持率算出好的占多少% | |
/// </summary> | |
/// <param name="bad">不好</param> | |
/// <param name="good">好</param> | |
/// <returns></returns> | |
public static string TotalScore(int bad, int good) | |
{ | |
if (good == 0 && bad == 0) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* iPhone CSS 写法 */ | |
body { margin:0px;-webkit-text-size-adjust:none;} | |
body[orient="profile"]{width:320px;height:100%;} | |
body[orient="landscape"]{width:480px;height:100%;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- MS SQL 对比两个时间相差 | |
-- 结果:10天3小时12分 | |
select | |
replace(str(datediff(d,getdate(),[due])) + '天' + | |
str(datediff(hh,getdate(),[due]) % 24) + '小时' + | |
str(datediff(mi,getdate(),[due]) % 60) + '分钟',' ','') as [remain] | |
from [users] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# clear unsafe char with url slug | |
def safe_slug(slug) | |
slug.gsub(/[^a-zA-Z_0-9]/,'_') | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
huacnlee@ubuntu:/home/huacnlee/wwwroot$ sudo apt-get install sendmail | |
正在读取软件包列表... 完成 | |
正在分析软件包的依赖关系树 | |
正在读取状态信息... 完成 | |
.... | |
.... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Linux 自动备份 MySQL与网站并发邮件到自已邮箱 | |
# 定义临时目录 | |
BACKUP_PATH=/tmp/autobackups | |
# 定义日期字符串 | |
DATE_NAME=`date +%y%m%d` | |
# 创建临时目录 | |
mkdir $BACKUP_PATH | |
# 打包文件 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Linux 参看CPU信息 | |
jason@ubuntu:~$ cat /proc/cpuinfo | |
processor : 0 | |
vendor_id : GenuineIntel | |
cpu family : 15 | |
model : 6 | |
model name : Intel(R) Pentium(R) 4 CPU 3.00GHz | |
stepping : 5 | |
cpu MHz : 2400.000 | |
cache size : 2048 KB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 开启在 script/console 里面显示SQL查询日志 | |
# Ruby on Rails script/server 的时候,你会看到所有查询的调用日志,SQL语句,是否用缓存,还有执行时间等 | |
# 如何在 script/console 里面也实现这样的功能呢? | |
# 我们只需要修改 ~/.irbrc 文件并加入下面的代码就好了(.irbrc 如果没有可直接创建一个) | |
# jason@ubuntu:/home/huacnlee/wwwroot/pasite$ cd ~ | |
# jason@ubuntu:~$ sudo vim .irbrc | |
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER') | |
require 'logger' | |
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Linux 自动备份 MySQL与网站并发邮件到自已邮箱 1 | |
# 1.将刚才到处的MySQL文件压缩,以节省邮箱空间 | |
tar zcf $BACKUP_PATH/pasite_db_$DATE_NAME.tar.gz $DATE_NAME/pasite.sql | |
tar zcf $BACKUP_PATH/personlab_db_$DATE_NAME.tar.gz $DATE_NAME/personlab.sql | |
# 2.打包压缩网站 | |
tar zcf $BACKUP_PATH/pasite_src_$DATE_NAME.tar.gz ~home/huacnlee/wwwroot/pasite/ | |
tar zcf $BACKUP_PATH/personlab_src_$DATE_NAME.tar.gz ~home/huacnlee/wwwroot/personlab/ | |
# Linux 自动备份 MySQL与网站并发邮件到自已邮箱 2 | |
# 发送邮件 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mysql 完整备份数据库 | |
# -uroot(root是用户名 -u与root之间没空格) -p123123 (123123是密码 -p与123123之间没空格) | |
mysqldump -uroot -p123123 --databases pasite > $BACKUP_PATH/pasite.sql |