Skip to content

Instantly share code, notes, and snippets.

@edgarrmondragon
edgarrmondragon / tap.py
Created January 8, 2024 16:58
Singer SDK: split an API response into multiple streams
from typing_extensions import override
from singer_sdk import Stream, Tap
class ParentStream(Stream):
name = "parent"
schema = {
"properties": {
"W": {"type": "string"},
@edgarrmondragon
edgarrmondragon / README.md
Last active February 16, 2024 05:58
Custom logging handlers in Meltano

Send Meltano logs to Cloud Logging on GCP Compute Engine

  1. Create the smallest instance available with the following settings:

    1. Firewall: no inbound traffic
    2. Allow access to all Cloud APIs: https://cloud.google.com/logging/docs/setup/python#run-gce
    3. Check Install Ops Agent for Monitoring and Logging in the Observability - Ops Agent section
  2. SSH into the instance

  3. Check system

@edgarrmondragon
edgarrmondragon / generate.py
Last active September 12, 2023 20:20
generate_singer_messages.py
"""
https://mimesis.name/en/master/schema.html
"""
import functools
import json
import sys
import typing as t
from mimesis import Field, Schema
@edgarrmondragon
edgarrmondragon / resume.json
Last active January 24, 2023 06:50
JSON Resume
{
"meta": {
"theme": "elegant"
},
"basics": {
"name": "Edgar Ramírez",
"label": "Software Engineer",
"image": "",
"email": "edgarrm358@gmail.com",
"phone": "TODO",
@edgarrmondragon
edgarrmondragon / nohuman.py
Created January 5, 2022 04:53
Parse human-readable relative times with Arrow
import arrow
now = arrow.utcnow()
print(now)
# <Arrow [2022-01-05T04:51:29.467539+00:00]>
relative = now.dehumanize("3 months ago")
print(relative)
# <Arrow [2021-10-05T04:51:29.467539+00:00]>
@edgarrmondragon
edgarrmondragon / badge.json
Last active March 16, 2021 05:25
[Badge Endpoint] Example Dynamic JSON endpoint for https://shields.io/
{
"schemaVersion": 1,
"label": "Hello",
"message": "sweet world",
"color": "red"
}
@edgarrmondragon
edgarrmondragon / relationalize.py
Last active August 22, 2020 03:10
[Relationalize JSON Schema] #jsonschema #unnest
def _process_property(schema, _breadcrumbs=(), _root=()):
"""Create multiple, flat schemas from a single nested schema."""
t = schema['type']
# Leaf node
if t not in {'array', 'object'}:
yield _root, _breadcrumbs, schema
# Denest array
{
"PatentBulkData": [
{
"patentCaseMetadata":{
"applicationNumberText":{
"value":"16732312",
"electronicText":"16732312"
},
"filingDate":"2020-01-01",
@edgarrmondragon
edgarrmondragon / crypto.ipynb
Created April 29, 2020 21:48
[Bitcon & Ethereum Cointegration] #timeseries #python #dickey-fuller
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@edgarrmondragon
edgarrmondragon / blocked_blocking.sql
Last active May 7, 2020 19:29
[Fix PostgreSQL Table Locks] #sql #postgresql
-- The following query may be helpful to see what processes or applications are
-- blocking SQL statements (these only find row-level locks, not object-level locks).
SELECT blocked_locks.pid AS blocked_pid,
blocked_activity.usename AS blocked_user,
blocking_locks.pid AS blocking_pid,
blocking_activity.usename AS blocking_user,
blocked_activity.query AS blocked_statement,
blocking_activity.query AS current_statement_in_blocking_process,
blocked_activity.application_name AS blocked_application,
blocking_activity.application_name AS blocking_application