Bioengineering-Toolbox
Total Page:16
File Type:pdf, Size:1020Kb
bioengineering-toolbox Mar 13, 2021 Contents: 1 Code development 1 1.1 Git FAQ..................................................1 1.1.1 General.............................................1 1.1.2 GitHub.............................................1 1.1.3 CLI (command line interface).................................1 1.2 Github FAQ................................................3 1.2.1 Adding badges to repositories.................................3 1.2.2 Renaming repositories and updating remote paths of clones..................3 1.3 Pycharm FAQ..............................................4 1.3.1 How to open interactive python console by default?......................4 2 Documentation 5 2.1 Creating documentation.........................................5 2.1.1 Getting started.........................................5 2.1.2 Example repositories......................................5 2.1.3 Markdown............................................5 2.1.4 Building documentation....................................6 2.1.5 Additional features.......................................7 2.1.6 restructuredText.........................................7 2.2 Sphinx FAQ...............................................8 2.2.1 Force rebuild of html, including autodoc............................8 2.2.2 Adding a sphinx build configuration to pycharm........................8 2.2.3 Table width fix for Read the Docs Sphinx theme........................8 2.2.4 Sphinx and Jupyter notebooks.................................8 2.2.5 Updating logo for sphinx_rtd_theme..............................8 2.2.6 Updating sphinx_rtd_theme colours..............................9 2.2.7 Graphs in Sphinx/RestructuredText...............................9 2.3 Markdown FAQ............................................. 10 2.3.1 Best practices.......................................... 10 2.3.2 Cheatsheet............................................ 10 2.3.3 Table generator......................................... 10 2.3.4 Escape characters........................................ 10 2.3.5 Create note........................................... 10 2.4 Restructured text FAQ.......................................... 10 2.4.1 Examples of well documented code repositories........................ 10 2.4.2 Commenting restructuredText files............................... 10 i 2.4.3 Hyperlinks and cross-referencing................................ 11 2.4.4 Showing example code..................................... 12 2.4.5 Add images........................................... 13 2.4.6 Creating tables......................................... 13 2.4.7 Notes and warnings....................................... 13 2.5 ReadTheDocs FAQ............................................ 13 2.5.1 Adding Github organisation repos to readthedocs....................... 13 2.5.2 Troubleshooting......................................... 14 3 Documentation 17 3.1 Docker FAQ............................................... 17 3.1.1 Common commands...................................... 17 3.1.2 Activating a Conda environment in your Dockerfile...................... 17 3.1.3 Tips to Reduce Docker Image Sizes.............................. 18 3.1.4 Create Docker Images for Docker Hub............................. 18 3.1.5 Debugging applications with totalview in dockers....................... 18 4 FEM 19 4.1 OpenCMISS FAQ............................................ 19 4.1.1 Building OpenCMISS..................................... 19 4.1.2 Using python bindings on hpc3................................. 20 4.1.3 Debugging OpenCMISS examples............................... 20 4.1.4 Hydrostatic pressure export................................... 20 4.2 CMGUI FAQ............................................... 20 4.2.1 Replicating cmgui 3.01 visualisation using gfx commands.................. 20 5 File formats 23 5.1 JSON FAQ................................................ 23 5.1.1 JSON examples......................................... 23 5.1.2 Schema............................................. 23 6 Linux 25 6.1 Linux FAQ................................................ 25 6.1.1 Find files in a terminal..................................... 25 6.1.2 Change file permissions..................................... 25 6.1.3 tar/untar or zip/unzip...................................... 26 6.1.4 Search for files in directory................................... 26 6.1.5 Find size of directory...................................... 26 6.1.6 Print all environmental variables................................ 26 6.1.7 Download file from the internet................................. 26 6.1.8 Restart network manager (Ubuntu 16.04)........................... 26 6.1.9 GUI utility to mount remote filesystems over SSH....................... 27 6.2 Screen FAQ................................................ 28 6.3 Photo and video FAQ........................................... 28 6.3.1 Video software......................................... 28 6.3.2 Create gifs from images (commandline)............................ 28 7 Python 29 7.1 Python FAQ............................................... 29 7.1.1 Python virtual environments.................................. 29 7.1.2 Strings.............................................. 29 7.1.3 Displaying docstrings to see function arguments and info................... 29 7.1.4 Comparisons.......................................... 29 7.1.5 Objects............................................. 30 7.1.6 Dictionaries........................................... 30 ii 7.1.7 Path and IO functions...................................... 30 7.1.8 Load/save json......................................... 31 7.1.9 Understanding decorators.................................... 31 7.1.10 Manually throw/raise an exception............................... 31 7.2 Python bindings............................................. 33 7.2.1 Manually building h5py bindings with local version of hdf5.................. 33 7.3 Virtualenv FAQ.............................................. 33 7.3.1 Create virtual environments for python with conda...................... 33 7.4 Pandas FAQ............................................... 33 7.4.1 Create empty dataframe..................................... 33 7.4.2 Creating & editing entries................................... 33 7.4.3 Concatenating dataframes................................... 33 7.4.4 Renaming headers....................................... 34 7.4.5 Concatenating.......................................... 34 7.4.6 Find number of rows in dataframe............................... 34 7.4.7 Indexing data.......................................... 34 7.5 Jupyter notebook FAQ.......................................... 34 7.5.1 Guide.............................................. 34 7.6 Matplotlib FAQ.............................................. 34 7.6.1 Plotting tutorials........................................ 34 7.7 Morphic FAQ............................................... 34 7.7.1 Using groups.......................................... 34 7.7.2 Build wxPython on Ubuntu 16.04 (required by mayavi2, which is used by morphic)..... 35 7.8 Mayavi FAQ............................................... 35 7.8.1 Speed up mayavi rendering................................... 35 7.9 Goolge API FAQs............................................ 35 7.9.1 First steps............................................ 35 8 University of Auckland 37 8.1 UoA eResearch Virtual machine FAQ.................................. 37 8.1.1 Add user on eReserach VM................................... 37 9 Web 39 9.1 Best practices............................................... 39 9.2 Javascript FAQ.............................................. 39 9.2.1 var vs let vs const........................................ 39 9.2.2 Comparisons.......................................... 40 9.2.3 Strings.............................................. 40 9.2.4 Arrays.............................................. 40 9.2.5 Converting between data types................................. 41 9.2.6 Conditional operator (if and ?)................................. 41 9.2.7 Classes............................................. 42 9.2.8 Objects............................................. 42 9.2.9 Looping............................................. 43 9.2.10 TypedArray........................................... 44 9.2.11 ES6 Modules.......................................... 44 9.2.12 Mastering javascript callbacks/bind/apply/call......................... 44 9.2.13 Fetching............................................. 44 9.2.14 Adding and removing event listeners with access to ‘this’................... 44 9.2.15 Alerts.............................................. 45 9.2.16 Disable right-click context menu................................ 45 9.3 Dat.Gui FAQ............................................... 45 9.3.1 Accessing object methods and attributes inside an event callback................ 45 9.4 Three.js FAQ............................................... 46 iii 9.4.1 Tips and tricks......................................... 46 9.4.2 Vector to array conversion................................... 46 9.4.3 View axes............................................ 46 9.4.4 Find absolute position of a vertex................................ 46 9.4.5 View point cloud........................................ 46 9.4.6 View vertices of an existing geometry............................. 46 9.4.7 Create BufferGeometry..................................... 47 9.4.8 Dynamic visualisations using BufferGeometry........................