Skip to content

Instantly share code, notes, and snippets.

# from https://unix.stackexchange.com/a/740187/580914
# add to your .bashrc:
## cdf -- cd to frequent directories
function cdf() {
# Use awk to extract the directories from the history, using null characters as the separator
DIRS=$(history | tr '\n' '\0' | awk -v RS='\0' '$2 == "cd" && !/\$DIR/ { $1=""; $2=""; sub("^[[:space:]]*", ""); print }' | grep -v -P -C 5 'cd.*$DIR' | sort | uniq -c | sort -rn | head -n 12 | awk '{$1=""; sub("^[[:space:]]*", ""); print }')
# Filter out directories that don't exist and parent directories
VALID_DIRS=()
" Lua 跳转到函数定义 {
fun! GotoLuaFuncDifinition()
let w = expand("<cword>")
exec "Rg \\b" . l:w . "\\b"
exec "norm! gg"
let rr = search("| function\\>", 'c')
if !rr
exec "cclose"
echo "search FAILED for " . l:w
return
" 清理 Lua 文件头多余的 local 赋值语句 TidyLuaHeadStatements {
fun! IsLuaLocalAssignStatement()
return getline(".") =~ '^local\s\+\S\+\s*='
endfun
fun! IsNecessaryLuaAssignment()
let v1 = line('.')
silent! exe "norm! #"
let v2 = line('.')
@xebecnan
xebecnan / bit_array.lua
Created August 25, 2022 03:09
bit array implemented in Lua
local M = {}
local BITS_PER_BYTE = 8
local BYTES_PER_INT = string.packsize('j')
local BITS_PER_INT = BITS_PER_BYTE * BYTES_PER_INT
function M.get_bit(h, i)
local index = i // BITS_PER_INT
local v = h[index]
if not v then
@xebecnan
xebecnan / EasingFunctions.cs
Created March 9, 2020 07:03 — forked from cjddmut/EasingFunctions.cs
Easing Functions for Unity3D
/*
* Created by C.J. Kimberlin
*
* The MIT License (MIT)
*
* Copyright (c) 2019
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
public static class SimpleCSVParser {
static List<List<string>> ParseCSV(string text) {
var list = new List<List<string>>();
List<string> row = null;
var sb = new StringBuilder();
int i = 0;
while (i < text.Length) {
var c = text[i++];
if (c == '"') {
@xebecnan
xebecnan / reload_adb_devices.py
Created January 6, 2018 03:37
reload_adb_devices.py
#!/usr/bin/python
import re
import sys
from subprocess import Popen, PIPE, STDOUT
def print_lines(tag, lines):
lines = str(lines).splitlines()
n = len(tag)
n += (4 - (n % 4)) % 4
nmap <silent> -we :silent !explorer /select,"%"<CR>
nmap <silent> -wr :!start cmd<CR>
nmap <silent> -nn :tabnew %<CR>
nmap <silent> zfc ggVG"+y
nmap <silent> zfv ggVG"+P
@xebecnan
xebecnan / .vimrc
Created December 28, 2016 08:06 — forked from lvzixun/.vimrc
"HYDRA : OPEN LR UI RES EDITOR {
nmap <C-k> yiw:silent !call-hydra.sh <C-r>"<CR>
"}
"HYDRA : OPEN LR UI RES EDITOR {
nmap <C-k> yiw:silent !call-hydra.sh <C-r>"<CR>
"}