Skip to content

Instantly share code, notes, and snippets.

View patrickmineault's full-sized avatar
🦊

Patrick Mineault patrickmineault

🦊
View GitHub Profile
@patrickmineault
patrickmineault / Narwhal
Created December 23, 2021 21:40
Bash Narwhal
# Put this at the end of ~/.bashrc for a nice login narwhal
echo " . "
echo " # "
echo " % "
echo " % "
echo " &&&&%&%% "
echo " #%#&& ,(((##%@@ "
echo " #&#&%(#(#, .,*/(/////( "
echo " @&&&@((#%/*****//(//////* "
echo " .@&&%%(/#&&#&@#//(((/////// "
def jax_curve_fit(f, xdata, ydata, p0):
"""
Curve fit using jax. Similar interface to scipy.optimize.curve_fit
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html
"""
def logprob_fun(params, inputs, targets):
preds = f(inputs, *params)
return jnp.sum((preds - targets)**2)
@patrickmineault
patrickmineault / downsample.py
Created December 28, 2020 19:37
Downsample a stack of 2d images in PyTorch
def downsample_2d(X, sz):
"""
Downsamples a stack of square images.
Args:
X: a stack of images (batch, channels, ny, ny).
sz: the desired size of images.
Returns:
The downsampled images, a tensor of shape (batch, channel, sz, sz)
@patrickmineault
patrickmineault / place_things.lua
Last active June 23, 2020 04:57
Place things
--Made by a completely reasonable person for 100% legitimate reasons.
obs = obslua
screen = ""
webcam = ""
-- A very useful debug method
function log(message)
obs.script_log(obs.LOG_INFO, message)
end
@patrickmineault
patrickmineault / timezone_options.html
Last active June 19, 2020 16:22
Timezone options
<select id="timezone"><option value="Etc/GMT+12">(GMT-12:00) International Date Line West</option><option value="Pacific/Midway">(GMT-11:00) Midway Island, Samoa</option><option value="Pacific/Honolulu">(GMT-10:00) Hawaii</option><option value="America/Juneau">(GMT-08:00) Alaska</option><option value="America/Dawson">(GMT-07:00) Pacific Time (US and Canada); Tijuana</option><option value="America/Phoenix">(GMT-07:00) Arizona</option><option value="America/Belize">(GMT-06:00) Central America</option><option value="America/Boise">(GMT-06:00) Mountain Time (US and Canada)</option><option value="America/Chihuahua">(GMT-06:00) Chihuahua, La Paz, Mazatlan</option><option value="America/Regina">(GMT-06:00) Saskatchewan</option><option value="America/Bogota">(GMT-05:00) Bogota, Lima, Quito</option><option value="America/Chicago">(GMT-05:00) Central Time (US and Canada)</option><option value="America/Mexico_City">(GMT-05:00) Guadalajara, Mexico City, Monterrey</option><option value="America/Caracas">(GMT-04:00) Caraca