Skip to content

Instantly share code, notes, and snippets.

View icedraco's full-sized avatar
🐲
Rawr

IceDragon icedraco

🐲
Rawr
View GitHub Profile
import itertools
import os
# =============================================================================================== #
class LameDhcp(object):
"""A cooperative filesystem-based IP reservation mechanism
"""
#--- CONFIGURATION ---------------------------------------------------------------------------#
@icedraco
icedraco / multiproc.py
Last active July 17, 2022 16:46
Multiprocessing example
import time
import multiprocessing as mp
def main():
# how many processes should we spawn?
num_parallel_procs = 12
# queue that will pass work to each worker
q = mp.Queue(num_parallel_procs)
@icedraco
icedraco / furcadia-bot.py
Last active February 14, 2022 03:21
Simple Furcadia bot
#!/usr/bin/env python3
### Furcadia Login / Connection Example
#
# Last Updated: 2022-02-14
# Author: Artex <icedragon@quickfox.org>
#
import errno
import re
@icedraco
icedraco / generator.cc
Created November 16, 2021 23:33
POSIX Message Queues Example
#include <string>
#include <sstream>
#include <unistd.h>
#include "mq.h"
#define MQ_NAME "/ice.test"
void printSyntax(const char* exe)
{
@icedraco
icedraco / mynumber.py
Created April 27, 2021 01:07
toy example + unit test by its side
class MyNumber:
def __init__(self, n: int):
self.__n = n
def __repr__(self) -> str:
return f"{self.__class__.__name__}({self.value})"
def __str__(self) -> str:
return str(self.value)
@icedraco
icedraco / mynumber.py
Created April 27, 2021 00:14
Unit tests inside operational code (disgusting, but works)
#!/usr/bin/env python3
# Run: python3 mynumber.py
# Test: python3 -m unittest mynumber.py
import unittest
class MyNumber:
def __init__(self, n: int):
self.__n = n
@icedraco
icedraco / idsm.py
Last active July 18, 2020 21:31
File Split & Merge Script
"""
IceDragon's Split & Merge (IDSM) Script
"""
from __future__ import annotations
import os
import sys
import struct
import hashlib
@icedraco
icedraco / BinaryFile.hpp
Created May 8, 2020 01:02
ByteCompare: A means to find different blocks of bytes inside two otherwise very similar files
#pragma once
#include <exception>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include "DiffBlock.hpp"
@icedraco
icedraco / bqueue.hpp
Created May 1, 2020 20:04
C++ blocking queue implementation
#pragma once
#include <mutex>
#include <condition_variable>
#include "circular_queue.hpp"
template <typename T, size_t N>
class bqueue
@icedraco
icedraco / smartptr.cpp
Created April 30, 2020 23:43
Custom C++ smart_ptr for the sake of exsercise...
#include <cstdio>
template<typename T>
class smartptr {
public:
smartptr(T* v) : _data(new data(v)) {
printf(" * smartptr: obtained value %d\n", *_data->value);
}
smartptr(const smartptr &other) : _data(other._data) {