Skip to content

Instantly share code, notes, and snippets.

ryu1kn / Makefile
Last active Dec 27, 2020
Use SonarQube to analyse a project
View Makefile
# 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 / Makefile
Created May 20, 2020
DynamoDB Local
View Makefile
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 / App.kt
Last active May 8, 2020
Kotlin + Vert.x simple web server
View App.kt
// 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 / WithReader.purs
Last active May 3, 2020
Same code with and without Reader monad
View WithReader.purs
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}
ryu1kn / core.clj
Last active Apr 8, 2020
Use clojure to fetch Dialogflow log from Stackdriver
View core.clj
; src/clojure__gcp/core.clj
(ns clojure--gcp.core
(:import ( LoggingOptions Logging$EntryListOption Logging)))
; Advanced logs 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 / main.js
Created Mar 29, 2020
GCP KMS node.js client (googleapis and @google-cloud/kms) usage
View main.js
const locationId = "KMS key's region ID"
const projectId = "KMS key's project ID"
const keyRring = "KMS key's key ring"
const keyId = "KMS key's ID"
const encryptedText = 'CiQAfn8U68PD1weop5nXO43I8srZ2pMLaxXci2tcaDnfwLt2YOUSMwDNtppaQLU82bYtoRXx/NCnLnUt05WtHl8Y2QKUNCq6QS9FJdoxCszzjsnpym7SktWn+g==';
async function useGoogleapisModule() {
console.log('Use `googleapis` module to decrypt KMS encrypted secret')
const {google} = require('googleapis')
ryu1kn / Makefile
Created Mar 11, 2020
Terraform, instantiate the same module multiple times
View Makefile
export AWS_PROFILE := your-aws-profile
auto_approve_target = apply destroy
init apply destroy:
cd infra && terraform $@ $(if $(filter $@,$(auto_approve_target)),-auto-approve)
ryu1kn /
Last active Feb 8, 2020
Page get with no external dependencies
import java.util.Scanner;
class GetPage {
public static void main(String[] args) throws IOException {
String endpoint = System.getProperty("endpoint");
if (endpoint == null) printUsage();
else printPage(endpoint);
ryu1kn /
Last active Apr 9, 2021
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 script with tools like step.

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

ryu1kn /
Created Aug 20, 2019
Google Cloud Deployment Manager sample

Google Cloud Deployment Manager samples



Using configuration

gcloud deployment-manager deployments create sample-deployment --config vm_config.yaml