2013年12月9日 星期一

CentOS firewall config

# vi /etc/sysconfig/iptables
# HTTP
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

# NFS
-A INPUT -m state --state NEW -m udp -p udp --dport 2049 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 32769 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 32803 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 892 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 892 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 875 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 875 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 662 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 662 -j ACCEPT

# Samba
-A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 445 -j ACCEPT
# /etc/init.d/iptables restart




References:
CentOS / Redhat Iptables Firewall Configuration Tutorial

Raspbian 預設帳號密碼

Username: pi
Password: raspberry




Reference :
Raspberry Pi Beginners Guide - neil-black.co.uk

2013年12月6日 星期五

javscript json encdoe & decode

> var arr = { };
undefined
> arr['aa'] = 111;
111
> arr['bb'] = 222;
222
> arr
{ aa: 111, bb: 222 }
> var json = JSON.stringify(arr);  // dictionary to json string
undefined
> typeof(json);
'string'
> json
'{"aa":111,"bb":222}'
> JSON.parse(json);  // json decode
{ aa: 111, bb: 222 }





Reference :
Encoding Javascript Object to Json string - Stack Overflow
How to parse JSON in JavaScript - Stack Overflow