Skip to content

Instantly share code, notes, and snippets.

@b1naryth1ef
b1naryth1ef / enum.py
Last active July 17, 2024 10:19
PeeWee Postgres Enum Field
from peewee import *
class BModel(Model):
class Meta:
database = db
@classmethod
def create_table(cls, *args, **kwargs):
for field in cls._meta.get_fields():
if hasattr(field, "pre_field_create"):
HOLY SHIT EVERYTHING IS BLOCKED:
First up: python -m trace --trace yoloswag.py
Then: http://stackoverflow.com/questions/1032813/dump-stacktraces-of-all-active-threads
@b1naryth1ef
b1naryth1ef / ClioProto.md
Last active August 29, 2015 14:02
Clio Protocol Documentation

Clio Protocol Documentation

Clio is an advanced P2P network protocol which represents a completely distributed and decentralized structure. It uses a variety of modern technologies and ideologies such as peer seeding, message passing, and segmented routing to keep a structurally simple and yet robust design. Clio was built with the intention of creating a modern social/sharing network, but was also explicitly designed as a application-agnostic protocol. It was written in Go, using OpenGPG as the encryption and identification layer.

Authentication

Authentication in Clio is a two step processes with an assumed success structure, avaibile due to the use of encryption for all packets outside of the handshaking process. The following is an example of how two peers (Bob and Lucy) would authenticate with eachother:

Bob attempts to authenticate with Lucy:

@b1naryth1ef
b1naryth1ef / ClioProto.md
Created June 20, 2014 21:06
Clio Protocol Documentation

Clio

@b1naryth1ef
b1naryth1ef / gist:93cdc12471d58d4e2ef6
Created June 17, 2014 15:02
Clio Authentication System
Given two nodes, Bob and Amy, Bob initiates a connection and authentication with Amy.
Bob sends a packet (id 1) containing json serialized data of:
{
"ID": 1,
"PublicKey": (Bobs public key),
"NetworkHash": A 32 bit string representing the network ID Bob is on,
"Token": a 32-bit random integer
}
@b1naryth1ef
b1naryth1ef / post.md
Created May 5, 2014 07:35
Someday... #blog

At some point I might actually post stuff here. Until then, this will just be a boring blog.

@b1naryth1ef
b1naryth1ef / example_usage.py
Created May 3, 2014 09:11
An async proof of concept for eventual variables.
def endpoint(request):
# This will enqueue this database query in the background, if anything
# uses request.user later, it will hopefully have finished the query,
# otherwise it will block on that query
request.user = db.later(db.query("SELECT * FROM users WHERE id=?", (
request.cookies.get("user"), )))
import sweg
def render_post(post, user):
return {
"name": post.name,
"author": user.username
}
def render_homepage():
result = []
@b1naryth1ef
b1naryth1ef / steamid.py
Created March 2, 2014 18:20
Converts a 64bit steamid to 32bit, and vice-versa
def convert(id):
if len(id) == 17:
return int(id[3:]) - 61197960265728
else:
return '765' + str(int(x) + 61197960265728)
@b1naryth1ef
b1naryth1ef / example.py
Created February 19, 2014 18:13
Python Scheduler in 22 lines
from schedule import schedule, run
@schedule(hours=1)
def my_task():
print "Yolo Swag!"
run()