Skip to content

Instantly share code, notes, and snippets.

View thenrich's full-sized avatar

Tim Henrich thenrich

  • Loop Science
  • Maryland
View GitHub Profile
@thenrich
thenrich / wpa_supplicant.conf
Created December 17, 2014 12:21
wpa_supplicant for Raspian
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="[YOUR SSID HERE]"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="[YOUR WPA KEY HERE]"
@thenrich
thenrich / interfaces
Created December 17, 2014 12:25
Raspian /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
@thenrich
thenrich / run
Created December 17, 2014 13:18
Bluetooth-agent Daemontools run script
#!/bin/sh
exec 2>&1
hciconfig hci0 piscan
exec /usr/bin/bluetooth-agent 0000
@thenrich
thenrich / run
Created December 17, 2014 13:20
Bluetooth-agent Daemontools log run script
#!/bin/bash
exec multilog t ./main
@thenrich
thenrich / gate_svr.py
Created December 18, 2014 01:05
Python Bluetooth Gate Opener Server
import datetime, time, signal, sys
from bluetooth import *
import RPi.GPIO as GPIO
# Setup GPIO
PIN = 19
GPIO.setmode(GPIO.BCM)
GPIO.setup(PIN, GPIO.OUT, GPIO.PUD_DOWN, 0)
server_sock = BluetoothSocket(RFCOMM)
@thenrich
thenrich / AndroidManifest.xml
Last active August 29, 2015 14:11
AndroidManifest.xml for Gate Opener Android App
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="YOURPACKAGE.gateopener" >
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
@thenrich
thenrich / GateOpener.java
Created December 18, 2014 01:51
GateOpener.java Widget for Android Gate Opener
package YOURPACKAGE.gateopener;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.RemoteViews;
@thenrich
thenrich / Receiver.java
Created December 18, 2014 02:02
BroadcastReceiver for Android Gate Opener
package YOURPACKAGE.gateopener;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
@thenrich
thenrich / gate_opener.xml
Created December 18, 2014 02:04
gate_opener.xml layout for Android Gate Opener
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/widget_margin"
android:background="#c0c0c0" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Open Gate"
@thenrich
thenrich / uwsgi.service
Created January 22, 2015 20:57
uWSGI systemd unit file
[Unit]
Description=uWSGI
After=docker.service
Requires=docker.service
[Service]
EnvironmentFile=/home/core/environ
User=core
TimeoutStartSec=300
ExecStartPre=-/usr/bin/docker kill uwsgi