Skip to content

Instantly share code, notes, and snippets.

View lsevero's full-sized avatar

Lucas Severo lsevero

  • São Paulo, Brazil
View GitHub Profile
@lsevero
lsevero / diff_side_by_side.py
Created May 8, 2024 21:05 — forked from jlumbroso/diff_side_by_side.py
Side-by-Side Diff Comparison in Python
# Code licensed LGPLv3 by Jérémie Lumbroso <[email protected]>
import difflib
import itertools
import textwrap
import typing
def side_by_side(
left: typing.List[str],
@lsevero
lsevero / GPG and git on macOS.md
Created November 17, 2021 15:48 — forked from danieleggert/GPG and git on macOS.md
How to set up git to use the GPG Suite

GPG and git on macOS

Setup

No need for homebrew or anything like that. Works with https://www.git-tower.com and the command line.

  1. Install https://gpgtools.org -- I'd suggest to do a customized install and deselect GPGMail.
  2. Create or import a key -- see below for https://keybase.io
  3. Run gpg --list-secret-keys and look for sec, use the key ID for the next step
  4. Configure git to use GPG -- replace the key with the one from gpg --list-secret-keys
@lsevero
lsevero / run_in_executor.py
Created September 23, 2021 02:38 — forked from ddelange/executor.py
Make a sync function async
import asyncio
from functools import wraps, partial
def run_in_executor(fn=None, *, executor=None):
"""Make a sync function async. By default uses ThreadPoolExecutor."""
if fn is None:
# allow using this decorator with brackets, e.g.
# @run_in_executor(executor=ThreadPoolExecutor(1))
return partial(run_in_executor, executor=executor)
@lsevero
lsevero / airflow_eg.py
Created April 29, 2021 22:03 — forked from abridgett/airflow_eg.py
airflow XCOM notification example
MAP_SLACK_ATTACHMENTS = [
{
"fallback": "{{params.map}} {{ task_instance.xcom_pull(task_ids=params.map, key='slack_status') }}",
"pretext": "{{params.map}} update {{ task_instance.xcom_pull(task_ids=params.map, key='slack_status') }}",
"fields": [
{
"title": "Copied",
"value": "{{ task_instance.xcom_pull(task_ids=params.map, key='copied') }}",
"short": True
}
@lsevero
lsevero / listen.py
Created January 8, 2021 14:13 — forked from kissgyorgy/listen.py
How to use PostgreSQL's LISTEN/NOTIFY as a simple message queue with psycopg2 and asyncio
import asyncio
import psycopg2
# dbname should be the same for the notifying process
conn = psycopg2.connect(host="localhost", dbname="example", user="example", password="example")
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
cursor = conn.cursor()
cursor.execute(f"LISTEN match_updates;")
@lsevero
lsevero / Pipfile
Created December 30, 2020 14:21 — forked from onecrayon/Pipfile
async/await FastAPI with SQLAlchemy test
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
pylint = "*"
[packages]
sqlalchemy = "*"
@lsevero
lsevero / 000_how-to-construct-environment-for-common-lisp.md
Created August 2, 2020 16:04 — forked from otaon/000_how-to-construct-environment-for-common-lisp.md
vim と slimv と roswell と swank で common lisp を書く環境を作る

本記事の位置づけ

下記を実現するための手順書。

  • roswell(lisp実行環境構築ツール)を導入する
  • slimv(VimにおけるSLIME)を導入する
  • roswellとslimvでcommon lispをコーディング、実行するための設定をする

手順一覧

下記の順番に環境構築する。

@lsevero
lsevero / gist:c1cd2cd2e6f19757fefb2e5eecb15fca
Created August 2, 2020 00:18 — forked from sebfisch/gist:2235780
Laymans explanation of delimited continuations with examples of using them for exception handling and nondeterministic programming.

Delimited Continuations

Delimited continuations manipulate the control flow of programs. Similar to control structures like conditionals or loops they allow to deviate from a sequential flow of control.

We use exception handling as another example for control flow manipulation and later show how to implement it using delimited continuations. Finally, we show that nondeterminism can also be expressed using delimited continuations.

Exception Handling

@lsevero
lsevero / core.clj
Created May 5, 2020 16:04 — forked from mikeball/core.clj
Postgres listen/notify in Clojure using http://impossibl.github.io/pgjdbc-ng/
; Postgres listen/notify in Clojure using http://impossibl.github.io/pgjdbc-ng/
; in project.clj dependencies
; [com.impossibl.pgjdbc-ng/pgjdbc-ng "0.5"]
(ns pglisten.core
(:import [com.impossibl.postgres.jdbc PGDataSource]
[com.impossibl.postgres.api.jdbc PGNotificationListener]))
@lsevero
lsevero / README.md
Created March 5, 2020 04:04 — forked from gdamjan/README.md
Setup for an easy to use, simple reverse http tunnels with nginx and ssh. It's that simple there's no authentication at all. The end result, a single ssh command invocation gives you a public url for your web app hosted on your laptop.

What

A lot of times you are developing a web application on your own laptop or home computer and would like to demo it to the public. Most of those times you are behind a router/firewall and you don't have a public IP address. Instead of configuring routers (often not possible), this solution gives you a public URL that's reverse tunnelled via ssh to your laptop.

Because of the relaxation of the sshd setup, it's best used on a dedicated virtual machine just for this (an Amazon micro instance for example).

Requirements