Skip to content

Instantly share code, notes, and snippets.

View hoangong's full-sized avatar
🏠
Working from home

Hoang Ong hoangong

🏠
Working from home
View GitHub Profile
@hoangong
hoangong / intellij-macos
Last active November 9, 2023 17:53
keymaps
‎‎​
@hoangong
hoangong / docker.md
Created May 28, 2023 20:57
useful commands

clean up unused images that is older than 30 days:

0 0 * * 0 /usr/bin/docker image prune -a --force --filter "until=$(date -d "30 days ago" +%Y-%m-%d)T00:00:00"
@hoangong
hoangong / regex.md
Created February 20, 2019 20:25 — forked from vitorbritto/regex.md
Regex Cheat Sheet

Regular Expressions

Basic Syntax

  • /.../: Start and end regex delimiters
  • |: Alternation
  • (): Grouping

Kafka 0.11.0.0 (Confluent 3.3.0) added support to manipulate offsets for a consumer group via cli kafka-consumer-groups command.

  1. List the topics to which the group is subscribed
kafka-consumer-groups --bootstrap-server <kafkahost:port> --group <group_id> --describe

Note the values under "CURRENT-OFFSET" and "LOG-END-OFFSET". "CURRENT-OFFSET" is the offset where this consumer group is currently at in each of the partitions.

  1. Reset the consumer offset for a topic (preview)
@hoangong
hoangong / KeycloakAuthorization.scala
Last active February 11, 2022 17:56 — forked from daniel-shuy/KeycloakAuthorization.scala
Akka HTTP (Scala) Keycloak token verifier #scala #akka-http #keycloak
import java.math.BigInteger
import java.security.spec.RSAPublicKeySpec
import java.security.{KeyFactory, PublicKey}
import java.util.Base64
import akka.actor.ActorSystem
import akka.event.LoggingAdapter
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.HttpRequest
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
@hoangong
hoangong / build.sh
Last active January 17, 2019 14:20
Build scala case class from proto file #scala #proto #rpc
rm -rf output && mkdir output
bin/./scalapbc \
--proto_path=/path/your/proto \
--proto_path=/path/to/googleapis-master/ \ # download from https://github.com/googleapis/googleapis
--proto_path=/path/to/protobuf-master/src/ \ # download from https://github.com/protocolbuffers/protobuf
--scala_out=output rpc.proto
@hoangong
hoangong / generate.sh
Last active March 10, 2019 06:20
generate lnd key with custom dns
# do this once for server private key:
openssl ecparam -genkey -name prime256v1 -out tls.key
# both server and all clients have to use the same cert file tls.cert
openssl req -new -sha256 \
-key tls.key \
-subj "/CN=localhost/O=lnd" \
-reqexts SAN \
-config <(cat /etc/ssl/openssl.cnf \
<(printf "\n[SAN]\nsubjectAltName=DNS:localhost,DNS:aaaa,DNS:bbbb,IP:192.168.1.xxx")) \
@hoangong
hoangong / get absoluate current bash folder
Created January 4, 2019 13:21
get absoluate current bash folder #bash #current #folder
PWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@hoangong
hoangong / JVM cert commands
Last active January 5, 2019 15:53
JVM cert command #java #cert #jvm
list CAs
keytool -list -keystore $(/usr/libexec/java_home)/jre/lib/security/cacerts
Add new CA
sudo keytool -keystore $(/usr/libexec/java_home)/jre/lib/security/cacerts -importcert -alias new_cert -file cer_file.cer/pem
default pass: changeit
@hoangong
hoangong / init.sql
Last active January 6, 2019 00:33
init postgres user and grant permission #postgres
sudo -u postgres psql postgres
CREATE USER testuser WITH PASSWORD '123123';
CREATE DATABASE testdb;
GRANT ALL PRIVILEGES ON DATABASE testdb to testuser;