Skip to content

Instantly share code, notes, and snippets.


Wasin Thonkaew haxpor

View GitHub Profile
haxpor / caveat_getfuncname.vim
Created Aug 29, 2021
Implementation to get the current function in the current scope as of cursor position is in (with caveat)
View caveat_getfuncname.vim
" show the function name for the current position the cursor is in
" cursor needs to be embraced into the context of function
" CAVEAT: not work yet with macros
" CAVEAT: cursor outside of functions but inside a namespace will return upper
" function scope, not the namespace scope
function! ShowFuncNameC_CPP()
let lnum = line(".")
let col = col(".")
let is_found = 0
echohl ModeMsg
haxpor / lightline_WhatFunction.patch
Created Aug 28, 2021
patch for vim lightline (at bb0b401) be fix its non-updated col when use vim script to get function name
View lightline_WhatFunction.patch
diff --git a/autoload/lightline.vim b/autoload/lightline.vim
index 2076a11..6aab48f 100644
--- a/autoload/lightline.vim
+++ b/autoload/lightline.vim
@@ -106,7 +106,7 @@ let s:_lightline = {
\ 'paste': '%{&paste?"PASTE":""}', 'readonly': '%R', 'charvalue': '%b', 'charvaluehex': '%B',
\ 'spell': '%{&spell?&spelllang:""}', 'fileencoding': '%{&fenc!=#""?&fenc:&enc}', 'fileformat': '%{&ff}',
\ 'filetype': '%{&ft!=#""?&ft:"no ft"}', 'percent': '%3p%%', 'percentwin': '%P',
- \ 'lineinfo': '%3l:%-2v', 'line': '%l', 'column': '%c', 'close': '%999X X ', 'winnr': '%{winnr()}'
+ \ 'lineinfo': '%3l:%-2{col(".")}', 'line': '%l', 'column': '%c', 'close': '%999X X ', 'winnr': '%{winnr()}'
haxpor / gist:dd192e03104e67ef9f473c78ec8b2081
Created Aug 15, 2021
Result from objdump of linux module which didn't use `module_init()/module_exit()`, and the one that use it.
View gist:dd192e03104e67ef9f473c78ec8b2081
haxpor@haxpor-desktop:.../Projects/kern_st/hello-1$ objdump -Tt hello-1.ko
hello-1.ko: file format elf64-x86-64
objdump: hello-1.ko: not a dynamic object
0000000000000000 l d 0000000000000000
0000000000000000 l d .note.Linux 0000000000000000 .note.Linux
0000000000000000 l d .text 0000000000000000 .text
0000000000000000 l d .text.unlikely 0000000000000000 .text.unlikely
haxpor / hello-1.c
Last active Aug 14, 2021
strace for insmod, and rmmod of a simple kernel module. Executed with `sudo strace -v insmod <.ko-file>` and vice-versa.
View hello-1.c
## insmod
execve("/usr/sbin/insmod", ["insmod", "hello-1.ko"], ["COLORTERM=truecolor", "LC_ADDRESS=en_US.UTF-8", "LC_NAME=en_US.UTF-8", "LC_MONETARY=en_US.UTF-8", "XAUTHORITY=/run/user/1000/gdm/Xa"..., "LC_PAPER=en_US.UTF-8", "LANG=en_US.UTF-8", "LS_COLORS=rs=0:di=01;34:ln=01;36"..., "TERM=screen-256color", "LC_IDENTIFICATION=en_US.UTF-8", "DISPLAY=:0", "LC_TELEPHONE=en_US.UTF-8", "LC_MEASUREMENT=en_US.UTF-8", "LC_TIME=en_US.UTF-8", "PATH=/usr/local/sbin:/usr/local/"..., "LC_NUMERIC=en_US.UTF-8", "MAIL=/var/mail/root", "LOGNAME=root", "USER=root", "HOME=/root", "SHELL=/bin/bash", "SUDO_COMMAND=/usr/bin/strace -v "..., "SUDO_USER=haxpor", "SUDO_UID=1000", "SUDO_GID=1000"]) = 0
brk(NULL) = 0x564213d1c000
arch_prctl(0x3001 /* ARCH_??? */, 0x7ffff1ceef80) = -1 EINVAL (Invalid argument)
access("/etc/", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_dev=makedev(0x103, 0x2), st_ino=16966, st_mode=
haxpor / cmake_v3.20.5_pdcurses_msvc.patch
Created Aug 8, 2021
Patch for compile both CMake and PDCurses with MSVC
View cmake_v3.20.5_pdcurses_msvc.patch
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a2fcf2e372..9d2a8f20da 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -656,15 +656,10 @@ macro (CMAKE_BUILD_UTILITIES)
- # Use curses?
- if (UNIX)
haxpor / cmake_v3.20.5_pdcurses.patch
Created Aug 8, 2021
Patch for CMake (v3.20.5) and PDCurses (3.9) for cross-compile with mingw64
View cmake_v3.20.5_pdcurses.patch
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a2fcf2e372..ae32ce17b8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -656,25 +656,12 @@ macro (CMAKE_BUILD_UTILITIES)
- # Use curses?
- if (UNIX)
haxpor /
Last active Aug 9, 2021
Guideline to cross-compile CMake that also includes ccmake for Windows on Ubuntu Linux

There are 3 attempts used

  1. Cross-compile CMake with mingw64 + pre-built mingw64 ncurses - See
  2. Cross-compile both CMake and pdcurses with mingw64 - See (Recommended)
  3. Natively compile CMake and pdcurses with MSVC - See

All above 3 attempts shared the common steps but still listing such shared content in each of its own guide for reference and clear guideline.


haxpor / cmake_mingw64_v3.20.5.patch
Last active Aug 8, 2021
Patch to compile CMake from source for specific version v3.20.5 via mingw64 to work with pre-built mingw64 of ncurses
View cmake_mingw64_v3.20.5.patch
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a2fcf2e372..4b78f9ee01 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -656,6 +656,9 @@ macro (CMAKE_BUILD_UTILITIES)
+ set(CURSES_INCLUDE_PATH "/usr/x86_64-w64-mingw32/include/ncursesw")
+ set(CURSES_LIBRARY "/usr/x86_64-w64-mingw32/lib/libncursesw.a;/usr/x86_64-w64-mingw32/lib/libformw.a")
haxpor / .config
Created Jun 6, 2021
From `cat /lib/modules/$(uname -r)/build/.config` while running with 5.8.0-50-generic kernel on Ubuntu 20.04. Official ubuntu kernel package.
View .config
# Automatically generated file; DO NOT EDIT.
# Linux/x86 5.8.0-50-generic Kernel Configuration
CONFIG_CC_VERSION_TEXT="gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0"
haxpor /
Created Mar 27, 2021
Script updated to make it work withROCm 4.1.x for Ubuntu 20.04 (tested with kernel 5.8.0-48). See context for older version at
# Original by tuxutku (
# Modified by haxpor (based also on older version tha work with ROcm 3.3 at
# This version with following changes
# - support ROCm 4.1.x for Ubuntu 20.04 (tested with kernel 5.8.0-48-generic)
# - improved to not re-download a driver package again unncessary
# - early exit with error if found error
# - refactor misc code