2013年8月28日 星期三

smbclient NT_STATUS_ACCESS_DENIED

A1.
關閉 SELinux


A2.
# setsebool samba_export_all_ro on
# setsebool samba_export_all_rw on

# getsebool -a | grep samba




Reference :
HowTos/SetUpSamba - CentOS Wiki

Temporarily disable SELinux

# echo 0 >/selinux/enforce

# sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: permissive
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted




Reference :
HowTo: Temporarily Switch Off SELinux Enforcement

2013年8月27日 星期二

CentOS install Samba server

// install
# yum install samba samba-client samba-common -y

// firewall
# vi /etc/sysconfig/iptables
-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

# /etc/init.d/iptables restart

// add samba user
# smbpasswd -a user1 // 須在系統上有相同的帳號

// set share directory
# vi /etc/samba/smb.conf
[global]
    security = user
[share]
     comment = Share Storage
     path = /mnt/datadisk
     browsable = yes
     guest ok = yes
     read only = no
     valid users = user1 user2

// restart services
# /etc/init.d/smb restart




Reference :
Samba Add a User

CentOS install NFS Server

Server :
# yum install nfs* -y

# vi /etc/exports
/mnt/data 192.168.1.0/24(rw,sync,no_root_squash,no_all_squash)

# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
-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

:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

# /etc/init.d/iptables restart
# /etc/init.d/rpcbind restart
# /etc/init.d/nfs restart

Client  :
# yum install nfs* -y
# /etc/init.d/rpcbind restart
# /etc/init.d/nfs restart
# mount -t nfs 192.168.1.200:/mnt/data/ /nfs/shared/




Reference :
Setup NFS Server in CentOS / RHEL / Scientific Linux 6.3 Step by step | Ostechnix

CentOS install nginx

# vi  /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
# yum install nginx -y

# /etc/init.d/nginx restart





Reference :
Install
RHEL / Centos 6: Install Nginx Using Yum Command

2013年8月25日 星期日

2013年8月20日 星期二

ImportError: cannot import name EXT_PASS

from sqlalchemy.orm import MapperExtension, EXT_PASS
ImportError: cannot import name EXT_PASS


use EXT_CONTINUE instead of EXT_PASS




Reference :
ImportError: cannot import name EXT_PASS - Google Groups

2013年8月13日 星期二

python gdata Spreadsheet feed worksheet raw



Reference :
Grabbing Google Docs information with a Python - GersteinInfo

python gdata Spreadsheet update cell value




Reference :
Automatically update spreadsheets and graphs – Part 1 | pseudo-scripter

python gdata get Spreadsheet ID and get Worksheets ID




Reference :
Reading Google Spreadsheets in Python

vim spell check

:set spell
]s 跳到下個錯字
[s 跳到前個錯字
z= 顯示建議字詞
zg 新增正確拼字
zug 刪除正確拼字
zw 新增錯誤拼字
zuw  刪除錯誤拼字

python 取得區域變數 locals() 與全域變數 globals()

locals()
globals()


× locals is read-only, globals is not

>>> x = 1
>>> locals()['x'] = 2
>>> x 
>>> globals()['x'] = 3
>>> x 




Reference :



python get function parameter


>>> help('func')
寫在函式裏的註解說明會被顯示出來

>>> inspect.getargspec(func)
Get the names and default values of a Python function’s arguments.





Reference :
27.13. inspect — Inspect live objects — Python v2.7.5 documentation
How can I find the number of arguments of a Python function? - Stack Overflow

2013年8月9日 星期五

auto create, update time in sqlalchemy

Column('creation_date', DateTime, default=func.now()),
Column('last_modified', DateTime, onupdate=func.now()),

2013年8月2日 星期五

滷大腸

去腥
1. 在市場買到已翻好的大腸,將大腸在鍋子內,加入麵粉與白醋將雜質揉出來,然後用清水洗淨
2. 起滾水,加入薑、蒜、大腸,煮至大腸可用筷子戳過 (約 1 小時)





滷鍋
1. 將冰糖與少許油炒至糖融化、變色
2. 蔥、薑、蒜、辣椒(去籽)、香菜頭用刀子拍過,洋蔥切片,炒香
3. 加入醬油、紹興酒煮滾 30 分鐘




滷大腸
滷鍋煮滾,加蓋滷 30 分鐘,然後開蓋泡 10 分鐘





Reference :
美食鳳味 郭主義 滷大腸食譜 - YouTube