-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhowto
executable file
·333 lines (333 loc) · 15.1 KB
/
howto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
#!/bin/bash
#
# BECAUSE SOMETIMES MEMORY JUST ISN'T ENOUGH
#
#
function usage {
echo 'Usage: howto [what]'
echo ' Examples for [what]:'
echo ' tar : how to tar stuff!'
echo ' ssh : everything ssh'
echo ' ln : link files'
echo ' rsync : synchronising filesystems'
echo ' regex : regular expressions'
echo ' sed : this is the hardest one'
echo ' gau : Gaussian related commands'
echo ' pgi : Portland compiler info'
echo ' tags : ctags to follow code'
echo ' misc : miscellanea commands'
}
#
# Help!
if [ ${#} -eq 0 ]; then
usage
exit 0
fi
#
# Now do the work
for input in ${@}; do
case ${input} in
ams )
echo 'COMPILING'
echo ' cd $AMSHOME; source $( find ${AMSHOME} -maxdepth 1 -name amsbashrc.sh )'
echo ' Install/configure -b "myconfig -o GNU -p intelmpi -staticmkl"'
echo ' $AMSBIN/foray -j 8'
echo ' ./Utils/git_post_clone_setup.sh'
echo 'RUNNING'
echo ' submit.py $ADFHOME/Utils/run_test adf'
echo 'GIT'
echo ' git clone --filter=blob:limit=128k ssh://[email protected]/SCM/amshome.git'
echo ' git pull --rebase'
;;
conda )
echo ' conda activate myenv'
echo ' conda install numpy matplotlib'
echo ' conda deactivate'
;;
fq )
echo 'Rick:'
echo ' O'
echo ' CHI 0.116859'
echo ' ETA 0.584852'
echo ' SUBEND'
echo ' H'
echo ' CHI 0.000001'
echo ' ETA 0.625010'
echo ' SUBEND'
echo 'Giovannini:'
echo ' O'
echo ' CHI 0.189194'
echo ' ETA 0.523700'
echo ' SUBEND'
echo ' H'
echo ' CHI 0.012767'
echo ' ETA 0.537512'
echo ' SUBEND'
;;
gau )
echo "DEBUG COMPILATION:"
echo " (with setgau) makec l502c"
echo "FIND WHERE CALCULATION DIES:"
echo " ulimit -c unlimited"
echo " [run calculation normally to get the core]"
echo " gdb path/l502.exe core.12345 ; then type where"
echo "PERMISSIONS:"
echo ' for file in $( find ${g16root} \( -name *.F -o -name *.make \) -print ); do chgrp gausrc ${file}; done'
echo "COMPILE Gaussian:"
echo " tcsh"
echo ' setenv g16root `pwd`'
echo ' source $g16root/g16/bsd/g16.login'
echo ' source ~/.tcshrc (FOR PGI, DEPENDS ON MACHINE)'
echo ' rehash; cd $g16root/g16'
echo ' nohup ./bsd/bldg16 all > & build.log &'
;;
git )
echo "INTRO:"
echo " Git is a data structure stored in a Repository within the folder .git"
echo " git init (creates a repository in current directory)"
echo " A repository is a set of Commit Objects (each with its SHA1 name, its files, and its references to parent objects)"
echo " and Branches (references to the commit objects)"
echo " A commit object has a Name (found with git log), references to Parent commit objects, and the files that compose it"
echo " The current branch is referenced as HEAD, and the main one is referenced as master"
echo "WORKFLOW:"
echo " git log (shows the log of all commits up to the initial one)"
echo " git status (to see which files I have changed)"
echo " git diff {old} {new} (to see exactly what I changed or differences between commits with arguments [head1]..[head2])"
echo " git {add,mv,rm} (to add, move, remove files in this commit)"
echo " git commit -am [message] (to commit changes)"
echo " Note: -m allows to specify the message in command line rather than in the file itself, -a commits all modified files"
echo " alternatively just use git add [files] to specify which files to commit (unchanged files are added automatically)"
echo "BRANCHING:"
echo " git branch (lists the branches)"
echo " git branch -d [branch_name] (deletes a branch)"
echo " git branch [new_branch_head_name] [reference_to_object_to_branch_from] (creates branch)"
echo " Note: You can use git log to find the SHA1 name of the object to branch from or use its branch name (maybe)"
echo " git checkout [branch_head_name] (sets the branch as current branch)"
echo " git pull . [source_head] (pull the changes from the source_head into the current head)"
echo "COLLABORATING:"
echo " git clone [repository_address] (get and thus join a repository)"
echo " git fetch origin (get changes made by others from the server)"
echo " git merge origin master (merge the changes done by me and others)"
echo " git push origin (push my changes to the repository)"
echo "WEB:"
echo " git push -u origin master"
echo "SCM:"
echo " git add . ; git commit ; git pull --rebase ; git push"
echo " git switch --create mybranch trunk"
echo "NOTES:"
echo " Maintain a stable master commit and create a new branch before developing new features"
echo " Always commit any changes before changing branch with git checkout"
echo " Use merge to draw new features into the master branch, or more rarely to pull a bugfixed master into the development version"
;;
gromacs | gmx )
echo " gmx_mpi trjconv -sep -b SKIP_ps -dt DELTAt_ps -f TRAJECTORY.xtc -o OUTPUT.pdb"
;;
howto | -h )
usage
;;
lammps )
echo "INSTALLAZIONE:"
echo " mkdir ~/usr/local/lammps ; cd ~/usr/local/lammps"
echo " wget https://download.lammps.org/tars/lammps-stable.tar.gz"
echo " tar -xzvf lammps-stable.tar.gz"
echo " cd lammps-23Jun2022"
echo " mkdir build; cd build"
echo " cmake ../cmake -DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc -DCMAKE_Fortran_COMPILER=ifort -DBUILD_LIB=yes -DBUILD_SHARED_LIBS=yes -DLAMMPS_EXCEPTIONS=yes -DBUILD_MPI=no -DBUILD_OMP=yes -DPKG_OPENMP=yes -DPKG_GPU=yes -DPKG_MOLECULE=yes -DPKG_EXTRA-MOLECULE=yes -DPKG_KSPACE=yes"
echo " cmake --build ."
echo " make install"
echo " make install-python"
;;
ln )
echo "ln original link"
;;
mutt )
echo 'mutt -s "Subject" -a attachment.dat -- [email protected] <<< "bla bla"'
echo 'mutt -s "Subject" -a attachment.dat -- [email protected] < file.txt'
;;
pdf )
echo "pdfunite file1.pdf file2.pdf filemerge.pdf"
echo "pdfseparate [-f 2 -l 5] file.pdf file%d.pdf"
echo 'pdftocairo -svg ${file} ${file%.pdf}.svg'
;;
pgi )
echo "Loading PGI (as root, password L1Gr0up or L1Gr0up123)"
echo 'cd ${PGIDIR}/bin ; ./lmgrd'
;;
python )
echo 'PRINTING'
echo ' format = "Hello %s you have %.2f dollars"'
echo ' mytuple = ("Franco",7.00)'
echo ' print format % mytuple'
echo ' %s ; %d ; %.3f # Format types for string (also numbers), integer, float with 3 mantissa digits'
echo 'TYPES: No typing necessary, everything is an object, numbers are integers or floats'
echo ' myint = 7 ; myfloat = 7.0 ; mystring = "seven"'
echo 'OPERATIONS'
echo ' NUMBERS:'
echo ' + - * / ** % # Plus, Minus, Times, Divided, Elevated, Modulo'
echo ' STRINGS:'
echo ' mystring + mystring ; mystring * 2 # Both give sevenseven'
echo ' mystring + mystring # Gives sevenseven'
echo ' len(mystring) # Gives length of the string'
echo 'COMMANDS'
echo ' STRINGS: Defined with double (better) or single quotes'
echo ' mystring.index("char") # Find index of first instance of char'
echo ' mystring.count("char") # Count instances of char'
echo ' mystring.upper("char") # Turn to upper case, also works with lower'
echo ' mystring.split("char") # Makes a list of strings splitting at char, most often space " "'
echo ' mystring.startswith("char") # True if string starts with char, also works with endswith'
echo ' mystring[-1:5:2] # Extract string starting from last character to the 4th with stride of 2'
echo ' LISTS: they can contain anything, defined with square brakets, indexing starts with 0'
echo ' mylist = [] # Declares an empty list'
echo ' len(mylist) # Gives the length of the list'
echo ' mylist.append("7.0") # Adds element 7.0 to the end of mylist'
echo ' mylist.count(x) # Counts how many of object x are in the list'
echo ' TUPLE: immutable lists, defined with parenthesis'
echo 'CONDITIONS'
echo ' BOOLEANS: True and False'
echo ' if x == 2 or x > 3 and y < 0:'
echo ' print True'
echo ' elif name in ["Bob","Tim"]:'
echo ' print name is either Bob or Tim'
echo 'ITERATIONS'
echo ' for i in range(0,40): # for numbers from 0 to 39 print until 10'
echo ' print i'
echo ' if i == 10:'
echo ' break'
echo ' while n < 10: # continue goes to the next iteration step'
echo ' if n < 5:'
echo ' continue'
echo ' n = n + 1'
echo ' else'
echo ' print "done"'
echo 'FUNCTIONS'
echo ' def myfunc(arg1,arg2):'
echo ' return arg1 + arg2'
echo ' somma = myfunc(1,2)'
echo 'OBJECTS'
echo ' CLASSES: templates containing various variables or functions'
echo ' class identity:'
echo ' firstname = "blank"'
echo ' lastname = "blank"'
echo ' def fullname(firstnam,lastnam):'
echo ' return firstnam + " " + lastnam'
echo ' OPERATIONS: accessing objects'
echo ' io = identity()'
echo ' io.firstname = "Franco"'
echo 'MODULES'
echo ' IMPORTING: A module is a .py file that lists objects, classes, and functions'
echo ' import numpy as np # import numpy.py and use it as np.func() etcetera'
echo ' dir(np) # list functions in the module'
echo ' help(np.pi) # seek help for function pi'
echo ' PACKAGE: A directory containing a __init__.py file and multiple .py modules'
echo ' import package.module # access it as package.module.function()'
echo ' from package import module # access it as module.function()'
;;
qc2 )
echo "DOWNLOAD:"
echo " git clone [email protected]:qc2nl/qc2.git"
echo "INSTALL:"
echo " conda create -n qc2 python=3.11"
echo " conda activate qc2"
echo " cd qc2 ; python3 -m pip install -e ."
echo " python3 -m pip install -e .[pennylane]"
echo "TEST:"
echo " pytest -v"
;;
regex )
echo ". = Any single character"
echo "a|b = matches either a or b"
echo "* = Preceding pattern zero or more times"
echo "+ = Preceding pattern one or more times"
echo "? = Preceding pattern zero or one times"
echo "^,$ = Start and End of line, respectively"
;;
rsync )
echo "rsync -avn --exclude-from=[exclude-file] source destination"
echo " -a syncs all"
echo " -v verbose"
echo " -n dry run to test before doing anything"
echo " -P to visualize progress and allow restart"
echo " -z to compress files"
echo " --delete to delete files that no longer exist"
echo " --exclude-from reads patterns to exclude from a specified file"
;;
sed )
echo "Delete all lines starting with pattern and 2 lines after them:"
echo " $ sed -i '/pattern/,3d' file"
echo "Delete last line:"
echo " $ sed -i '\$d' file"
echo "Change all lines starting with pattern:"
echo " $ sed -i 's/^pattern.*$/replacement/g' file"
;;
ssh )
echo "ssh -X user@where (to use graphical softwares)"
echo ""
echo "ssh user@where command (to run any command remotely)"
echo "ssh user@where 'bash -s' <<< command"
echo ""
echo "Generate key!"
echo "ssh-keygen -t rsa (then press Enter a bunch of times)"
echo "ssh-copy-id user@where"
;;
slurm )
echo "saldo -bc (Project allotted time remaining balance)"
echo "sinfo -s (Prints queue information about nodes and partitions)"
echo "squeue (List jubs in the schedule)"
echo "sbatch job_script.sh (submit job)"
echo "scancel job_ID (Cancel Job)"
;;
svn )
echo "svn info #Print information about repository"
echo "svn status #Print information about changes"
echo ""
echo "svn ls svn+ssh://[email protected]/home/svn/src/branches/FrancoEgidi/"
echo "svn checkout svn+ssh://[email protected]/home/svn/src/branches/FrancoEgidi/MyBranch ams2020.new"
echo "svn copy -r NUMBER svn+ssh://[email protected]/home/svn/src/trunk svn+ssh://[email protected]/home/svn/src/branches/FrancoEgidi/MyBranch -m MESSAGE"
echo "svn merge svn+ssh://[email protected]/home/svn/src/branches/FrancoEgidi/MyBranch@rXXXX ."
echo "svn move svn+ssh://[email protected]/home/svn/src/branches/FrancoEgidi/Branch1 svn+ssh://[email protected]/home/svn/src/branches/FrancoEgidi/Branch2"
echo "svn switch svn+ssh://[email protected]/home/svn/src/branches/FrancoEgidi/Branch2"
echo "svn add/delete file"
echo "svn commit -m \"My message\""
;;
tags | ctags )
echo 'SETUP TAGS FILE:'
echo ' ctags -R $directory'
echo ' mv tags $HOME/.tags'
echo 'SETUP VIM OPTIONS IN .vimrc:'
echo ' if filereadable($HOME."/.tags")'
echo ' "look for the .tags file"'
echo ' set tags=~/.tags'
echo ' "make ctags open routines as new vertical splits with Ctrl+\"'
echo ' map <C-\> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>'
echo ' endif'
echo 'EXPECTED USE:'
echo ' Hover the cursor on the routine name, then:'
echo ' Ctrl+\ should open a new vertical split on the right'
echo ' Ctrl+] should replace current window with tagged file'
echo ' :pop should close the tagged window'
;;
tar )
echo "tar -xvf goofy.tar (opens the uncompressed archive goofy.tar and puts it in the folder)"
echo "tar -cvf goofy.tar file1 file2 (creates the uncompressed archive goofy.tar with file1 and file2)"
echo "tar -rvf goofy.tar addme.new (adds addme.new to goofy.tar)"
echo "tar -tf goofy.tar (lists the contents of an archive)"
echo " use the -z option to handle gzip files .tgz or .tar.gz"
;;
user* | group* | grp | usr )
echo "sudo adduser NEWSER"
echo "sudo usermod -a -G GROUP NEWSER"
echo "sudo deluser USER GROUP"
echo "sudo groupadd GROUP"
;;
misc )
echo 'COMPARE FILES : cmp $1 $2 || vimdiff $1 $2'
echo 'ABSOLUTE PATH : realpath $1'
echo "FILE FIND/SORT: find . -type f -exec du -ha {} + | sort -n -r | less > deleteme.tmp (non-ideal file find/sort)"
;;
fosfo )
echo $'if [[ -f final.dat ]]; then rm final.dat; fi; for i in *log; do grep -m 3 Radiative ${i} > out${i}.dat; done; paste *.dat > final.dat; sedi \'Radiative lifetime:\' \'\' final.dat ; sedi s \'\' final.dat; rm *log.dat; scp final.dat [email protected]:~/temp'
;;
* )
echo "we do not have ${input} in the list, sorry"
esac
done