Skip to content

Instantly share code, notes, and snippets.

Android Bluetooth Debugging

  • In developer options, turn on "Enable Bluetooth HCI snoop log". Will create a log at "/sdcard/btsnoop_hci.log"
  • To download the file, "adb pull /sdcard/btsnoop_hci.log"
  • To delete the file, "adb shell rm /sdcard/btsnoop_hci.log"

Open the file in Wireshark to see bluetooth packets wireshark -r btsnoop_hci.log

# Caculate the BSCCO checksum for a file
# Usage: `$ ruby bscco.rb your_file.txt`
# Based on the algorithm description in https://www.elexon.co.uk/wp-content/uploads/2013/11/bscp533_appx_a_v17.0.pdf
def bscco(file)
lines_except_last = File.read(file).lines[0..-2]
lines_as_bytes = lines_except_last
.map(&:chomp)
.map(&:bytes)
.map do |line_bytes|
@ajesler
ajesler / cucumber_step_debugging.rb
Created March 22, 2016 04:32
Start of a helper for understanding cucumber specs
module CucumberStepDebugging
def print_step_definitions
step_definitions.each do |sdl|
puts "#{sdl.regexp_source} in #{sdl.file_colon_line}"
end
end
def step_definitions
language_map = @__cucumber_runtime.instance_variable_get("@support_code").instance_variable_get("@language_map")
step_definitions = language_map["rb"].instance_variable_get("@available_step_definition_hash").keys
#define D3 3
#define SECONDS_PER_HOUR = 3600
const int photoresistorPin = D3;
const int impressionsPerkWh = 1000;
volatile long readingStart = 0;
volatile long readingEnd = 0;
volatile boolean readingAvailable = 0;
@ajesler
ajesler / readme.md
Created July 20, 2015 07:53
wator simulator using ncurses
@ajesler
ajesler / mbtiles.rb
Last active June 30, 2023 22:40
An mbtiles wrapper in ruby
require 'sqlite3'
# https://github.com/mapbox/mbtiles-spec/blob/master/1.1/spec.md
class Mbtiles
attr_reader :tile_format, :db_file_name
def initialize(db_file_name, format=:png)
@db_file_name = db_file_name
load_database(db_file_name)
@ajesler
ajesler / led_lamp.ino
Last active November 13, 2016 20:51
Arduino sketch for a remote controllable LED lamp.
// IRLib from https://github.com/cyborg5/IRLib
#include <IRLib.h>
// RGBEffects from https://github.com/ajesler/Arduino-RGBEffects
#include <RGBEffects.h>
// if isPaused is true, update will stop being called until the lamp is unpaused.
int isPaused = 0;
// the time between effect updates.
int effect_delay = 2100;
@ajesler
ajesler / readme.md
Last active August 29, 2015 14:03
Translation practice based on grabbing tweets in the desired language and feeding through google translate and speaking the text.

Twitter Translation Practice

This project was conceived with the idea of getting some real world language practice.

Installation

  1. Install the required gems.
gem install google-translate
@ajesler
ajesler / junit-test-times.rb
Last active August 29, 2015 14:01
Sort JUnit test results.
require 'nokogiri' # swap to using REXML - may be slower but its built in to the ruby standard lib.
require 'optparse'
######################################
# called like 'ruby junit-test-times.rb /home/user/project/target/surefire-reports'
######################################
class JUnitTestTimes
@options = {}
@ajesler
ajesler / .gitconfig
Created December 13, 2013 02:13
My .gitconfig file
[user]
name = <NAME>
email = <EMAIL>
[credential]
helper = cache --timeout=43200
[core]
editor = nano
#pager = less -r