Skip to content

Instantly share code, notes, and snippets.

Avatar

Lars Kumbier LarsKumbier

View GitHub Profile
@LarsKumbier
LarsKumbier / update-keys.sh
Created Feb 15, 2019
This will update the remote ssh keys and reset the known_hosts file after a redeploy of new machines
View update-keys.sh
#!/usr/bin/env bash
##
## This will update the remote ssh keys and reset the known_hosts file after a redeploy of a new VM
##
## will return the found *.example.com host names from an ansible file
## - alternatively, put your own logic here or give a fixed list:
## HOSTS=( host1.example.com host2.example.de )
HOSTS=( $(grep -o -e "[a-zA-Z0-9\-]*\.example\.com" inventory/heidelberg/inventory) )
@LarsKumbier
LarsKumbier / check-for-hsts-redirect-loops.py
Created Aug 13, 2018
When activating HSTS, all links of a page will be rewritten from http to https upon clicking on them. This might lead to redirect-loops, where an https-page is redirecting to http and back on badly programmed rewrite rules. This script takes a list of urls and checks, if they run into a redirect-loop upon activating HSTS.
View check-for-hsts-redirect-loops.py
from urllib.parse import urlparse
import requests
import sys
MAX_REDIRECTS=8
URL_LIST='urls.txt'
def requestUrl(url, counter=0):
def upgradeUrl(url):
View db.users.find.json
{
"userId" : 1,
"__classname__" : "some-static-string",
"failedLoginCount": 0,
"mailValidated": true,
"answers": {
"toTheQuestion": -42,
"niceBlog": "Slate Star Codex"
}
}
View mongoimport.sh
mongoimport -d db -c users --type tsv --file export.tsv --headerline --columnsHaveTypes
View result.tsv
userId.auto() __classname__.auto() failedLoginCount.int32() mailValidated.boolean() answers.toTheQuestion.int32() answers.niceBlog.auto()
1 'some-static-string' 0 TRUE -42 'Slate Star Codex'
2 'some-static-string' 2 FALSE -42 'Slate Star Codex'
@LarsKumbier
LarsKumbier / export.sql
Last active Apr 16, 2019
Export Postgresql for mongoimport
View export.sql
COPY (
SELECT
userid AS "userId.auto()",
'some-static-string' AS "__classname__.auto()",
failed_login_count AS "failedLoginCount.int32()",
CASE WHEN mail_validated=TRUE THEN 'TRUE' ELSE 'FALSE' END AS "mailValidated.boolean()",
-42 AS "answers.toTheQuestion.int32()",
'Slate Star Codex' AS "answers.niceBlog.auto()"
FROM
users.accounts
@LarsKumbier
LarsKumbier / keybase.md
Created Apr 19, 2014
Proof of Identity for keybase.io
View keybase.md

Keybase proof

I hereby claim:

  • I am LarsKumbier on github.
  • I am larskumbier (https://keybase.io/larskumbier) on keybase.
  • I have a public key whose fingerprint is 61DF 4812 8447 4B95 689B 9DB0 EE73 4042 E4AC D8BA

To claim this, I am signing this object: