Skip to content

Instantly share code, notes, and snippets.

Martin Dybdal dybber

Block or report user

Report or block dybber

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
dybber /
Last active May 2, 2019
MicroPython, module for simplified WiFi connectivity
import time
import network
# Connect to a specific wifi network
def connect(essid, password, timeout=30000):
wifi = network.WLAN(network.STA_IF)
if not wifi.isconnected():
print("Connecting to WiFi network...")
wifi.connect(essid, password)
dybber /
Created Oct 21, 2018
PySide2 Exception not raised to the user
import sys
import PySide2.QtCore as QtCore
import PySide2.QtWidgets as QtWidgets
class Worker(QtCore.QObject):
on_start = QtCore.Signal()
def on_start(self):
print("This line is executed!")
dybber /
Created Aug 24, 2018
import ure
def parseDateTime(datestr):
regex = ("^(19|2[0-9][0-9][0-9])-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])"
match = ure.match(regex, datestr)
if match:
year = int(
month = int(
View pyboard.py_enter_raw_repl
def enter_raw_repl(self):
# Brief delay before sending RAW MODE char if requests
if _rawdelay > 0:
self.serial.write(b'\x02') # ctrl-B: exit RAW repl
self.serial.write(b'\x03') # ctrl-C
self.serial.write(b'\r\x03\x03') # ctrl-C twice: interrupt any running program
dybber /
Last active Aug 22, 2018
MicroPython wifi connection w. timeout
import machine
import time
import network
import urequests
# Function to connect to a specific wifi network
def connectToWifi(wifi, essid, password, timeout):
if not wifi.isconnected():
print("Connecting to WiFi network...")
wifi.connect(essid, password)
dybber /
Last active Aug 1, 2018
Simple dustsensor MicroPython library
import machine
import time
# Python version of
# returns duration in MICRO seconds
def pulseIn(pin, value):
# Wait till we hit the wanted value
while pin.value() != value:
dybber / combination_lock.pyde
Last active Jul 31, 2018
Kombinationslås, PyProcessing, Kickstart i Programmering, DIKU 2018
View combination_lock.pyde
# Tilstandsvariablen
lockState = "LOCKED"
# Tegner en lås givet (x,y) koordinat, størrelsesangivelse og
# en boolean open, der angiver om låsen skal tegnes som låst
# eller åben (True = Åben)
def drawLock(x, y, size, open):
rect(x-1.3*size/2,y-size/2, 1.3*size, size, size/10)
dybber / ArduinoSerialTest.ino
Created Aug 5, 2016
Arduino/Processing SerialTest
View ArduinoSerialTest.ino
int colour = 0;
void setup() {
void loop() {
colour = (colour + 1) % 255;
View gist:b4e76a2720ffeeb3a29b
fun chess idim =
let val dim = Real.fromInt idim
fun rep3 v = (v,v,v)
fun chess' (ii, ij) =
let val (i,j) = (Real.fromInt ii,
Real.fromInt (idim-ij))
val s = 3.0/(j+99.0)
in (Real.round((i+dim)*s+j*s) mod 2 +
Real.round((dim*2.0-i)*s+j*s) mod 2)*127
View gist:2002774
; Hide certain messages from channel tracking
(setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE"))
; Hide these messages from all buffers
(setq erc-hide-list '("JOIN" "PART" "QUIT"))
(defun set-empty-hide-list-eggsml ()
(if (equal "#eggsml" (buffer-name))
(set (make-local-variable 'erc-hide-list) '())))
You can’t perform that action at this time.