Skip to content

Instantly share code, notes, and snippets.

@allenk
allenk / testfile.sh
Created January 29, 2024 02:16
Recognize file headers and rename file extensions
#!/bin/bash
# test all files
for file in *; do
if [ -f "$file" ]; then
# read first 3 bytes
bytes=$(head -c 3 "$file" | od -An -t x1 | tr -d ' \n')
# test file bytes
case $bytes in
@allenk
allenk / deepclean.cmd
Last active May 2, 2024 07:45
ASUS Software Clean Up Tool
@echo off
:: ------------------------------------------------------------------------------------------------------------
:: Clean Up ASUS All
:: ------------------------------------------------------------------------------------------------------------
:: The tool helps to clean up all ASUS software from system
:: ------------------------------------------------------------------------------------------------------------
:: Before running the tools,
:: 1. Complete backup your system.
:: 2. Disable ASUS Apps from BIOS (MyASUS and Armoury)
:: 3. Run ASUS remove tools (Armoury Crate Uninstall Tool.exe, or geek_uninstall.exe).
@allenk
allenk / mybackup_restore.cmd
Created April 8, 2023 23:02
Move Files and Log
@echo off
:: ------------------------------------------------------------------------------------------------------------
:: Backup Package Installation
:: ------------------------------------------------------------------------------------------------------------
:: You should check errors from logs with 資料錯誤 (循環冗餘檢查)
echo Backup packages ... kwyshell@gmail.com
setlocal enabledelayedexpansion
:: backup package list
@allenk
allenk / solution.txt
Created April 6, 2023 03:24 — forked from Jacob-Tate/solution.txt
windows: 0x800705b4
Error:
After installing this update, users may experience this error "0x800705b4" when launching windows defender application guard or windows sandbox
Fix:
Use the credentials of a local admin to create and set the following registry keys on the host OS then restart the host.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Containers\CmService\Policy]
"DisableClone"=dword:00000001
"DisableSnapshot"=dword:00000001
@allenk
allenk / code_style.md
Created February 23, 2023 11:12 — forked from jesseschalken/code_style.md
Code style

My preferred code style is 2-space K&R. This is intended to provide a justification for this style.

Why K&R?

K&R style has the following properties:

  1. Provides symmetric size (in terms of screen space consumed) between the opening and closing syntax of a clode block.
  2. Forces no empty or meaningless lines, thereby avoiding artificial distance between related things that should be together.
  3. Consumes the minimum vertical space while keeping the opening and closing syntax of a block on separate lines from the content.
@allenk
allenk / fix_wsl_fs.sh
Created October 24, 2022 10:06
Fixed WSL2 soft link when using NTFS.
#!/bin/bash
# Allen Kuo, TEE soft-link fix for WSL2. (see my OneNote, Notion)
# echo "Bash version ${BASH_VERSION}..."
# define targets
#targets=(folder1 folder2 folder3 folder4)
targets=(myfolder)
# target start
start=1
@allenk
allenk / compile_git.md
Created January 1, 2022 00:11 — forked from samrocketman/compile_git.md
Compiling git

The version of git that comes with RHEL6 is very old. I'll outline steps for compiling the latest git version on RHEL6. Working from /usr/local/src.

Following instructions for Git Pro book Getting Started Installing Git.

Prerequisites

yum install gcc curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker

Optional man page prereqs.

@allenk
allenk / libevent-v-libuv.md
Created December 9, 2021 13:40 — forked from eddieh/libevent-v-libuv.md
libevent vs libuv

libevent vs libuv

Comparing libevent and libuv. My upfront biased: I want to like libevent. However, I want to objectively compare the two and make an informed decision.

What versions are we comparing?

  • libevent 2.0.22 (Stable) [2014-01-05]
  • libuv 1.8.0 (Stable) [2015-12-15]
@allenk
allenk / delete_git_submodule.md
Created August 11, 2020 14:33 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@allenk
allenk / YUV420PGrabber.cpp
Last active March 24, 2020 19:13 — forked from roxlu/YUV420PGrabber.cpp
OpenGL RGB > YUV420P shader/class (doesn't do much more. implementation/usage is up to you)
#include <assert.h>
#include <roxlu/core/Utils.h>
#include <roxlu/core/Log.h>
#include "YUV420PGrabber.h"
YUV420PGrabber::YUV420PGrabber()
:y_prog(0)
,y_vert(0)
,y_frag(0)
,uv_prog(0)