Skip to content

Instantly share code, notes, and snippets.

@anhkind
anhkind / .wezterm.lua
Created April 8, 2026 12:51
Wezterm config for iTerm hotkey style
-- Pull in the wezterm API
local wezterm = require 'wezterm'
-- This will hold the configuration.
local config = wezterm.config_builder()
-- This is where you actually apply your config choices.
-- For example, changing the initial geometry for new windows:
config.initial_cols = 120
@anhkind
anhkind / steps.txt
Created April 6, 2026 07:55
Switch IDE / RAID to AHCI within Windows 10 without reinstallation
# from https://www.reddit.com/r/Ubuntu/comments/iu6gf9/comment/g5j12p3/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
1. While logged into Windows normally, click the Start Button and type cmd
2. Right-click the result and select Run as administrator
3. Type this command and press ENTER: bcdedit /set {current} safeboot minimal
4. Restart the computer and enter BIOS Setup
5. Change the SATA Operation mode to AHCI from either IDE or RAID
6. Save changes and exit Setup and Windows will automatically boot to Safe Mode.
7. While in Safe Mode, Right-click the Windows Start Menu once more. Choose Command Prompt (Admin).
8. Type this command and press ENTER: bcdedit /deletevalue {current} safeboot
@anhkind
anhkind / lzw_encoder.js
Created August 29, 2025 02:13 — forked from revolunet/lzw_encoder.js
LZW javascript compress/decompress
// LZW-compress a string
function lzw_encode(s) {
var dict = {};
var data = (s + "").split("");
var out = [];
var currChar;
var phrase = data[0];
var code = 256;
for (var i=1; i<data.length; i++) {
currChar=data[i];
@anhkind
anhkind / memorySizeOf.ts
Created August 13, 2025 03:06
Calculate Memory Size of a JS Object
function memorySizeOf(obj: any) {
const seen = new WeakSet<object>();
function sizeOf(value: any): number {
if (value === null || value === undefined) return 0;
const t = typeof value;
if (t === "number" ) return 8;
if (t === "boolean") return 4;
if (t === "bigint" ) return 8;
@anhkind
anhkind / load_dotenv.sh
Created July 6, 2025 10:26 — forked from mihow/load_dotenv.sh
Load environment variables from dotenv / .env file in Bash
# The initial version
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
# My favorite from the comments. Thanks @richarddewit & others!
set -a && source .env && set +a
@anhkind
anhkind / unix.md
Last active May 9, 2024 08:36
Unix misc
@anhkind
anhkind / wirerest_grafana_config.yml
Last active April 5, 2024 11:18
Wirerest dashboard on Grafana
# For Grafana dashboard: https://grafana.com/grafana/dashboards/19458-wireguard-wirerest-jvm/
# put these under `metrics.configs.scrape_configs`
- job_name: 'wirerest'
metrics_path: '/actuator/prometheus'
authorization:
credentials: YOUR_WIREREST_TOKEN
static_configs:
targets: ['YOUR_WIREREST_IP:8081']
@anhkind
anhkind / .profile
Last active January 22, 2024 07:18
Select git executable in WSL
# from: https://github.com/microsoft/WSL/issues/4401#issuecomment-670080585
# checks to see if we are in a windows or linux dir
function isWinDir {
case $PWD/ in
/mnt/*) return $(true);;
*) return $(false);;
esac
}
# wrap the git command to either run windows git or linux
@anhkind
anhkind / rerender.directive.ts
Created August 5, 2021 08:56
Angular directive to re-render a template if it detects any changes of the input
/**
* Example:
*
* <ng-container *rerender='changingInput'>
* this content will be re-rendered everytime `changingInput` changes
* </ng-container>
*/
import { Directive,
Input,
@anhkind
anhkind / yardoc_cheatsheet.md
Created April 9, 2020 07:17 — forked from phansch/yardoc_cheatsheet.md
Improved YARD cheatsheet