Skip to content

Instantly share code, notes, and snippets.

View luiarthur's full-sized avatar

Arthur Lui luiarthur

View GitHub Profile
@luiarthur
luiarthur / vimrc
Last active March 12, 2023 19:40
Basic vimrc for native windows.
" Place in ~/vimfiles/vimrc, on native Windows OS (not WSL).
" Basic setup to remove.
set number
set mouse=a
set autoindent
set showtabline=2
set clipboard=unnamed
set t_Co=256
@luiarthur
luiarthur / git-uncommit
Last active February 16, 2023 02:53
Undo the last commit and add, keeping the changes so they can be stashed.
#!/bin/bash
# Usage:
# Undo the last commit by:
# > git uncommit
# Installation:
# 1. Put this file in `~/bin/git-uncommit`
# 2. `chmod +x ~/bin/git-uncommit`
@luiarthur
luiarthur / git-fire
Last active February 16, 2023 02:53
Save everything in case of an emergency
#!/bin/bash
# Usage:
# In case of emergency, IF POSSIBLE, run
# > git fire
#
# Unsaved changes will be saved and pushed to a new branch named:
# $USER/fire/some-long-hash
#
# Optionally, a name can be provided, e.g.
@luiarthur
luiarthur / kernel_regression.py
Last active February 16, 2023 02:52
Kernel Regression
import numpy as np
from scipy.spatial import KDTree
import matplotlib.pyplot as plt
# Color map.
cmap = plt.get_cmap("bwr")
# True surface.
def f(X):
return np.cos(X[:, 0] * 10) + np.sin(X[:, 1] * 10) * 2
@luiarthur
luiarthur / benchmark-ad.jl
Created November 9, 2022 00:20
Automatic Differentiation Benchmarks
# Comparing AD backends.
# - Zygote, ForwardDiff, ReverseDiff, Complex-step differentiation
using ForwardDiff, ReverseDiff, Zygote, Tracker
using StatsFuns
using Random
using ProgressMeter
using BenchmarkTools
import LinearAlgebra.I as eye
@luiarthur
luiarthur / ordered-knn.ipynb
Created October 26, 2022 16:48
Order K nearest neighbors, for Vecchia
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@luiarthur
luiarthur / .condarc
Created October 3, 2022 18:52
My `~/.condarc`
auto_activate_base: true
auto_stack: 1
@luiarthur
luiarthur / .lintr
Created September 28, 2022 19:51
My global `~/.lintr`
linters: linters_with_defaults(
assignment_linter = NULL
)
@luiarthur
luiarthur / seaborn-demo.py
Created September 22, 2022 22:53
Seaborn plots
import numpy as np
import matplotlib.pyplot as plt
with sns.axes_style("darkgrid"), sns.plotting_context("talk", font_scale=1.2):
plt.plot(np.random.randn(100))
plt.show()
@luiarthur
luiarthur / ess-multi-modal.ipynb
Created September 22, 2022 21:10
ESS for multi-modal model
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.