Skip to content

Instantly share code, notes, and snippets.

View amoodie's full-sized avatar

Andrew Moodie amoodie

View GitHub Profile
@amoodie
amoodie / symlinks_latex_github.sh
Created March 7, 2018 20:38
Using symbolic links to add GitHub based class to LaTeX path (TeX tree)
@amoodie
amoodie / add_tex_path.md
Created March 8, 2018 15:49
my .bashrc config

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 / generalized_darcy_weisbach.m
Created April 2, 2018 02:32
Generalized Darcy-Weisbach normal flow depth as single-line Matlab function
% 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 / seq2gif.sh
Last active June 13, 2018 16:12
convert still sequence to gif
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
# 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 / changepathpermissions.md
Created September 4, 2018 18:19
the path file pathdef.m might be read-only

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.

@amoodie
amoodie / Matlab2017b.sublime-build
Last active October 1, 2018 18:20
Sublime 3 build system for Matlab on Ubuntu Linux
{
// 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"
}
@amoodie
amoodie / twoparam_nonlinear_rouse.m
Created November 6, 2018 21:01
Demonstration of two-parameter Rouse regression
% 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 / Change axes, colors, and fonts
Last active March 4, 2019 22:16
Change root figure options in matlab
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)
# test the possibility of setting and getting mwe within jitted functions
import numpy as np
import numba
@numba.jit
def set_random_seed(_seed):
np.random.seed(_seed)