Professional Documents
Culture Documents
Workshop 1:
Programming Basics, Unix, Remote Computing
October 13, 2004
Motivation
Before you start coding
Programming Conventions
Documentation
Names, comments
Directory Structure
Basic Constructs
Miscellaneous (debugging, cross-checking
results)
Motivation
Facilitate research
Save time
Cleaner code
Easily share programs
Basic Concepts
MUCH better programming
Programming Conventions
Who cares?
Examples
Readability of code
Organization
Transferring code to others
THINK
WRITE down the problem
WRITE down the algorithm in English (not code)
Modularity
Comments
Create test (if reasonable)
Naming Conventions
Not a detail!
Good names clarify your code
Portray meaning/purpose
Adopt a convention and BE CONSISTENT
MergeHH.sas, MergeHH.do
MergeHHsas.log, MergeHHsta.log
Programs
Log files
fixMissingAge
matXX
Commenting Code
Good code is SELF-COMMENTING
Comments explain
Comments DO NOT
Directory Structure
A project consists of
many different types of
files
Use folders to
SEPARATE files in a
logical way
Be consistent across
projects if possible
ATTIC folder for older
versions
HOME
PROJECT NAME
DATA
RESULTS
LOG
PROGRAMS
ATTIC
Miscellaneous Tips
Programming Constructs
Constructs - Looping
Constructs - If/then/else
Constructs - Elseif/case
AND
True
AND
False
AND
False
OR
True
OR
True
OR
False
XOR
False
XOR
True
XOR
False
Constructs - Break
Constructs - keywords
PART 2: Unix
Motivation
Basic Commands
Job submission and management
Pipes
Unix Shell
Script files
Unix
Motivation
A quick history
Unix variants
Where?
man -k command
whatis command
apropos keyword
mv filename1 filename2
cp filename1 filename2
rm filename
delete filename
more filename
cat filename
head filename
tail filename
mkdir dirname
rmdir dirname
cd dirname
cd
cd ..
cd ../..
home directory
cd ~/scripts
!v
!-2
arrow up/down
history
diff filename1
filename2
wc filename
who
cal
date
displays date
du a
ls l
Being nice
Interactive
user@nicco%stata
Foreground jobs
user@nicco%nice +19 stata b do jobfile.do
user@nicco%nice +19 sas jobfile.sas
Job Management
Ctrl-c
Ctrl-z
bg
ps u
ps ux
ps aux
ps aux | more
kill PID
top
Pipes
| redirects
command 1 output
command 2 input
Command
Result
top
grep piersol
ps -aux | more
Ps aux
More
ls | wc -l
ls
Wc l
Unix Shell
Remote Computing
Windows to Whitney
Remote Login
Remote Desktop
Connection
>= XP included*
< XP download*
Web-based
Remote Desktop
Connection*
File Transfer
Remote Computing
Windows to Unix
Remote Login
SSH Secure
Shell Client*
File transfer
SSH Secure
File Transfer Client*
* http://computing.sscnet.ucla.edu/training/tutorial_SSH.htm
** http://computing.sscnet.ucla.edu/training/tutorial_samba.htm
Finally