Skip to content

Instantly share code, notes, and snippets.

View mic159's full-sized avatar

Michael mic159

  • Atlassian
  • Australia
View GitHub Profile
@mic159
mic159 / AnimatedTransition.tsx
Last active April 30, 2019 12:16
Semantic UI React component to transition between two elements
import React, { ReactElement, useEffect, useState } from 'react'
import { SemanticTRANSITIONS, Transition, TransitionPropDuration } from 'semantic-ui-react'
interface AnimatedTransitionProps {
animation?: SemanticTRANSITIONS
duration?: number | string | TransitionPropDuration
children: ReactElement
}
const AnimatedTransition = ({children, animation, duration} : AnimatedTransitionProps) => {
@mic159
mic159 / twinkle.py
Created October 25, 2018 14:16
lifx tile patterns
from lifxlan import LifxLAN, TileChain
import random
import time
MAX_VAL = 65535
FADE_IN_SPEED = MAX_VAL * 0.125 # 32
FADE_OUT_SPEED = MAX_VAL * 0.078 # 20
tiles = LifxLAN().get_device_by_name('Tiles')
# tiles = TileChain('d0:73:d5:33:5b:c2', '10.10.0.66')
@mic159
mic159 / golomb.py
Created March 18, 2018 13:57
Exponential-Golomb coding in hachoir
from hachoir.field import Field
class UExponentialGolomb(Field):
def __init__(self, parent, name, description=None):
super(UExponentialGolomb, self).__init__(parent, name, description=description)
self._zeros = None
self.determine_size()
def determine_size(self):
@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;
@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 / 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 / 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 / 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 / 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 / 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