Skip to content

Instantly share code, notes, and snippets.

@OzieWest
OzieWest / create_ssl.sh
Created July 24, 2017 14:15
Create rootCA certificate
#!/bin/bash
# From https://github.com/thojansen/client-certificates/blob/master/ssl/setup.sh
# create rootCA certificate
openssl genrsa -out rootCA.key 2048
openssl req -x509 -new -nodes -key rootCA.key -days 1024 -out rootCA.crt -subj "/C=DE/ST=Germany/L=Walldorf/O=SAP SE/OU=Tools/CN=rootCA"
# create server key and certificate
openssl genrsa -out server.key 2048
openssl req -new -key server.key -out server.csr -subj "/C=DE/ST=Germany/L=Walldorf/O=SAP SE/OU=Tools/CN=localhost"
function jsfy(objFromJson: any) {
if (typeof objFromJson === 'undefined') {
return undefined;
}
if (objFromJson === null) {
return null;
}
if (typeof objFromJson === 'string') {
return `'${objFromJson}'`;
}
@OzieWest
OzieWest / chain.js
Created July 17, 2017 11:51
Simple impl of lodash.chain
function map(arr, fn) {
console.log('invoked map');
if (arr) {
return arr.map(fn);
}
return [];
}
function filter(arr, fn) {
console.log('invoked filter');
@OzieWest
OzieWest / private-docker-registry-setup.md
Last active January 20, 2017 09:29
Setup your Private Docker Registry

Running on localhost

Start your registry:

docker run -d -p 5000:5000 --restart=always --name registry registry:2

Use a Storage Volume

@OzieWest
OzieWest / keybase.md
Created January 15, 2017 13:58
keybase.md

Keybase proof

I hereby claim:

  • I am soramusoka on github.
  • I am soramusoka (https://keybase.io/soramusoka) on keybase.
  • I have a public key whose fingerprint is 6994 1C08 33CB D1A0 F140 DDC4 126A 9B4A 8856 AA34

To claim this, I am signing this object:

@OzieWest
OzieWest / asyncMap.js
Created December 31, 2016 09:55
Async Map  -  A Simple Implementation Without Promises
// asyncMap takes two arguments, a collection of tasks and a callback to run on those tasks
var asyncMap = function (tasks, cb) {
// declare a counter - set it at zero
var counter = 0;
// here we are given tasks as an object
// it's possible tasks is an array
// get number of tasks we need to come back
var numberTask = Object.keys(tasks).length;
// object we will run the final cb on when all tasks have returned
var results = {};
@OzieWest
OzieWest / init.sh
Last active November 26, 2016 12:50
TypeScript with NodeJS - Quick start
npm init -y && npm install typescript --save-dev && npm install @types/node --save-dev && node ./node_modules/.bin/tsc --init && npm install ts-node --save-dev && npm install nodemon --save-dev
@OzieWest
OzieWest / resolve.js
Created November 25, 2016 15:13
Accessing nested JavaScript objects with string key
function resolve (path, obj) {
return path.split('.').reduce((prev, curr) => {
return prev ? prev[curr] : undefined;
}, obj)
}
@OzieWest
OzieWest / monitoring.js
Created November 24, 2016 20:10
Node.js - Monitoring the event loop
import Heavy from 'heavy';
const heavy_instance = new Heavy({
sampleInterval: 1000,
});
const min_time_between_log_messages = 1000;
const event_loop_logging_threshold = 5;
let logging_interval;
@OzieWest
OzieWest / readme.md
Last active September 1, 2016 10:19
Creating a Self-Signed SSL Certificate for an Amazon ELB

Generate a Private Key The Private Key is used to decrypt messages sent to the server. Keep this safe and secret! Use any password when prompted (we’ll remove it later).

openssl genrsa -des3 -out domain.key 1024

Generate a Certificate Signing Request (CSR) The CSR contains the Public Key, used to encrypt messages, and information about the application so the end user (visitor) can see, so enter the information accordingly.

openssl req -nodes -newkey rsa:2048 -keyout domain.key -out domain.csr