Skip to content

Instantly share code, notes, and snippets.

View sneakers-the-rat's full-sized avatar

Jonny Saunders sneakers-the-rat

View GitHub Profile
@hirrolot
hirrolot / printf.idr
Last active October 1, 2024 17:21
Generic `printf` implementation in Idris2
data Fmt = FArg Fmt | FChar Char Fmt | FEnd
toFmt : (fmt : List Char) -> Fmt
toFmt ('*' :: xs) = FArg (toFmt xs)
toFmt ( x :: xs) = FChar x (toFmt xs)
toFmt [] = FEnd
PrintfType : (fmt : Fmt) -> Type
PrintfType (FArg fmt) = ({ty : Type} -> Show ty => (obj : ty) -> PrintfType fmt)
PrintfType (FChar _ fmt) = PrintfType fmt
@lambertbrady
lambertbrady / pyodide-provider.js
Created July 13, 2021 23:35
Pyodide React Component
import { createContext, useRef, useState } from 'react'
export const PyodideContext = createContext()
export default function PyodideProvider({ children }) {
const pyodide = useRef(null)
const hasLoadPyodideBeenCalled = useRef(false)
const [isPyodideLoading, setIsPyodideLoading] = useState(true)
return (
@ACK-J
ACK-J / metrix_block.py
Last active July 17, 2023 20:03
Find all the domains ThreatMetrix is using to exfil user tracking data
from shodan import Shodan
api = Shodan('API-KEY')
results = api.search('isp:"ThreatMetrix Inc." port:443 Bad Request')
for banner in results['matches']:
# Only care about services that use SSL
if 'ssl' in banner:
print(banner['ssl']['cert']['subject']['CN'])
@TRPB
TRPB / arch-macbook2018.md
Last active June 14, 2024 17:31
Guide: Running Arch on a 2018 MacBook Pro

Hardware Prerequisites

You'll need at least the following hardware:

  • At least 3 USB-A to USB-C converters or hub with enough ports for at least 3 USB devices if all your devices are USB-A then:
  • A USB drive
  • A USB keyboard
  • USB to Ethernet adapter, compatible USB dongle or USB tethering on a phone
@joinAero
joinAero / camera.py
Created May 19, 2017 06:36
Use Kinect with OpenCV (Python)
import cv2
import sys
class Camera(object):
def __init__(self, index=0):
self.cap = cv2.VideoCapture(index)
self.openni = index in (cv2.CAP_OPENNI, cv2.CAP_OPENNI2)
self.fps = 0
@njbbaer
njbbaer / ca.py
Last active October 27, 2022 18:05
Fast implementation of cellular automata using 2D convolution
import time
import numpy as np
from numpy.fft import fft2, ifft2
from matplotlib import pyplot, animation
def fft_convolve2d(board, kernal):
board_ft = fft2(board)
kernal_ft = fft2(kernal)
height, width = board_ft.shape
@artizirk
artizirk / 01-video.py
Last active November 22, 2022 11:48
Python v4l2 webcam capture test using PlayStation 3 camera. More advanced script can be found here: https://github.com/eik-robo/zoidberg/blob/master/examples/purepy_video_capture.py
#!/usr/bin/env python3
from v4l2 import *
import fcntl
import mmap
import select
import time
vd = open('/dev/video0', 'rb+', buffering=0)
@judell
judell / mmr.py
Last active March 23, 2022 10:46
monthly morphometry report
import requests, re, json, types, traceback
class HypothesisAnnotation:
def __init__(self, row):
"""Encapsulate relevant parts of one row of a Hypothesis API search."""
self.tags = []
if row.has_key('tags') and row['tags'] is not None:
self.tags = row['tags']
@hubgit
hubgit / README.md
Last active November 5, 2024 10:29
Remove metadata from a PDF file, using exiftool and qpdf. Note that embedded objects may still contain metadata.

Anonymising PDFs

PDF metadata

Metadata in PDF files can be stored in at least two places:

  • the Info Dictionary, a limited set of key/value pairs
  • XMP packets, which contain RDF statements expressed as XML

PDF files

@tk0miya
tk0miya / index.txt
Last active January 29, 2019 23:03
sphinxcontrib_wikitable.py
Usage
======
.. wiki-table::
:header-rows: 1
:widths: 2 3 5
|id|header1|header2|
|1|hello|world|
|2|foo|:strong:`bar`|