Skip to content

Instantly share code, notes, and snippets.

View rlee287's full-sized avatar

Ryan Lee rlee287

  • 04:06 (UTC -07:00)
View GitHub Profile
@rlee287
rlee287 / gram_schmidt.py
Created December 9, 2018 00:54
Gram Schmidt process on np.ndarray vectors
#DISCLAIMER: Gram-Schmidt is numerically unstable. Use np.linalg.qr if you actually need to calculate an orthonormal basis.
def proj(vec,u):
return np.dot(u,vec)/np.dot(u,u)*u
def gram_schmidt(*vectors):
retlist=list()
for vec in vectors:
vec_calc=np.copy(vec)
for exist_vec in retlist:
vec_calc=vec_calc-proj(vec,exist_vec)
@rlee287
rlee287 / vimrc
Created April 15, 2019 03:08
dotfiles
" Setting some decent VIM settings for programming
ru! defaults.vim
set ai " set auto-indenting on for programming
set showmatch " automatically show matching brackets. works like it does in bbedit.
set vb " turn on the "visual bell" - which is much quieter than the "audio blink"
set ruler " show the cursor position all the time
set laststatus=2 " make the last line where the status is two lines deep so you can see status always
set backspace=indent,eol,start " make that backspace key work the way it should
@rlee287
rlee287 / config_toml.patch
Last active January 22, 2022 22:03
rustc build comparison notes
--- config.toml.example 2022-01-04 02:07:27.613408300 +0000
+++ config.toml 2022-01-04 02:15:02.840182900 +0000
@@ -248,14 +248,14 @@
#locked-deps = false
# Indicate whether the vendored sources are used for Rust dependencies or not
-#vendor = false
+vendor = true
# Typically the build system will build the Rust compiler twice. The second
@rlee287
rlee287 / once_storage.rs
Last active December 21, 2023 01:21
Proposed OnceStorage for `oncecell::race`
use core::sync::atomic::{Ordering, AtomicU32};
use core::mem::MaybeUninit;
use core::cell::UnsafeCell;
use core::hint::spin_loop;
use core::convert::Infallible;
/// A thread-safe cell which can only be written to once.
pub struct OnceStorage<T> {
/// The actual storage of the stored object
data_holder: UnsafeCell<MaybeUninit<T>>,
#!/bin/sh
# This commit-msg git hook enforces the author of a commit signing off on it when not on a branch that contains the word "throwaway".
SIGNOFF_LINE=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
echo "Checking for line $SIGNOFF_LINE"
# Check if signoff line is present
if ! grep -qs "^$SIGNOFF_LINE" "$1"; then
# If line is not present, check if we're on a branch with "throwaway" in it