Skip to content

Instantly share code, notes, and snippets.

View martin-mok's full-sized avatar

Martin martin-mok

  • /dev/null
View GitHub Profile
@martin-mok
martin-mok / exercise_stringers.go
Created January 27, 2024 16:32
A Tour of Go Exercise: Stringers
package main
import (
"strings"
"fmt"
)
type IPAddr [4]byte
func (ips IPAddr) String() string {
@martin-mok
martin-mok / handler.js
Created January 17, 2024 15:56 — forked from jeffrafter/handler.js
Simple HTTP Server and Router in node.js
exports.createHandler = function (method) {
return new Handler(method);
}
Handler = function(method) {
this.process = function(req, res) {
params = null;
return method.apply(this, [req, res, params]);
}
}
@martin-mok
martin-mok / 00_README.md
Created January 17, 2024 06:58 — forked from reagent/00_README.md
Custom HTTP Routing in Go

Custom HTTP Routing in Go

Basic Routing

Responding to requests via simple route matching is built in to Go's net/http standard library package. Just register the path prefixes and callbacks you want invoked and then call the ListenAndServe to have the default request handler invoked on each request. For example:

package main

import (
@martin-mok
martin-mok / Example.java
Created November 22, 2023 11:14 — forked from kherge/Example.java
Null Coalescing in Java
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.Optional;
public class Example {
public static void main(String []args) {
// Create a series of nullable objects.
Test a = new Test();
@martin-mok
martin-mok / git__stash__commands.md
Created November 13, 2023 15:43 — forked from Preethi-Dev/git__stash__commands.md
Cheat sheet for git stash commands

Stash the changes

  1. git stash
  2. git stash save

Stash the untracked files

  1. git stash --include-untracked
  2. git stash -u

List the stashes

  1. git stash list

show the latest stash

  1. git stash show
@martin-mok
martin-mok / jwtRS256.sh
Created September 17, 2023 13:40 — forked from ygotthilf/jwtRS256.sh
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@martin-mok
martin-mok / multiple_ssh_setting.md
Created September 15, 2023 06:00 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
@martin-mok
martin-mok / work-with-multiple-github-accounts.md
Created September 15, 2023 05:58 — forked from rahularity/work-with-multiple-github-accounts.md
How To Work With Multiple Github Accounts on your PC

How To Work With Multiple Github Accounts on a single Machine

Let suppose I have two github accounts, https://github.com/rahul-office and https://github.com/rahul-personal. Now i want to setup my mac to easily talk to both the github accounts.

NOTE: This logic can be extended to more than two accounts also. :)

The setup can be done in 5 easy steps:

Steps:

  • Step 1 : Create SSH keys for all accounts
  • Step 2 : Add SSH keys to SSH Agent
@martin-mok
martin-mok / Dockerfile
Created September 5, 2023 15:17 — forked from nzvtrk/Dockerfile
Nest.js multi-stage build dockerfile + docker-compose with postgres & migrations
FROM node:12.14.1-alpine AS build
# If you have troubles with node-gyp use should install these dependencies
RUN apk add g++ make python
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . ./
# build js & remove devDependencies from node_modules
@martin-mok
martin-mok / firebase.tf
Created July 5, 2023 04:18 — forked from zebreus/firebase.tf
Terraform configuration for creating a firebase project with firestore, functions and storage
# firebase.tf https://gist.githubusercontent.com/Zebreus/906b8870e49586adfe8bd7bbff43f0a8/raw/firebase.tf
# Terraform configuration for creating a firebase project with firestore, functions and storage
# Unfinished
terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = "4.11.0"
}