Skip to content

Instantly share code, notes, and snippets.

View revmischa's full-sized avatar
🇺🇦

Mischa Spiegelmock revmischa

🇺🇦
View GitHub Profile
@revmischa
revmischa / handler.py
Created January 15, 2019 08:03
Twilio call handler lambda
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 October 27, 2017 20:22
European Bash Prompt ($PS1)
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 November 20, 2018 10:25
Heroku logplex syslog handler lambda
"""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 June 13, 2017 02:42
Open IoT Security Certification Draft

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 November 19, 2021 01:31
Deferred jobs with sqlalchemy/flask/apscheduler
# 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 October 17, 2016 20:08
XSLT to convert XML TO JSON (lol)
<?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
"""Mass invite users from one channel to another."""
from slacker import Slacker
from pprint import pprint
slack = Slacker('xxxxx')
me = slack.auth.test().body
me_id = me['user_id']
#!/usr/bin/env perl
# convert postgres slow query log query w/ separate 'parameters:' line into an executable EXPLAIN ANALYZE query
use strict;
use warnings;
use Data::Dump qw/ddx/;
my $qfile = shift @ARGV or die "query file required";
@revmischa
revmischa / shitlink.pl
Last active November 11, 2015 02:29
Irssi script to prevent clicking of low-quality links on the internet
#!/bin/bash
# usage: bin/slackmsg "blah blah blah" => #engineering
# escape message for JSON:
MSG=$(printf '%q' $*)
echo $MSG
PAYLOAD="payload={\"channel\": \"#engineering\", \"username\": \"engbot\", \"text\": \"$MSG\", \"icon_emoji\": \":shipit:\"}"
echo $PAYLOAD