Skip to content

Instantly share code, notes, and snippets.

View revmischa's full-sized avatar
🇺🇦

Mischa Spiegelmock revmischa

🇺🇦
View GitHub Profile
@revmischa
revmischa / readme.spec.ts
Created May 16, 2021 11:53
Unit test that tries to compile each code block in the README.md
import { createProjectSync, ts } from "@ts-morph/bootstrap"
import * as fs from "fs"
import * as path from "path"
import { default as SimpleMarkdown } from "simple-markdown"
describe("README examples", () => {
const readmePath = path.join(__dirname, "..", "..", "README.md")
const readmeContents = fs.readFileSync(readmePath)
// extract examples
@revmischa
revmischa / latynka.md
Last active May 8, 2021 20:21
Latínka Mishí

Ukrainian Latínka Amerikanskiy

A proposal to make life easy for Anglo/Romantic/Germanic speakers.

Latin Cyrillic Comment
í и Easy to write on mac
j дж Like Jesus would want
y й Fuck a "j" for this sound
v в Fuck using "w" for this
@revmischa
revmischa / aptCmd.groovy
Created April 30, 2020 12:11
Jenkins groovy routine to wait for apt lock before running commands.
/**
* 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 April 1, 2020 18:45
Build chromium on amazon linux 2
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 <[email protected]>"
LABEL chromium="${VERSION}"
WORKDIR /
@revmischa
revmischa / amzlinux2-ami-mapping.yml
Last active March 20, 2020 15:12
Amazon Linux 2 AMI ID mapping for cloudformation
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:

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:

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 April 11, 2019 10:21
Serverless CloudFormation to provide private RDS and lambda networking with internet access in VPC.
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 March 11, 2019 18:34
Always unwrap a JSON response key using Retrofit/Moshi/Kotlin
// 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 February 9, 2019 16:12
Autoconf m4 to check if minimum SDL library version exists
# 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