Skip to content

Instantly share code, notes, and snippets.

View rlee287's full-sized avatar

Ryan Lee rlee287

  • 17:40 (UTC -04:00)
View GitHub Profile
@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>>,
@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 / 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 / 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 / plot_entropy_linux.py
Created September 28, 2018 15:04
A python script to matplotlib plot the estimated entropy of a system
import matplotlib.dates
import pylab as plt
import numpy as np
from datetime import datetime
def get_entropy():
with open("/proc/sys/kernel/random/entropy_avail","r") as fil:
res=fil.read()
return int(res)
@rlee287
rlee287 / feca_hdr.py
Created July 28, 2018 02:43
An updated version of the GIMP Ferenc Kalman (feca) HDR plugin, tested with GIMP 2.10
#!/usr/bin/env python
# Gimp-Python - allows the writing of Gimp plugins in Python.
# Copyright (C) 2007 Kalman, Ferenc <fkalman@index.hu>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
@rlee287
rlee287 / deploy_tag.sh
Last active March 17, 2018 04:56
FRC Tag Deploy Script
#!/bin/sh
if [ $# -lt 1 ]; then
echo "Usage: $0 <name of tag>"
exit
fi
git add --all
git diff --staged --quiet
hasdiff=$?
if [ $hasdiff -eq 0 ]; then
echo "No changes exist on the index"
@rlee287
rlee287 / noiseless.png
Last active April 15, 2017 21:01
The effect of noise on numerical integration
noiseless.png
@rlee287
rlee287 / nbody.c
Created March 12, 2017 16:59
LLVM bug report
/* The Computer Language Benchmarks Game
* http://benchmarksgame.alioth.debian.org/
*
* contributed by Christoph Bauer
* slightly sped up by Petr Prokhorenkov
*
* Taken from https://github.com/cythonbook/examples (04-nbody 03-pure-c)
*/
#include <math.h>
@rlee287
rlee287 / Alabaster.html
Last active December 29, 2016 03:22
Alabaster footer vs default footer
{%- block footer %}
<div class="footer">
{% if show_copyright %}&copy;{{ copyright }}.{% endif %}
{% if theme_show_powered_by|lower == 'true' %}
{% if show_copyright %}|{% endif %}
Powered by <a href="http://sphinx-doc.org/">Sphinx {{ sphinx_version }}</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster {{ alabaster_version }}</a>
{% endif %}
{%- if show_source and has_source and sourcename %}
{% if show_copyright or theme_show_powered_by %}|{% endif %}