Skip to content

Instantly share code, notes, and snippets.

View nghnam's full-sized avatar
🎯
Focusing

Nguyen Hoang Nam nghnam

🎯
Focusing
View GitHub Profile
@nghnam
nghnam / fatal
Created February 28, 2024 15:30
fatal
fatal error: all goroutines are asleep - deadlock!
goroutine 1 [semacquire]:
sync.runtime_Semacquire(0xc00006a0c0?)
/usr/local/go/src/runtime/sema.go:62 +0x25
sync.(*WaitGroup).Wait(0xc00006c180?)
/usr/local/go/src/sync/waitgroup.go:116 +0x48
main.readFileLineByLineIntoAMap({0x7ffc80a97569, 0x10})
/home/namnh/workspace/1brc-go/main.go:176 +0x346
main.evaluate({0x7ffc80a97569?, 0xc000014070?})
cache:
paths:
- .cache/pip
- /root/.cache/trivy # used to cache trivy DB
build image:
stage: build
script:
- docker build . --tag "$IMAGE_NAME"
only:
@nghnam
nghnam / namespaces.yaml
Created February 21, 2020 03:24
list all namespaces
{{- range .Values.namespaces }}
---
apiVersion: v1
kind: Namespace
metadata:
name: {{ .name }}
{{- if .labels }}
labels:
{{- range $key, $value := .labels }}
{{ $key }}: {{ $value | quote }}
@nghnam
nghnam / values.yaml
Last active February 21, 2020 03:19
Helm values.yaml
# YAML anchor
privateRegCred: &privateRegCred |
{
"auths": {
"private-registry.local": {
"username": "admin",
"password": "private-registry-password"
}
}
}
@nghnam
nghnam / kong.tf
Last active February 14, 2020 06:42
Use terraform to manage Kong
provider "kong" {
kong_admin_uri = "http://192.168.1.100:8001"
}
variable "kong_admin_url" {
description = "Kong admin api"
default = "http://192.168.1.100:8001"
}
variable "example-user" {
# /lib/systemd/system/switcher.service
[Unit]
Description=Switcher service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=5
#!/bin/bash -e
# Usage ./k8s-service-account-kubeconfig.sh ( namespace ) ( service account name )
TEMPDIR=$( mktemp -d )
trap "{ rm -rf $TEMPDIR ; exit 255; }" EXIT
SA_SECRET=$( kubectl get sa -n $1 $2 -o jsonpath='{.secrets[0].name}' )
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 88.5M 1 loop /snap/core/7270
loop2 7:2 0 88.4M 1 loop /snap/core/7169
sda 8:0 0 40G 0 disk
├─sda1 8:1 0 1M 0 part
└─sda2 8:2 0 40G 0 part /
sr0 11:0 1 1024M 0 rom
# echo 1 > /sys/class/block/sda/device/rescan
@nghnam
nghnam / chunk_upload.py
Created July 23, 2019 03:55 — forked from nbari/chunk_upload.py
python chunk upload files
#!/usr/bin/env python
import os
import requests
import uuid
from random import randint
from uuid import uuid4
def read_in_chunks(file_object, chunk_size=65536):
while True:
@nghnam
nghnam / poodir-notes.md
Created July 22, 2019 14:08 — forked from speric/poodir-notes.md
Notes From "Practical Object-Oriented Design In Ruby" by Sandi Metz

Chapter 1 - Object Oriented Design

The purpose of design is to allow you to do design later, and it's primary goal is to reduce the cost of change.

SOLID Design:

  • Single Responsibility Principle: a class should have only a single responsibility
  • Open-Closed Principle: Software entities should be open for extension, but closed for modification (inherit instead of modifying existing classes).
  • Liskov Substitution: Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
  • Interface Segregation: Many client-specific interfaces are better than one general-purpose interface.