Skip to content

Instantly share code, notes, and snippets.

View peplin's full-sized avatar

Christopher Peplin peplin

View GitHub Profile
@peplin
peplin / pygatt_test.py
Created September 10, 2016 17:28
A quick test for running the 2 pygatt backends in a coffee shop, connecting to any device we can and reading one characteristic
#!/usr/bin/env python
from __future__ import print_function
import logging
logging.basicConfig()
logging.getLogger('pygatt').setLevel(logging.INFO)
import binascii
import pygatt
@peplin
peplin / combined_3des_key.py
Created October 9, 2015 18:36
Generate a combined 3DES key for DUKPT from two components
from __future__ import print_function
from Crypto.Cipher import DES3
import os
import binascii
def xor_bytes(this, that):
return bytearray([ord(x) ^ ord(y) for x, y in zip(this, that)])
@peplin
peplin / nose2_addressable_test_name.py
Created May 13, 2015 18:18
A nose2 plugin to render the name of tests as something you can copy and paste and provide to nose at the command line to run an individual test
from nose2.events import Plugin
class AddressableTestNameOutcome(Plugin):
"""Render name of each test in results as as something you can copy and
paste and provide directly to nose2 at the command line to run a single
test.
"""
configSection = 'addressable_test_name'
@peplin
peplin / gist:88ef5f26c4cc53160448
Created March 19, 2015 12:42
Patch conflicting, old version of `six`
import pyxb
# pyxb bundles an old version of the 'six' package (1.5.1) that is not compatible with
# werkzeug 0.10's auto-reloader. It was fixed in six 1.5.2, and the latest
# release is 1.9.0! We work around it by deleting the one problematic module
# that is added (winreg is only available on Windows, Tk on Linux).
import sys
import copy
del sys.modules['pyxb.utils.six.moves.winreg']
for module in copy.copy(sys.modules):
@peplin
peplin / dupes.pl
Created June 16, 2014 13:27
Perl script to find duplicate filenames
#!/usr/bin/perl -w
use File::Find;
my %files;
my @dirs;
foreach $argnum (0 .. $#ARGV) {
push(@dirs, $ARGV[$argnum]);
}
@peplin
peplin / config.json
Created June 4, 2014 02:33
OpenXC custom command to send CAN message
{ "buses": {
"hs": {
"controller": 1,
"speed": 500000,
"raw_writable": true
}
},
"commands": [
{"name": "my_custom_command",
"handler": "sendMyCanMessage"
@peplin
peplin / training.mkd
Created September 27, 2013 15:34
Ford APA OpenXC Training Sessions

OpenXC Introduction

Length: 1 hour

OpenXC is an API to your car - by installing a small hardware module to read and translate metrics from a car's internal network, the data becomes accessible from most Android applications using the OpenXC library. You can start making vehicle-aware applications that have better interfaces based on context, can minimize distraction while driving, are integrated with other connected services, and can offer you more insight into your car's operation. This session presents a high level introduction to the OpenXC platform appropriate for engineers, business, IT, marketing, etc. The presentation will explain what OpenXC is and what was the motivation for creating the project at Ford and for releasing it as open source hardware and software. The high-level architecture of OpenXC will be detailed (Android apps, an DIY-friendly vehicle interface and a standardized data format) and some basic vehicle data concepts explained (like the CAN bus and read vs. write capabilities). The

@peplin
peplin / AndroidManifest.xml
Last active December 16, 2015 16:40
Complete example "Hello Car" app for OpenXC
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
@peplin
peplin / gist:5114028
Created March 8, 2013 03:33
Fixed PKGBUILD for dl-fldigi-git package in Arch AUR - https://aur.archlinux.org/packages/dl-fldigi-git/
# Contributor: [Philip Crump](mailto:pdc1g09@soton.ac.uk) aka M0DNY
# Maintainer: [Philip Crump](mailto:pdc1g09@soton.ac.uk) aka M0DNY
pkgname=dl-fldigi-git
#pkgver=3.21.36
pkgver=20130307
pkgrel=1
pkgdesc="Tracking Program for UK HAB Launches by James Coxon"
arch=('i686' 'x86_64')
url="https://github.com/jamescoxon/dl-fldigi"
@peplin
peplin / gist:2483204
Created April 24, 2012 20:05 — forked from agriffis/gist:2481292
.bashrc.virtualenvwrapper
# Dynamically load virtualenvwrapper functions to reduce shell startup
# time.
#
# Copyright 2012 Aron Griffis <aron@arongriffis.com>
# Released under the GNU GPL v3
#######################################################################
# Python virtualenvwrapper loads really slowly, so load it on demand.
if [[ $(type -w workon) != "workon: function" ]]; then
virtualenv_funcs=( workon deactivate mkvirtualenv )