Skip to content

Instantly share code, notes, and snippets.

View hackjutsu's full-sized avatar

CosmoX hackjutsu

View GitHub Profile

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 /
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 / 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);
# installation: pip3 install wordcloud
wordcloud_cli --text mytext.txt --imagefile wordcloud.png
hackjutsu / test.graphql
Created May 31, 2021 21:02
[GraphQL test]
query {
resolution {
#define section-info
section {
parameters {
hackjutsu /
Created June 20, 2020 01:33
[Guava Retryer] Snippet for retrying by Guava Retryer
Callable<Boolean> callable = new Callable<Boolean>() {
public Boolean call() throws Exception {
return true; // do something useful here
Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder()
hackjutsu / test.bat
Created June 6, 2020 19:57
[test scirpt for batch]
for /l %%a IN (4,-1,0) do (
echo.%%a: First command in block
echo. Second command in block
if exist "c:\windows" (
echo.The c:\windows directory exist.
set "IsWin=YES"
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

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. From


The intuition behind this approach is that the area formed between the lines will always be limited by the height of the shorter line. Further, the farther the lines, the more will be the area obtained.

We take two pointers, one at the beginning and one at the end of the array constituting the length of the lines. Futher, we maintain a variable \text{maxarea}maxarea to store the maximum area obtained till now. At every step, we find out the area formed between them, update \text{maxarea}maxarea and move the pointer pointing to the shorter line towards the other end by one step.