Skip to content

Instantly share code, notes, and snippets.

Avatar

Lukas Lösche lloesche

View GitHub Profile
@lloesche
lloesche / process.py
Created Aug 22, 2019
Python coding challenge
View process.py
#!/usr/bin/env python3
from pprint import pprint
document_uri = 'https://gist.githubusercontent.com/demersdesigns/4442cd84c1cc6c5ccda9b19eac1ba52b/raw/cf06109a805b661dd12133f9aa4473435e478569/craft-popular-urls'
def process(document, num_threads=10):
"""Processes a document either found on the local disk or a remote http/https URI
The function reads the document (either from a local file or remote URL) and finds all the http and https URLs in it.
@lloesche
lloesche / short2long_regions.py
Created Apr 23, 2019
boto short to long region names for use with AWS pricing API
View short2long_regions.py
# Get the long region names used by the AWS Pricing API
#
# There's currently no proper API to do this
#
# Example:
# print(SHORT_TO_LONG_REGIONS['us-west-2'])
# > US West (Oregon)
from pkg_resources import resource_filename
@lloesche
lloesche / pullall.sh
Last active Feb 7, 2019
Checkout/Pull all repos of a Github organization
View pullall.sh
#!/bin/bash
set -o errexit -o pipefail
org=dcos-terraform
parallel=10
function main {
local num_repos=-1
local page=1
local i
local x
@lloesche
lloesche / zkdump.py
Created May 16, 2018
dump DC/OS pre-cockroachdb IAM data
View zkdump.py
#!/usr/bin/env python3
import logging
logging.basicConfig()
from kazoo.client import KazooClient
zk = KazooClient(hosts='10.0.28.160:2181', auth_data=[("digest", "super:xxxxxxxxxx")])
zk.start()
data, stat = zk.get("/bouncer/datastore/data.json")
text_file = open("data.json", "w")
text_file.write(data.decode("utf-8"))
@lloesche
lloesche / test.rb
Last active May 9, 2018
Just a test
View test.rb
#!/usr/bin/env ruby
require 'logger'
STDOUT.sync = true
log = Logger.new(STDOUT)
log.level = Logger::DEBUG
loop do
log.info "Hello World"
puts "Hello puts"
STDERR.puts "Hello stderr"
sleep 30
@lloesche
lloesche / migrate.sh
Last active Jun 3, 2019
Backup/Restore DC/OS Services and Jobs from one cluster to another in a suspended state
View migrate.sh
CLUSTER_A=olddcos
CLUSTER_B=newdcos
# BACKUP SERVICES
dcos cluster attach $CLUSTER_A
curl -H "Authorization: token=$(dcos config show core.dcos_acs_token)" $(dcos config show core.dcos_url)/service/marathon/v2/apps | \
jq '.[] | del(.[].version) | del(.[].uri) | del(.[].versionInfo) | del(.[].tasksStaged) | del(.[].tasksRunning) | del(.[].tasksHealthy) | del(.[].tasksUnhealthy) | del(.[].deployments)' > apps.json
for id in $(jq -r '.[] | "\(.id)"' apps.json); do cleanid="${id//\//_}"; jq ".[] | select(.id==\"$id\") | .instances=0" apps.json > service.${cleanid:1}.json; done
# BACKUP JOBS
@lloesche
lloesche / nvmelink.py
Created Apr 17, 2018
Create symlinks for AWS EC2 nvme devices
View nvmelink.py
@lloesche
lloesche / gist:a99e9e487f7bdc3b59c14c2c5ee4a25d
Created Jun 27, 2017
Testing our Github credential leakage scanner
View gist:a99e9e487f7bdc3b59c14c2c5ee4a25d
[default]
aws_access_key_id = AKIAJQATOQGMX2TOF1CX
aws_secret_access_key = I3rNML6Nl0vPbh0CuQdqSQ3LB5kHYAaBrWd+VEho
(these are invalid credentials)
View gist:482c72986fd739200a24c22d73b63ce7
Dockerfile:
FROM alpine:edge
CMD ["Hello World"]
ENTRYPOINT ["echo"]
{
"id": "/marathon-test",
"instances": 1,
"container": {
View Cert with X509v3 extension subjectAltName IP and DNS
# Create your CA crt and key:
openssl req -new -x509 -nodes -newkey rsa:4096 -extensions v3_ca -sha256 -days 3650 -subj "/C=US/ST=CA/L=San Francisco/O=Acme Inc./CN=Acme Insecure Certificate Authority" -keyout ca.key -out ca.crt
chmod 600 ca.key
# Create a CSR:
openssl req -newkey rsa:2048 -nodes -sha256 -keyout cert.key -out cert.csr -subj "/C=US/ST=CA/L=San Francisco/O=Snakeoil Inc./OU=Core/CN=lobotomat.de"
# Check contents of CSR (optional):
openssl req -in cert.csr -text -noout
You can’t perform that action at this time.