Skip to content

Instantly share code, notes, and snippets.

@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>}
*/
@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 / Makefile
Created November 1, 2017 10:29
Script to merge one repository into another
# Merge SRC_REPO into a DEST_REPO under its subdirectory NEW_DIR
# cf. https://stackoverflow.com/questions/277029/combining-multiple-git-repositories
#
# Place 2 repository and this Makefile as follows:
#
# ./
# DEST_REPO/
# Makefile
#
# Then execute
@ryu1kn
ryu1kn / mp4-download.sh
Last active January 3, 2018 09:55
mp4 downloader
#!/bin/bash
# Download MP4 files. Run the command with --help option to see more details
COMMAND_NAME=./mp4-download.sh
LOGFILE=download.log
FILENAME=""
ARGV_BASE_INDEX=1
ARGV_DEBUG=NO
ARGV__=()
@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 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 / 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 / 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 / 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 / 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