Skip to content

Instantly share code, notes, and snippets.

:bowtie:
🧐

Mischa Spiegelmock revmischa

:bowtie:
🧐
Block or report user

Report or block revmischa

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View qclocust.py
from random import uniform, randint
from locust import TaskSequence, HttpLocust
from locust import seq_task
import random
import string
import os
def randomStringDigits(stringLength=6):
"""Generate a random string of letters and digits """
@revmischa
revmischa / serverless.yml
Last active Apr 11, 2019
Serverless CloudFormation to provide private RDS and lambda networking with internet access in VPC.
View serverless.yml
plugins:
- serverless-pseudo-parameters
provider:
name: aws
runtime: python3.7
stage: ${opt:stage, 'dev'}
environment:
SQLALCHEMY_DATABASE_URI: # DB DSN
@revmischa
revmischa / response_unwrap.kt
Created Mar 11, 2019
Always unwrap a JSON response key using Retrofit/Moshi/Kotlin
View response_unwrap.kt
// for parsing "data" out of every response object
// https://stackoverflow.com/questions/23070298/get-nested-json-object-with-gson-using-retrofit/40691739#40691739
class ItemTypeAdapterFactory : TypeAdapterFactory {
override fun <T> create(gson: Gson, type: TypeToken<T>): TypeAdapter<T> {
val delegate = gson.getDelegateAdapter(this, type)
val elementAdapter = gson.getAdapter(JsonElement::class.java)
return object : TypeAdapter<T>() {
override fun write(out: JsonWriter, value: T) {
@revmischa
revmischa / sdl_version_check.m4
Last active Feb 9, 2019
Autoconf m4 to check if minimum SDL library version exists
View sdl_version_check.m4
# SDL
AC_ARG_ENABLE([sdl], AS_HELP_STRING([--enable-sdl], [Build SDL2 application]), [], [enable_sdl=check])
AS_IF([test "$enable_sdl" != "no"], [
m4_include([m4/sdl2.m4])
SDL_VERSION="2.0.5"
AS_IF([test "$TRAVIS"], [SDL_VERSION=2.0.2]) # travis has old SDL, we don't care
AS_IF([test "$EMSCRIPTEN"], [SDL_VERSION=2.0.0]) # emscripten has old SDL, we don't care
# Check for libSDL >= $SDL_VERSION
found_sdl=no
@revmischa
revmischa / handler.py
Created Jan 15, 2019
Twilio call handler lambda
View handler.py
from twilio.twiml.voice_response import VoiceResponse, Dial
from twilio.rest import Client
from urllib.parse import parse_qsl
import requests
import json
from pprint import pprint
import boto3
session = boto3.session.Session()
@revmischa
revmischa / eurobash_prompt.sh
Last active Oct 27, 2017
European Bash Prompt ($PS1)
View eurobash_prompt.sh
if [[ `whoami` == "root" ]]; then
ISROOT=1
fi
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(❲.*\)/ ❲\1❳/'
}
# git status
parse_git_dirty() {
@revmischa
revmischa / logplex_syslog_lambda.py
Last active Nov 20, 2018
Heroku logplex syslog handler lambda
View logplex_syslog_lambda.py
"""Sample handler for parsing Heroku logplex drain events (https://devcenter.heroku.com/articles/log-drains#https-drains).
Expects messages to be framed with the syslog TCP octet counting method (https://tools.ietf.org/html/rfc6587#section-3.4.1).
This is designed to be run as a Python3.6 lambda.
"""
import json
import boto3
import logging
import iso8601
@revmischa
revmischa / open_iot_security_cert.md
Created Jun 13, 2017
Open IoT Security Certification Draft
View open_iot_security_cert.md

Level I - Basic

Network

Software/Firmware

  • No default username/password
    • Devices must not ship with a well-known username and/or password
      • Unless the password must be changed on first use No backdoor passwords in firmware. This can be dumped and reversed and published.
@revmischa
revmischa / myapp.py
Last active Nov 20, 2016
Deferred jobs with sqlalchemy/flask/apscheduler
View myapp.py
# sample usage:
class MyFlaskApp(Flask):
...
def start_heartbeat(self):
"""Schedule periodic heartbeat updates."""
if hasattr(self, 'heartbeat_sched'):
raise Exception("Heartbeat already started")
sched = self.get_scheduler()
self.heartbeat_sched = sched
@revmischa
revmischa / xml2json.xslt
Last active Oct 17, 2016
XSLT to convert XML TO JSON (lol)
View xml2json.xslt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--
Copyright (c) 2006,2008 Doeke Zanstra
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
You can’t perform that action at this time.