Skip to content

Instantly share code, notes, and snippets.

View Swexti's real colorscheme.yml
# Real colorscheme for
# Purportedly, the dotfile is from here:
# But these are not the same as the screenshot in the post.
# The following colorscheme is colorpicked from the screenshot
# Default colors
background: '#F4F5F8'
foreground: '#464658'
Palpatineli / serve
Created January 18, 2022 17:27
get host ip and start server
View serve
HOST_IP=`nslookup $HOST_NAME | awk /Address:\ [-.0-9]/ | awk -F\ '{print $NF}'`
if [ $# -eq 0 ]
View tmux-powerline.conf
set-option -g visual-activity off
set-option -g visual-bell off
set-option -g visual-silence off
set-window-option -g monitor-activity off
set-option -g bell-action none
# The window modes {
setw -g mode-style bg="black",fg="red",bold
# }
Palpatineli /
Created July 29, 2020 18:33
cumulative annual return
from collections import deque
import numpy as np
def cumulative_return(x: np.ndarray) -> np.ndarray:
"""Calculate the cumulative annual return from monthly fluctuations
x: an 1D array, each item is a float showing proportion of change of investment in that month
an 1D array, each item is the annual rate of change (return) for the 12 previous months
Palpatineli /
Created April 22, 2020 21:43
common pca: stepwise algorithm to find the nth common principle components
import numpy as np
from scipy.linalg import eigh
def cpca(cov: np.ndarray, sample_n: np.ndarray, comp_n: int = 0, tol: float = 1E-6,
max_iter: int = 1000) -> np.ndarray:
cov: 3D array where the last 2 axes are covariance matrices.
sample_n: for each covariance, how many samples were in there.
Palpatineli /
Created July 25, 2019 22:11
Diagonal Distribution for a scatterplot in matplotlib
from typing import Optional, List
import numpy as np
from scipy.stats import gaussian_kde
from matplotlib.axes import Axes
from matplotlib.transforms import Affine2D
import matplotlib.pyplot as plt
from mpl_toolkits.axisartist.floating_axes import GridHelperCurveLinear, FloatingSubplot
HISTOGRAM_RATIO = 0.2 # length vs. height ratio of the histogram
View gist:2ab6add658b5dc5014fd8bff7762e8e0
let hintcharacters = "asdfghjkl;"
map d closeTab
map u lastClosedTab
map <C-o> goBack
map <C-i> goForward
let searchalias w = "wikipedia"
let searchalias s = "scholar"