Skip to content

Instantly share code, notes, and snippets.

@ryu1kn
ryu1kn / main.js
Created March 29, 2020 09:21
GCP KMS node.js client (googleapis and @google-cloud/kms) usage
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
ryu1kn / Makefile
Created March 11, 2020 09:56
Terraform, instantiate the same module multiple times
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
ryu1kn / Makefile
Last active February 12, 2020 09:22
Manually check if a server cert can be verified with its issuer cert
SHELL := /bin/bash
openssl := /usr/local/opt/openssl@1.1/bin/openssl
work_dir := __work
message_digest_type := sha256
ifneq ($(wildcard __override.mk),)
include __override.mk
endif
@ryu1kn
ryu1kn / GetPage.java
Last active February 8, 2020 02:18
Page get with no external dependencies
import java.io.*;
import java.net.URL;
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
ryu1kn / Makefile
Last active November 9, 2019 22:37
Encrypt/decrypt a directory using GPG with symmetric key option
# Encrypt/decrypt a directory using GPG with symmetric key option
dir_name := plain-files
encrypted_file := encrypted-dir.blob
tmp_file := tmp.tgz
encrypt-dir:
tar czf $(tmp_file) $(dir_name)
gpg --no-symkey-cache -o $(encrypted_file) -c $(tmp_file)
rm -f $(tmp_file)
@ryu1kn
ryu1kn / README.md
Created August 20, 2019 13:56
Google Cloud Deployment Manager sample

Google Cloud Deployment Manager samples

Usage

Creating

Using configuration

gcloud deployment-manager deployments create sample-deployment --config vm_config.yaml
@ryu1kn
ryu1kn / terraform-debug.log
Created August 16, 2019 15:26
Debug log: Terraform google provider failing to apply IAM policy when user email address has uppercase characters
2019-08-17T00:50:53.531+1000 [DEBUG] plugin.terraform-provider-google_v2.13.0_x4: 2019/08/17 00:50:53 [DEBUG] Google API Request Details:
2019-08-17T00:50:53.531+1000 [DEBUG] plugin.terraform-provider-google_v2.13.0_x4: ---[ REQUEST ]---------------------------------------
2019-08-17T00:50:53.531+1000 [DEBUG] plugin.terraform-provider-google_v2.13.0_x4: POST /v1/projects/my-project:getIamPolicy?alt=json&prettyPrint=false HTTP/1.1
2019-08-17T00:50:53.531+1000 [DEBUG] plugin.terraform-provider-google_v2.13.0_x4: Host: cloudresourcemanager.googleapis.com
2019-08-17T00:50:53.531+1000 [DEBUG] plugin.terraform-provider-google_v2.13.0_x4: User-Agent: google-api-go-client/0.5 Terraform/0.12.6 (+https://www.terraform.io) terraform-provider-google/2.13.0
2019-08-17T00:50:53.531+1000 [DEBUG] plugin.terraform-provider-google_v2.13.0_x4: Content-Length: 3
2019-08-17T00:50:53.531+1000 [DEBUG] plugin.terraform-provider-google_v2.13.0_x4: Content-Type: application/json
2019-08-17T00:50:53.531+1000 [DEBUG] plugin.terraform-pr
@ryu1kn
ryu1kn / Makefile
Created August 11, 2019 14:51
Access Kubernetes API server with a service account token
# Accessing Kubernetes API server with a service account token
service_account_name := default
tmp_cacert_file := __cacert.pem
check-api:
$(MAKE) get-ca-cert > $(tmp_cacert_file)
bash -c 'curl $(shell $(MAKE) get-cluster-address)/api \
--header "Authorization: Bearer $(shell $(MAKE) get-api-token)" \
--cacert $(tmp_cacert_file)'
@ryu1kn
ryu1kn / Dockerfile
Last active May 15, 2019 08:44
SQL Server Application Intent Read Only with TinyTDS
FROM ruby:2.5
RUN apt-get update -y \
&& apt-get install -y wget build-essential libtool-bin libc6-dev libssl1.0-dev \
&& mkdir -p /opt \
&& cd /opt \
&& wget http://www.freetds.org/files/stable/freetds-1.1.6.tar.gz \
&& tar -xzf freetds-1.1.6.tar.gz \
&& cd freetds-1.1.6 \
&& ./configure --prefix=/usr/local --with-tdsver=7.3 \
@ryu1kn
ryu1kn / EnumBase.js
Created February 21, 2015 07:21
Enum on Sencha Touch (ExtJS as well?)
/**
* @abstract
* @class MyApp.EnumBase
*/
Ext.define('MyApp.EnumBase', {
inheritableStatics: {
/**
* @return {Array.<MyApp.EnumBase>}
*/