Skip to content

Instantly share code, notes, and snippets.

View able8's full-sized avatar

Able Lv able8

View GitHub Profile
@m-radzikowski
m-radzikowski / script-template.sh
Last active November 15, 2024 11:25
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@dragonsinth
dragonsinth / gcp-kube.go
Last active August 1, 2024 13:47
Connect to Google Kubernetes with GCP credentials and pure Golang
package main
import (
"context"
"encoding/base64"
"flag"
"fmt"
"log"
container "google.golang.org/api/container/v1beta1"
package main
import (
"fmt"
"time"
)
func main() {
st := time.Now()
n := 100000000
@seblegall
seblegall / reverseproxy.go
Last active November 10, 2024 08:08
A reverse proxy in Golang using Gin
package main
import (
"fmt"
"net/http"
"net/http/httputil"
"net/url"
"github.com/gin-gonic/gin"
)
@ryu1kn
ryu1kn / README.md
Last active October 4, 2024 06:12
Getting GCP access token from a service account key JSON file

Getting GCP access token from a service account key

Use your service account's key JSON file to get an access token to call Google APIs.

Good for seeing how things work, including the creation of JWT token.

To create a JWT token, you can replace create-jwt-token.sh script with tools like step.

If you just want to get an access token for a service account,

@sergeyklay
sergeyklay / journalctl-cheatsheet.md
Last active October 26, 2024 00:11
Journalctl Cheat Sheet

Journalctl Cheat Sheet

Configuration

Permissions

To see messages from other users and the system as well as performing various log operations from a regular user add it to the group:

sudo usermod -aG systemd-journal $USER
@j33ty
j33ty / print-memory.go
Created May 22, 2019 20:54
Go print current memory
package main
import (
"runtime"
"fmt"
"time"
)
func main() {
// Print our starting memory usage (should be around 0mb)
@wknapik
wknapik / empty_bucket.sh
Last active March 5, 2024 09:53
Empty an s3 bucket of all object versions and delete markers in batches of 400
#!/usr/bin/env bash
set -eEo pipefail
shopt -s inherit_errexit >/dev/null 2>&1 || true
if [[ ! "$#" -eq 2 || "$1" != --bucket ]]; then
echo -e "USAGE: $(basename "$0") --bucket <bucket>"
exit 2
fi
@andresanches
andresanches / update-godaddy-dns.bash
Last active February 5, 2022 22:10
update-godaddy-dns.bash
#! /usr/bin/env bash
#
# Usage: update-godaddy-dns.sh "api_key" "api_secret" "domain_domain" "domain_name" "log_file"
# Note: log_file defaults to /var/log/update-godaddy-dns.log if not provided
set -e
set -o pipefail
log_file="/var/log/update-godaddy-dns.log"
@ndunks
ndunks / cloudflare-ddns-update.sh
Created December 17, 2018 14:23
Cloudflare Update DNS IP with bash
#!/bin/bash
ip=$(curl -s https://api.ipify.org/)
echo "DDNS-UPDATE: Public IP is: $ip, Updating IP..."
host=home.klampok.id
curl -X PUT "https://api.cloudflare.com/client/v4/zones/00000000000000000000/dns_records/00000000000000000000000" \
-H "X-Auth-Email: *******@gmail.com" \
-H "X-Auth-Key: *******" \
-H "Content-Type: application/json" \
--data '{"type":"A","name":"home.klampok.id","content":"'"$ip"'","ttl":120,"proxied":false}' )