Skip to content

Instantly share code, notes, and snippets.

View Tarliton's full-sized avatar
🐍

Tárliton Basso de Godoy Tarliton

🐍
  • Amsterdam - Netherlands
  • 10:33 (UTC +02:00)
View GitHub Profile
@Tarliton
Tarliton / pyenv-in-docker.md
Created August 20, 2023 10:30
compile pyenv inside docker

Compiling a python version with pyenv inside docker

  • Start docker container with desired gcc version
  • Add your pynev directory as a volume inside the container

🔴Important🔴:

  • only use the same path as your user if you know what you are doing

Command:

@Tarliton
Tarliton / solution.py
Last active June 3, 2022 21:27
Tree in array shortest path.
# pip install Dijkstar python-constraint
from constraint import *
from dijkstar import Graph, find_path
tam = 10
problem = Problem()
variables = []
for i in range(tam):
@Tarliton
Tarliton / main.go
Created July 7, 2021 15:24
Auto GORM New Relic instrumentation/integration
package main
import (
"context"
"database/sql"
"fmt"
_ "github.com/newrelic/go-agent/v3/integrations/nrmysql"
"github.com/newrelic/go-agent/v3/newrelic"
"gorm.io/driver/mysql"
"gorm.io/gorm"
@Tarliton
Tarliton / oph.py
Created April 29, 2021 22:40
open processes hashes
import hashlib
import psutil
BUF_SIZE = 65536
exes = set()
for p in psutil.process_iter():
exe = p.exe()
@Tarliton
Tarliton / requirements.in
Created April 24, 2021 13:07
netdata anomaly detection install
llvmlite
numpy==1.20.1
netdata-pandas==0.0.32
numba==0.50.1
scikit-learn==0.23.2
pyod==0.8.3
wheel
cython
pybind11
@Tarliton
Tarliton / setup.py
Last active April 12, 2021 20:49
Shim setup.py for editable pip install (-e). For projects with pyproject.toml
import setuptools
if __name__ == "__main__":
setuptools.setup()
@Tarliton
Tarliton / sqlalchemy_reflect_simple.py
Last active February 26, 2023 12:58
Quick sqlalchemy reflect whole database
from sqlalchemy import create_engine
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import sessionmaker
url = 'mysql://<user>:<password>@<ip>:<port>/<name>'
engine = create_engine(url, echo=True)
Base = automap_base()
Base.prepare(autoload_with=engine)
Session = sessionmaker(bind=engine)
session = Session()
@Tarliton
Tarliton / README.md
Created October 11, 2020 04:37
namedtuple broken Python 3.9.0

In Python <= 3.8, if you run:

from collections import namedtuple
MyClass = namedtuple("MyClass", "")
m = MyClass()
print(m.__class__['__name__'])
print(type(m.__class__['__name__']))

It will raise TypeError in:

@Tarliton
Tarliton / incredible_factorial.py
Created August 25, 2020 18:20
Solution to MindYourDecisions video https://www.youtube.com/watch?v=9dyK_op-Ocw with constraint programming
from constraint import *
def fact(n):
f = 1
for i in range(1,n+1):
f = f * i
return f
@Tarliton
Tarliton / sudoku.py
Created August 23, 2020 02:40
solve sudoku with python constraint
from collections import defaultdict
from constraint import *
example = """.......92
...1...4.
9..24...7
8..7..15.
65.9.1.78
.74..8..6
3...95..1