Welcome to Software Carpentry Etherpad!
This pad is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents.
Use of this service is restricted to members of the Software Carpentry and Data Carpentry community; this is not for general purpose use (for that, try etherpad.wikimedia.org).
Users are expected to follow our code of conduct: http://software-carpentry.org/conduct.html
All content is publicly available under the Creative Commons Attribution License: https://creativecommons.org/licenses/by/4.0/
UCL Research programming hub: https://www.ucl.ac.uk/research-it-services/research-it-services/research-software-development/programming-hub
post-workshop survey in http://rits.github-pages.ucl.ac.uk/2018-04-25-UCL_software_carpentry/
Python session
Remember to login to Socrative - https://b.socrative.com/login/student/ - room name: RITS
Go here for setup instructions: http://swcarpentry.github.io/python-novice-inflammation/setup/
here for a glossary of the concepts I will be talking about: http://swcarpentry.github.io/python-novice-inflammation/reference
and here to follow the notes: http://swcarpentry.github.io/python-novice-inflammation/
In Jupyter notebook, to execute code in a cell ==> <shift> <enter>
To get list of functions in a library ==> <libname>. and then press <tab>
(eg. numpy. and then <tab>)
For programming help/questions: https://stackoverflow.com/
Additional data types:
dictionaries: { key1 : value1, key2 : value2, .... }
- eg. my_dict = {"Monday" : "Sucks", "Tuesday" : "A bit better", "Friday" : "Yeay!"}
Helpful website https://www.tutorialspoint.com/python/python_strings.htm
Git session
Remember to login to Socrative - https://b.socrative.com/login/student/ - room name: RITS
Hints
- To exit paginated output, press q . To go to the next page, press space. You can also move up and down with the arrow keys.
- If for any reason you find yourself in the vi editor, type the escape key, followed by :q! (colon, lower-case 'q', exclamation mark), then hitting Return to return to the shell.
Links & Resources
The software carpentry lesson this was based on: http://swcarpentry.github.io/git-novice/
Guidelines for a (subjectively!) good commit message: https://chris.beams.io/posts/git-commit/
Advanced use of 'git add':
'git add -u' stages the working copy versions of all files being tracked by git
'git add -p' takes you through each change in turn interactively and asks whether to stage it
Both of these can also take file/folder name arguments, so you can do e.g. 'git add -u chapter1/' to stage only modified files in the chap
ter1 folder
More learning resources:
* http://marklodato.github.io/visual-git-guide/index-en.html (Visual Git Reference - pictorial representations of what Git commands do)
* Tips (and rationale) for good commit messages:
* https://chris.beams.io/posts/git-commit/
* http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
* https://help.github.com/categories/collaborating-with-issues-and-pull-requests/ (Collaborating using GitHub)
* http://learngitbranching.js.org/?demo
* http://sethrobertson.github.io/GitFixUm/fixup.html (On undoing, fixing, or removing commits in git)
* https://github.com/jlord/git-it-electron (A desktop app that teaches you how to use git and GitHub on the command line)
* https://presentate.com/bobthecow/talks/changing-history (General lessons for using git in open source projects)
Useful tools:
* Graphical interfaces: https://git-scm.com/downloads/guis
* Diff/merge tools: https://sourcegear.com/diffmerge/
(but there are many and git asks you what to use)
Using Word files with git:
* https://github.com/vigente/gerardus/wiki/Integrate-git-diffs-with-word-docx-files
* http://ben.balter.com/2015/02/06/word-diff/
Excel seems to be a bit more complicated, but various people have solutions:
* http://programmaticallyspeaking.com/git-diffing-excel-files.html
* https://wiki.ucl.ac.uk/display/~ucftpw2/2013/10/18/Using+git+for+version+control+of+spreadsheet+models+-+part+1+of+3 (by a former UCL student)
* http://stackoverflow.com/questions/17083502/how-to-perform-better-document-version-control-on-excel-files-and-sql-schema-fil
* https://xltools.net/excel-version-control/ (paid-for product)
Other options for conflict resolution:
git checkout --theirs -- path/to/conflicted-file.txt
git checkout --ours -- path/to/conflicted-file.txt
See `git checkout --help` for more!
Shell session
Setup
whoami ==> tells you who you are as a user
pwd (present working directory) ==> where you are in the file directory structure
ls (listing) ==> what's in pwd
ls -F ==> same output as before but folder names end with a /
man ls (or ls --help) ==> manual page for the ls command
exiting paginated content (eg. in man) ==> q
ls -F <directory name or directory path> ==> same output from the directory specified
cd <directory path> ==> change directory to the specified location
cd .. ==> moves to the next level up in the directory tree
ls -F -a ==> lists every directory with a trailing / (-F) and the hidden files (-a)
cd ==> takes you back to your /home directory
cd /home/<your name>/Desktop ==> takes you to the specified directory with the absolute path
clear ==> clears your screen
mkdir <directory name> ==> makes a directory
nano <file name> ==> creates/edits a file using nano
^ ==> the control key (ctrl) in nano
rm <file name> ==> removes file !!!
rm -r <directory name> ==> removes recursively
rm -r -i <directory name> ==> removes recursively and interactively (ask for permission to remove)
answer to -i ==> y for yes, n for no
mv <origin file path> <final location path> ==> moves a file from a location to another (also used for renaming)
cat <file name> ==> catalogues a file, shows its content
cp <origin file name> <final file path> ==> copies file from a location to another
wc <file name> ==> word counts in a file name | lines | words | characters |
* ==> is a wildcard which stands for "any character of any number"
? ==> is a wildcard which stands for "any character but one character"
wc -l ==> word counts the number of lines (-w for words)
<command> > <file name> ==> redirects the output to a file
<tab> ==> auto-completes command or filename
sort -n <file name> ==> sorts numerically (rather than alphabetically) the contents of a file
head -n <integer> <file name>==> picks out the first <integer> lines of the file
tail -n <integer> <file name> ==> takes the last <integer> lines of the file
echo <message> ==> prints out the message on the screen
<command1> | < command2>==> pipes (chains) commands together, passes the output
of command1 as input for command2
for <command> ==> begin marker of a for loop
do <command> ==> executes the command
done ==> end marker of the loop
<ctrl>c ==> terminate a process/exit from a confusing state (eg. inside a for loop, some other non-prompt state...)
bash <shell script> ==> executes the shell script