Skip to content

Instantly share code, notes, and snippets.

View deskoh's full-sized avatar
👽
iamdeskoh

Desmond Koh deskoh

👽
iamdeskoh
View GitHub Profile
@deskoh
deskoh / nodejs.jenkinsfile
Created November 3, 2019 09:02
Jenkinsfile
pipeline {
agent none
stages {
stage('Checkout') {
agent {
docker { image 'node:alpine' }
}
stages {
@deskoh
deskoh / artifactory.conf
Last active July 28, 2022 08:03
Artifactory Nginx Configuration
###########################################################
## this configuration was generated by JFrog Artifactory ##
###########################################################
## server configuration
server {
listen 80 ;
server_name ~(?<repo>.+)\.jfrog.dev.local jfrog.dev.local;
@deskoh
deskoh / Jenkinsfile
Last active April 30, 2024 03:04
Jenkinsfile Examples
Jenkinsfile examples
@deskoh
deskoh / jwt.js
Created May 3, 2020 23:19
Asymmetric JWTs
var assert = require('assert')
var crypto = require('crypto')
var jose = require('jose')
var jws = require('jws')
var convert = require('jwk-to-pem')
var { publicKey, privateKey } = crypto.generateKeyPairSync('rsa', {
modulusLength: 4096,
publicKeyEncoding: {
type: 'spki',
@deskoh
deskoh / webcrypto-examples.md
Created May 9, 2020 14:00 — forked from pedrouid/webcrypto-examples.md
Web Cryptography API Examples
@deskoh
deskoh / README.md
Last active May 23, 2020 02:00
VS Code Debug Recipes

Debugging Receipes for VS Code

@deskoh
deskoh / sftp-client.js
Last active May 17, 2020 04:54
SFTP Client
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const Client = require('ssh2-sftp-client');
// Host public key e.g. /etc/ssh/ssh_host_ecdsa_key.pub
const fingerprint = process.env.HOST_FINGERPRINT;
const hostConfig = {
host: process.env.HOST,
port: process.env.PORT || 22,
@deskoh
deskoh / rsa-encrypt-decrypt.js
Created May 20, 2020 02:55
NodeJS RSA Cryptoraphy
const crypto = require('crypto');
const keyPair = crypto.generateKeyPairSync('rsa', {
// Max length of plaintext = (512 / 8) - 42 = 22 bytes
modulusLength: 512,
publicKeyEncoding: {
type: 'spki',
format: 'pem'
},
privateKeyEncoding: {
@deskoh
deskoh / _AWS Resource-Based Policy Examples.md
Last active April 18, 2024 22:38
AWS Resource-based policies example

AWS Resource-Based Policy Examples

@deskoh
deskoh / s3-download.js
Last active August 6, 2020 02:08
NodeJS S3 Upload / Download
const fs = require('fs')
const AWS = require('aws-sdk')
const BUCKET_NAME = 'my-bucket'
const ACCESS_KEY = 'AKIAXXXXXXXXXXXXXXXX'
const SECRET_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
const FILE = 'file-to-download.txt'
AWS.config.update({
region: 'ap-southeast-1',