Skip to content

Instantly share code, notes, and snippets.

@ryu1kn
ryu1kn / Makefile
Last active March 24, 2024 10:29
Work with DataHub GraphQL API
.PHONY: init use-virtual-env
init:
pip install 'acryl-datahub[datahub-rest]'
curl -L -o docker-compose.yaml https://raw.githubusercontent.com/datahub-project/datahub/master/docker/quickstart/docker-compose-without-neo4j-m1.quickstart.yml
datahub docker quickstart -f docker-compose.yaml -f docker-compose.override.yaml
use-virtual-env:
python -m venv .venv
@ryu1kn
ryu1kn / README.md
Last active March 18, 2024 14:19
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,

@ryu1kn
ryu1kn / Makefile
Last active March 19, 2023 13:02
Encrypt/decrypt with AWS KMS using AWS cli
# How to encrypt/decrypt your text/blob secret with AWS KMS with AWS cli
KEY_ID=alias/my-key
SECRET_BLOB_PATH=fileb://my-secret-blob
SECRET_TEXT="my secret text"
ENCRYPTED_SECRET_AS_BLOB=encrypted_secret_blob
DECRYPTED_SECRET_AS_BLOB=decrypted_secret_blob # Result of decrypt-blob target
encrypt-text:
@ryu1kn
ryu1kn / core.clj
Last active March 13, 2023 18:59
Use clojure to fetch Dialogflow log from Stackdriver
; src/clojure__gcp/core.clj
(ns clojure--gcp.core
(:import (com.google.cloud.logging LoggingOptions Logging$EntryListOption Logging)))
; Advanced logs queries: https://cloud.google.com/logging/docs/view/advanced-queries
(defn make-filter [project-id]
(str "logName = \"projects/" project-id "/logs/dialogflow_agent\"
labels.type = \"dialogflow_response\"
timestamp >= \"2020-04-05T00:00:00+11:00\""))
@ryu1kn
ryu1kn / README.md
Last active August 14, 2021 14:46
Parallel job execution and aggregated exit status with Bash
@ryu1kn
ryu1kn / JsonSpec.scala
Last active August 3, 2021 13:38
spray-json. Remove empty string before deserialising JSON
import org.scalatest.{Matchers, WordSpec}
import spray.json._
object JsonHelper {
implicit class JsObjectWrap(obj: JsObject) {
def removeEmptyValues: JsObject = JsObject(obj.fields
.map {
case (key, value: JsObject) => (key, value.removeEmptyValues)
@ryu1kn
ryu1kn / Makefile
Last active December 27, 2020 12:09
Use SonarQube to analyse a project
# Usage:
#
# 1. `make qube` to bring up SonarQube server
# 2. Open http://localhost:9000 with your browser,
# setup a new project (e.g. my-first-project) and generate a token.
# Put the token and project key in this Makefile
# 3. `make scan` against the repository you want to analyse
# Refs
#
@ryu1kn
ryu1kn / Makefile
Created May 20, 2020 13:26
DynamoDB Local
export AWS_REGION := ap-southeast-2
export AWS_ACCESS_KEY_ID := fakeForLocalDynamodb
export AWS_SECRET_ACCESS_KEY := fakeSecretForLocalDynamodb
endpoint := --endpoint-url http://localhost:8000
table_name := people
container_name := dynamodb-local
dynamo = aws dynamodb $(endpoint)
@ryu1kn
ryu1kn / App.kt
Last active May 8, 2020 11:07
Kotlin + Vert.x simple web server
// src/App.kt
import io.vertx.core.Vertx
import io.vertx.ext.web.Router
fun main(args: Array<String>) {
val vertx = Vertx.vertx()
val router = Router.router(vertx)
router.get("/health").handler { ctx -> ctx.response().end("OK") }
@ryu1kn
ryu1kn / WithReader.purs
Last active May 3, 2020 12:51
Same code with and without Reader monad
module WithReader where
import Prelude
import Control.Monad.Reader (Reader, asks, runReader)
import Data.String (toLower)
import Effect (Effect)
import Effect.Console (log)
type Config = {username :: String}