Skip to content

Instantly share code, notes, and snippets.

Avatar

Lauri Võsandi laurivosandi

View GitHub Profile
@laurivosandi
laurivosandi / switcharoo.c
Last active Nov 13, 2017
Illustrative and probably very buggy example of what su essentially does
View switcharoo.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <string.h>
#include <crypt.h>
/**
* Illustrative and probably very buggy example of what su essentially does
*
@laurivosandi
laurivosandi / esp32-oled-demo.py
Last active Apr 11, 2020
OLED screen demo on ESP32 with MicroPython
View esp32-oled-demo.py
# Pull the SDD1306 lib from here https://github.com/adafruit/micropython-adafruit-ssd1306/blob/master/ssd1306.py
from time import sleep_ms
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
buf = "wubba lubba dub dub "
i2c = I2C(-1, Pin(4),Pin(5),freq=40000) # Bitbanged I2C bus
assert 60 in i2c.scan(), "No OLED display detected!"
@laurivosandi
laurivosandi / uwebsockets.py
Created Aug 18, 2017
Websockets client for MicroPython
View uwebsockets.py
"""
Websockets client for micropython
Based very heavily on
https://github.com/aaugustin/websockets/blob/master/websockets/client.py
"""
import ubinascii as binascii
import urandom as random
import ure as re
@laurivosandi
laurivosandi / smarty.py
Created May 12, 2017
SMART info parser
View smarty.py
#!/usr/bin/python
# encoding: utf-8
import subprocess
import os
import re
print "Storage status:"
for node in os.listdir("/dev"):
if not re.match("[sv]d[a-z]$", node): continue
cmd = "/usr/sbin/smartctl", "-a", "/dev/%s" % node
View middleware.py
"""
Estonian ID-card authentication middleware for Django,
but this should be pretty easily modifiable for any application
To use install cryptography.io:
apt-get install -y python python-pip python-dev \
python-cffi build-essential libffi-dev libssl-dev
pip install cryptography
You can’t perform that action at this time.