Skip to content

Instantly share code, notes, and snippets.

@jeamland
jeamland / gist:11284662
Created April 25, 2014 10:20
Bluetooth LE on OS X via Python
import select
import socket
import sys
import objc
from PyObjCTools import AppHelper
objc.loadBundle("CoreBluetooth", globals(),
bundle_path=objc.pathForFramework(u'/System/Library/Frameworks/IOBluetooth.framework/Versions/A/Frameworks/CoreBluetooth.framework'))
@jeamland
jeamland / playlist_extractor.py
Last active September 14, 2021 21:29
iTunes Library (non-XML) playlist extractor
#!/usr/bin/env python
# Extract playlists from a non-XML iTunes Library file (.itl)
# Copyright (c) 2018 Benno Rice, released under the BSD (2 Clause) Licence.
# Important information on the encryption used in the .itl file found here:
# https://mrexodia.cf/reversing/2014/12/16/iTunes-Library-Format-1
# Highly useful information on the .itl format itself found here:
# https://github.com/josephw/titl/blob/master/titl-core/src/main/java/org/kafsemo/titl/ParseLibrary.java
@jeamland
jeamland / shuttle.swift
Created November 17, 2016 22:51
My stunning adventures in Swift
import Foundation
import IOKit
import IOKit.hid
import Quartz
let ioman = IOHIDManagerCreate(kCFAllocatorDefault,
IOOptionBits(kIOHIDOptionsTypeNone))
let runloop : CFRunLoop = CFRunLoopGetCurrent()
let devices = [
kIOHIDVendorIDKey: 0x0b33,
@jeamland
jeamland / tarpaulin-output.txt
Created May 13, 2020 01:34
Tarpaulin output from tide-rs
> cargo tarpaulin -v
[INFO tarpaulin] Creating config
[INFO tarpaulin] Running Tarpaulin
[INFO tarpaulin] Building project
Compiling libc v0.2.70
Compiling proc-macro2 v1.0.12
Compiling unicode-xid v0.2.0
Compiling autocfg v1.0.0
Compiling cfg-if v0.1.10
Compiling syn v1.0.20
@jeamland
jeamland / fakedevice.py
Created December 2, 2019 04:23
Attempt at a fake device in Python
#!/usr/bin/env python
import os
import select
import subprocess
import time
import traceback
import functionfs
import functionfs.ch9
@jeamland
jeamland / fishbash.txt
Last active October 17, 2018 04:39
fish vs bash
# Necessary establishing information...
fish$ fish --version
fish, version 2.7.1
# Let's create a file that contains newlines.
fish$ cat > testfile.txt
foo
bar
@jeamland
jeamland / thing.c
Created August 7, 2018 05:38
Benno's Misadventures in libusb
$ uname -a
Darwin benno-mac.local 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64$ cc -o thing -I/usr/local/include/libusb-1.0 -L/usr/local/lib thing.c -lusb-1.0
$ ./thing
thing: set config failed: No such device (it may have been disconnected): No such file or directory
thing: claim interface failed: Access denied (insufficient permissions)
import curses
import paho.mqtt.client as mqtt
MQTT_SERVER = '127.0.0.1'
MQTT_TOPIC = 'lolibot/esp32_4e8854/in'
client = mqtt.Client()
client.connect(MQTT_SERVER, 1883, 60)
client.publish(MQTT_TOPIC, '(led:write 255 0 0)')
Python 3.6.4 (default, Dec 19 2017, 15:26:29)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import parse
>>> parse.parse('r{:d}', 'r4')
<Result (4,) {}>
>>> parse.parse('r{:d}', 'r 4')
<Result (4,) {}>
>>> parse.parse('r{:0d}', 'r 4')
<Result (4,) {}>
@jeamland
jeamland / failtest.c
Created August 3, 2017 21:54
Example of jemalloc test failure code
#include <errno.h>
#include <stdio.h>
#include "jemalloc/jemalloc.h"
int
main(int argc, char **argv)
{
int *thing, frob, res;
size_t frobsize;