2014年11月12日 星期三

PHP开发框架

FuelPHP

http://fueldocs.ycnets.com/index.html

Laravel

http://kejyun.github.io/Laravel-4-Documentation-Traditional-Chinese/docs/introduction/

http://code.csdn.net/phpframework/#

Phalcon是用C语言实现的拥有高性能和低功耗等特点的PHP开发框架
http://phalconphp.com/zh/

ThinkPHP 是一个免费开源的
http://www.thinkphp.cn/document/index.html


在 Symfony2 建立一個部落格

http://twpug.net/docs/symblog/index.html

Symfony2中文文档

https://symfony-docs-chs.readthedocs.org/en/latest/

Linux Shell 脚本中字符串的连接方法

如果想要在变量后面添加一个字符,可以用一下方法:
$value1=home
$value2=${value1}"="
echo $value2
把要添加的字符串变量添加{},并且需要把$放到外面。
这样输出的结果是:home=,也就是说连接成功。
又如:
[root@localhost sh]# var1=/etc/
[root@localhost sh]# var2=yum.repos.d/
[root@localhost sh]# var3=${var1}${var2}
[root@localhost sh]# echo $var3
/etc/yum.repos.d/
shell 如何实现字符串不足N位自动补零
# 仅适用于数字
printf "%04d\n" 86
echo 86|awk '{printf("%04d\n",$0)}'


将echo的结果赋给一个变量
var=`echo aaa`

解決 "maximal mount count reached" 與硬碟檢測
檢查 mount 次數
$ tune2fs -l /dev/sdb1 | grep ^M
Mount count:              26
Maximum mount count:      22
取消最大 mount 次數檢查
$ tune2fs -c0 -i0 /dev/sdb1
tune2fs 1.39 (29-May-2006)
Setting maximal mount count to -1
Setting interval between checks to 0 seconds
$ tune2fs -l /dev/sdb1 | grep ^M
Mount count:              26
Maximum mount count:      -1
檢查檔案系統
$ umount /dev/sdb1

當 mount 硬碟時老是出現
"EXT3-fs warning: maximal mount count reached, running e2fsck is recommended"
是提醒你該用 e2fsck 做檔案系統的檢查,請依下列步驟處理:
1. 查看目前的 mount 次數及限制
2. 取消最大 mount 次數檢查
3. 查看目前的 mount 次數及限制
1. 取消 mount,並做檔案系統檢查及自動修復處理

$ e2fsck -p /dev/sdb1

代碼對於標准bash而言沒有錯,因为Ubuntu为了加快開機速度,用dash代替了傳統的bash,是dash在搗鬼。
解决方法是取消dash:
sudo dpkg-reconfigure dash
在選擇項中選No,即可。



PC安裝Clover EFI與Hackintosh-準備安裝工具

http://megamo.logdown.com/posts/198831-black-apple-pc-install-clover-efi-hackintosh-and-ready-to-install-tools


SSH 使用金鑰連線的設定步驟

以下使用 ssh-keygen 產生 RSA2 的金鑰為範例,然後會得到兩個檔案分別為公鑰(id_rsa.pub)、私鑰 (id_rsa),原則上你可以只產生一份金鑰,然後將>該公鑰設定給多個主機,使用同一私鑰登入不同的主機。
  1. 在 Command Line 中使用 ssh-keygen 指令產生金鑰。
    $ ssh-keygen -t rsa1 -C "username@xxx.xxx"  # 產生 RSA1 金鑰
    $ ssh-keygen -t rsa -C "username@xxx.xxx"  # 產生 RSA2 金鑰
    $ ssh-keygen -t dsa -C "username@xxx.xxx"  # 產生 DSA 金鑰
    
    
  2. 將公鑰設定到欲連線的主機。
    $ scp ~/.ssh/id_rsa.pub [欲連線主機]:~/.ssh/
    
  3. 系統預設處理公鑰的檔案為 authorized_keys,因此要先登入欲連線的主機,再將公鑰附加於該檔案之中。
    $ ssh [欲連線的主機]
    # 將 public key 附加到檔案的最後面
    $ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
    # 調整 authorized_keys 的檔案權限
    $ chmod 644 ~/.ssh/authorized_keys

SSH隧道与端口转发及内网穿透

http://blog.creke.net/722.html

防止SSH連線逾時(timeout)

ubuntu的SSH連線預設只要一段時間沒有輸入文字,伺服器會逾時(timeout)而自動斷線
所以我們必需修改OpenSSH Server的設定,讓sshd每隔5秒就送出小封包,以維持連線不中斷.
防止SSH連線逾時的方法有以下幾種。

方法一:
修改/etc/ssh/ssh_config
加上
ServerAliveInterval 5
然後,重啟SSH服務:
#sudo /etc/init.d/ssh restart 或
#sudo service ssh restart
方法二:
編輯 /etc/ssh/sshd_config
加上
KeepAlive yes
ClientAliveInterval 60
然後,重啟SSH服務:
#sudo /etc/init.d/ssh restart 或
#sudo service ssh restart
方法三:
若是從linux環境連上server,可以修改使用者個人的ssh設定檔:
編輯 ~/.ssh/config
加上
ServerAliveInterval 60

hokag_user@hokag:~$ netstat -tnl | grep 127.0.0.1


http://portable.easylife.tw/entry/Reverse-SSH-Tunnel%E5%AF%A6%E9%9A%9B%E9%81%8B%E7%94%A8%EF%BC%8C%E6%90%AD%E9%85%8Dauotssh%E6%B0%B8%E4%B8%8D%E6%96%B7%E7%B7%9A%EF%BC%8Cputty%E5%BB%BA%E7%AB%8B%E5%8F%8D%E5%90%91tunnel



使用 Git 管理源代码

http://www.ibm.com/developerworks/cn/linux/l-git/

官方教程的中文版
http://git-scm.com/book/zh/v1

Where can I find the serial number of the Raspberry Pi I am currently using?
http://raspberrypi.stackexchange.com/questions/2086/how-do-i-get-the-serial-number
pi@raspberrypi:~$ cat /proc/cpuinfo
grep -Po '^Serial\s*:\s*\K[[:xdigit:]]{16}' /proc/cpuinfo

crc驗證
http://www.cppblog.com/smagle/archive/2014/05/29/74119.html


在linux c使用openssl/md5.h加密
#include<stdio.h>
#include<openssl/md5.h>
#include<string.h>

int main( int argc, char **argv )
{
unsigned char *data = "123";
unsigned char md[16];
int i;
char tmp[3]={'\0'},buf[33]={'\0'};
MD5(data,strlen(data),md);
for (i = 0; i < 16; i++){
    sprintf(tmp,"%02x",md[i]);
    strcat(buf,tmp);
}
printf("%s\n",buf);
return 0;
输出:
sudo apt-get install openssl libssl-dev libssl-doc libcurl4-openssl-dev
gcc MD5test.c -lcrypto -o MD5test
202cb962ac59075b964b07152d234b70 

1. %02X或%02x强制输出两位(分别对应大写字符串和小写字符串)。
2.一定要使用unsigned char,虽然是char,其实就是个int,当然,它只有一个字节,和char的区别是,unsigned char 0~255 ,char -127~127。使用char会出问题。这个md5加密函数,返回16个十进制数,范围在0~255间,把它format为十六进制就是32为md5编码了。
3.gcc编译的时候,后面加上参数 -lcrypto 如果系统没有安装libcrypto,是不能用这个方法的。

4. 可以使用strtol来转换16位进制的字符串为long型整数 具体请man strtol 有示例代码

ssh 的話加個 -v 去連 看看卡在哪邊 03/16 18:55
CP64:個人的情形是去 sshd_config 把 GSSAPI 關掉就好了 03/16 18:55
感謝:) 加了-v後看到卡在 debug1: SSH2_MSG_SERVICE_ACCEPT received google後看到在sshd_config設定 UseDNS no 即可。 GSSAPI 還在研究他的作用。但至少加了UseDNS no 就不會卡在那了。

sudo tzselect
sudo /usr/sbin/ntpdate tock.stdtime.gov.tw
date


為你的 Raspberry Pi 裝上 Watchdog

http://coldnew.github.io/blog/2013/12/13_b1756.html

How to automatically reconnect WiFi?

http://raspberrypi.stackexchange.com/questions/4120/how-to-automatically-reconnect-wifi

Well, there is a very simple solution:
  1. Go to /etc/ifplugd/action.d/ and rename the ifupdown file to ifupdown.original
  2. Then do: cp /etc/wpa_supplicant/ifupdown.sh ./ifupdown
  3. Finally: sudo reboot
That's all. Test this by turning off/on your AP; you should see that your Raspberry Pi properly reconnects.

Wifi Reconnect on drop

http://www.raspberrypi.org/forums/viewtopic.php?f=91&t=16054&start=25