Skip to content

Instantly share code, notes, and snippets.

import os
import json
from http.server import BaseHTTPRequestHandler,HTTPServer
from _thread import start_new_thread
song_info = {}
#This class will handles any incoming request from
#the browser
class RequestHandler(BaseHTTPRequestHandler):
import time
import random
import socket
import struct
import argparse
class CANMessage:
id = 0
dlc = 0
data = bytearray(0x00)
from threading import Timer
def debounce(wait, argument_dependent=False):
""" Decorator that will postpone a functions
execution until after wait seconds
have elapsed since the last time it was invoked. """
def decorator(fn):
def debounced(*args, **kwargs):
def call_it():
import re
import base64
import math
import threading
import argparse
metadata = {}
lock = threading.Lock()
def update_metadata(type, code, length, data):
<html>
<head>
</head>
<body>
<!--<svg viewBox="0 0 1000 1000">
<path
id="path"
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:10;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="M 500,500 A 500,500 0 1 1 0,500 500,500 0 1 1 1000,500"
@moritzmhmk
moritzmhmk / ddi.sh
Last active September 25, 2015 17:29
improved dd with percentage
#!/bin/bash
in="$1"
out="$2"
if [[ $# -ne 2 ]] ; then
echo "Usage: $0 <input> <output>"
exit
fi
@moritzmhmk
moritzmhmk / root-ro
Last active October 2, 2015 20:01 — forked from niun/root-ro
Read-only Root-FS with overlayfs for Raspian
#!/bin/sh
#
# Read-only Root-FS for Raspian
#
# Modified 2015 by Pascal Rosin to work on raspian-ua-netinst with
# overlayfs integrated in Linux Kernel >= 3.18.
#
# Originally written by Axel Heider (Copyright 2012) for Ubuntu 11.10.
# This version can be found here:
# https://help.ubuntu.com/community/aufsRootFileSystemOnUsbFlash#Overlayfs
@moritzmhmk
moritzmhmk / lws.patch
Created December 20, 2015 15:28
Patch mosquitto for new libwebsocket API
diff -Naur a/lib/net_mosq.c a/lib/net_mosq.c
--- a/lib/net_mosq.c 2015-12-20 16:21:08.560283714 +0100
+++ a/lib/net_mosq.c 2015-12-20 16:13:17.750398153 +0100
@@ -166,7 +166,7 @@
#ifdef WITH_BROKER
# ifdef WITH_WEBSOCKETS
if(mosq->wsi){
- libwebsocket_callback_on_writable(mosq->ws_context, mosq->wsi);
+ lws_callback_on_writable(mosq->wsi);
return 0;
@moritzmhmk
moritzmhmk / sane-rpi-arch.md
Last active February 21, 2016 16:43
Network Scanner on Raspberry Pi
pacman -S sane
gpasswd -a moritz scanner
gpasswd -a moritz lp

sane-find-scanner
nano /etc/sane.d/saned.conf
	192.168.1.0/24

systemctl enable saned.socket
systemctl start saned.socket
@moritzmhmk
moritzmhmk / CEC_Pi_zero.md
Last active July 30, 2017 17:11
CEC Pi zero

Faking HDMI Port

echo "pa 30 00" | cec-client

sets physical address to 3.0.0.0 - which is HDMI Port 3 - receiving remote control signals from different hdmi port

Use Pi zero as "Pulse8 CEC Adapter"

Enable USB Serial

/boot/config.txt add dtoverlay=dwc2 /boot/cmdline.txt add modules-load=dwc2 (not dwc2,g_serial - see below)