Julia's Library

From Crowfly

Jump to: navigation, search


To Read

Useful Links

Unix Commands

python/dev paths:
export LCONF=~/library/conf/dev.yml 
export PYTHONPATH=~/library/lib
Helpful Emacs Cheat Sheets:
crtl-d #end (exit)

ctrl c #break
awk # a filter like sed but with different syntax
cat#concatenate. Prints a file to standard output. 
cat file | program #sends a file (pipes a file) to be run by a program.
grep #GNU regular expression parser. Given a file and a regex print all lines with 
that regex (p. 79 book)
grep pancake menu # print all lines of menu that have 'pancake' in them. 
head #print the first 10 lines of a file

tail #prints last 10 lines of text
cut # extracts columns as defined by a parameter -b19: 19th byte, -c19: 19th
character, -f5: 5th field, -d, :delimited by commas (p84 book) 
cut -d' ' -f1 <SITE>.log #cut the first field out of SITE logs, fields delimited 
by ' ' (space)

paste #combines several files to standard out put. (p. 84 book)
find . -name "bash*"  # find anything here (.) with the bash anything in its name
ln #creates a link (shortcut) to a file. By default it makes a hardlink which 
actually makes a copy of the file. -s=symlink links by file path only. 
ln -s /home/<USER>/library/web <SITE> #create a symlink to the website
more #page through text. Spacebar jumps one page. Down arrow jumps one 
line down. Added to other command like ls
ps #what processes are running? (p. 117 book)
ps -ef | grep <USER> #show processes that are running that have the regex 
USER in them -ef=command lines truncated to screen width
scp #secure copy. When at local machine can copy files and send them to the 
remote server
scp when_read.csv <USER>@antares.net: #grab when_read.csv (must be in 
current directory) and send it to home directory of [email protected]
sed #shows fie with text manipulations (p. 91 book)
sed-i #in place editing. creates a temp file to output then replaces original 
contents with temp ones. 
sed-i.bak # makes the new file a backup (file type .bak) 
sed -i.bak "s/ *$//g"  main.py  #get main.py file in place edit, make a 
back up substitute/*$/with a blank space/generate data.
cut -d' ' -f4 <SITE>.log | sed -e "s/:.*//"  #cut out the 4th field from SITE 
logs, fields delimited by ' ' send it to sed which substitutes :.* with ' '. 
Improves readability of log output 
sudo #super user does something
sudo su #super user becomes a substitute user
sudo su -root # super user becomes the root user (this is default) 
the - means execute the environment/settings of this user. 
sudo tail -f  /var/log/apache2/<SITE>-error.log #  super user shows the 
last 10lines of the error logs -f= keep this open and update it as new lines 
(errors) are added
sort #prints lines of text defaults to alphabetical but has other options 
(p. 87 book)
tr #translates one set of characters to another
wc # word count program
mysqldump -u<USER> -p<PASSWORD> library | gzip - > library_2014_13_04.dump.gz #make a back up  
of data and structures in library DB called library_2014_13_04.dump.gz

SQL Commands

load data local infile 'data/products.csv' into table products
fields terminated by ',' optionally enclosed by '"' ignore 1 lines;

Git Commands

Good Cheat Sheet: http://byte.kde.org/~zrusin/git/git-cheat-sheet-medium.png
Friendly Tutorials: https://www.atlassian.com/git/tutorial
Read this Later- Directed Acyclic Git Graphs: http://eagain.net/articles/git-for-computer-scientists/
git init

git add # needs to be instructed what to add. git add . adds everything downstream, 
add --all adds everything downstream and records deletions and branch removals.

git status # show status. Which files have been changed since last commit

git diff lib/books.py # show line by line differences in books.py

q # exit diff view

git commit -m # commits changes to local repo. Take comment after -m in double 

git push origin master # pushes changes to remote repo. 

git rm

git mv

git checkout . # checks out everything from local repo and replaces current files
with files as of last commit. Will lose uncommitted changes. Alternately restores 
troubled files.

git reset --hard FETCH_HEAD # use after fetch origin master, makes local repo like
remote repository.
Personal tools