Skip to content

Instantly share code, notes, and snippets.

View bayucandra's full-sized avatar
🙂

Bayu Candra bayucandra

🙂
View GitHub Profile
@bayucandra
bayucandra / gcp-workspace-mac.sh
Created February 28, 2025 13:02
gcp-workspace-mac
#!/bin/bash
# Config Vars
MAX_IDLE_TIME_MINUTES=15
GCP_COMPUTE_NAME=ml-workspace
GCP_COMPUTE_ZONE=asia-southeast2-c
GCP_COMPUTE_IS_STOPPED=0
egress() {
echo "Exiting script...."
@bayucandra
bayucandra / gcp-workspace
Created December 25, 2024 09:08
Start VM instance when start to work. It will auto stop when computer is idle for certain amount of time as defined on the config vars
#!/bin/bash
# Config Vars
MAX_IDLE_TIME_MINUTES=15
GCP_COMPUTE_NAME=ml-node
GCP_COMPUTE_ZONE=us-central1-c
GCP_COMPUTE_IS_STOPPED=0
egress() {
echo "Exiting script...."
@bayucandra
bayucandra / gcp-auto-shutdown.sh
Last active January 21, 2025 02:46
GCP compute instance auto shutdown when vscode remote edit currently doesn't run/connected
#!/bin/bash
# Requred packages to install:
# sudo, lsof, gcloud,
# CONFIG VARS===================
LAST_RUN_CHECK_FILE_NAME="./last-run-check" #Place to store date time when last port check performed
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
RUNNING_PROCESS_NAME=code-fabd
MAX_LAST_RUN_MINUTES=20
@bayucandra
bayucandra / download.go
Created April 7, 2022 09:52 — forked from albulescu/download.go
golang download file with progress
package main
/**
* @website http://albulescu.ro
* @author Cosmin Albulescu <[email protected]>
*/
import (
"bytes"
"fmt"
package main
//https://play.golang.org/p/_iu24fTdt57
import (
"fmt"
"regexp"
)
func main() {
str := `an..19` //https://en.wikipedia.org/wiki/ISO_8583#Examples_3
@bayucandra
bayucandra / self-signed-certificate-with-custom-ca.md
Created January 3, 2020 01:50 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@bayucandra
bayucandra / mongo-get-duplicate-field.go
Created December 16, 2019 02:47
Mongo get duplicate field by using regular expression
package main
import (
"fmt"
"regexp"
)
func main() {
errStr := `rpc error: code = AlreadyExists desc = multiple write errors: [{write errors: [{E11000 duplicate key error ` +
`collection: mai_webmin_inventory_service.groups index: unique_name dup key: { name: "aa1234" }}]}, {<nil>}]`