Skip to content

Instantly share code, notes, and snippets.

View icedraco's full-sized avatar
🐲
Rawr

Artex icedraco

🐲
Rawr
View GitHub Profile
@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) {
@icedraco
icedraco / bthog.py
Last active April 26, 2020 11:17
Designed to aggressively hold an open connection to a Bluetooth speaker
# Bluetooth Speaker Hogging Script
#
# Designed to aggressively hold an open connection to a Bluetooth speaker.
#
# Particularly useful for when your neighbors have an "incompatible" taste in
# music and don't consider it a problem that they play it too loud.
#
# Requirements:
# sudo apt install libbluetooth-dev
# python3.7 -m pip install pybluez
@icedraco
icedraco / test-request.kt
Created December 31, 2019 16:53
HTTP requests using Kotlin and a built-in java.net.URL class
package org.icerealm.examples
import java.net.HttpURLConnection
import java.net.URL
fun main() {
val url = URL("https://postman-echo.com/status/403")
val con: HttpURLConnection = url.openConnection() as HttpURLConnection
con.requestMethod = "GET"
con.connectTimeout = 10*1000
@icedraco
icedraco / uuid.kt
Created October 3, 2019 04:06
Kotlin UUID3 and UUID5 tool
/***
* Source:
* https://stackoverflow.com/questions/40230276/how-to-make-a-type-5-uuid-in-java
*/
import java.security.MessageDigest
import java.security.NoSuchAlgorithmException
import java.util.UUID
@icedraco
icedraco / dependency-injection-demo.py
Last active April 29, 2019 13:49
Python Dependency Injection via MRO/super() demo based on Raymong Hettinger talk during PyCon 2015
"""
This example demonstrates a "dependency injection" technique described
by Raymond Hettinger during PyCon 2015:
https://www.youtube.com/watch?v=EiOglTERPEo
Regular dependency injection requires one to provide a resource to an object
that requires it using the __init__() method (or a class constructor).
This method provides an alternative way to specify a resource using Python's
Method Resolution Order (MRO) and super() magic.
import numpy as np
from numpy.random import randint
from typing import List, Tuple
G_GRID_SIZE = 100
G_INIT_CRYSTAL_COORDS = (50, 50)
G_NUM_PARTICLES = 10
G_PARTICLE_INCREMENTS = range(10, 31, 10)
@icedraco
icedraco / gdrive-reencode.py
Created May 4, 2018 17:06
Re-encode broken filenames from Google Drive Takeout folder
#!/usr/bin/env python3
import os
from typing import List, Callable
def transform(name: str) -> str:
return bytes(name, "latin1").decode("utf-8")
@icedraco
icedraco / netmon.py
Created May 4, 2018 12:09
Windows-based packet monitoring script sample done in Python
from socket import *
# IP ranges we are monitoring
MONITOR_NETWORKS = [
'192.168.0.0/16',
'10.0.0.0/8',
'169.254.0.0/16'
]

Keybase proof

I hereby claim:

  • I am icedraco on github.
  • I am icedraco (https://keybase.io/icedraco) on keybase.
  • I have a public key ASBF5Vf0wwLeueo-RWhQQKq03z5TSoY28EGxWTXhUnJUcwo

To claim this, I am signing this object: