Skip to content

Instantly share code, notes, and snippets.

View serial-coder's full-sized avatar
🎯
Focusing

Phuwanai Thummavet serial-coder

🎯
Focusing
View GitHub Profile
@serial-coder
serial-coder / markdown-details-collapsible.md
Created February 12, 2024 09:15 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@serial-coder
serial-coder / unsubmodule.md
Created July 10, 2023 17:03 — forked from dansuh17/unsubmodule.md
Convert git submodule to regular directory

From Stack Overflow.

# Fetch the submodule commits into the main repository
git remote add submodule_origin git://url/to/submodule/origin
git fetch submodule_origin

# Start a fake merge (won't change any files, won't commit anything)
git merge -s ours --no-commit submodule_origin/master
@serial-coder
serial-coder / git_submodules.md
Created July 1, 2023 04:20 — forked from gitaarik/git_submodules.md
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:

  • Separate big codebases into multiple repositories.
@serial-coder
serial-coder / hardhat-openzeppelin-project.md
Created September 20, 2022 08:11 — forked from alkavan/hardhat-openzeppelin-project.md
Hardhat and OpenZeppelin project bootstrap for Ethereum contract development

Install Instructions

Install Hardhat

npm install --save-dev hardhat

Initiate a new Hardhat project (in empty directory)

npx hardhat
@serial-coder
serial-coder / collision.js
Created November 11, 2021 11:27 — forked from samcorcos/collision.js
Algorithm for calculating hash collision probability
const calculate = (n, k) => {
const exponent = (-k * (k - 1)) / (2 * n)
return 1 - Math.E ** exponent
}
// where `n` is the number of possible unique hashes
// where `k` is the number of values created
// calculate(100000, 25) => 0.0029955044966269995 aka 0.29% chance of collision
@serial-coder
serial-coder / ComputeHmac256.go
Created December 20, 2020 04:17 — forked from byrnedo/ComputeHmac256.go
Compute a hmac for a message in golang
func ComputeHmac256(message string, secret string) string {
key := []byte(secret)
h := hmac.New(sha256.New, key)
h.Write([]byte(message))
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
@serial-coder
serial-coder / endorsmentpolicy.pegjs
Created August 28, 2020 04:26 — forked from mbwhite/endorsmentpolicy.pegjs
Hyperledger Fabric: Parsing the Endorsement Policies
// Grammar for parsing of the Fabric Endorsment Policies
//
// Defined in the documentation at
// https://hyperledger-fabric.readthedocs.io/en/latest/endorsement-policies.html#endorsement-policy-syntax
// The expression will be an operator with arguments, each of the arguments can be an expression
// The OutOf operator is a bit different as that demands the first agument be a number
Expression
= op:Operator '(' _ args:Some_Expression_Args _ ')'
{
@serial-coder
serial-coder / mount-nfs.sh
Created July 20, 2020 05:17 — forked from n-sviridenko/mount-nfs.sh
NFS for OSX on minikube
#!/usr/bin/env sh
HOST_PATH=$(pwd)
GUEST_PATH=/usr/app
HOST_EXPORT="${HOST_PATH} -network 192.168.99.0 -mask 255.255.255.0 -alldirs -maproot=root:wheel"
if ! grep -q "$HOST_EXPORT" /etc/exports; then
echo $HOST_EXPORT | sudo tee -a /etc/exports
sudo nfsd restart
fi
@serial-coder
serial-coder / kvm_minikube.md
Created July 3, 2020 08:52 — forked from alexellis/kvm_minikube.md
Run multiple minikube Kubernetes clusters on Ubuntu Linux with KVM

Ramp up your Kubernetes development, CI-tooling or testing workflow by running multiple Kubernetes clusters on Ubuntu Linux with KVM and minikube.

In this tutorial we will combine the popular minikube tool with Linux's Kernel-based Virtual Machine (KVM) support. It is a great way to re-purpose an old machine that you found on eBay or have gathering gust under your desk. An Intel NUC would also make a great host for this tutorial if you want to buy some new hardware. Another popular angle is to use a bare metal host in the cloud and I've provided some details on that below.

We'll set up all the tooling so that you can build one or many single-node Kubernetes clusters and then deploy applications to them such as OpenFaaS using familiar tooling like helm. I'll then show you how to access the Kubernetes clusters from a remote machine such as your laptop.

Pre-reqs

  • This tutorial uses Ubuntu 16.04 as a base installation, but other distributions are supported by KVM. You'll need to find out how to install
@serial-coder
serial-coder / kube-registry.yaml
Created February 26, 2020 07:38 — forked from coco98/kube-registry.yaml
Docker registry on minikube
apiVersion: v1
kind: ReplicationController
metadata:
name: kube-registry-v0
namespace: kube-system
labels:
k8s-app: kube-registry
version: v0
spec:
replicas: 1