Skip to content

Instantly share code, notes, and snippets.

View nblagoev's full-sized avatar

Nikolay Blagoev nblagoev

  • Sofia, Bulgaria
View GitHub Profile
@nblagoev
nblagoev / selfSignedCert.sh
Last active January 27, 2021 07:36
Create self-signed certificate
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
-keyout example.key -out example.crt -subj "/CN=example.com" \
-addext "subjectAltName=DNS:example.com,DNS:www.example.net,IP:10.0.0.1"
openssl req -x509 -newkey rsa:4096 -sha256 -days 1825 -nodes \
-keyout example.key -out example.crt -extensions san -config \
<(echo "[req]";
echo distinguished_name=req;
echo "[san]";
echo subjectAltName=DNS:example.com,DNS:www.example.net,IP:10.0.0.1
@nblagoev
nblagoev / gpg-import-and-export-instructions.md
Created June 12, 2020 14:29 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@nblagoev
nblagoev / build-local-repo.md
Last active December 23, 2019 17:16
Build local maven repo

Build local maven repo of local jars

  1. Create a new folder, let’s say local-maven-repo at the root of your Maven project. Just add a local repo inside your of your pom.xml:
<repositories>
    <repository>
        <id>local-maven-repo</id>
        <url>file:///${maven.multiModuleProjectDirectory or project.basedir}/local-maven-repo</url>
    </repository>
@nblagoev
nblagoev / README.md
Created September 16, 2019 07:49 — forked from kacole2/README.md
Installing OpenFaaS on Pivotal Container Service (PKS) with Helm

The OpenFaaS documentation for faas-netes gives a clear explanation of how to install with Helm, but Pivotal Container Service (PKS) has 2 caveats since provisoned Kubernetes clusters are non-RBAC but are token backed and LoadBalancer inclusion with NSX-T. This is going to be a quick streamline of the documentation that adds out of the box support for PKS.

$ curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash
$ kubectl -n kube-system create sa tiller && kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
$ helm init --skip-refresh --upgrade --service-account tiller
$ kubectl apply -f https://raw.githubusercontent.com/openfaas/faas-netes/master/namespaces.yml
$ helm repo add openfaas https://openfaas.github.io/faas-netes/
$ helm repo update && helm upgrade openfaa
@nblagoev
nblagoev / ssl_test.sh
Created January 16, 2019 14:12 — forked from jaydansand/ssl_test.sh
Use OpenSSL to scan a host for available SSL/TLS protocols and cipher suites
#!/bin/bash
# Author: Jay Dansand, Technology Services, Lawrence University
# Date: 10/17/2014
# OpenSSL requires a port specification; default to 443.
SERVER="$1:443"
SERVER_HOST=$(echo "$SERVER" | cut -d ":" -f 1)
SERVER_PORT=$(echo "$SERVER" | cut -d ":" -f 2)
if [[ -z "$SERVER_HOST" || -z "$SERVER_PORT" ]]; then
echo "Usage: $0 host[:port] [ciphers [delay in ms]]"
import org.reactivestreams.Subscription;
import java.time.LocalTime;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import reactor.core.publisher.BaseSubscriber;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@nblagoev
nblagoev / tmux-cheats.md
Created December 23, 2017 21:10
My personal tmux cheat sheet for working with sessions, windows, and panes.

Sessions

New Session

  • tmux new [-s name] [cmd] (:new) - new session

Switch Session

  • tmux ls (:ls) - list sessions
  • tmux switch [-t name] (:switch) - switches to an existing session
@nblagoev
nblagoev / string-utils.js
Created October 22, 2017 06:58 — forked from jonlabelle/string-utils.js
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str){
return str.toLowerCase();
@nblagoev
nblagoev / Shape.ts
Created August 20, 2017 06:56
TypeScript snippets
type Shape =
{ kind: "circle", radius: number } |
{ kind: "rectangle", w: number, h: number } |
{ kind: "square", size: number };
function assertNever(obj: never) {
throw new Error("Unexpected object");
}
function getArea(shape: Shape) {
@nblagoev
nblagoev / tmux.cheat
Created August 8, 2017 15:08 — forked from afair/tmux.cheat
Tmux Quick Reference & Cheat sheet - 2 column format for less scrolling!
========================================== ==========================================
TMUX COMMAND WINDOW (TAB)
========================================== ==========================================
List tmux ls List ^b w
New -s <session> Create ^b c
Attach att -t <session> Rename ^b , <name>
Rename rename-session -t <old> <new> Last ^b l (lower-L)
Kill kill-session -t <session> Close ^b &