Skip to content

Instantly share code, notes, and snippets.

View jsmolina's full-sized avatar

Jordi Sesmero jsmolina

  • Barcelona
View GitHub Profile
@jsmolina
jsmolina / gist:5550a0490e1dd327599790c863c706e4
Created April 26, 2022 14:00
Open Macos keyboardAssistant
sudo open /System/Library/CoreServices/KeyboardSetupAssistant.app/Contents/MacOS/KeyboardSetupAssistant
@jsmolina
jsmolina / ec2_monitoring.py
Last active March 21, 2022 15:26
Simple ec2 monitoring for opentelemetry
import botocore.session
from botocore import monitoring
from opentelemetry.trace import get_tracer
from opentelemetry import trace
from opentelemetry.trace import SpanKind
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace.status import Status, StatusCode
from opentelemetry.instrumentation.utils import (
http_status_to_status_code,
)
@jsmolina
jsmolina / snippet.js
Created March 15, 2022 15:45
React snippet for tracking user enters or leaves a page
const [lastVisit, setLastVisit] = useState(null);
useEffect(
() =>
history.listen((e) => {
logEvent(TrackEvents.PAGE_VISIT, { route: e.pathname });
const now = Date.now() / 1000;
lastVisit &&
logEvent(TrackEvents.PAGE_LEAVE, {
route: lastVisit.path,
@jsmolina
jsmolina / http-servers.go
Created January 27, 2022 12:26
Go Thrift decode server without IDL
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
import "github.com/thrift-iterator/go"
import "github.com/thrift-iterator/go/general"
@jsmolina
jsmolina / app.py
Created November 12, 2021 12:04
simple w3c tracecontext plugin for traceapi
from plugin import TraceParentLogger
def create_app():
config = get_api_settings()
app = FastAPI...
....
app.add_middleware(RawContextMiddleware, plugins=(TraceParentLogger(),)
@jsmolina
jsmolina / Dockerfile
Last active September 27, 2022 16:06
simple http server for testing kong api gw
FROM python:3.9.5-slim-buster
ENV PYTHONUNBUFFERED 1
RUN adduser \
--disabled-password \
--gecos "" \
--home /app \
app
@jsmolina
jsmolina / zx_spectrum_color.py
Created January 8, 2021 08:32
python3 script to determine which number corresponds to the specific zx spectrum color + paper + flash + bright
# python3 script to determine
# 1 flash, 1 bit bright,3 bits paper,3 bits ink
if __name__ == '__main__':
colors = {
"INK_BLACK": 0x00,
"INK_BLUE": 0x01,
"INK_RED": 0x02,
"INK_MAGENTA": 0x03,
"INK_GREEN": 0x04,
"INK_CYAN": 0x05,
"""
Converts in batch 7zip files to zip
"""
import zipfile
import glob
from io import BytesIO
import argparse
# Uncomment to use macos hack brew version of of libarchive
# import os
@jsmolina
jsmolina / wait_for_vpn.sh
Created November 14, 2018 16:02
Blocks until host is reachable by SSH. Useful for opening a VPN asynchronously and waiting for connection to be ready.
#!/usr/bin/env bash
until nc -nz $1 22 -w 5 &>/dev/null; do :; done
@jsmolina
jsmolina / unmerge_parquet.py
Created November 14, 2018 15:10
Allows splitting merged parquet files with an accidental hadoop fs -getmerge
"""
Obtained from
https://stackoverflow.com/questions/41564291/parquet-build-with-hdfs-getmerge-recovery
"""
import sys
import locale
import os
import re
import io