Skip to content

Instantly share code, notes, and snippets.

Avatar
🧐

Mischa Spiegelmock revmischa

🧐
View GitHub Profile
@revmischa
revmischa / aptCmd.groovy
Created Apr 30, 2020
Jenkins groovy routine to wait for apt lock before running commands.
View aptCmd.groovy
/**
* Wait for apt lock to be free, then run command.
* @param aptArgs E.g. `install -y emacs xterm`
*/
void call(String aptArgs) {
def timeout = 120 // wait for lock this long
def fileno = 1000 // unused file descriptor number
def lockfile = "/var/lib/dpkg/lock"
sh """
/usr/bin/sudo bash -c "(flock --timeout $timeout $fileno; apt $aptArgs) $fileno> $lockfile"
@revmischa
revmischa / DockerfileLambdaChromium
Created Apr 1, 2020
Build chromium on amazon linux 2
View DockerfileLambdaChromium
FROM lambci/lambda:build-python3.8
# ref: https://chromium.googlesource.com/chromium/src.git/+refs
ARG VERSION
ENV VERSION ${VERSION:-master}
LABEL maintainer="Mischa Spiegelmock <me@mish.dev>"
LABEL chromium="${VERSION}"
WORKDIR /
@revmischa
revmischa / amzlinux2-ami-mapping.yml
Last active Mar 20, 2020
Amazon Linux 2 AMI ID mapping for cloudformation
View amzlinux2-ami-mapping.yml
Mappings:
AWSAMIRegionMap:
# https://aws.amazon.com/amazon-linux-2/release-notes/
AMI:
AMZNLINUXHVM: amzn2-ami-hvm-2.0.20200207.1-x86_64-gp2
ap-east-1:
AMZNLINUXHVM: ami-47e4a036
eu-central-1:
AMZNLINUXHVM: ami-0df0e7600ad0913a9
us-west-2:
View keybase.md

Keybase proof

I hereby claim:

  • I am revmischa on github.
  • I am cybermischa (https://keybase.io/cybermischa) on keybase.
  • I have a public key ASA2gwimJ5iuAryMq_bkJ9OECR-6vpSHXoeCAGg_-GlY-Ao

To claim this, I am signing this object:

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() {
You can’t perform that action at this time.