Skip to content

Instantly share code, notes, and snippets.

@simbo1905
simbo1905 / PwnedPasswords.md
Last active October 27, 2023 14:31
How To Load The HIBP Pwned Passwords Database Into Redis

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.

@simbo1905
simbo1905 / .htaccess
Last active February 13, 2018 08:10
.htaccess write traffic to a subfolder to move a site into a subfolder
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/concrete575/
RewriteRule (.*) http://www.mysite.net/concrete575/$1 [R=301,L]
</IfModule>
@simbo1905
simbo1905 / gist:1d2d198db1c54b85e41b1389cd37dce8
Created February 12, 2018 20:22
chmod recursively if you only have ftp and cpanel access
#!/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'
@simbo1905
simbo1905 / git_clobber_contents.sh
Created December 10, 2017 05:13
git replace local repo contents with new remote repo contents
# 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
@simbo1905
simbo1905 / InterruptProbability.scala
Created September 4, 2017 07:46
The probability that two random numbers in the range [0,1] are 0.35 apart.
/**
* 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 = {
@simbo1905
simbo1905 / php-5.2.17.patch
Created July 24, 2017 21:01
patch php 5.2.17 for Centos7 with patch -p0 < ../php-5.2.17.patch
--- ext/dom/node.c 2012-08-06 17:49:48.826716692 +0800
+++ ext/dom/node.c 2012-08-06 17:52:47.633484660 +0800
@@ -1895,9 +1895,17 @@ static void dom_canonicalization(INTERNA
RETVAL_FALSE;
} else {
if (mode == 0) {
+#ifdef LIBXML2_NEW_BUFFER
+ ret = xmlOutputBufferGetSize(buf);
+#else
ret = buf->buffer->use;
def perms(positions: List[Int]) = {
val x: Set[List[Int]] = positions.permutations.map(_.take(2)).toSet
val y = x filter {
case a :: b :: Nil =>
(a, b) match {
case (a: Int, b: Int) if a < b => true
case _ => false
}
case _ => false
@simbo1905
simbo1905 / docker-cassandra.md
Last active March 15, 2017 17:16
docked cassandra cluster
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/favicon.ico", "/resources/**", "/signup",
"/register", "/public")
.permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
@simbo1905
simbo1905 / Pickling.scala
Created April 23, 2015 20:16
org.scala-lang.modules:scala-pickling_2.11:0.10.0.jar crashes Oracle Java OSX 1.8.0_45
package com.github.simbo1905.trex.internals
import java.nio.ByteBuffer
import akka.util.ByteString
object Pickle {
import scala.pickling.Defaults._