Skip to content

Instantly share code, notes, and snippets.

@jennifersmith
jennifersmith / ioctls.md
Created December 5, 2023 10:33
IOCTLs and _IOC outputs in strace

I'm trying to figure out exactly what code is being called on the other side of this bluetooth/bluez btattach call using strace. While I'm pretty sure I have guessed the code that is handling it from context, I'd like to still understand the parts that go into this.

Command am running:

sudo strace btattach -P bcm -B hci_pty2
@jennifersmith
jennifersmith / bluetooth_and_bumble.md
Last active December 3, 2023 12:13
Bluetooth + Bumble + Socat fun

Getting Bumble - Python Bluetooth Stack going on Mac and Linux with QEMU + UTM

I tried to follow the example here: (https://github.com/google/bumble/blob/main/examples/README.md#running-run_controllerpy-with-a-bluez-host-running-on-linux) but it may need updating to change the order of running stuff and some of the params to the example file (or I need to read it more carefully).

Step 0: Prep

Anyway, I had a freshly installed QEMU based VM running Debian Bookworm - got this started via the UTM app which was new to me and handy for this quick hack. Also useful for quick hacks, I used the default networking offerd by the UTM inteface (host networking or whatever it is called) to avoid having to deal with ports and routing. Installed a few bits, most relevantly bluez and socat.

On my host machine (mac) I cloned the Bumble repo, venv-ed, pipped and so on so I c

@jennifersmith
jennifersmith / run_controller.py
Created December 3, 2023 11:23
modified example from bumble codebase
# Copyright 2021-2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
public void ThisIsAnOldMethod()
{
// carry on with remaining functions
var testedCode = new TestedCode(parameter1, parameter2);
testedCode.DoTheNewThingWeTested();
// carry on with remaining functions
}
@jennifersmith
jennifersmith / gist:6688adfce900bf93e585f787b7780f0e
Created March 30, 2016 00:05
Mine arbitrary package.json script configs I have lying around
find ~/ -name 'package.json' | xargs jq -sr '.[].scripts | keys[]' | sort | uniq
@jennifersmith
jennifersmith / codepages.rb
Created February 3, 2015 07:07
This seemed wonderfully important to me about 10 minutes ago.
(33..255).map {|x| windoze = x.chr(Encoding::CP1250); [x, windoze , begin windoze.encode(Encoding::UTF_8) rescue 'ass' end]}.select{|x| x[1] != x[2]}
@jennifersmith
jennifersmith / fixDates.rb
Created December 30, 2014 21:56
This is a bit of a rubbish script that spiders thru json and decides whether something is a timestamp or not on some assy heuristics - basically if you have a bunch of numbers and you think some of them are dates then it will convert them
#!/usr/bin/env ruby
require 'json'
require 'pry'
require 'date'
# basically if the number results in a ts that is less than 10 years ago it's probably a timestamp :D
YEARS_TO_BE_CONSIDERED_TIMESTAMP = 10
def fix_potential_timestamp potential_timestamp
# binding.pry
@jennifersmith
jennifersmith / go.sh
Last active August 29, 2015 14:10
Convert requires into a graph - this is pretty dreadful please can someone do better?
egrep -e "require\s\"([a-z]|_|/)+\"" -o -r lib | ./sniffrequires.rb | dot -Tsvg > /tmp/foo.svg; open /tmp/foo.svg
@jennifersmith
jennifersmith / aws.bash
Last active August 29, 2015 14:06
Too much aws and JSON make jen go something something http://bit.ly/1m8OONb
function which-aws {
echo "You are on an AWS account with alias(es)" `aws iam list-account-aliases | jq '.AccountAliases | join(",")' -r` | cowsay
}
function cfn-describe {
aws cloudformation describe-stacks --stack-name "$1"
}
require 'rspec/expectations'
class Pain
def tear_inducing?
true
end
end
class Fear
def tear_inducing?