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
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 / upstream.md
Last active December 11, 2023 07:44
[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.

@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
public static boolean[][] deepCopy(boolean[][] original) {
if (original == null) {
return null;
}
final boolean[][] result = new boolean[original.length][];
for (int i = 0; i < original.length; i++) {
result[i] = Arrays.copyOf(original[i], original[i].length);
// For Java versions prior to Java 6 use the next:
// System.arraycopy(original[i], 0, result[i], 0, original[i].length);

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