Skip to content

Instantly share code, notes, and snippets.

View bjing's full-sized avatar

Brian Jing bjing

  • Australia
View GitHub Profile
bjing / gist:eeef40fe8ee1cc8c6e728c35904c32db
Created September 6, 2023 11:57
Scala dev environment (Linux)
# Java
## Install java
Install latest LTS version from OS package manager, e.g.
sudo apt install openjdk-17-jdk
## Jenv (for managing java version)
### Install
bjing / scala_base64_encode_decode.scala
Created August 21, 2023 23:48 — forked from frgomes/scala_base64_encode_decode.scala
Scala - Base64 encode/decode
// Base64 encode
val text = "This is plaintext."
val bytesEncoded = java.util.Base64.getEncoder.encode(text.getBytes())
// Base64 decode
val textDecoded = new String(java.util.Base64.getDecoder.decode(bytesEncoded))
bjing /
Created August 2, 2022 02:42 — forked from myusuf3/
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
bjing /
Last active January 7, 2022 11:47 — forked from mikekeke/
PAB setup

Hosted PAB setup

This document describes how to prepare hosted PAB deployment from scratch that can operate on Alonzo purple testnet.

The following required to be run on host machine to use PAB with contracts in hosted scenario on testnet (for 2020-11-05 PAB Release):

  • Cardano node connected to Alonzo testnet
  • cardano wallet connected to node
  • chain-index connected to node
  • PAB executable connected to node, cardano-wallet and chain-index

Note: we are using somewhat more involved setup with a bit custom docker compose, and wallet and chain-index being built from sources, but there is ready to go node+wallet docker solution available

alias urlencode='python -c "import urllib.parse, sys; print(urllib.parse.quote_plus(sys.argv[1])) if len(sys.argv) > 1 else print(urllib.parse.quote_plus(sys.stdin.readline()[0:-1]))"'
alias urldecode='python -c "import urllib.parse, sys; print(urllib.parse.unquote(sys.argv[1])) if len(sys.argv) > 1 else print(urllib.parse.unquote(sys.stdin.readline()[0:-1]))"'
# percent encode
urlencode $VALUE
# HMAC-SHA1 hashing
echo -n $VALUE | openssl dgst -sha1 -hmac $KEY
# Base64
1. Rename branch from Github branch settings.
2. Then on local checkout:
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a
bjing / cats-amm
Last active September 11, 2023 02:12
Use Cats and Cats Effect in Ammonite
interp.configureCompiler(_.settings.YpartialUnification.value = true)
import $ivy.`org.typelevel::cats-core:2.10.0`
import $ivy.`org.typelevel::cats-effect:3.5.1`
import cats._
import cats.implicits._
import cats.effect._
import cats.effect.unsafe.implicits._
import cats.effect.IO