Skip to content

Instantly share code, notes, and snippets.

View manhdaovan's full-sized avatar

Vanmanh Dao manhdaovan

View GitHub Profile
@manhdaovan
manhdaovan / distributed-load-testing-on-aws.template
Created November 7, 2023 07:35
DLT on AWS _ Cloudformation template
Description: (SO0062) - Distributed Load Testing on AWS is a reference architecture to perform application load testing at scale. Version v3.2.3
AWSTemplateFormatVersion: "2010-09-09"
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Console access
Parameters:
- AdminName
- AdminEmail
@manhdaovan
manhdaovan / Dockerfile
Last active July 3, 2023 05:43
Testing graceful shutdown with PID != 1 in Docker container
FROM alpine:latest
WORKDIR /app
COPY . /app
ENTRYPOINT [ "ash", "entry.sh" ]
@manhdaovan
manhdaovan / goid.go
Created April 13, 2022 02:12
Simple approach to get Goroutine ID
var goroutineID uint64
// Go is a simple replacement for `go` keyword, but returns its ID.
// Go also passes the goroutine ID to function `f`.
// Only use it when you want to use the ID attached with function `f` executed by a goroutine.
// Otherwise, just use nornal `go` keyword.
func Go(f func(goroutineID uint64)) uint64 {
id := atomic.AddUint64(&goroutineID, 1)
go f(id)
return id
- Algorithmic complexity / Big-O / Asymptotic analysis
- Data Structures
- Arrays
- Linked Lists
- Stack
- Queue
- Hash table
- More Knowledge
- Binary search
- Sorting
@manhdaovan
manhdaovan / check_probe.sh
Last active October 5, 2021 07:04
Simple tool to check probation of given URL using cURL with HTTP GET method.
#!/bin/bash
# Simple tool to check probation of given URL
# using cURL with HTTP GET method.
url=$1
TXT_RED='\033[0;31m'
TXT_GREEN='\033[0;32m'
# check until pressing Ctr+C

##Working configuration to accomplish 0-downtime deploy with unicorn 5.x and systemd on centos 7

The scope is to accomplish a 0-downtime reload of a unicorn service managed by Systemd on a Centos 7 distro.

The examples and assumptions that i found on the bogomips's unicorn repo seems not working for centos 7.

Below a working configuration tested on Centos 7 and unicorn 5.1

Any advice/remark will be appreciated

@manhdaovan
manhdaovan / install_mysql2_gem_on_catalina.md
Last active February 15, 2021 05:38
Install mysql2 gem on MacOS catalina (10.15.x)
@manhdaovan
manhdaovan / annoying_scope.go
Last active September 5, 2020 02:18
Annoying scope variable in Golang
package main
import (
"fmt"
)
type A struct {
val int
}
type sequenceIDGenerator struct {
idMgrClient IDManagerClient // client for getting IDPrefix
preGenerateIDs chan string // pre-generated ids
}
// Pre-generate id and send to channel.
// This method should be called once and only once when init generator
func (g *sequenceIDGenerator) preGenIDs() {
var idBase, id string
var seq uint64