Skip to content

Instantly share code, notes, and snippets.

@gavxin
gavxin / readme
Created January 23, 2018 13:25
Get latest gn.exe windows binary from google chromium project.
- From chromium source, find `gn.exe.sha1` file and get content of file. You can search at https://cs.chromium.org with `file:gn.exe.sha1` .
- The content is something like `c0d03f78af494365ff38c663297a20fe61da29ea`,
download file from url `https://storage.googleapis.com/chromium-gn/<content of file>`, like
`https://storage.googleapis.com/chromium-gn/c0d03f78af494365ff38c663297a20fe61da29ea` and rename the downloaded file to `gn.exe`
@gavxin
gavxin / gist:a21128ba0fba006db285c962da941898
Created December 13, 2024 08:33
install python3.13 on CentOS7
sudo yum install devtoolset-11-gcc\*
sudo yum install ncurses-devel openssl11 openssl11-devel readline readline-devel lzma-sdk lzma-sdk-devel xz-devel
# download python
wget https://www.python.org/ftp/python/3.13.1/Python-3.13.1.tgz
tar xzvf Python-3.13.1.tgz
cd Python-3.13.1
# configure
# patch openssl
@gavxin
gavxin / gist:15e35935a220674363b31d2379345aea
Created March 31, 2025 04:16
pre-commit black for other file type
solution: just add `types_or: [file]`
```
- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
name: black for your file type
types_or: [file]
files: \.your_file_type$
@gavxin
gavxin / convert_to_utf8.py
Created November 24, 2015 03:49
notepad++ python script plugin script for convert files to UTF8 encoding and Unix EOL.
#-*- encoding:gb2312 -*-
#
# Notepad++ Python script plugin script.
# For converting file encoding & lineending.
#
import os;
import sys;
filter_exts = [".h", ".cpp", ".c"]
SC_CP_UTF8 = 65001
SC_EOL_LF = 2
@gavxin
gavxin / progress_bar.rs
Created January 24, 2024 14:46
bevy ui simple ProgressBar
use bevy::{ecs::system::Command, prelude::*};
pub struct ProgressBarPlugin;
impl Plugin for ProgressBarPlugin {
fn build(&self, app: &mut App) {
app.register_type::<ProgressBarValues>()
.add_systems(Update, progress_bar_system);
}
}
@gavxin
gavxin / init.lua
Last active June 19, 2023 09:20
neovim config
-- Please place this file to following location
-- ~/.config/nvim/init.lua on Mac, Linux
-- ~/AppData/Local/nvim/init.lua on Windows
--------------------------------------------------------------
-- basic configs
vim.o.ignorecase = true
vim.o.smartcase = true
vim.o.expandtab = true
vim.o.tabstop = 2
vim.o.shiftwidth = 2
@gavxin
gavxin / genlib.bat
Created June 10, 2015 04:13
Generate import library file from dll
REM
REM Generate import library file from dll
REM
REM based on http://stackoverflow.com/questions/9946322/how-to-generate-an-import-library-lib-file-from-a-dll
REM
REM Please run in VS Command Prompt. needs dumpbin.exe and lib.exe.
@echo off
if "%~1"=="" goto usage
@gavxin
gavxin / wt.reg
Created July 11, 2022 16:50
add shell shortcut menu for windows terminal
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\background\shell\wt]
@="通过 Windows Terminal 打开"
"Icon"="C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminal_1.13.11431.0_x64__8wekyb3d8bbwe\\WindowsTerminal.exe"
[HKEY_CLASSES_ROOT\Directory\background\shell\wt\command]
@="wt -d \"%V\""
@gavxin
gavxin / main.cpp
Last active December 4, 2018 15:41
USB storage device plug event detection.
#include <Windows.h>
#include <Dbt.h>
#include "resource.h"
INT_PTR CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam) {
switch (uMsg) {
case WM_DEVICECHANGE:
PDEV_BROADCAST_HDR pHdr = (PDEV_BROADCAST_HDR)lParam;
switch (pHdr->dbch_devicetype) {
@gavxin
gavxin / batch_compile.bat
Created December 1, 2018 06:07
Abseil-cpp cmake batch complation.
@ECHO OFF
SET VCVARSALL="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat"
cmd /c compile_one.bat x86 d md
cmd /c compile_one.bat x86 r md
cmd /c compile_one.bat x64 d md
cmd /c compile_one.bat x64 r md