Instantly share code, notes, and snippets.

View GnuPG-2.2.md

GnuPG 2.2.x Build Instructions

Below are my build instructions for GnuPG 2.2.9, released on July 12th, 2018. These instructions are built for a headless Centos 7 LTS server (specificaly the openshift/base-centos7 docker image).

You use the below install script to install GnuPG 2.2.x by running the following commands:

# if you are root in a docker image:
curl -OL "https://gist.githubusercontent.com/simbo1905/ba3e8af9a45435db6093aea35c6150e8/raw/83561e214e36f6556fd6b1ec0a384cf28cb2debf/install-gnupg22.sh" && bash ./install-gnupg22.sh
# else if you need to sudo to do the installs:
View commands.sh
# If there is a repo in, say Heroku, or say BitBucket, and you want to push to it code from GitHub
git remote add upstream git@github.com:hyperledger/indy-sdk.git
# pull everything from upstream clobbering anything local (assumes you start with an empty repo)
git pull -s recursive -X theirs upstream master
View how-to-start-up-on-openshift.md

Introduction

These instructions are for a demo I will be giving of how to setup a realistic backend API and frontend SPA. Due to time constraints I will start with a working setup and demo skip straight to the section "Some 'real world' things to demo in the presentation".

The demo code we will deploy is part of the www.realworld.io project where different people write alternative interoperable frontends or backends. Below I have chosen ReactJS and Laravel but you could use any of the demo apps that use different langages and frameworks.

Prerequisites Instructions

Here we fork the demo code repos (so that we can setup GitHub web hooks to CI build the code) and create and OpenShift account to run it on.

View create-env-secret.sh
#!/bin/bash
if [ "$NAME" = "" ]
then
echo "You must set NAME of the secet as an env var"
exit 1
else
echo "Creating secet/$NAME"
fi
View PwnedPaswordsMongoDB.md

How To Load The HIBP Pwned Passwords Database Into MongoDB

NIST recommends that when users are trying to set a password you should reject those that are commonly used or compromised:

When processing requests to establish and change memorized secrets, 
verifiers SHALL compare the prospective secrets against a list that 
contains values known to be commonly-used, expected, or compromised.

But how do you know what are the compromised passwords? Luckily Troy Hunter put a lot of effort into building the "Have I Been Pwned (HIBP)" database with the SHA1 hashes of 501,636,842 passwords that have been compromised on the internet. Sweet.

View PwnedPasswords.md

How To Load The HIBP Pwned Passwords Database Into Redis

NIST recommends that when users are trying to set a password you should reject those that are commonly used or compromised:

When processing requests to establish and change memorized secrets, 
verifiers SHALL compare the prospective secrets against a list that 
contains values known to be commonly-used, expected, or compromised.

But how do you know what are the compromised passwords? Luckily Troy Hunter put a lot of effort into building the "Have I Been Pwned (HIBP)" database with the SHA1 hashes of 501,636,842 passwords that have been compromised on the internet. Sweet.

View .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/concrete575/
RewriteRule (.*) http://www.mysite.net/concrete575/$1 [R=301,L]
</IfModule>
View gist:1d2d198db1c54b85e41b1389cd37dce8
#!/bin/bash
lftp <<EOF
set ftp:ssl-allow no
set ftp:passive-mode true
set ftp:list-options -a
open -u user,password my.host.com
chmod -R 0777 /public_html/images/cache
EOF
# you can 'brew install lftp'
View git_clobber_contents.sh
# sometimes your local repo is created by some tool and you need to seed it with some other
# sample code where you don't need/want to fork the sample code. Try this:
GIT_SRC_URL=$1
remote add simplecode $GIT_SRC_URL
git pull simplecode master -X theirs --allow-unrelated-histories
View InterruptProbability.scala
/**
* The probability that two numbers in the range [0,1] are 0.35 apart.
*
* See discussion at https://math.stackexchange.com/a/2182330
* Which explains this chart
* http://www.mathsisfun.com/data/grapher-equation.html?func1=x-y%3D0.35&func2=y-x%3D0.35&xmin=-0.2147&xmax=1.512&ymin=-0.01944&ymax=1.276
*/
object InterruptProbability {
import scala.util.Random.nextFloat
def main(args: Array[String]): Unit = {