Skip to content

Instantly share code, notes, and snippets.

View snsinfu's full-sized avatar
🕺
📆🍩🍩🍩📲

snsinfu snsinfu

🕺
📆🍩🍩🍩📲
View GitHub Profile
import matplotlib.pyplot as plt
import numpy as np
def main():
dimension = 7
subst = 0b101010 # Use this to coherently substitute vertex IDs
distortion = 0 # Increase this to mitigate vertex overlaps by distorting embedding
assert subst < 2 ** dimension
@snsinfu
snsinfu / rainbow.zsh
Created October 18, 2020 15:15
ZSH rainbow animated prompt
zmodload zsh/sched
rainbow_palette=(
196 202 208 214 220 226 226 190 154 82 46 46 47 48 49
50 51 45 39 33 27 21 21 57 129 165 201 201 200 199 198 197
)
rainbow_offset=0
rainbow_color:inc() {
local n=${#rainbow_palette}
@snsinfu
snsinfu / scatter_contour.py
Last active January 15, 2021 06:43
[matplotlib] Scatter with 2dhist contour
x_data, y_data = # Given
bins = np.linspace(-3, 3, num=30)
valid = ~(np.isnan(x_data) | np.isnan(y_data))
densities, xedges, yedges = np.histogram2d(x_data[valid], y_data[valid], bins=bins)
xcenters = (xedges[1:] + xedges[:-1]) / 2
ycenters = (yedges[1:] + yedges[:-1]) / 2
xmesh, ymesh = np.meshgrid(xcenters, ycenters, indexing="ij")
@snsinfu
snsinfu / smooth.py
Last active October 22, 2020 14:13
[numpy/scipy] Gaussian smoothing of (time, particle, dimension) signal along the time axis
def smooth(signal, window, sigma=3):
"""
Apply Gaussian FIR filter to signal.
"""
rank = len(signal.shape)
kernel = np.exp(-np.linspace(-sigma, sigma, num=window)**2 / 2)
kernel = kernel / np.sum(kernel)
kernel = kernel.reshape(kernel.shape + (1, ) * (rank - 1))
@snsinfu
snsinfu / mpi.hpp
Created September 16, 2020 15:22
MPI replica exchange
#ifndef REX_MPI
#define REX_MPI
#include <string>
#include <system_error>
#include <mpi.h>
namespace rex
{

Install wine

$ sudo dnf install wine wine-alsa wine-mono winetricks

Create wine environment

Create a 32-bit wine environment for sdvx:

@snsinfu
snsinfu / README.md
Last active July 26, 2020 07:55
Fedora: Install Visual Studio Code from Microsoft's RPM repository

VSCode on Fedora Linux

See: microsoft/vscode#229 (comment)

Import Microsoft's repository key:

$ cd /tmp
$ curl -fsSLO https://packages.microsoft.com/keys/microsoft.asc
$ sudo rpm --import microsoft.asc
#!/bin/bash
#PBS -W Shell_Path_List=/bin/bash
#PBS -N name
cd "${PBS_O_WORKDIR:-.}"
seed="${PBS_ARRAYID:-0}"
@snsinfu
snsinfu / ftplugin.vim
Created June 14, 2020 14:41
vim configuration to syntax-highlight <basename>.example as file type detected for <basename>
augroup filetypedetect
au BufNewFile ?\+.example exec "doau filetypedetect BufNewFile " . fnameescape(expand("<afile>:r"))
au BufRead ?\+.example exec "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r"))
augroup END
@snsinfu
snsinfu / 2020.profile
Created May 25, 2020 11:28
TeXLive 2020 profile
selected_scheme scheme-full
binary_x86_64-linux 1
instopt_portable 1
TEXDIR /opt/texlive/2020
TEXMFCONFIG $TEXMFSYSCONFIG
TEXMFVAR $TEXMFSYSVAR
TEXMFHOME $TEXMFLOCAL
TEXMFLOCAL /opt/texlive/2020/libexec/texmf-local
TEXMFSYSCONFIG /opt/texlive/2020/libexec/texmf-config