func extractTimestamp(uuid string) (time.Time, error) {
parts := strings.Split(uuid, "-")
millisecondsStr := parts[0] + parts[1]
milliseconds, err := strconv.ParseInt(millisecondsStr, 16, 64)
if err != nil {
return time.Time{}, err
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ -z "$1" ]; then | |
echo "Usage: $0 <container-id>" | |
exit 1 | |
fi | |
CONTAINER_ID=$1 | |
CPU_PERCENT=$(docker stats $CONTAINER_ID --no-stream --format "{{.CPUPerc}}" | tr -d '%') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or replace function gen_uuidv7() returns uuid as $$ | |
declare | |
begin | |
return gen_uuidv7(clock_timestamp()); | |
end $$ language plpgsql; | |
create or replace function gen_uuidv7(p_timestamp timestamp with time zone) returns uuid as $$ | |
declare | |
v_time numeric := null; | |
v_unix_t numeric := null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
encode() { | |
local input="$1" | |
if [ -z "$input" ]; then | |
input=$(cat) | |
fi | |
echo -n "$input" | base64 -w0 | tr '+/' '-_' | tr -d '=' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"regexp" | |
"golang.org/x/net/publicsuffix" | |
) | |
func isRootDomain(domain string) (bool, error) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PHONY: up down | |
up: | |
mkdir -p mq-vol | |
sudo chown -R 1001 mq-vol | |
docker compose up --build --detach | |
down: | |
docker compose down | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func isPower(number int, isPowerOf int) bool { | |
if number < 1 { | |
return false | |
} | |
if number%isPowerOf == 0 { | |
return isPower(number/isPowerOf, isPowerOf) | |
} | |
return number == 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
contexts=$(docker context ls | awk '{if ($1 != "NAME") print $1}') | |
selected_option=$(printf "%s\n" "${contexts[@]}" | fzf --prompt="Select docker contexts: " --height=~50% --layout=reverse --border --exit-0) | |
docker context use $selected_option |
NewerOlder