Skip to content

Instantly share code, notes, and snippets.

View mic159's full-sized avatar

Michael mic159

  • Atlassian
  • Australia
View GitHub Profile
@mic159
mic159 / README.md
Last active February 28, 2018 10:42
Dashing Widget: Red Green Meter

Dashing Widget: Red Green Meter

A modified Meter widget that sets the background colour to either red or green depending on a threshold.

To use it, use something like this on your dashboard:

    <li data-row="1" data-col="3" data-sizex="1" data-sizey="1">
 
@mic159
mic159 / README.md
Last active May 26, 2016 18:21
Dashing Widget: Time Since Last (Red Green)

Dashing Widget: Time Since Last (Red Green)

This is a modified version of the Time Since Last widget by hannesfostie that is a bit simplified and with the red-green inverted (goes red when too much time has passed).

It does not use HTML local storage (no need, the server remembers it for us) and the threshold is just called 'threshold' and it is in hours.

Installation

@mic159
mic159 / mjpeg.py
Created January 20, 2015 13:48
MJPEG client in PyGtk+
import pygtk
pygtk.require('2.0')
import gtk
import urllib
import gobject
import threading
STREAM_URL = 'http://10.10.1.1:8196/'
class VideoThread(threading.Thread):
@mic159
mic159 / import.py
Created January 18, 2016 22:57
input_algorithms python import validator and normaliser
class Import(valid_string_spec):
validators = [regexed("^(?P<module>[a-zA-Z_][a-zA-Z_0-9]*(\.[a-zA-Z_][a-zA-Z_0-9]*)*):(?P<class>[a-zA-Z_][a-zA-Z_0-9]*)$")]
def setup(self, checked_class):
self.checked_class = checked_class
def normalise_filled(self, meta, val):
# Run string & regex validator
val = super(Import, self).normalise_filled(meta, val)
# Now validate it is importable
@mic159
mic159 / scan.py
Created December 27, 2016 14:33
SYN scan in python
#!/usr/bin/env python
"""
Do a syn scan over a host.
To run as non-root:
> sudo setcap cap_net_raw=ep /home/michaelc/.virtualenvs/tmp/bin/python2
Sources:
- http://www.secdev.org/projects/scapy/doc/usage.html
- https://securitylair.wordpress.com/2014/02/21/simple-port-scanner-in-python-with-scapy-2/
@mic159
mic159 / USB_watch.md
Last active March 4, 2017 05:06
USB Digital Silicone Watch

8GB USB Digital Silicone Watch

Video teardown: https://www.youtube.com/watch?v=4uUUDYiGjno

USB Interface

When I plug the watch into the computer, it appears as a single USB MicroSD Storage device with idVendor=05e3 idProduct=0741. Nothing stands out as interesting, just a standard IN and OUT endpoint.

@mic159
mic159 / mjpeg_udp.py
Created April 26, 2017 12:07
Raspberry Pi MJPEG stream over UDP
from picamera import PiCamera
from io import BytesIO
import socket
import time
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
with PiCamera(resolution='VGA', framerate=5) as camera:
time.sleep(2)
@mic159
mic159 / zfec_test.py
Created June 5, 2017 13:23
python zfec usage
from zfec.easyfec import Encoder, Decoder
import random
# 5 correction blocks for every 20 blocks
enc = Encoder(20, 25)
dec = Decoder(20, 25)
# Dummy payload
data = ' '.join(str(x) for x in range(100))
@mic159
mic159 / esp_ov7670.ino
Created October 22, 2017 11:04
Broken attempt to get OV7670 working with ESP32
#include "sccb.h"
#include <driver/ledc.h>
#define PIN_XCLK 18 // Clock provided to camera
#define PIN_RESET 5 // Reset pin.
#define OV7670_ADDR (0x21)
#define OV7670_REG_PID (0x0A)
#define OV7670_REG_VER (0x0B)
#define OV7670_REG_MIDH (0x1c)
@mic159
mic159 / ESP32_raw_packet.ino
Last active March 16, 2024 22:33
ESP32 raw packets
#include <WiFi.h>
#include "wifi_headers.h"
#include <esp_wifi.h>
//#include <esp_wifi_internal.h>
#include <lwip/err.h>
typedef union {
uint8_t fix_rate;
uint8_t b5;
uint8_t b4;