Skip to content

Instantly share code, notes, and snippets.

View daemotron's full-sized avatar
refuelling

Jesco Freund daemotron

refuelling
View GitHub Profile
@daemotron
daemotron / zerorpc_server.py
Last active May 28, 2017 15:52
POC ZeroRPC server
# -*- coding: utf-8 -*-
import logging
import platform
import signal
import gevent
import zerorpc
Server = None
@daemotron
daemotron / distance.py
Created May 28, 2017 15:05
POC distance class with unit conversion
import math
factors = {
'mm': 0.001,
'cm': 0.01,
'in': 0.0254,
'dm': 0.1,
'ft': 0.3048,
'yd': 0.9144,
'm': 1.0,
@daemotron
daemotron / ortho4xp.md
Created October 27, 2018 20:27
Install Ortho4XP on Windows

Python can be installed in various flavours - I have 2.7, 3.6 and 3.7 installed on my machine in parallel, without further issues. For Ortho4XP, I'd recommend Python 3.7 in a 64 bit flavour - and install it under C:\python37 (it doesn't interfere with Python 2.7).

My Ortho lives on an external HDD (mine is called k:). There, I just created a directory for O4XP to live in. I use 1.30 for quite a while, so I had to fetch it via git. Not sure it's still the case, but it's the only way I know... I use cmder to have a better console than default, and it comes with Git for Windows bundled if you like to...

Furthermore, you'll need a couple of Python libraries which normally require a compiler, but there's a site hosting pre-compiled packages for Windows, which is highly useful: www.lfd.uci.edu/~gohlke/pythonlibs/

@daemotron
daemotron / asyncio_loops.py
Created September 9, 2021 09:28 — forked from lars-tiede/asyncio_loops.py
asyncio + multithreading: one asyncio event loop per thread
import asyncio
import threading
import random
def thr(i):
# we need to create a new loop for the thread, and set it as the 'default'
# loop that will be returned by calls to asyncio.get_event_loop() from this
# thread.
loop = asyncio.new_event_loop()
@daemotron
daemotron / client.py
Created September 10, 2021 11:09 — forked from bashkirtsevich/client.py
asyncio UDP client
import asyncio
class EchoClientProtocol:
def __init__(self, message, loop):
self.message = message
self.loop = loop
self.transport = None
def connection_made(self, transport):
self.transport = transport