Sunday, May 12, 2019

Some common-sense rules or laws in the world

Schneiers Law
https://www.schneier.com/blog/archives/2011/04/schneiers_law.html

Be pythonic

The Zen of Python

    Beautiful is better than ugly.
    Explicit is better than implicit.
    Simple is better than complex.
    Complex is better than complicated.
    Flat is better than nested.
    Sparse is better than dense.
    Readability counts.
    Special cases aren't special enough to break the rules.
    Although practicality beats purity.
    Errors should never pass silently.
    Unless explicitly silenced.
    In the face of ambiguity, refuse the temptation to guess.
    There should be one-- and preferably only one --obvious way to do it.
    Although that way may not be obvious at first unless you're Dutch.
    Now is better than never.
    Although never is often better than *right* now.
    If the implementation is hard to explain, it's a bad idea.
    If the implementation is easy to explain, it may be a good idea.
    Namespaces are one honking great idea -- let's do more of those!

See https://legacy.python.org/dev/peps/pep-0020/

Python Code Style

https://docs.python-guide.org/writing/style/

Pytonic

"Pythonic" means something like "idiomatic Python"
The sense of how to use Python the right way. 
The idiom the Python language encourages.
To be Pythonic is to use the Python constructs and datastructures with clean, readable idioms.

Exploiting the features of the Python language to produce code that is clear, concise and maintainable.

https://blog.startifact.com/posts/older/what-is-pythonic.html

Wednesday, January 22, 2014

piVC Serversetup

piVC is a logic verfication program by Stanford University. To serve the class CS458, it requires a piVC server set up for students to use Java piVC client.

To provide better portability, the piVC server is set up in a Virtual Machine (VM) on KVM virtualization.

VM name: piVC
VM credentials: GDC convention
VM ip: 128.153.145.236

Below are the instructions on HOWTO install piVC server:

1. check out the piVC source code:

https://github.com/jgalenson/piVC

1) install svn
sudo apt-get install subversion
2) checkout source code
svn  checkout svn://www.jasonland.com/piVC
3) download yices
http://yices.csl.sri.com/download.shtml

cp   yices-1.0.40/bin/yices  ../../piVC/bin

4) install build tool
sudo apt-get install build-essential
sudo apt-get install ocaml

5) install java for the client
sudo apt-get install openjdk-7-jdk

6)compile the source code

cd piVC/src
make

7) Configure the server
check the machine ip:  ifconfig

specify the local machine static ip in piVC/conf/piVC_server.conf
dp_server_address =  xxx.xxx.xxx.xxx:4243

8) Run the service
cd piVC/bin
./both_servers

9) Config the piVC client
Download the client from here
http://cs.stanford.edu/people/jasonaue/pivc/

Run the client by
java -jar  PiVC.jar

Change the server address
Settings->Change Server Address -> xxx.xxx.xxx.xxx:4242

Run the program
Compile

Sunday, August 2, 2009

Samba Server on Centos HOWTO

TDB database
root: > smbd -b | grep PRIVATE_DIR
/etc/samba

root: >smbd -b | grep LOCKDIR
/var/cache/samba

use tdbbackup utility to backup those tdb files

mkdir a directory and change its ownship
chown account.group /path/to/directory

Samba Configruation File
root: >smbd -b | grep smb.conf
/etc/samba/smb.conf

Dry run Samba Configurations
root: >testparm /etc/samba/smb.conf
root: >smbclient -L xxx.xxx.xxx.xxx(SambaServerIP) -U%

Samba valid user setup
root: >smbpasswd -a csguest
New SMB password:
Retype new SMB password:
startsmbfilepwent_internal: file /etc/samba/smbpasswd did not exist. File successfully created.
Added user csguest.

chown user.group /path/to/sambashare

Run/start/stop/restart Samba Server
root: >service smb reload
root: >service smb start
root: >service smb stop
root: >service smb condrestart

Mount Samba Share in Linux
root: >apt-get install smbfs
root: >smbmount //SambaServerIP/SambaShare /mnt/Dir -o username=account, password=pwd

Access Samba Share in WindowsXP
Control Panel -> User Accounts -> yourUserAccount
Click Manage my network passwords
Add button to enter Server, User name and Password
Server: xxx.xxx.xxx.xxx(SambaServerIP)
Username: xxx.xxx.xxx.xxx\AccountName
Password:******

My Computer -> Tools -> Map Network Drive
Folder: //SambaServerIP/SambaShare