Reid Otsuji
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Software Caprentry Intro to Python Workshop ### UCSD Biomedical Library Building, Classroom 4 - 9:00am - 4:30pm ### November 27-28, 2018 --- ### This HackMD: https://goo.gl/3uiqg6 # Editing this HackMD has been locked by the Instructors. --- ## Workshop Schedule: https://ucsdlib.github.io/2018-11-27-UCSD/ --- # Please Sign in here: #### (name, affiliation (faculty, staff, student, post-doc, etc.), department/Office/Lab) Reid Otsuji, Data Curation Librarian, Library Stephanie Labou, Data Science Librarian, Library Rick McCosh, Post-doc, OB/GYN+Repro Sci. Arden Tran, Research Facilitator, Research IT Bryan S. Kehr, Library ITS Saranya Canchi, POst-doc, Neurosciences Hamanda Badona Cavalheri, Biology, grad student Maya Becker, graduate student, Scripps Institution of Oceanography Jesse Wilson, Post-doc, Scripps Institute of Oceanography Margaret Lindeman, graduate student, SIO Emelia Bainto, Data Manager, KD Research Lab Marion Alberty, graduate student, SIO Luke Colosi, undergraduate student, UCSD Erik Klimczak, Staff Research Associate, SIO, Ali Hamidi, Postdoc, SIO Robina Shaheen, associate research scientist --- # Add your notes here: #### (These are collaborative notes, please make sure you do not overwrite others notes) # Day 1 - Morning ## Unix Shell: Data files download: http://swcarpentry.github.io/shell-novice/data/data-shell.zip Save to your desktop and unzip Shell file system hierarchy Start Terminal in MacOS Start Gitbash in Windows Print working directory - shows where you are in the file system (file path) great command to use when you need to know where you are in the system ``` pwd ``` Change directory ``` cd ``` Move up in the filesystem hierarchy ``` cd .. ``` Make a new folder ``` mkdir ``` using `cd` will take you back you to the home directory ``` cd ``` list the contents of a directory ``` ls ``` to change your directory to 'desktop' ``` cd desktop ``` #### Tip: use the `Tab` key to Auto complete For help you can use: `man` will list all the flags and usage for the command ``` man [command] #example: $man ls on Windows (Git Bash) use: $ ls --help ``` #### Great site for looking up shell commands. http://explainshell.com/ Move back to the user/home folder ``` cd ~ ``` Display folders in a `ls` list ``` ls -F ``` Move folder command ``` mv ``` create the folder data-process ``` mkdir data-process ``` Naming files and folders: don’t use spaces! * Use _ or - instead * Can also use camelcase: FileName * Can use numbers, but never as the first character Remove directory ``` rm ``` Making new files ``` nano ``` Use a file extension to specify. For example, make a new text file in your current directory: ``` nano newfile.txt ``` Word count command - lists lines, words, and characters useful to see what's in the files ``` wc ``` wildcards using `*` or `?` for wc to fit different patterns. you can use wildcard when referencng a file. e.g. `ls *.pdb` Return all files with extension .pdb ``` wc *.pdb ``` Return all files ending in "ethane.pdb" ``` wc ?ethane.pdb ``` View contents one page at a time ``` less ``` Return the output sorted ``` sort ``` Sort, specifying by numeric ``` sort -n ``` Sort length.text and write out result to new file, sorted-lengths.txt ``` sort -n length.txt > sorted-lengths.txt ``` ``` head -n 1 sorted-lengths.txt 9 methane.pdb ``` ``` tail -n 1 sorted-lengths.txt 9 methane.pdb ``` Use the pipe `|` to send the output of one Use `cat` to print a file to the terminal (cat is short for concatenate) ``` cat salmon.txt ``` `cut` command can be used to break up the file ``` cut -d, -f 2 animals.txt ``` to save output as a new file ``` cut -d, -f 2 animals.txt >> animals-today.txt ``` `>>` append command is used to add text to an existing file #### creating a loop to rename the files: basic loop structure `for`,`in`, `do`, `done` ``` for filename in basilist.dat unicorn.dat >do >head -n 3 $filename >done ``` when you start a loop byt typing `for` the prompt will change to a `>` this is how you know you are starting a loop Example loop: ``` for datafile in *.pdb do ls $datafile done ``` Another loop: ``` for chem in *pdb do ls $chem > test.txt done ``` Note that this loop *overwrites* each output, so that there is only one value in test.txt We can fix this by appending to test.txt, rather than recreating it each time: ``` for chem in *pdb do ls $chem >> test.txt done ``` #### n.b.: how to save a variable To save a file as a temporary variable outside of a loop: ``` export VARIABLENAME=filename.xxx ``` example: Give ethane.pdb handle "x" & then display it in the terminal: ``` export x=ethane.pdb cat $x ``` ### To get a list of ALL the commands you’ve used in this session ``` history ``` You can save the output a file ``` history > command_history.txt ``` # Day 1 - Afternoon # Git ## Basic Git commands ``` git status git add [file.name] git commit -m "[short desscriptive message]" git log git diff ``` to setup global configuration for Git ``` git config ``` To set your username ``` git config --global user.name "[your name here]" ``` set your email address (make sure it is an email that can be public) ``` git config --global user.name "[your emailaddress that is ok to be public here]" ``` There are line endings for Windows and MacOS machines. FOr windows set config global to: ``` git config --global core.autocrlf true ``` For Mac set config global to: ``` git config --global core.autocrlf input ``` To track and preserve changes/versions of file ``` git add filename git commit -m "commit message" ``` `git add` "stages" your file and `git commit` adds that snapshot to your repository If you run `git status` after you make a change, after `git add` and after `git commit`, you can see how git is tracking your changes (i.e., see change but not tracked, staged for commit, committed and up to date) show the last commit information ``` git log ``` display short 7 digit identifer list of recent commits ``` git log --oneline ``` view the version changes between commits ``` git diff HEAD [7 alpha# ID] [file.name] ``` Roll back changes to previous version ``` git checkout [7 alpha# ID] [file.name] ``` go back to the latest version ``` git checkout head [file.name] #for exmple git checkout head refrerences.txt ``` ##### detached head state to revert back to master state use ``` git checkout master ``` If you're on Mac and want to see branch names in your command prompt like on Stephanie's computer, add the following to `~/.bash_profile` (from https://gist.github.com/joseluisq/1e96c54fa4e1e5647940): ``` # Git branch in prompt. parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ " ``` Create a new branch ``` git checkout -b [branchname] ``` This will create a new branch *starting from the current state of your repository* So, if you roll back your repository, then start a new branch, your new branch will start from that stage of your files. ``` # roll back to prior version git checkout [commitID] [file.name] # make new branch from this version git checkout -b [newbranchname] # get back to master branch git checkout master # get back to current state of repo, back to HEAD git checkout HEAD [file.name] ``` More about branches: https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging Then open a new terminal window or use `source ~/.bash_profile` Remove from staging ``` git reset HEAD [file.name] ``` ## Git ignore Create git .ignore file add `.gitignore.txt` file to your folder ## Github collaboration: Setting up remotes in GitHub: https://swcarpentry.github.io/git-novice/07-github/index.html ``` git remote add origin [URL] git push -u origin master ``` "Pull" changes in GitHub to local ``` git pull origin master ``` "Push" local changes to GitHub ``` git push origin master ``` Best practice: always start your local session by pulling from remote repository (incorporate any changes made by collaborators before starting your own edits) Fix merge conflicts by editing file directly, then add and commit fixed file Use this link to accept collaboration invitation: https://github.com/notifications

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully