Skip to content

Instantly share code, notes, and snippets.

View aallan's full-sized avatar

Alasdair Allan aallan

View GitHub Profile
@aallan
aallan / keybase.md
Created January 27, 2015 13:58
Keybase proof

Keybase proof

I hereby claim:

  • I am aallan on github.
  • I am aallan (https://keybase.io/aallan) on keybase.
  • I have a public key whose fingerprint is A2E0 84E9 5E95 B4CB 0562 7672 5CA0 5526 5413 2159

To claim this, I am signing this object:

@aallan
aallan / i2c_lcd_smbus.py
Created August 24, 2015 18:36
Prints the current IP address to the SainSmart I2C 16×2 LCD panel using the ThinkBowl I2C library
import smbus
from time import *
# Older version of library that uses smbus, no longer updated
# For new projects use i2c_lcd
class i2c_lcd:
# Commands
CMD_Clear_Display = 0x01
@aallan
aallan / dual_ip.py
Last active September 5, 2015 18:29
Prints the current IP address for eth0 and eth1 to the SainSmart I2C 16×2 LCD panel using the ThinkBowl I2C library
#!/usr/bin/python
import socket
import fcntl
import struct
from i2clibraries import i2c_lcd_smbus
def get_ip_address(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
@aallan
aallan / i2c_scanner.ino
Last active September 20, 2015 16:28
Arduino sketch that scans the I2C bus for devices.
#include <Wire.h>
// i2c_scanner
// Version 1
// This program (or code that looks like it) can be found in many places. For example on the Arduino.cc forum.
// The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
// Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26 2013
// V3 by louarnold
@aallan
aallan / contacts.pl
Last active January 1, 2016 22:39
Perl script to match a list of US phone numbers to the leaked Snapchat database of phone numbers and user names. Run in the same directory as the schat.csv file, and another file called contacts.tel that contains a list of US phone numbers—one number per line in the file. Since the final two digits of the number are obscured in the leaked file, …
#!/usr/bin/perl
print "Reading schat.csv\n";
open ( my $schat, "<schat.csv") || die "Can't open schat.csv: $!";
my @snaps = <$schat>;
close($schat);
chomp( @snaps );
print "Reading contacts.tel\n";
open ( my $contacts, "<contacts.tel") || die "Can't open contacts.tel: $!";
@aallan
aallan / locations.pl
Last active January 1, 2016 22:39
Perl script to go through the leaked Snapchat database of phone numbers and user names, and divide it into separate CSV files split by location. Will create a file for each location in a locations/ subdirectory in the current working directory. Will report the totals for each location in CSV format.
#!/usr/bin/perl
use strict;
print "Reading schat.csv\n";
unless ( open ( FILE, "<schat.csv") ) {
print "Cannot open file for read\n";
exit;
}
@aallan
aallan / 0_get_beacon_json.sh
Last active January 7, 2016 20:17
The CES 2016 Beacons
curl -H 'Authorization: Token token=a00723c600c97d3aa96ad13475252be945cb1f0539b54ed4f66f9a0dcd18ae0b' https://proximitykit.radiusnetworks.com/api/kits/4276 > file.json
/*
Controlling large 7-segment displays via serial
By: Nathan Seidle, SparkFun Electronics
Modified: Alasdair Allan, Babilim Light Industries
Original: February 25th, 2015
Modifications: February 3rd, 2017
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
@aallan
aallan / counter_serial.pl
Last active October 26, 2017 10:27
Script uses an ARP scan to counter the number of devices on the network and saves this information to an SQLite3 database. Outputs the current number of devices to /dev/ttyUSB0.
#!/usr/bin/env perl
#+
# Name:
# counter.pl
# Language:
# Perl
@aallan
aallan / mirror_cloudapi.py
Created October 29, 2017 00:14
Magic Mirror weather implementation using Google Cloud Speech API
#!/usr/bin/env python3
import threading
import requests
import time
import aiy.audio
import aiy.cloudspeech
import aiy.voicehat