Skip to content

Instantly share code, notes, and snippets.

Andrew Moodie amoodie

Block or report user

Report or block amoodie

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@amoodie
amoodie / Change axes, colors, and fonts
Last active Mar 4, 2019
Change root figure options in matlab
View Change axes, colors, and fonts
get(0, 'factory') % lists all the options
set(0, 'defaultAxesBox', 'on')
set(0, 'defaultAxesXColor', [0 0 0])
set(0, 'defaultAxesYColor', [0 0 0])
set(0, 'defaultAxesLineWidth', 1.5)
set(0, 'defaultAxesFontSize', 10)
@amoodie
amoodie / twoparam_nonlinear_rouse.m
Created Nov 6, 2018
Demonstration of two-parameter Rouse regression
View twoparam_nonlinear_rouse.m
% load some example data
sampleDepth = [0.9500; 0.9500; 0.9500; 0.8500; 0.8500; 0.8500; 0.7500; 0.7500; 0.7500; 0.5000; 0.5000; 0.5000; 0.1000; 0.1000; 0.1000];
sampleZ = [0.0850; 0.0850; 0.0850; 0.2550; 0.2550; 0.2550; 0.4250; 0.4250; 0.4250; 0.8500; 0.8500; 0.8500; 1.5300; 1.5300; 1.5300];
conc = [1.5897; 1.8884; 2.3833; 1.0620; 0.8321; 0.8760; 0.4087; 0.5752; 0.4819; 0.4908; 0.6069; 0.5313; 0.2321; 0.2569; 0.2492];
% organize into a model structure
modelParams.flowDepth = 1.7;
modelParams.b = 0.0850;
@amoodie
amoodie / changepathpermissions.md
Created Sep 4, 2018
the path file pathdef.m might be read-only
View changepathpermissions.md

the path file pathdef.m might be read-only

In Matlab, enter:

>> which pathdef
/usr/local/MATLAB/R2018a/toolbox/local/pathdef.m

Enter a Linux terminal and change file permissions to read and write for anyone.

View my .bashrc additions
# added by AM
# Show git branch name
# based largely on code from ankurk91: https://gist.github.com/ankurk91/2efe14650d54d7d09528cea3ed432f6d#file-bashrc-md
# and
# Dominik Schoeler: https://makandracards.com/makandra/1090-customize-your-bash-prompt
#
force_color_prompt=yes
color_prompt=yes
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
@amoodie
amoodie / generalized_darcy_weisbach.m
Created Apr 2, 2018
Generalized Darcy-Weisbach normal flow depth as single-line Matlab function
View generalized_darcy_weisbach.m
% function for normal flow depth following from Ganti et a., 2014 supplementary material
HnfunDW = (@(Q, B, Cf, S0, g) ((Q./B).^(2/3).*(Cf./(g.*S0)).^(1/3))); % generalized Darcy Weisbach, from Ganti et al., 2014 supp info
@amoodie
amoodie / make_random_names.md
Last active Mar 15, 2019
Make random names in Python
View make_random_names.md

The following code is written for Python3. Complete random name function in next file.

The first bit of code grabs a disctionary listing from the web and returns a list of all the entries in that dictionary.
(see https://stackoverflow.com/a/49524775/4038393)

import urllib.request

word_url = "http://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-type=text/plain"
response = urllib.request.urlopen(word_url)
@amoodie
amoodie / seq2gif.sh
Last active Jun 13, 2018
convert still sequence to gif
View seq2gif.sh
fps=20
scale=800
nzero=4
ffmpeg -r $fps -i %0"$nzero"d.png -c:v libx264 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -pix_fmt yuv420p -y out.mp4
ffmpeg -i out.mp4 -vf fps=$fps,scale=$scale:-1:flags=lanczos,palettegen -y palette.png
ffmpeg -i out.mp4 -i palette.png -filter_complex "fps=$fps,scale=$scale:-1:flags=lanczos[x];[x][1:v]paletteuse" -y output.gif
View add_tex_path.md

Add texlive install path

  • Add this line to your ~/.bashrc file
export PATH=$PATH:/usr/local/texlive/2015/bin/x86_64-linux
  • Close and re-open your gnome-terminal
@amoodie
amoodie / symlinks_latex_github.sh
Created Mar 7, 2018
Using symbolic links to add GitHub based class to LaTeX path (TeX tree)
View symlinks_latex_github.sh
@amoodie
amoodie / Matlab2017b.sublime-build
Last active Oct 1, 2018
Sublime 3 build system for Matlab on Ubuntu Linux
View Matlab2017b.sublime-build
{
// setup for 2017b, Ubuntu 16.04
// change path for other Matlab versions
// quit call closes all figures and kills matlab process
"cmd": ["/usr/local/MATLAB/R2017b/bin/matlab", "-nodesktop", "-nosplash", "-r", "$file_base_name;quit"],
"selector": "source.m"
}
You can’t perform that action at this time.