Skip to content

Instantly share code, notes, and snippets.

@vizee
vizee / clean-vscode-server.sh
Created April 16, 2023 13:46
clean vscode server
#!/bin/bash
set -e
cd $HOME/.vscode-server
for f in $(ls -1 --sort=time .*.token | tail -n +2); do
id=${f:1:40}
if [[ -z "$id" ]]; then
echo "invalid file $f"
@vizee
vizee / km2md.go
Last active August 3, 2021 03:24
package main
import (
"encoding/json"
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"strings"
@vizee
vizee / bootstrap.rs
Last active April 27, 2021 05:59
terminal bootstrap
// rustc -O bootstrap.rs
use std::env;
use std::process::Command;
#[cfg(target_os = "windows")]
fn terminal() -> Command {
Command::new("msys2.exe")
.env("CHERE_INVOKING", "1")
}
@vizee
vizee / searchtag_amd64.s
Created March 20, 2020 16:31
search indirect tag by binary search
#include "textflag.h"
// func searchTag(m *Message, tag int) int
TEXT ·searchTag(SB), NOSPLIT, $0-24
MOVQ m+0(FP), BX
MOVQ tag+8(FP), R9
MOVQ 16(BX), DI
MOVQ 24(BX), CX
MOVQ 40(BX), SI
XORQ DX, DX
@vizee
vizee / treap.go
Created December 5, 2019 10:06
treap
package treap
type node struct {
key int
prior int
left *node
right *node
}
func zig(p *node) *node {
@vizee
vizee / appime.c
Last active October 9, 2020 10:50
hook Apps key to switch IME
/*
gcc -std=c99 -O3 -Wall -Werror \
-DUNICODE \
-o $@ $^ \
-lkernel32 -luser32 \
-Wl,--subsystem,windows,--gc-sections,--strip-all
*/
#include <windows.h>
#define WM_USER_SWITCH_IME (WM_USER + 1)
@vizee
vizee / dupfile.go
Created September 17, 2018 17:13
find duplicated file
package main
import (
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"encoding/hex"
"flag"
"fmt"
"io/ioutil"
@vizee
vizee / xxtea.go
Last active May 28, 2018 07:49
xxtea
package xxtea
import (
"unsafe"
)
const _DELTA = 0x9e3779b9
func EncryptBytes(m []byte, k *[4]uint32) {
if len(m) < 8 {
@vizee
vizee / enable-bbr.sh
Last active May 18, 2018 17:42
setup ss
if [ -z `lsmod | grep bbr` ]; then
modprobe tcp_bbr
echo "tcp_bbr" >> /etc/modules-load.d/modules.conf
fi
if [ -z `sysctl net.ipv4.tcp_congestion_control | grep bbr` ]; then
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p
fi
@vizee
vizee / lgb.sh
Created October 13, 2017 16:58
linux go build
#!/bin/bash
set -e
hook=
if [ "$1" == "-c" ]; then
hook=$2
shift 2
fi