Skip to content

Instantly share code, notes, and snippets.

@hiboyang
hiboyang / self-signed-certificate-with-custom-ca.md
Created April 10, 2025 00:36 — 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
@hiboyang
hiboyang / google_oauth_main.go
Last active December 15, 2022 15:53 — forked from salrashid123/main.go
Getting a google id token in golang for cloud endpoints and identity proxy
package main
import (
"io/ioutil"
"log"
"net/http"
"net/url"
"strings"
"crypto/rsa"
@hiboyang
hiboyang / GCP_Access_Token.md
Last active December 15, 2022 15:46 — forked from ryu1kn/README.md
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,

@hiboyang
hiboyang / gcp-kube.go
Created December 14, 2022 06:31 — forked from dragonsinth/gcp-kube.go
Connect to Google Kubernetes with GCP credentials and pure Golang
package main
import (
"context"
"encoding/base64"
"flag"
"fmt"
"log"
"google.golang.org/api/container/v1"
select role, processUuid,
max(heapMemoryTotalUsed)/(1024*1024) maxHeapMemoryMB,
avg(processCpuLoad)/1000000000 avgProcessCpuLoad
from profiler_CpuAndMemory
where appId = 'application_1508123456789_12345678'
and role = 'executor'
group by 1, 2
spark-submit --deploy-mode cluster --master yarn --conf spark.jars=hdfs://hdfs_url/lib/jvm-profiler-0.0.5.jar --conf spark.driver.extraJavaOptions=-javaagent:jvm-profiler-0.0.5.jar --conf spark.executor.extraJavaOptions=-javaagent:jvm-profiler-0.0.5.jar --class com.company.SparkJob spark_job.jar
hdfs dfs -put target/jvm-profiler-0.0.5.jar hdfs://hdfs_url/lib/jvm-profiler-0.0.5.jar
java -javaagent:target/jvm-profiler-0.0.5.jar=reporter=com.uber.profiling.reporters.KafkaOutputReporterbrokerList=localhost:9092,topicPrefix=profiler_ -cp target/jvm-profiler-0.0.5.jar com.uber.profiling.examples.HelloWorldApplication
...
ConsoleOutputReporter - CpuAndMemory: {"nonHeapMemoryTotalUsed":1.080164E7,"bufferPools":[{"totalCapacity":0,"name":"direct","count":0,"memoryUsed":0},{"totalCapacity":0,"name":"mapped","count":0,"memoryUsed":0}],"heapMemoryTotalUsed":2.1689544E7,"epochMillis":1522433751081,"nonHeapMemoryCommitted":1.3303808E7,"heapMemoryCommitted":2.57425408E8...
java -javaagent:target/jvm-profiler-0.0.5.jar=reporter=com.uber.profiling.reporters.ConsoleOutputReporter -cp target/jvm-profiler-0.0.5.jar com.uber.profiling.examples.HelloWorldApplication