Skip to content

Instantly share code, notes, and snippets.

View Tarliton's full-sized avatar
🐍

Tárliton Basso de Godoy Tarliton

🐍
  • Brazil
  • 04:26 (UTC -03:00)
View GitHub Profile
#include <Python.h>
int Cfib(int n){
if (n < 2)
return n;
return Cfib(n-1) + Cfib(n-2);
}
static PyObject* fib(PyObject* self, PyObject* args){
int n;
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev systemtap-sdt-dev
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
docker run --rm -it gcc:11 bash -c "gcc -march=native -Q --help=target "
/etc/docker/daemon.json
{
"dns": ["10.0.0.2", "8.8.8.8"]
}
sudo service docker restart
wget -O - https://bootstrap.pypa.io/get-pip.py | sudo python
@Tarliton
Tarliton / async_sqlalchemy_thread.py
Last active February 26, 2023 13:07
asyncio with a thread executor and sqlalchemy
import asyncio
import base64
import os
import random
from sqlalchemy import Column, Integer, String
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker, declarative_base
# SQLAlchemy==2.0.4
import vpk
def build_cache(path, map_name):
pak1 = vpk.open(path)
total = 0
for i, f in enumerate(pak1):
if map_name in f:
print(f'reading {i}', f, pak1[f].file_length)
pak1[f].read()
import asyncio
import inspect
from textwrap import dedent
def asynchronize(method):
argspec = inspect.getfullargspec(method)
args = ', '.join(argspec.args)
args_without_self = ', '.join(argspec.args[1:])
source = f"""
import socket, sys, select
class Proxy:
def __init__(self, raddr, rport, laddr='0.0.0.0', lport=5000):
self.local_addr = laddr
self.local_port = lport
self.lsock = []
self.remote_addr = raddr
self.remote_port = rport
from collections import defaultdict
create_dict = lambda: defaultdict(create_dict)
def auto_defaultidct(keys, d=create_dict()):
buffer = ''
for i, item in enumerate(range(len(keys))):
if i == 0:
buffer = 'd'
@Tarliton
Tarliton / docker_commands.sh
Created February 24, 2020 17:55
docker commands
# update docker images
docker images | awk '{if(NR>1)print $1 ":" $2}' | xargs -n1 docker pull
# remove dangling images
docker images | grep none | awk '{print $3}' | xargs docker rmi