垃圾回收机制:当需要分配的内存空间不再使用的时候,JVM将调用垃圾回收机制来回收内存空间。
ie innerHTML 报"未知运行时错误" 错误
Php/Js/Shell/Go jackxiang 2013-9-3 22:15
这个破问题调了一下午,火狐没问题,在网上搜了下发现是ie 下innerHTML的优先级不够,不能给td、tr、p之类的加innerHTML要改成span、div之类的。按正常问题应该就解决了,但是我这个页面用几个页面拼到一起,还是不好用。之后把form去掉又好用了,以为是form的问题。
但最好调来调去还是页面的问题,引的其它页面里面代码不完整。比如<td>有开始没有结束之类的,或者其它页面引的js有问题。
最后把其它页面的代码修改了下就好用了。。。。。
总结如下
要实现的功能需要在ajax输出的页面结构中再次使用ajax输出新的内容,如果把所有ajax输出区域放在静态页面,可以实现;但是,改成在动态页面区域中再重新定义动态区域输出时,IE就报出“未知的运行时错误”,查找相关资料,做的尝试如下:
1.检查尝试加到innerHTML的html代码是否包含破损的html标签,没有发现此类错误;
2.把容器改成那些比较“包容”的标签,已将容器改成div和span;
3.将容器标签放在form外面,已做修改;
来自:http://blog.sina.com.cn/s/blog_4586764e0100ktb7.html
但最好调来调去还是页面的问题,引的其它页面里面代码不完整。比如<td>有开始没有结束之类的,或者其它页面引的js有问题。
最后把其它页面的代码修改了下就好用了。。。。。
总结如下
要实现的功能需要在ajax输出的页面结构中再次使用ajax输出新的内容,如果把所有ajax输出区域放在静态页面,可以实现;但是,改成在动态页面区域中再重新定义动态区域输出时,IE就报出“未知的运行时错误”,查找相关资料,做的尝试如下:
1.检查尝试加到innerHTML的html代码是否包含破损的html标签,没有发现此类错误;
2.把容器改成那些比较“包容”的标签,已将容器改成div和span;
3.将容器标签放在form外面,已做修改;
来自:http://blog.sina.com.cn/s/blog_4586764e0100ktb7.html
用vb的WebBrowser控件打开一个网页,经常出现脚本错误(如图)。而直接在浏览器中输入网址不会有错误。怎样避免用WebBrowser控件打开网页时弹出的脚本错误提示呢?
要通过vb编程代码实现
启动IE,执行“工具→Internet选项”菜单,选择“高级”选项卡,选中“禁止脚本调试”复选框,最后单击“确定”按钮即可。
通过vb编程代码实现
回答
Private Sub Command1_Click()
'首先引用Registry Access Functions
Dim mREG As New REGTool5.Registry
Dim ret As Boolean
ret = mREG.UpdateKey(HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\Main ", "Disable Script Debugger ", "yes ")
ret = mREG.UpdateKey(HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\Main ", "DisableScriptDebuggerIE ", "yes ")
End Sub
追问
如有时间能讲解下吗?
回答
就是修改注册表HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main下的
"Disable Script Debugger "为 "yes "
"DisableScriptDebuggerIE "为 "yes"
相当于我一开始说的选中“禁止脚本调试”复选框
来自:http://zhidao.baidu.com/link?url=8njedX8PzANICk_fTdutW1_1kQ673TS2QoqbhVX0JMAiLah_X6roH6pcdTlefAnWLot3sZ7yKOMZYt1-8HUas_
要通过vb编程代码实现
启动IE,执行“工具→Internet选项”菜单,选择“高级”选项卡,选中“禁止脚本调试”复选框,最后单击“确定”按钮即可。
通过vb编程代码实现
回答
Private Sub Command1_Click()
'首先引用Registry Access Functions
Dim mREG As New REGTool5.Registry
Dim ret As Boolean
ret = mREG.UpdateKey(HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\Main ", "Disable Script Debugger ", "yes ")
ret = mREG.UpdateKey(HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\Main ", "DisableScriptDebuggerIE ", "yes ")
End Sub
追问
如有时间能讲解下吗?
回答
就是修改注册表HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main下的
"Disable Script Debugger "为 "yes "
"DisableScriptDebuggerIE "为 "yes"
相当于我一开始说的选中“禁止脚本调试”复选框
来自:http://zhidao.baidu.com/link?url=8njedX8PzANICk_fTdutW1_1kQ673TS2QoqbhVX0JMAiLah_X6roH6pcdTlefAnWLot3sZ7yKOMZYt1-8HUas_
背景:现在都用一个小小的;听评论说:已经自己亲身验证没问题~~~
阅读全文
阅读全文
背景:刷新Iframe会有闪动,这儿说这种方法可以不闪动,备案下。
来自:http://hi.baidu.com/625570671/item/968b7bad7a876d32030a4da8
js控制div滚动条显示与隐藏:
来自:http://www.bcw52.com/JSS/1951.html
来自:http://hi.baidu.com/625570671/item/968b7bad7a876d32030a4da8
js控制div滚动条显示与隐藏:
来自:http://www.bcw52.com/JSS/1951.html
curl如果需要进行毫秒超时,需要增加:
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L);
或者是:
curl_setopt ( $ch, CURLOPT_NOSIGNAL, true); 是可以支持毫秒级别超时设置的
[codes=php]
<?php
if (!isset($_GET['foo'])) {
// Client
$ch = curl_init('http://example.com/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOSIGNAL, 1); //注意,毫秒超时一定要设置这个
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 200); //超时毫秒,cURL 7.16.2中被加入。从PHP 5.2.3起可使用
$data = curl_exec($ch);
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
curl_close($ch);
if ($curl_errno > 0) {
echo "cURL Error ($curl_errno): $curl_error\n";
} else {
echo "Data received: $data\n";
}
} else {
// Server
sleep(10);
echo "Done.";
}
?>
[/code]
来自:http://developer.51cto.com/art/201208/351996_2.htm
curl的超时时间 :
今天在一台服务器上突然看到一个curl进程已经运行了28天还木结束, 有点奇怪! 我在使用curl的时候也设置了超时时间, --connect-timeout 5
curl --connect-timeout 5 --data-binary "set=${L_UPLOAD_DATA_ENCODED}" http://172.88.99.00:8080/xxx.php &>/dev/null
按理来说, 应该是5s就会超时退出了! 纳闷之余想起wget好像对超时时间, 是有分阶段的, 比如说请求的超时, 传输的超时等等, 所以就仔细查看了下curl的手册页:
原来使用curl时,有两个超时时间:一个是连接超时时间,另一个是整个过程允许的最大时间,
--connect-timeout <seconds>
Maximum time in seconds that you allow the connection to the server to take. This only limits the connection phase, once curl has connected this option is of no more use. See also the -m/--max-time option.
If this option is used several times, the last one will be used.
这个是指定连接超时时间。 如果出错, 提示形如:curl: (28) connect() timed out!
-m/--max-time <seconds>
Maximum time in seconds that you allow the whole operation to take. This is useful for preventing your batch jobs from hanging for hours due to slow networks or links going down. See also the --connect-timeout option.
If this option is used several times, the last one will be used.
这个是指定最大的允许时间。 出错提示如:curl: (28) Operation timed out after 2000 milliseconds with 0 bytes received
还可以这样用: curl -o x.log "http://www.yyyy.com" --speed-time 5 --speed-limit 1
是说将url内容保存到x.log中, 如果传输速度小于1字节/秒的状态持续5秒,该连接就会终止.
来自:http://blog.chinaunix.net/uid-20788470-id-1841681.html
[聊天加密]前端crypto-js AES加密解密和PHP后端解密,加密。
Php/Js/Shell/Go jackxiang 2013-8-27 10:19
实践中遇到的问题:
在Js加密时出现,用Jquery进行$("#login_pwd")是不行的,包括用手写赋值也是不蚝的,还得(chatValidate是form的name名字):
document.chatValidate.login_pwd.value = encryptedLoginUserPwd;//加密后再传输
通过console.log输出这个encryptedLoginUserPwd是一个对旬,但用:document.write是可以输出的,可能还是对这个加密函数不是太了解罢,还是对Js:
crypto-js提供了多种常用加密算法的JS库。这里不多解释。
这里主要讲 前端使用crypto-js AES加密后,php解密。
前端js
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/aes.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/md5.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/pad-zeropadding.js"></script>
<script>
var key_hash = CryptoJS.MD5("Message");
var key = CryptoJS.enc.Utf8.parse(key_hash);
var iv = CryptoJS.enc.Utf8.parse('1234567812345678');
var encrypted = CryptoJS.AES.encrypt("Message", key, { iv: iv,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.ZeroPadding});
document.write("encode:"+encrypted);
</script>
php代码
<?php
$text = "Message";
$key = md5($text); //key的长度必须16,32位,这里直接MD5一个长度为32位的key
$iv='1234567812345678';
$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $text, MCRYPT_MODE_CBC, $iv);
$decode = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $crypttext, MCRYPT_MODE_CBC, $iv);
echo base64_encode($crypttext);
echo "<br/>";
echo $decode;
echo "<br/>";
?>
http://localhost/aes/aes.html
encode:yMjizJCGQh+jxX4BXEtlNw==
http://localhost/aes/aes.php
yMjizJCGQh+jxX4BXEtlNw==
Message
实践是OK的,来自:
http://www.madeby83.com/%E5%89%8D%E7%AB%AFcrypto-js-aes%E5%8A%A0%E5%AF%86-php%E5%90%8E%E7%AB%AF%E8%A7%A3%E5%AF%86.html
前端解密:
http://localhost/chat/JsJiamiJiemi.html
dd52feee2ecea4ca159399e2dfb1d0bb
31323334353637383132333435363738
31323334353637383132333435363738
undefined
3VL+7i7OpMoVk5ni37HQuw==
1234567890
PHP加密:
$chat_msg_Html = nl2br($chat_msg);
$outEncryOutText = "Message";
$key = md5($outEncryOutText); //key的长度必须16,32位,这里直接MD5一个长度为32位的key
$iv='1234567812345678';
$cryptEncryOutText = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $outEncryOutText, MCRYPT_MODE_CBC, $iv);
echo base64_encode($cryptEncryOutText);
如果内容是message则echo会输出 :
yMjizJCGQh+jxX4BXEtlNw==
在Js加密时出现,用Jquery进行$("#login_pwd")是不行的,包括用手写赋值也是不蚝的,还得(chatValidate是form的name名字):
document.chatValidate.login_pwd.value = encryptedLoginUserPwd;//加密后再传输
通过console.log输出这个encryptedLoginUserPwd是一个对旬,但用:document.write是可以输出的,可能还是对这个加密函数不是太了解罢,还是对Js:
crypto-js提供了多种常用加密算法的JS库。这里不多解释。
这里主要讲 前端使用crypto-js AES加密后,php解密。
前端js
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/aes.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/md5.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/pad-zeropadding.js"></script>
<script>
var key_hash = CryptoJS.MD5("Message");
var key = CryptoJS.enc.Utf8.parse(key_hash);
var iv = CryptoJS.enc.Utf8.parse('1234567812345678');
var encrypted = CryptoJS.AES.encrypt("Message", key, { iv: iv,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.ZeroPadding});
document.write("encode:"+encrypted);
</script>
php代码
<?php
$text = "Message";
$key = md5($text); //key的长度必须16,32位,这里直接MD5一个长度为32位的key
$iv='1234567812345678';
$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $text, MCRYPT_MODE_CBC, $iv);
$decode = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $crypttext, MCRYPT_MODE_CBC, $iv);
echo base64_encode($crypttext);
echo "<br/>";
echo $decode;
echo "<br/>";
?>
http://localhost/aes/aes.html
encode:yMjizJCGQh+jxX4BXEtlNw==
http://localhost/aes/aes.php
yMjizJCGQh+jxX4BXEtlNw==
Message
实践是OK的,来自:
http://www.madeby83.com/%E5%89%8D%E7%AB%AFcrypto-js-aes%E5%8A%A0%E5%AF%86-php%E5%90%8E%E7%AB%AF%E8%A7%A3%E5%AF%86.html
前端解密:
http://localhost/chat/JsJiamiJiemi.html
dd52feee2ecea4ca159399e2dfb1d0bb
31323334353637383132333435363738
31323334353637383132333435363738
undefined
3VL+7i7OpMoVk5ni37HQuw==
1234567890
PHP加密:
$chat_msg_Html = nl2br($chat_msg);
$outEncryOutText = "Message";
$key = md5($outEncryOutText); //key的长度必须16,32位,这里直接MD5一个长度为32位的key
$iv='1234567812345678';
$cryptEncryOutText = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $outEncryOutText, MCRYPT_MODE_CBC, $iv);
echo base64_encode($cryptEncryOutText);
如果内容是message则echo会输出 :
yMjizJCGQh+jxX4BXEtlNw==
php时区设定,确保date()返回正确的本地时间,php程序报date()警告的处理(date_default_timezone_set)。PHP5中的时间相差8小时的解决办法。PHP错误日志的时间与系统时间不一致,怎么解决?Linux下查看/修改系统时区、时间。
Php/Js/Shell/Go jackxiang 2013-8-23 17:27
背景:做了个聊天程序,发现后面的时间显示有问题。
写到文件第一行内:
问题:echo date('Y-m-d H:i:s'); 输出结果与本地时间相差8小时。一看就知道我们神州大地是在东八区,时区错了。
三种解决方法:
1.加入date_default_timezone_set('PRC');//手册上说这个是PHP5.1后才有的
2. 修改php.ini
[Date]
; Defines the default timezone used by the date functions
date.timezone = PRC 注:PRC为中化人民共和国
相关参考如下:
#############################################################################
从 PHP 5.1.0 ,当对使用date()等函数时,如果timezone设置不正确,在每一次调用时间函数时,都会产生E_NOTICE 或者 E_WARNING 信息。而又在php5.1.0中,date.timezone这个选项,默认情况下是关闭的,无论用什么php命令都是格林威治标准时间,但是PHP5.3中好像如果没有设置也会强行抛出了这个错误的,解决此问题,只要本地化一下,就行了。
以下是三种方法(任选一种都行):
一、在页头使用date_default_timezone_set()设置 date_default_timezone_set('PRC'); //东八时区 echo date('Y-m-d H:i:s');
二、在页头使用 ini_set('date.timezone','Asia/Shanghai');
三、修改php.ini。打开php5.ini查找date.timezone 去掉前面的分号修改成为:date.timezone =PRC
重启http服务(如apache2或iis等)即可。
XXX可以任意正确的值。对于我们国内来说:可以为以下值:Asia/Chongqing ,Asia/Shanghai ,Asia/Urumqi (依次为重庆,上海,乌鲁木齐)港台地区可用:Asia/Macao ,Asia/Hong_Kong ,Asia/Taipei (依次为澳门,香港,台北),还有新加坡:Asia/Singapore,当然PRC也行。
来自:http://wz102.blog.51cto.com/3588520/1243649
#############################################################################
bool date_default_timezone_set ( string timezone_identifier )
说明
date_default_timezone_set() 设定用于所有日期时间函数的默认时区。
注: 自 PHP 5.1.0 起(此版本日期时间函数被重写了),如果时区不合法则每个对日期时间函数的调用都会产生一条 E_NOTICE 级别的错误信息。
参数
timezone_identifier
时区标识符,例如 UTC 或 Europe/Lisbon
返回值
本函数永远返回 TRUE(即使 timezone_identifier 参数不合法)。
来自:http://www.css88.com/archives/4552
在写php程序中有时会出现这样的警告:
[07-Jan-2014 07:21:44 UTC] PHP Warning: Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in Unknown on line 0
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for '8.0/no DST' instead in D:\PHPWEB ews\file.php on line 17 。
这是因为PHP所取的时间是格林威治标准时间,所以和你当地的时间会有出入格林威治标准时间和北京时间大概差8个小时左右,我们可以按照下面的方法解决:
1、在页头使用date_default_timezone_set()设置我的默认时区为北京时间,即 <?php date_default_timezone_set("PRC"); ?>就可以了。
2、在php.ini中设置date.timezone的值为PRC,设置好以后的为:date.timezone=PRC或者date.timezone = Asia/Shanghai,同时取消这一行代码的注释,即去掉前面的分号就可以了。
然后重启apache即可!
参考:http://www.jb51.net/article/42315.htm
PHP5中的时间相差8小时的解决办法:
http://www.jb51.net/article/13988.htm
————背景:遇到线上仿真机的PHP错误日志的时间不对————
PHP错误日志的时间与系统时间不一致,怎么解决?来自:http://zhidao.baidu.com/link?url=Dx0OfG9Kd5xkb_plZeopiskR_jUnCqB2WLdBXshvpv5hJTAi-UHUoSC4qRHK7mFCP84118D3mRhWlcBdwNX2dbl7MnocNPPDQeycWxnUkgW
我已经把php.ini的date.timezone设置为PRC了,调用date("H:i:s")函数也能输出与系统时间相一致的时间,但就是不知道为什么错误日志里的时间总是跟系统时间相差8个小时
提问者采纳
你修正只是php这样级别的时区,所以网页显示出来的时间跟你浏览器所在电脑时间是一致的(修正好了)。
但错误日志的运行一般是apache或者php-cgi,它们是直接调用操作系统的时间和时区的,所以写出来的日志时间有时差。依照你的描述,估计你用的是linux,试一下修正一下linux的时区一下就可以了。命令如下:
rm -f /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
实践如下:
[root@localhost etc]# cp localtime localtime.bak.2013.12.25
[root@localhost etc]# ls /usr/share/zoneinfo/Asia/Shanghai
/usr/share/zoneinfo/Asia/Shanghai
[root@localhost etc]# rm -Rf localtime
[root@localhost etc]# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
然后最好使用下面的命令将更改写入bios。
hwclock
[root@localhost tmp]# hwclock
Wed 25 Dec 2013 11:07:18 AM CST -0.848372 seconds 【后面发现还是不行,估计机器有问题。】
必须要生效才行,上面生效来自:
http://soft.chinabyte.com/133/11146633.shtml
摘录自:http://ggmmchou.blog.163.com/blog/static/5933314920091137114514/
方法(1)
# tzselect
方法(2 仅限于RedHat Linux 和 CentOS)
# timeconfig
方法(1)
# tzselect
方法(2 仅限于RedHat Linux 和 CentOS)
# timeconfig3. 复制相应的时区文件,替换系统默认时区
CentOS实践:
[root@localhost tmp]# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
1) Africa
2) Americas
3) Antarctica
4) Arctic Ocean
5) Asia
6) Atlantic Ocean
7) Australia
8) Europe
9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 5
Please select a country.
1) Afghanistan 18) Israel 35) Palestine
2) Armenia 19) Japan 36) Philippines
3) Azerbaijan 20) Jordan 37) Qatar
4) Bahrain 21) Kazakhstan 38) Russia
5) Bangladesh 22) Korea (North) 39) Saudi Arabia
6) Bhutan 23) Korea (South) 40) Singapore
7) Brunei 24) Kuwait 41) Sri Lanka
8) Cambodia 25) Kyrgyzstan 42) Syria
9) China 26) Laos 43) Taiwan
10) Cyprus 27) Lebanon 44) Tajikistan
11) East Timor 28) Macau 45) Thailand
12) Georgia 29) Malaysia 46) Turkmenistan
13) Hong Kong 30) Mongolia 47) United Arab Emirates
14) India 31) Myanmar (Burma) 48) Uzbekistan
15) Indonesia 32) Nepal 49) Vietnam
16) Iran 33) Oman 50) Yemen
17) Iraq 34) Pakistan
#? 9
Please select one of the following time zone regions.
1) east China - Beijing, Guangdong, Shanghai, etc.
2) Heilongjiang (except Mohe), Jilin
3) central China - Sichuan, Yunnan, Guangxi, Shaanxi, Guizhou, etc.
4) most of Tibet & Xinjiang
5) west Tibet & Xinjiang
#? 1
The following information has been given:
China
east China - Beijing, Guangdong, Shanghai, etc.
Therefore TZ='Asia/Shanghai' will be used.
Local time is now: Wed Dec 25 11:49:52 CST 2013.
Universal Time is now: Wed Dec 25 03:49:52 UTC 2013.
Is the above information OK?
1) Yes
2) No
#? 1
You can make this change permanent for yourself by appending the line
TZ='Asia/Shanghai'; export TZ
to the file '.profile' in your home directory; then log out and log in again.
Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Shanghai
# cp /usr/share/zoneinfo/$主时区/$次时区 /etc/localtime
对于中国服务器则执行:
# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# cp /usr/share/zoneinfo/$主时区/$次时区 /etc/localtime
对于中国服务器则执行:
# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 4. 将当前时间写入BIOS永久生效(避免重启后失效)
# hwclock
# hwclock
[root@localhost tmp]# date -R
Wed, 25 Dec 2013 11:56:13 +0800
来自:http://www.cnblogs.com/ningvsban/archive/2012/12/18/2823036.html
1)查看Linux硬件时间
[root@localhost tmp]# hwclock --show
Wed 25 Dec 2013 01:02:15 PM CST -0.494817 seconds
[root@localhost tmp]# date
Wed Dec 25 13:40:48 CST 2013
2)修改Linux硬件时间
hwclock --set --date
3)让系统时间与硬件时钟同步,用:
hwclock --hctosys
4)相反地,让硬件时钟与系统时间同步:
hwclock --systohc
对上面1)进行同步操作(让硬件时钟与系统时间同步)的实践OK:
[root@localhost tmp]# hwclock --systohc
[root@localhost tmp]# hwclock --show
Wed 25 Dec 2013 01:44:36 PM CST -0.973671 seconds
[root@localhost tmp]# date
Wed Dec 25 13:44:40 CST 2013
没同步上,直接修改硬件时间:
[root@localhost tmp]# hwclock --set --date "2013-12-25 13:48:51"
[root@localhost tmp]# hwclock --show
Wed 25 Dec 2013 01:48:56 PM CST -0.365535 seconds
[root@localhost tmp]# date
Wed Dec 25 13:48:39 CST 2013
来自:http://blog.163.com/dk_linux/blog/static/20322616620122401426999/
写到文件第一行内:
问题:echo date('Y-m-d H:i:s'); 输出结果与本地时间相差8小时。一看就知道我们神州大地是在东八区,时区错了。
三种解决方法:
1.加入date_default_timezone_set('PRC');//手册上说这个是PHP5.1后才有的
2. 修改php.ini
[Date]
; Defines the default timezone used by the date functions
date.timezone = PRC 注:PRC为中化人民共和国
相关参考如下:
#############################################################################
从 PHP 5.1.0 ,当对使用date()等函数时,如果timezone设置不正确,在每一次调用时间函数时,都会产生E_NOTICE 或者 E_WARNING 信息。而又在php5.1.0中,date.timezone这个选项,默认情况下是关闭的,无论用什么php命令都是格林威治标准时间,但是PHP5.3中好像如果没有设置也会强行抛出了这个错误的,解决此问题,只要本地化一下,就行了。
以下是三种方法(任选一种都行):
一、在页头使用date_default_timezone_set()设置 date_default_timezone_set('PRC'); //东八时区 echo date('Y-m-d H:i:s');
二、在页头使用 ini_set('date.timezone','Asia/Shanghai');
三、修改php.ini。打开php5.ini查找date.timezone 去掉前面的分号修改成为:date.timezone =PRC
重启http服务(如apache2或iis等)即可。
XXX可以任意正确的值。对于我们国内来说:可以为以下值:Asia/Chongqing ,Asia/Shanghai ,Asia/Urumqi (依次为重庆,上海,乌鲁木齐)港台地区可用:Asia/Macao ,Asia/Hong_Kong ,Asia/Taipei (依次为澳门,香港,台北),还有新加坡:Asia/Singapore,当然PRC也行。
来自:http://wz102.blog.51cto.com/3588520/1243649
#############################################################################
bool date_default_timezone_set ( string timezone_identifier )
说明
date_default_timezone_set() 设定用于所有日期时间函数的默认时区。
注: 自 PHP 5.1.0 起(此版本日期时间函数被重写了),如果时区不合法则每个对日期时间函数的调用都会产生一条 E_NOTICE 级别的错误信息。
参数
timezone_identifier
时区标识符,例如 UTC 或 Europe/Lisbon
返回值
本函数永远返回 TRUE(即使 timezone_identifier 参数不合法)。
来自:http://www.css88.com/archives/4552
在写php程序中有时会出现这样的警告:
[07-Jan-2014 07:21:44 UTC] PHP Warning: Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in Unknown on line 0
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for '8.0/no DST' instead in D:\PHPWEB ews\file.php on line 17 。
这是因为PHP所取的时间是格林威治标准时间,所以和你当地的时间会有出入格林威治标准时间和北京时间大概差8个小时左右,我们可以按照下面的方法解决:
1、在页头使用date_default_timezone_set()设置我的默认时区为北京时间,即 <?php date_default_timezone_set("PRC"); ?>就可以了。
2、在php.ini中设置date.timezone的值为PRC,设置好以后的为:date.timezone=PRC或者date.timezone = Asia/Shanghai,同时取消这一行代码的注释,即去掉前面的分号就可以了。
然后重启apache即可!
参考:http://www.jb51.net/article/42315.htm
PHP5中的时间相差8小时的解决办法:
http://www.jb51.net/article/13988.htm
————背景:遇到线上仿真机的PHP错误日志的时间不对————
PHP错误日志的时间与系统时间不一致,怎么解决?来自:http://zhidao.baidu.com/link?url=Dx0OfG9Kd5xkb_plZeopiskR_jUnCqB2WLdBXshvpv5hJTAi-UHUoSC4qRHK7mFCP84118D3mRhWlcBdwNX2dbl7MnocNPPDQeycWxnUkgW
我已经把php.ini的date.timezone设置为PRC了,调用date("H:i:s")函数也能输出与系统时间相一致的时间,但就是不知道为什么错误日志里的时间总是跟系统时间相差8个小时
提问者采纳
你修正只是php这样级别的时区,所以网页显示出来的时间跟你浏览器所在电脑时间是一致的(修正好了)。
但错误日志的运行一般是apache或者php-cgi,它们是直接调用操作系统的时间和时区的,所以写出来的日志时间有时差。依照你的描述,估计你用的是linux,试一下修正一下linux的时区一下就可以了。命令如下:
rm -f /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
实践如下:
[root@localhost etc]# cp localtime localtime.bak.2013.12.25
[root@localhost etc]# ls /usr/share/zoneinfo/Asia/Shanghai
/usr/share/zoneinfo/Asia/Shanghai
[root@localhost etc]# rm -Rf localtime
[root@localhost etc]# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
然后最好使用下面的命令将更改写入bios。
hwclock
[root@localhost tmp]# hwclock
Wed 25 Dec 2013 11:07:18 AM CST -0.848372 seconds 【后面发现还是不行,估计机器有问题。】
必须要生效才行,上面生效来自:
http://soft.chinabyte.com/133/11146633.shtml
摘录自:http://ggmmchou.blog.163.com/blog/static/5933314920091137114514/
方法(1)
# tzselect
方法(2 仅限于RedHat Linux 和 CentOS)
# timeconfig
方法(1)
# tzselect
方法(2 仅限于RedHat Linux 和 CentOS)
# timeconfig3. 复制相应的时区文件,替换系统默认时区
CentOS实践:
[root@localhost tmp]# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
1) Africa
2) Americas
3) Antarctica
4) Arctic Ocean
5) Asia
6) Atlantic Ocean
7) Australia
8) Europe
9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 5
Please select a country.
1) Afghanistan 18) Israel 35) Palestine
2) Armenia 19) Japan 36) Philippines
3) Azerbaijan 20) Jordan 37) Qatar
4) Bahrain 21) Kazakhstan 38) Russia
5) Bangladesh 22) Korea (North) 39) Saudi Arabia
6) Bhutan 23) Korea (South) 40) Singapore
7) Brunei 24) Kuwait 41) Sri Lanka
8) Cambodia 25) Kyrgyzstan 42) Syria
9) China 26) Laos 43) Taiwan
10) Cyprus 27) Lebanon 44) Tajikistan
11) East Timor 28) Macau 45) Thailand
12) Georgia 29) Malaysia 46) Turkmenistan
13) Hong Kong 30) Mongolia 47) United Arab Emirates
14) India 31) Myanmar (Burma) 48) Uzbekistan
15) Indonesia 32) Nepal 49) Vietnam
16) Iran 33) Oman 50) Yemen
17) Iraq 34) Pakistan
#? 9
Please select one of the following time zone regions.
1) east China - Beijing, Guangdong, Shanghai, etc.
2) Heilongjiang (except Mohe), Jilin
3) central China - Sichuan, Yunnan, Guangxi, Shaanxi, Guizhou, etc.
4) most of Tibet & Xinjiang
5) west Tibet & Xinjiang
#? 1
The following information has been given:
China
east China - Beijing, Guangdong, Shanghai, etc.
Therefore TZ='Asia/Shanghai' will be used.
Local time is now: Wed Dec 25 11:49:52 CST 2013.
Universal Time is now: Wed Dec 25 03:49:52 UTC 2013.
Is the above information OK?
1) Yes
2) No
#? 1
You can make this change permanent for yourself by appending the line
TZ='Asia/Shanghai'; export TZ
to the file '.profile' in your home directory; then log out and log in again.
Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Shanghai
# cp /usr/share/zoneinfo/$主时区/$次时区 /etc/localtime
对于中国服务器则执行:
# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# cp /usr/share/zoneinfo/$主时区/$次时区 /etc/localtime
对于中国服务器则执行:
# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 4. 将当前时间写入BIOS永久生效(避免重启后失效)
# hwclock
# hwclock
[root@localhost tmp]# date -R
Wed, 25 Dec 2013 11:56:13 +0800
来自:http://www.cnblogs.com/ningvsban/archive/2012/12/18/2823036.html
1)查看Linux硬件时间
[root@localhost tmp]# hwclock --show
Wed 25 Dec 2013 01:02:15 PM CST -0.494817 seconds
[root@localhost tmp]# date
Wed Dec 25 13:40:48 CST 2013
2)修改Linux硬件时间
hwclock --set --date
3)让系统时间与硬件时钟同步,用:
hwclock --hctosys
4)相反地,让硬件时钟与系统时间同步:
hwclock --systohc
对上面1)进行同步操作(让硬件时钟与系统时间同步)的实践OK:
[root@localhost tmp]# hwclock --systohc
[root@localhost tmp]# hwclock --show
Wed 25 Dec 2013 01:44:36 PM CST -0.973671 seconds
[root@localhost tmp]# date
Wed Dec 25 13:44:40 CST 2013
没同步上,直接修改硬件时间:
[root@localhost tmp]# hwclock --set --date "2013-12-25 13:48:51"
[root@localhost tmp]# hwclock --show
Wed 25 Dec 2013 01:48:56 PM CST -0.365535 seconds
[root@localhost tmp]# date
Wed Dec 25 13:48:39 CST 2013
来自:http://blog.163.com/dk_linux/blog/static/20322616620122401426999/
php-fpm的hosts访问问题记录
Php/Js/Shell/Go jackxiang 2013-8-23 10:17
早上遇到一个php-fpm的问题:
以前设置了host,后去掉这个host后到公网后发现这个fastcgi还是用的以前那个host,出现找不到host了(用shell下的curl是Ok的),后查来查去,重启了下php才好了,是怎么回事?
群里:
必须这样,我遇到很多次了,都记住了,估计估计是有dns缓存是有dns缓存。
以前设置了host,后去掉这个host后到公网后发现这个fastcgi还是用的以前那个host,出现找不到host了(用shell下的curl是Ok的),后查来查去,重启了下php才好了,是怎么回事?
群里:
必须这样,我遇到很多次了,都记住了,估计估计是有dns缓存是有dns缓存。
mac系统:control+command+F键把网页设置成全屏
如何获取到这个DISPLAY的值呢?
http://jackxiang.com/post/7689/
实践Ok,确实能全屏,这样在cmd下和linux下都是可行的:
阅读全文
如何获取到这个DISPLAY的值呢?
http://jackxiang.com/post/7689/
实践Ok,确实能全屏,这样在cmd下和linux下都是可行的:
阅读全文
1 准备SD卡8G以上
编译过程中,会耗用大量存储空间,4G不够用的。
2 更新资源的索引清单
sudo apt-get update (从服务上下载索引清单)
sudo apt-get upgrade (比较索引清单,更新依赖关系)
3 安装 python-dev
sudo apt-get install python-dev
否则在编译SIP时,会提示 fatal error: Python.h: No such file or directory
4 安装libqt4-dev
sudo apt-get install libqt4-dev
否则在编译PyQt时会提示 Error:Make sure you have a working Qt qmake on your PATH or use the -q argument to explicitly specify a working Qt qmake 5 依次安装SIP和PyQt
wget http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.10/PyQt-x11-gpl-4.10.tar.gz
tar vxf PyQt-x11-gpl-4.10.tar.gz
cd PyQt-xll-gpl-4.10
python configure.py
make
make install
wget http://sourceforge.net/projects/pyqt/files/sip/sip-4.14.4/sip-4.14.4.tar.gz
tar vxf sip-4.14.4.tar.gz
cd sip-4.14.4
python configure.py
make
make install
5 运行Python&GUI的源代码
在QLineEdit中输入文本,QLabel上会同步显示。下面这张图是周末两天的成果,虽说很是简陋,但运行成功的一刻,一切都值得了:)。
-----------------------------吐槽一下安装经历-----------------------------------------------------
今天年有一个项目,要做一个可以独立运行的测量系统,想着不连接PC时怎么实现自动测量的问题。前些天一直在弄Python GUI,于是想到了一直闲置着的raspberry Pi, 或许配上一块HDMI监视器可以用。周五了,一边打游戏,一边计划周末干点什么呢?游戏打得顺,心情也好。想好了周六,玩raspberry Pi,周日逛街(没逛成,时间不够用啊)。
周六,一早起来,没吃早饭,就开搞了,重新格式化 SD 卡,拷贝上去Noobs v1.2.1。开机安装系统,一路的傻瓜选项,最后一步忘了选DESKTOP 还是command line 模式,默认用了command line,因为不知道怎么用命令启动desktop,又重装了一遍,会的朋友请留言指导一下,谢谢了。
---------- 测试python
进入系统了,
先输入
print 'hello world'
没问题。
再来一个
import math
print 'math.sin(3.14/2)'
也没问题。
------ 试运行代码
于是想当然的网盘下载了,前些天写的GUI练习代码。运行,提示找不到PyQt4.QtCore, QtGui等,想来这个机器上的python没有PyQt模块,下载PyQt的 tar.gz包,按装之,又没有sip。好吧再下载sip,安装之,又提示找不到python.h。这个怎么回事,没头绪,找找网友的解释吧,哦,缺少开发环境?
-------安装python开发环境和sip(具体做了什么?)
sudo apt-get instyall python-dev
Python-dev安装了以后果然好了,SIP.4.14.4可以编译了,
------安装Qt4开发包和PyQt
切到PyQt的文件夹,python configure.py,提示找不到 qt qmake。这是怎么回事,网友说要装Qt,那为啥说没qmake呢?找了半天答案,原来qmake 是包含在qt包的里,一般安装时就会带的,试过仅仅安装qmake,没用( sudo apt-get install qt4-qmake)。qt官网下载那个安装包可大了,怎么办,因为用的是debian raspberry,就搜索了一下 debian Qt,找找有没有源以及安装包的名称。找到了以下的地址,http://packages.debian.org/unstable/main/qt-sdk 看了以后忽然开朗,安装libqt4-dev好像是可以的。果断sudo apt-get install libqt4-dev.好像是找到了资源包,可以下载不下来。根据提示用了一下sudo apt-get update ,重新sudo apt-get install libqt4-dev,问题解决了,原来资源索引更新过时了。第一次,编译PyQt时,中途出错停止了,重启系统后,发现只能进入command line模式,着实让我不知所措。幸好,拔了SD卡,插入笔记本时,意外发现SD卡,基本满了,于是换了8G SD卡,也重新验证了一下遍流程的正确性。
若干没有借鉴意义的过程略去。。。。
扩展阅读
作者忽忽(很不错的自学教程):http://bbs.shumeipai.org/thread-489-2-1.html
来自:http://my.oschina.net/u/63375/blog/152228
编译过程中,会耗用大量存储空间,4G不够用的。
2 更新资源的索引清单
sudo apt-get update (从服务上下载索引清单)
sudo apt-get upgrade (比较索引清单,更新依赖关系)
3 安装 python-dev
sudo apt-get install python-dev
否则在编译SIP时,会提示 fatal error: Python.h: No such file or directory
4 安装libqt4-dev
sudo apt-get install libqt4-dev
否则在编译PyQt时会提示 Error:Make sure you have a working Qt qmake on your PATH or use the -q argument to explicitly specify a working Qt qmake 5 依次安装SIP和PyQt
wget http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.10/PyQt-x11-gpl-4.10.tar.gz
tar vxf PyQt-x11-gpl-4.10.tar.gz
cd PyQt-xll-gpl-4.10
python configure.py
make
make install
wget http://sourceforge.net/projects/pyqt/files/sip/sip-4.14.4/sip-4.14.4.tar.gz
tar vxf sip-4.14.4.tar.gz
cd sip-4.14.4
python configure.py
make
make install
5 运行Python&GUI的源代码
在QLineEdit中输入文本,QLabel上会同步显示。下面这张图是周末两天的成果,虽说很是简陋,但运行成功的一刻,一切都值得了:)。
-----------------------------吐槽一下安装经历-----------------------------------------------------
今天年有一个项目,要做一个可以独立运行的测量系统,想着不连接PC时怎么实现自动测量的问题。前些天一直在弄Python GUI,于是想到了一直闲置着的raspberry Pi, 或许配上一块HDMI监视器可以用。周五了,一边打游戏,一边计划周末干点什么呢?游戏打得顺,心情也好。想好了周六,玩raspberry Pi,周日逛街(没逛成,时间不够用啊)。
周六,一早起来,没吃早饭,就开搞了,重新格式化 SD 卡,拷贝上去Noobs v1.2.1。开机安装系统,一路的傻瓜选项,最后一步忘了选DESKTOP 还是command line 模式,默认用了command line,因为不知道怎么用命令启动desktop,又重装了一遍,会的朋友请留言指导一下,谢谢了。
---------- 测试python
进入系统了,
先输入
print 'hello world'
没问题。
再来一个
import math
print 'math.sin(3.14/2)'
也没问题。
------ 试运行代码
于是想当然的网盘下载了,前些天写的GUI练习代码。运行,提示找不到PyQt4.QtCore, QtGui等,想来这个机器上的python没有PyQt模块,下载PyQt的 tar.gz包,按装之,又没有sip。好吧再下载sip,安装之,又提示找不到python.h。这个怎么回事,没头绪,找找网友的解释吧,哦,缺少开发环境?
-------安装python开发环境和sip(具体做了什么?)
sudo apt-get instyall python-dev
Python-dev安装了以后果然好了,SIP.4.14.4可以编译了,
------安装Qt4开发包和PyQt
切到PyQt的文件夹,python configure.py,提示找不到 qt qmake。这是怎么回事,网友说要装Qt,那为啥说没qmake呢?找了半天答案,原来qmake 是包含在qt包的里,一般安装时就会带的,试过仅仅安装qmake,没用( sudo apt-get install qt4-qmake)。qt官网下载那个安装包可大了,怎么办,因为用的是debian raspberry,就搜索了一下 debian Qt,找找有没有源以及安装包的名称。找到了以下的地址,http://packages.debian.org/unstable/main/qt-sdk 看了以后忽然开朗,安装libqt4-dev好像是可以的。果断sudo apt-get install libqt4-dev.好像是找到了资源包,可以下载不下来。根据提示用了一下sudo apt-get update ,重新sudo apt-get install libqt4-dev,问题解决了,原来资源索引更新过时了。第一次,编译PyQt时,中途出错停止了,重启系统后,发现只能进入command line模式,着实让我不知所措。幸好,拔了SD卡,插入笔记本时,意外发现SD卡,基本满了,于是换了8G SD卡,也重新验证了一下遍流程的正确性。
若干没有借鉴意义的过程略去。。。。
扩展阅读
作者忽忽(很不错的自学教程):http://bbs.shumeipai.org/thread-489-2-1.html
来自:http://my.oschina.net/u/63375/blog/152228
As from my previous question, I asked what the power off button in the corner does. Then somebody said if you boot into the GUI automaticlly, it will give you some options.
My question is,
How to boot into the GUI at start-up?
Thanks in advance.
Assuming that you are using Raspbian, it is actually rather simple to do what you ask. Simply open the terminal, and type in the following:
sudo raspi-config
The following window should show up
Navigate to boot_behaviour and click enter. This should make it so that the GUI interface starts automatically.
if you are using Archlinux, please install X11 server follow steps on Archlinux Beginners Guide first. and install your favorite WM,
1.Add those line to your ~/.xinitrc
#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)
if [ -d /etc/X11/xinit/xinitrc.d ]; then
for f in /etc/X11/xinit/xinitrc.d/*; do
[ -x "$f" ] && . "$f"
done
unset f
fi
exec openbox-session ## i'm using openbox
#exec awesome
2.Start X when login, add the following to bottom of ~/.bash_profile if you use bash, or ~/.zprofile if your are using zsh. see more on Archlinux Wiki
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx
shareimprove this answer
answered May 3 at 7:17
Yuan He
412
up vote
0
down vote
Read this article which explains how to auto login and auto start desktop http://www.opentechguides.com/how-to/article/raspberry-pi/5/raspberry-pi-auto-start.html
来自:http://raspberrypi.stackexchange.com/questions/7261/how-to-set-my-raspberry-pi-to-boot-into-the-gui
今天玩树莓派,需要安装些东西,老是sudo感觉不方便于是想直接用root。咦···?默认不是空密码?试下密码raspberry。还不对。那是神马??
论他找了下,原来之前用centos习惯了,错觉,错觉!!
树莓派(raspberry)启用root账户:
树莓派使用的linux是debian系统,所以树莓派启用root和debian是相同的。
debian里root账户默认没有密码,但账户锁定。
当需要root权限时,由默认账户经由sudo执行,Raspberry pi 系统中的Raspbian
默认用户是pi 密码为raspberry
重新开启root账号,可由pi用户登录后,在命令行下执行
sudo passwd root
执行此命令后系统会提示输入两遍的root密码,输入你想设的密码即可,然后在执行
sudo passwd --unlock root
这样就可以解锁root账户了。
好了,搞定!
来自:http://my.oschina.net/quanpower/blog/135196
My question is,
How to boot into the GUI at start-up?
Thanks in advance.
Assuming that you are using Raspbian, it is actually rather simple to do what you ask. Simply open the terminal, and type in the following:
sudo raspi-config
The following window should show up
Navigate to boot_behaviour and click enter. This should make it so that the GUI interface starts automatically.
if you are using Archlinux, please install X11 server follow steps on Archlinux Beginners Guide first. and install your favorite WM,
1.Add those line to your ~/.xinitrc
#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)
if [ -d /etc/X11/xinit/xinitrc.d ]; then
for f in /etc/X11/xinit/xinitrc.d/*; do
[ -x "$f" ] && . "$f"
done
unset f
fi
exec openbox-session ## i'm using openbox
#exec awesome
2.Start X when login, add the following to bottom of ~/.bash_profile if you use bash, or ~/.zprofile if your are using zsh. see more on Archlinux Wiki
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx
shareimprove this answer
answered May 3 at 7:17
Yuan He
412
up vote
0
down vote
Read this article which explains how to auto login and auto start desktop http://www.opentechguides.com/how-to/article/raspberry-pi/5/raspberry-pi-auto-start.html
来自:http://raspberrypi.stackexchange.com/questions/7261/how-to-set-my-raspberry-pi-to-boot-into-the-gui
今天玩树莓派,需要安装些东西,老是sudo感觉不方便于是想直接用root。咦···?默认不是空密码?试下密码raspberry。还不对。那是神马??
论他找了下,原来之前用centos习惯了,错觉,错觉!!
树莓派(raspberry)启用root账户:
树莓派使用的linux是debian系统,所以树莓派启用root和debian是相同的。
debian里root账户默认没有密码,但账户锁定。
当需要root权限时,由默认账户经由sudo执行,Raspberry pi 系统中的Raspbian
默认用户是pi 密码为raspberry
重新开启root账号,可由pi用户登录后,在命令行下执行
sudo passwd root
执行此命令后系统会提示输入两遍的root密码,输入你想设的密码即可,然后在执行
sudo passwd --unlock root
这样就可以解锁root账户了。
好了,搞定!
来自:http://my.oschina.net/quanpower/blog/135196
I’ve been very happy with the results from my Raspberry Pi controlled water bath for sous vide cooking, but I knew that the control loop could be improved. Past runs show fairly continued oscillation:
Roast beef temps2
Roast beef run at 60C
I’ve been keeping track of the average power for my control loop, which has been coming out at 22%. So i modified the code to have a bias of 22%, and here’s the result:
Test run at 55C
Test run at 55C
Overall much more stable. The occasional hiccups are probably caused by the remote socket failing to receive off commands. There’s a 3C overshoot at the start, which I hope to have fixed by entering the control loop from initial warm up 3C earlier.
http://blog.thestateofme.com/2013/05/12/improved-temperature-control-for-raspberry-pi-sous-vide/
Temperature control for a sous vide water bath is a popular application for hobbyist microcontroller kits, with lots of well documented projects out there. My favourite is the Sous Vader – if only for the attention to detail in the decal on the box.
I’ve been planning my own for a little while, and got some DS18B20 temperature probes a little while ago. The long Easter weekend break finally brought me some time to progress the project.
Danger – High Voltage
I have an old slow cooker that’s perfectly good for doing pot roast. It’s been falling to bits for some time, and I’ve patched it up with a Sugru sample I got at Monkigras. I had thoughts of hacking it directly (and perhaps even building in a Raspberry Pi), but common sense took hold and I decided on a route that didn’t involve directly manipulating mains electricity.
To turn the slow cooker on and off I got hold of a radio controlled mains socket from Maplin – they’re available without the controller (which I didn’t need) for £7.99.
I found a library to control the remote socket on github – Raspberry Strogonanoff (thanks Duncan McGregor, and a clever choice of project name). This uses a Sparkfun 434MHz RF Link Transmitter (which as suggested by Duncan I got from Protopic).
Getting Raspberry Strogonanoff working was the easier part of the whole set up. Having looked at the socket to establish that it was set to channel 4 button 1 I simply ran this line to turn it on:
sudo ./strogonanoff_sender.py --channel 4 --button 1 --gpio 0 on
and this to turn it off again:
sudo ./strogonanoff_sender.py --channel 4 --button 1 --gpio 0 off
Getting control
A water bath is a good example of a control system. The water and pot collectively have quite a high specific heat capacity, and there’s quite a bit of latency between turning off power and the rise in temperature stopping. The standard way of dealing with this is to use a PID Controller (see this explanation for a BBQ application for something more straightforward than the Wikipedia article). The Sous Vader seems to have worked with just a PI controller (effectively D=0), so I tried that first. There is a python implementation of a PID controller, which I didn’t spend the time to integrate.
Tuning the control loop
This is the tricky and time consuming part. In theory there should be a nice library out there that figures out correct settings for P, I and D based on observed data, but in practice it seems that most people resort to manual tuning.
The hardware
I started out with things on a breadboard using my usual home made Pi Cobbler, but as I want to use this in the kitchen I’ve created a more permanent setup using a Ciseco Slice of Pi, which at £3.90 is a very inexpensive small project board. I used one of the header strips in the Slice of Pi kit as a place to plug in the 434MHz transceiver and the temperature probes (so it would be easy to use parts in other projects). It was then simply a case of soldering some connecting wires to the appropriate power (5v for the transceiver and 3.3v for the DS18B20), GPIO (0 for the transceiver and 7 for the DS18B20) and GND:
The system pictured above has an Edimax WiFi dongle so that I can control and monitor the whole thing when it’s in the kitchen..
The software
Update 14 Apr 2013 – the code (slightly improved over what’s below) is now available on GitHub along with (hopefully comprehensive) installation instructions.
It’s not especially pretty, but seems to be doing the job:
Conclusion
I’ve not had the chance to use the water bath for cooking yet, but I’m very much looking forward to trying out a few steaks and maybe some Sunday roasts. I’ll report back on the results.
来自:http://blog.thestateofme.com/2013/03/31/raspberry-pi-sous-vide-water-bath/
参考:
http://blog.thestateofme.com/2013/01/28/ds18b20-rpi/
http://www.flashingleds.net/sousvader/sousvader.html
自己参考:
(1)Raspberry Pi PWM编写的方法:
http://jackxiang.com/post/6591/
(2)树莓派Raspberry和ds18B20接合,可以接多个Ds18B20:http://jackxiang.com/post/6588/
Roast beef temps2
Roast beef run at 60C
I’ve been keeping track of the average power for my control loop, which has been coming out at 22%. So i modified the code to have a bias of 22%, and here’s the result:
Test run at 55C
Test run at 55C
Overall much more stable. The occasional hiccups are probably caused by the remote socket failing to receive off commands. There’s a 3C overshoot at the start, which I hope to have fixed by entering the control loop from initial warm up 3C earlier.
http://blog.thestateofme.com/2013/05/12/improved-temperature-control-for-raspberry-pi-sous-vide/
Temperature control for a sous vide water bath is a popular application for hobbyist microcontroller kits, with lots of well documented projects out there. My favourite is the Sous Vader – if only for the attention to detail in the decal on the box.
I’ve been planning my own for a little while, and got some DS18B20 temperature probes a little while ago. The long Easter weekend break finally brought me some time to progress the project.
Danger – High Voltage
I have an old slow cooker that’s perfectly good for doing pot roast. It’s been falling to bits for some time, and I’ve patched it up with a Sugru sample I got at Monkigras. I had thoughts of hacking it directly (and perhaps even building in a Raspberry Pi), but common sense took hold and I decided on a route that didn’t involve directly manipulating mains electricity.
To turn the slow cooker on and off I got hold of a radio controlled mains socket from Maplin – they’re available without the controller (which I didn’t need) for £7.99.
I found a library to control the remote socket on github – Raspberry Strogonanoff (thanks Duncan McGregor, and a clever choice of project name). This uses a Sparkfun 434MHz RF Link Transmitter (which as suggested by Duncan I got from Protopic).
Getting Raspberry Strogonanoff working was the easier part of the whole set up. Having looked at the socket to establish that it was set to channel 4 button 1 I simply ran this line to turn it on:
sudo ./strogonanoff_sender.py --channel 4 --button 1 --gpio 0 on
and this to turn it off again:
sudo ./strogonanoff_sender.py --channel 4 --button 1 --gpio 0 off
Getting control
A water bath is a good example of a control system. The water and pot collectively have quite a high specific heat capacity, and there’s quite a bit of latency between turning off power and the rise in temperature stopping. The standard way of dealing with this is to use a PID Controller (see this explanation for a BBQ application for something more straightforward than the Wikipedia article). The Sous Vader seems to have worked with just a PI controller (effectively D=0), so I tried that first. There is a python implementation of a PID controller, which I didn’t spend the time to integrate.
Tuning the control loop
This is the tricky and time consuming part. In theory there should be a nice library out there that figures out correct settings for P, I and D based on observed data, but in practice it seems that most people resort to manual tuning.
The hardware
I started out with things on a breadboard using my usual home made Pi Cobbler, but as I want to use this in the kitchen I’ve created a more permanent setup using a Ciseco Slice of Pi, which at £3.90 is a very inexpensive small project board. I used one of the header strips in the Slice of Pi kit as a place to plug in the 434MHz transceiver and the temperature probes (so it would be easy to use parts in other projects). It was then simply a case of soldering some connecting wires to the appropriate power (5v for the transceiver and 3.3v for the DS18B20), GPIO (0 for the transceiver and 7 for the DS18B20) and GND:
The system pictured above has an Edimax WiFi dongle so that I can control and monitor the whole thing when it’s in the kitchen..
The software
Update 14 Apr 2013 – the code (slightly improved over what’s below) is now available on GitHub along with (hopefully comprehensive) installation instructions.
It’s not especially pretty, but seems to be doing the job:
Conclusion
I’ve not had the chance to use the water bath for cooking yet, but I’m very much looking forward to trying out a few steaks and maybe some Sunday roasts. I’ll report back on the results.
来自:http://blog.thestateofme.com/2013/03/31/raspberry-pi-sous-vide-water-bath/
参考:
http://blog.thestateofme.com/2013/01/28/ds18b20-rpi/
http://www.flashingleds.net/sousvader/sousvader.html
自己参考:
(1)Raspberry Pi PWM编写的方法:
http://jackxiang.com/post/6591/
(2)树莓派Raspberry和ds18B20接合,可以接多个Ds18B20:http://jackxiang.com/post/6588/
背景:在一些国外网站上有一两个,两三个英语单词不认识,为此需要一个翻译的划词插件。如果仅仅是外语翻译,装个有道划词插件吧。
官网:
http://cidian.youdao.com/chromeplus/
https://chrome.google.com/webstore/detail/%E6%9C%89%E9%81%93%E8%AF%8D%E5%85%B8chrome%E5%88%92%E8%AF%8D%E6%8F%92%E4%BB%B6/eopjamdnofihpioajgfdikhhbobonhbb?hl=zh-CN
二)扩展程序沙拉查词-多词典专业划词翻译,来自黄冶:
https://chrome.google.com/webstore/detail/%E6%B2%99%E6%8B%89%E6%9F%A5%E8%AF%8D-%E5%A4%9A%E8%AF%8D%E5%85%B8%E4%B8%93%E4%B8%9A%E5%88%92%E8%AF%8D%E7%BF%BB%E8%AF%91/cdonnmffkdaoajfknoeeecmchibpmkmg?hl=zh-CN
ChaZD:https://chrome.google.com/webstore/detail/chazd/nkiipedegbhbjmajlhpegcpcaacbfggp?hl=zh-CN
官网:
http://cidian.youdao.com/chromeplus/
https://chrome.google.com/webstore/detail/%E6%9C%89%E9%81%93%E8%AF%8D%E5%85%B8chrome%E5%88%92%E8%AF%8D%E6%8F%92%E4%BB%B6/eopjamdnofihpioajgfdikhhbobonhbb?hl=zh-CN
二)扩展程序沙拉查词-多词典专业划词翻译,来自黄冶:
https://chrome.google.com/webstore/detail/%E6%B2%99%E6%8B%89%E6%9F%A5%E8%AF%8D-%E5%A4%9A%E8%AF%8D%E5%85%B8%E4%B8%93%E4%B8%9A%E5%88%92%E8%AF%8D%E7%BF%BB%E8%AF%91/cdonnmffkdaoajfknoeeecmchibpmkmg?hl=zh-CN
ChaZD:https://chrome.google.com/webstore/detail/chazd/nkiipedegbhbjmajlhpegcpcaacbfggp?hl=zh-CN
背景:xp不想让它自动升级浏览器IE6,于是得要关闭更新。
降级:如果卸载了IE7的话 重启后系统默认浏览器就变成了IE6了。。你可以用超级兔子来卸载IE7..卸载后他是自动变为IE6的 不用重新装IE6,系统是盗版的也没问题。(实践是Ok的,能降到IE6,需要重启。)
防止再次给升级:
分两步!
第一,“我的电脑”点右键,选“属性”,“自动更新”把有自动更新的选项去掉,选关闭自动更新即可。
第二,“我的电脑”点右键,选“管理”,点左边“服务和应用程序”旁的加号,展开,点“服务”。
或者直接在“运行”中输入“Services.msc”打开服务设置窗口。
在“服务”列表中,找到“AutomaticUpdates”这一项,双击,弹出的属性窗口中,“启动类型”设置为“已禁用”,确定即可。
“AutomaticUpdates”这个进程的作用是:自动从WindowsUpdate网络更新补丁。利用WindowsUpdate功能进行升级。
来自:http://zhidao.baidu.com/question/6442607.html
降级:如果卸载了IE7的话 重启后系统默认浏览器就变成了IE6了。。你可以用超级兔子来卸载IE7..卸载后他是自动变为IE6的 不用重新装IE6,系统是盗版的也没问题。(实践是Ok的,能降到IE6,需要重启。)
防止再次给升级:
分两步!
第一,“我的电脑”点右键,选“属性”,“自动更新”把有自动更新的选项去掉,选关闭自动更新即可。
第二,“我的电脑”点右键,选“管理”,点左边“服务和应用程序”旁的加号,展开,点“服务”。
或者直接在“运行”中输入“Services.msc”打开服务设置窗口。
在“服务”列表中,找到“AutomaticUpdates”这一项,双击,弹出的属性窗口中,“启动类型”设置为“已禁用”,确定即可。
“AutomaticUpdates”这个进程的作用是:自动从WindowsUpdate网络更新补丁。利用WindowsUpdate功能进行升级。
来自:http://zhidao.baidu.com/question/6442607.html