Skip to content

Instantly share code, notes, and snippets.

View martin-mok's full-sized avatar
🏠
Working from home

Martin martin-mok

🏠
Working from home
  • Hong Kong
View GitHub Profile
@martin-mok
martin-mok / multiple-ssh-keys-git.adoc
Created July 7, 2024 12:18 — forked from alejandro-martin/multiple-ssh-keys-git.adoc
Configure multiple SSH Keys for Git

Use Multiple SSH Keys for Git host websites (Github, Gitlab)

This is guide about how to configure multiple SSH keys for some Git host websites such as Github, Gitlab, among others.

Creating SSH keys

  1. Create SSH directory:

@martin-mok
martin-mok / nvmCommands.js
Created June 8, 2024 20:44 — forked from chranderson/nvmCommands.js
Useful NVM commands
// check version
node -v || node --version
// list locally installed versions of node
nvm ls
// list remove available versions of node
nvm ls-remote
// install specific version of node
@martin-mok
martin-mok / bookmarks-to-notion.js
Created May 30, 2024 16:34 — forked from iamandrewluca/bookmarks-to-notion.js
Export bookmarks to Notion as a Database
(function bookmarksExportToCsv() {
/**
* 1. Export bookmarks from browser (supported any Chromium based browsers and Safari) (chrome://bookmarks)
* 2. Open exported html file again in the browser
* 3. Copy paste this entire file in console, and execute it (hit enter)
* 4. You will be prompted to save a CSV file. Save it.
* 5. Open Notion. Click Import -> CSV
* 6. Select saved CSV file. Wait for import
* 7. You have a new database with all your bookmarks
*/
@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