Skip to content

Instantly share code, notes, and snippets.

View mikesol's full-sized avatar
🎯
Focusing

Mike Solomon mikesol

🎯
Focusing
View GitHub Profile
@mikesol
mikesol / openapi_py_to_hs.py
Last active April 24, 2020 07:57
Converts openapi.py in openapi_typed_2 to haskell
from openapi import OpenAPIObject, Reference, APIKeySecurityScheme, APIKeySecurityScheme, HTTPSecurityScheme, OAuth2SecurityScheme, OpenIdConnectSecurityScheme, Response
import openapi
from collections.abc import Mapping, Sequence
from typing import Union, Any, ForwardRef
import typing
def px(a):
return '(%s)' % a if (' ' in a) and (a[0] != '[') else a
@mikesol
mikesol / unmock-stripe.json
Created February 13, 2020 16:35
Mock stripe data generated by unmock
{
"data": [
{
"created": 74675021,
"id": "dolor enim minim culpa ipsum",
"livemode": true,
"object": "customer",
"sources": {
"data": [
{
@mikesol
mikesol / hoverfly-success-with-stripe.json
Created February 10, 2020 08:33
Customer success for a single customer with Stripe
{
"id": "cus_GhmV4PbooARHhM",
"object": "customer",
"account_balance": 0,
"address": {
"city": "Melbourne",
"country": "AU",
"line1": "1 Batman Way",
"line2": "",
"postal_code": "3000",
@mikesol
mikesol / hoverfly-matchers.json
Created February 10, 2020 08:28
A hoverfly error with matcher suggestions
Hoverfly Error!
There was an error when matching
Got error: Could not find a match for request, create or record a valid matcher first!
The following request was made, but was not matched by Hoverfly:
{
"Path": "/v1/customers/foobar",
@mikesol
mikesol / stripe-hoverfly-simulation.json
Last active February 10, 2020 08:20
A stripe hoverfly simulation
{
"error": {
"message": "You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g. 'Authorization: Bearer YOUR_SECRET_KEY'). See https://stripe.com/docs/api#authentication for details, or we can help at https://support.stripe.com/.", "type": "invalid_request_error"
}
}
@mikesol
mikesol / stripe-v1-customers.json
Created February 9, 2020 21:19
Mock data from stripe /v1/customers
{
"object": "list",
"data": [
{
"id": "cus_GhmXKD3awekHyV",
"object": "customer",
"account_balance": -755,
"address": {
"city": "Elk Grove",
"country": "US",
@mikesol
mikesol / test_list_elt_gt_1.py
Last active August 7, 2019 10:23
Prove that a list whose sum is greater than its length must have at least one element greater than one
from z3 import *
def test_list_elt_gt_1():
ll = Datatype('ll')
ll.declare('empty')
ll.declare('cons', ('car', IntSort()), ('cdr', ll))
ll = ll.create()
list_sum = Function('list_sum', ll, IntSort(), BoolSort())
list_len = Function('list_len', ll, IntSort(), BoolSort())
a,e = Consts('a e', ll)
@mikesol
mikesol / test_negative_list_sum.py
Last active August 7, 2019 10:18
Prove that the sum of a list of negative numbers is negative
from z3 import *
def test_negative_list_sum():
ll = Datatype('ll')
ll.declare('empty')
ll.declare('cons', ('car', IntSort()), ('cdr', ll))
ll = ll.create()
list_sum = Function('list_sum', ll, IntSort(), BoolSort())
a,e = Consts('a e', ll)
b,c,d = Ints('b c d')
@mikesol
mikesol / prose.kt
Last active August 19, 2019 19:36
Kotlin code snippet
class _First {
infix fun sign(into: _Into) = into
}
class _Into {
infix fun your(console: _Console) {
// insert sign in logic, ie via Robolectric
return console
}
}
class _Console { val Then = this
@mikesol
mikesol / tabhack.js
Created April 18, 2018 06:51
A hack for fenced code tabs in mkdocs material
document.addEventListener('DOMContentLoaded', function () {
var hashcache = {};
var langcache = {};
var ariacache = {};
Array.prototype.forEach.call(document.querySelectorAll('ul.nav.nav-tabs'), function(tablist) {
Array.prototype.forEach.call(tablist.querySelectorAll('li.nav-item'), function(tabitem) {
Array.prototype.forEach.call(tabitem.querySelectorAll('a'), function (anchor) {
var lang = anchor.getAttribute("data-lang");
var aria = anchor.getAttribute("aria-controls");
var obj = {