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.

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 / 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);
# installation: pip3 install wordcloud
wordcloud_cli --text mytext.txt --imagefile wordcloud.png
@hackjutsu
hackjutsu / test.graphql
Created May 31, 2021 21:02
[GraphQL test]
query {
resolution {
....
#define section-info
section {
name
uniqueName
href
parameters {
key
@hackjutsu
hackjutsu / retryer.java
Created June 20, 2020 01:33
[Guava Retryer] Snippet for retrying by Guava Retryer https://github.com/rholder/guava-retrying
Callable<Boolean> callable = new Callable<Boolean>() {
public Boolean call() throws Exception {
return true; // do something useful here
}
};
Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder()
.retryIfResult(Predicates.<Boolean>isNull())
.retryIfExceptionOfType(IOException.class)
.retryIfRuntimeException()
@hackjutsu
hackjutsu / test.bat
Created June 6, 2020 19:57
[test scirpt for batch]
@ECHO OFF
for /l %%a IN (4,-1,0) do (
echo.%%a: First command in block
echo. Second command in block
)
echo.
if exist "c:\windows" (
echo.The c:\windows directory exist.
set "IsWin=YES"
@hackjutsu
hackjutsu / .zshrc
Created June 6, 2020 19:24
[my zsh configurations] #zsh
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/cosmoqiu/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes