Skip to content

Instantly share code, notes, and snippets.

View otakbeku's full-sized avatar
🚀
Journey to the top

Ais otakbeku

🚀
Journey to the top
View GitHub Profile
@otakbeku
otakbeku / cache.py
Created May 10, 2022 14:41 — forked from leonjza/cache.py
Simple SQLite Cache
#!/usr/bin/python
import os
import errno
import sqlite3
import sys
from time import time
from cPickle import loads, dumps
import logging
@otakbeku
otakbeku / rust-python-cffi.md
Created April 2, 2022 04:08 — forked from seanjensengrey/rust-python-cffi.md
Calling Rust from Python/PyPy using CFFI (C Foreign Function Interface)

This is a small demo of how to create a library in Rust and call it from Python (both CPython and PyPy) using the CFFI instead of ctypes.

Based on http://harkablog.com/calling-rust-from-c-and-python.html (dead) which used ctypes

CFFI is nice because:

  • Reads C declarations (parses headers)
  • Works in both CPython and PyPy (included with PyPy)
  • Lower call overhead than ctypes
@otakbeku
otakbeku / install.sh
Created July 27, 2021 08:20 — forked from newcarrotgames/install.sh
Python code for running vqgan+clip on your own machine. Shamelessy taken from this colab: https://colab.research.google.com/drive/1go6YwMFe5MX6XM9tv-cnQiSTU50N9EeT#scrollTo=mFo5vz0UYBrF. USE AT YOUR OWN RISK!
# I _hope_ this is everything but there may be some other libs I forgot or you don't have,
# so just use pip to install them if vqgan_clip.py complains about missing modules.
# Make some folder, cd into it, and run this.
git clone https://github.com/openai/CLIP
git clone https://github.com/CompVis/taming-transformers
pip install ftfy regex tqdm omegaconf pytorch-lightning
pip install kornia
pip install stegano
apt install exempi
pip install python-xmp-toolkit
@otakbeku
otakbeku / min-char-rnn.py
Created September 10, 2017 09:41 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)