Skip to content

Instantly share code, notes, and snippets.

View Tarliton's full-sized avatar
🐍

Tárliton Basso de Godoy Tarliton

🐍
  • Brazil
  • 21:59 (UTC -03:00)
View GitHub Profile
@Tarliton
Tarliton / container_root.sh
Created February 26, 2020 22:09
enter container as root
sudo nsenter -t `pidof watch` -m -u -i -n -p /bin/bash
docker run --rm -it -v ~/Desktop:/work ubuntu
cd work/
apt update
apt-get install libimage-exiftool-perl
exiftool 20200703_111009.jpg
exiftool -all= 20200703_111009.jpg
exiftool 20200703_111009.jpg
@Tarliton
Tarliton / Dockerfile
Last active December 16, 2024 04:58
Create borg universal package
FROM quay.io/pypa/manylinux_2_34_x86_64
ARG python_version=cp313-cp313
ARG borg_version=1.4.0
RUN yum -y update && \
yum -y install openssl-devel libacl-devel lz4-devel libzstd-devel xxhash-devel
RUN git clone https://github.com/borgbackup/borg.git
@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
@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 / 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 / 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 / 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 / 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 / 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()