Skip to content

Instantly share code, notes, and snippets.

@jaysonsantos
jaysonsantos / force_spoon_java8.patch
Last active October 11, 2017 10:10
Force spoon to always run on java8
--- spoon.sh.bkp 2017-10-11 11:43:09.000000000 +0200
+++ spoon.sh 2017-10-11 11:52:07.000000000 +0200
@@ -1,5 +1,15 @@
#!/bin/sh
+# Hacky way to force java8
+JAVA_VMS_LOCATION="/Library/Java/JavaVirtualMachines"
+LATEST_JAVA_8="$(ls $JAVA_VMS_LOCATION | grep jdk1.8 | sort | tail -n 1)"
+if [ -z "$LATEST_JAVA_8" ]; then
+ echo "Java 8 not found"
@jaysonsantos
jaysonsantos / conftest.py
Created October 27, 2017 17:51
sqlalchemy + pytest patch session to avoid commits on tests
import pytest
@pytest.yield_fixture(scope='session')
def patch_session():
def commit():
"""Flush and expire caches."""
db.session.flush()
db.session.expire_all()
old_commit = db.session.commit
@jaysonsantos
jaysonsantos / .dockerignore
Last active November 19, 2018 01:47
Rust AWS Lambda Builder and Runner
target/*
# frozen_string_literal: true
require 'pathname'
class EnvImporter
def initialize(env_file, environment_name, app_name, overwrite = false,
number_of_threads = 4)
validate_aws_cli
@env_file = env_file
@environment_name = environment_name
#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
#include <arpa/inet.h>
int main(int argc, char **argv)
{
if (argc < 2) {
printf("Provide the host to be resolved\n");
return 1;
find_kafka_device() {
for device in $(nvme list | grep ^/dev | awk '{print $1}')
do
local found_device="$(nvme id-ctrl -v $device | grep -Po '/dev/[a-z0-9]+' || true)"
if [[ -n "$found_device" ]]; then
echo "$device"
return 0
fi
done
@jaysonsantos
jaysonsantos / pre-commit-poetry-lock.yaml
Last active November 21, 2019 18:00
Example hook for pre-commit to check if poetry file is locked
- repo: local
hooks:
- id: poetry_lock
name: Check if poetry is updated
entry: python -c "from poetry.poetry import Poetry;
assert Poetry.create('.').locker.is_fresh(), 'Poetry is not locked'"
language: python_venv
additional_dependencies:
- poetry
-- Logs begin at Sat 2019-10-19 17:13:06 CEST, end at Tue 2019-12-03 16:16:09 CET. --
Oct 22 22:00:17 jayson-lg systemd[1]: Started ZeroTier One.
Oct 23 09:59:20 jayson-lg zerotier-one[17481]: connect: Network is unreachable
Oct 23 09:59:20 jayson-lg zerotier-one[17481]: connect: Network is unreachable
Oct 23 21:42:00 jayson-lg zerotier-one[17481]: connect: Connection timed out
Oct 31 21:08:29 jayson-lg zerotier-one[17481]: connect: Connection refused
Oct 31 21:08:29 jayson-lg zerotier-one[17481]: connect: Connection refused
Oct 31 21:14:06 jayson-lg zerotier-one[17481]: connect: Connection refused
Oct 31 21:14:06 jayson-lg zerotier-one[17481]: connect: Connection refused
Oct 31 21:14:06 jayson-lg zerotier-one[17481]: connect: Connection refused
@jaysonsantos
jaysonsantos / Dockerfile
Last active December 28, 2019 20:07
killbill api with fargate/ecs/kubernetes systems
FROM killbill/killbill:0.20.0
ADD kpm.yml /var/lib/killbill/kpm.yml
# Patch to respect X-Fowarded-Proto and others when running with ELB
ADD server.xml.patch ./
RUN patch -p1 < server.xml.patch
# Script that setup traps to respect docker stop commands and stop catalina
ADD fargate-killbill.sh ./
import re
from dataclasses import dataclass, fields
from typing import Dict
CAMEL_CASE_RE = re.compile(r'([a-z])([A-Z])')
@dataclass(frozen=True)
class ApiGatewayRequest:
headers: Dict[str, str]