Skip to content

Instantly share code, notes, and snippets.

View deskoh's full-sized avatar
👽
iamdeskoh

Desmond Koh deskoh

👽
iamdeskoh
View GitHub Profile

Self-Signed cert

Linux

  1. Copy or SFTP certificate to machine
  2. Go to /usr/local/share/ca-certificates/
  3. Create a new folder, i.e. "sudo mkdir my-cert"
  4. Copy the .crt file into the my-cert folder
  5. Make sure the permissions are OK (755 for the folder, 644 for the file)
  6. Run sudo update-ca-certificates
@deskoh
deskoh / Branching.md
Last active January 22, 2024 07:50
GIT Cheatsheet

Local Branching

# Checkout new branch
:master> git checkout -b new-feature

# Feature completed.

# Update local master branch
:new-feather> git checkout master
@deskoh
deskoh / K8s Dashboard.md
Last active June 28, 2019 00:24
Kubernetes

Kubernetes Dashboard

Deploy dashboard.

kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml

Create service account to access dashboard

@deskoh
deskoh / Filesystem Performance Benchmarking.md
Last active June 2, 2019 00:43
Linux Filesystem and Disks

Benchmarking with fio

Reference: https://docs.gitlab.com/ee/administration/operations/filesystem_benchmarking.html

fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=test --filename=/path/to/git-data/testfile --bs=4k --iodepth=64 --size=4G --readwrite=randrw --rwmixread=75

This will create a 4GB file in /path/to/git-data/testfile. It performs 4KB reads and writes using a 75%/25% split within the file, with 64 operations running at a time. Be sure to delete the file after the test completes.

@deskoh
deskoh / TodoList.tsx
Last active May 25, 2019 04:16
Redux Typings
import { connect } from 'react-redux'
import { toggleTodo, TodoActionTypes } from './actions'
import { VisibilityFilters } from './actions'
import { AppState } from './reducers';
import { Dispatch } from 'react';
type StateProps = ReturnType<typeof mapStateToProps>
type DispatchProps = ReturnType<typeof mapDispatchToProps>
@deskoh
deskoh / app.js
Last active July 29, 2019 06:18 — forked from marshallswain/app.js
Authenticate on feathers-socketio connection with header
const socketio = require('feathers-socketio')
const authOnSocketConnect = require('./authenticate-on-socket-connect')
// ... Setup your Feathers app code or use the generator then replace the socketio registration with this
// When you register the feathers-socketio plugin, use the utility
app.configure(socketio(function (io) {
// Get Socket.io headers
io.on('connection', function (socket) {
authOnSocketConnect({ app, socket })
@deskoh
deskoh / default-spa.conf
Last active March 23, 2020 14:34
NGINX Config
server {
listen 80;
listen [::]:80 default ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
server_name _; # all hostnames
location / {
@deskoh
deskoh / async-js.md
Last active January 8, 2021 04:34
JavaScript Async Function

async function ensures function always returns a promise

Non-promise return value will be wrapped in a promise

async function increment(num) {
  // Value will be wrapped in a promise
  return num + 1;
}
@deskoh
deskoh / self-signed-certificate-with-custom-ca.md
Last active February 24, 2021 09:19 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

TLDR

# Generate CA key and cert (use -nodes to remove pass phrase)
openssl req -x509 -nodes -newkey rsa:2048 -keyout rootCA.key \
  -days 1024 -out rootCA.crt \
  -subj "/C=SG/OU=www.org/O=MyOrg, Inc./CN=My Org Root CA"
# Generate server key and CSR (OpenSSL 1.1.1+)
@deskoh
deskoh / Solace.md
Last active October 7, 2021 08:44
Solace PubSub+

Solace PubSub+

Solace CLI

Command Reference

Running CLI in Docker container: docker exec -it pubSubStandardSingleNode /usr/sw/loads/currentload/bin/cli -A

Advanced: Running CLI Scripts