Skip to content

Instantly share code, notes, and snippets.

@NelsonMinar
NelsonMinar / README.md
Created January 31, 2024 14:11
League of Legends rank data 2016
@NelsonMinar
NelsonMinar / mp.py
Last active December 5, 2023 15:26
multiprocessing Pool example
#!/usr/bin/env python2
"Demonstrate using multiprocessing.Pool()"
import multiprocessing, time, logging, os, random, signal, pprint, traceback
logging.basicConfig(level=logging.DEBUG)
_L = logging.getLogger()
class JobTimeoutException(Exception):
@NelsonMinar
NelsonMinar / Torena Somnopose Oscar convertor
Last active August 4, 2023 10:40
Torena to Somnopose data convertor for OSCAR
Notes:
https://nelsonslog.wordpress.com/2021/07/21/sleep-position-tracking-and-oscar/
http://www.apneaboard.com/forums/Thread-Torena-sleep-position-monitor-for-Android-similar-to-SomnoPose
@NelsonMinar
NelsonMinar / thread-logging.py
Created January 14, 2015 01:24
Demonstration of logging messages from different threads to different files
#!/usr/bin/env python2
"""Demonstration of a Python logging handler that creates a separate output
file for each stream. The key thing here is the class MultiHandler. It picks
the file name based on the thread name; could use anything in threading.local()
"""
import threading, logging, time, random, os
# Global object we log to; the handler will work with any log message
@NelsonMinar
NelsonMinar / README.txt
Last active October 9, 2022 05:39
GTA V Map Viewer
Tools for making a very simple web slippy map of Grand Theft Auto V maps.
By Nelson Minar <nelson@monkey.org>
I don't want to host this map myself because of copyright concerns.
No support provided for this code, just hoping it's a useful guide for
someone to roll their own amp.
maketiles.sh runs gdal2tiles.py to slice up the source image into tiles.
map.html is a simple Leaflet / web map.
@NelsonMinar
NelsonMinar / index.html
Created April 6, 2011 22:34
D3 id selection example
<!DOCTYPE html>
<html><head><script type="text/javascript" src="https://github.com/mbostock/d3/raw/master/d3.js"></script></head><body>
<script lang="text/javascript">
window.onload = function() {
// Create a red rectangle
d3.select("body").append("svg:svg")
.attr("width", "100").attr("height", "100")
.append("svg:rect")
.attr("id", "myrectangle")
@NelsonMinar
NelsonMinar / README.txt
Created January 20, 2022 18:59
Solar monitoring setup: PVS6, PGE, forecast.solar to Influx
Data imports for a custom solar monitoring system I build using Sunpower's PVS6, Telegraf, Influx, and Grafana.
See http://nelsonslog.wordpress.com/ for details
This code is provided without license or support. If you do something interested and related let me know!
--nelson@monkey.org
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@NelsonMinar
NelsonMinar / python-json-types.py
Created January 10, 2016 23:07
Testing various dict wrappers for Python JSON
"""
Various options for a JSON type for Python.
My best effort at using these libraries naturally for reading and writing JSON.
https://nelsonslog.wordpress.com/2016/01/08/a-better-python-object-for-json/
"""
import json, copy
import dotmap, attrdict, easydict, addict
@NelsonMinar
NelsonMinar / hatch.py
Created September 28, 2021 15:08
Hatching algorithm (in progress)
def hatch(polygon, spacing: float = 1, rotation: float = 0, tolerance: float = 5, inset: float = 0) -> shapely.geometry.MultiLineString:
"""
Fill a polygon with hatched lines.
Note this code is unit-independent. The default spacing of 1 was chosen with the idea of the units being
millimeters and the pen width being 0.5mm, for a 50% fill.
:param polygon: the shape to generate a hatch for
:param spacing: space between hatch lines
:param rotation: rotation of hatch lines (in degrees)
:param tolerance: limit on length of joining lines to make hatches a single line. Multiples of spacing.