Skip to content

Instantly share code, notes, and snippets.

View hackjutsu's full-sized avatar
:octocat:
building something great

CosmoX hackjutsu

:octocat:
building something great
View GitHub Profile
@hackjutsu
hackjutsu / tmux_cheatsheet.sh
Created November 30, 2025 20:34
[tmux snippets] useful #tmux snippets
# start a new session
tmux new -s mysession
# detach (leave it running in background)
Ctrl+b d
# start a program in a new tmux
tmux new -s <session> -d '<command to execute in shell>'
tmux new -s mysession -d 'uvicorn app.main:app --host 0.0.0.0 --port 8000'
@hackjutsu
hackjutsu / github-auth-with-gh.md
Last active November 30, 2025 19:22
[GitHub Authentication] How to authenticate Git to push changes to #GiHub with #gh

As I kept running into GitHub auth issues on each new local setups, I documented the steps here.

This gist documents how to set up your local dev env, especially on a headless Ubuntu machine, to push local Git changes to remote GitHub repositories.

It features

  • fine-grained auth token
  • headless env, e.g. remote ubuntu dev machine, where browser-based auth does not work well

Generate a personal access token in GitHub UI

To acquire the permission to push local changes to the remoate GitHub repos.

@hackjutsu
hackjutsu / upstream.md
Last active June 17, 2025 13:33
[set upstream] What does '--set-upstream' do? #tags: git
git branch --set-upstream-to <remote-branch>
# example
git branch --set-upstream-to origin feature-branch

# show up which remote branch a local branch is tracking
git branch -vv

sets the default remote branch for the current local branch.

A new Deployment will take effect when it's applied.

kubectl apply -f deployment.yaml
kubectl get deployment myapp-deployment # to verify the deployment

The kubectl apply command and the kubectl rollout command serve different purposes in managing deployments in Kubernetes.

kubectl apply

  • Primary Use: The kubectl apply command is used to create or update resources in a Kubernetes cluster. It takes a configuration file (usually in YAML format) and applies it to the cluster. This is the command you use to initially create objects like Deployments, Services, ConfigMaps, etc., or to apply changes to them.
@hackjutsu
hackjutsu / disable-usb-auto-suspension-in-ubuntu.sh
Last active December 26, 2023 03:48
[Disable USB power auto suspension] This gist disables the default auto usb power suspension in modern #Ubuntu system. This makes sure the USB mouse and keyboard can be recognized when (re)plugged in under various circunstances.
sudo vi /etc/udev/rules.d/92-usb-input-no-powersave.rules
# with content: ACTION=="add", SUBSYSTEM=="input", TEST=="power/control", ATTR{power/control}="on"
# reboot
# how this works
# When you connect an input device, such as a keyboard or mouse, to your system, udev triggers various rules.
# If the connected device is recognized as part of the input subsystem and has a power/control attribute, this
# rule will set that attribute to "on", effectively disabling USB autosuspend for that device.
@hackjutsu
hackjutsu / lepton.md
Last active December 9, 2023 18:21
[Lepton -- 打造GitHub千星项目的经验分享] #tags: lepton
@hackjutsu
hackjutsu / gai.config
Last active November 6, 2023 15:43
[IPv4 over IPv6 on Ubuntu] Solved the issue when connecting to archive.ubuntu.com takes too long. Edit /etc/gai.conf and uncomment line 4, which lets you keep IPv6 enabled, but sets the order of precedence to prefer IPv4 over IPv6. (http://askubuntu.com/a/354886) #tags: ubuntu, bittiger
#
# For sites which prefer IPv4 connections change the last line to
#
precedence ::ffff:0:0/96 100
@hackjutsu
hackjutsu / test.c
Created January 23, 2023 05:34
[test C highlighting] #test
int func(int N, int M)
{
float (*p)[N][M] = malloc(sizeof *p);
if (!p)
return -1;
for (int i = 0; i < N; i++)
for (int j = 0; j < M; j++)
(*p)[i][j] = i + j;
print_array(N, M, p);
free(p);
@hackjutsu
hackjutsu / .leptonrc
Last active December 7, 2022 01:01
[Template for .leptonrc] This is a template for Lepton's configuration file. Please place it on your home directory. #lepton
{
"theme": "light",
"autoUpdate": false,
"snippet": {
"expanded": true,
"newSnippetPrivate": false,
"sorting": "updated_at",
"sortingReverse": true
},
"editor" : {
@hackjutsu
hackjutsu / example.js
Last active November 16, 2022 14:16
[Highlight.js + line number] This snippet adds line number support to Highlight.js. Besides, special css trick is applied to stop the line numbers from being selected and copied. #tags: highlight, lepton
import HighlightJS from 'highlight.js'
createHighlightedCodeBlock (content, language) {
let lineNumber = 0
const highlightedContent = HighlightJS.highlightAuto(content, [language]).value
/* Highlight.js wraps comment blocks inside <span class="hljs-comment"></span>.
However, when the multi-line comment block is broken down into diffirent
table rows, only the first row, which is appended by the <span> tag, is
highlighted. The following code fixes it by appending <span> to each line