Skip to content

Instantly share code, notes, and snippets.

@tagroup
tagroup / manage_remote
Created July 6, 2012 07:39
Script to open a reverse ssh tunnel if a specific file exists on a server with 'yes' in it
#!/bin/bash
WGET="/usr/bin/wget"
$WGET -q --tries=10 --timeout=5 http://youralwaysonserver/openpi.php -O /tmp/openpi &> /dev/null
if grep -Fxq "yes" /tmp/openpi
then
ssh -gNnT -R *:55555:raspberrypi.local:80 piremoteuser@youralwaysonserver &
PID=$!
echo "Opened"
sleep 360s;
@tagroup
tagroup / tradeking_streaming_quotes.php
Created November 3, 2012 07:00
TradeKing PHP Streaming Quote API Example
<?php
/*
Very quick and dirty expansion on the TradeKing PHP example to allow you to handle and process streaming quotes
see more at http://thomasloughlin.com
enjoy at your own risk
*/
date_default_timezone_set('America/Chicago');
// Your keys/secrets for access
$consumer_key = 'uqM2342345234523452345234520NT';
@tagroup
tagroup / index.php
Created March 10, 2013 02:01
Hack to test Multilevel openzwave Switches
<?php
/////////////////////////
//
//For multilevel put 0-99 in as a status and click the light bulb
// more at http://thomasloughlin.com/new-open-zwaveraspbian-image-ready-for-download/
////////////////////////////
session_start();
define("ZWAVE_HOST", "localhost");
define("ZWAVE_PORT", 6004);
#!/bin/bash
##I had greater hopes and dreams at the start
export red="gpio write 0 0"
export yellow="gpio write 1 0"
export green="gpio write 2 0"
#CLAR MEANS CLEAR!! CLAR MEANS CLEAR!! DIVE! DIVE!
export clar_red="gpio write 0 1"
export clar_yellow="gpio write 1 1"
export clar_green="gpio write 2 1"
#
@tagroup
tagroup / stepper.sh
Last active December 16, 2015 18:09
GPIO Stepper Motor Code for Raspberry Pi
#!/bin/bash
gpio mode 0 out && gpio mode 1 out && gpio mode 2 out && gpio mode 3 out
gpio write 0 0 && gpio write 1 0 && gpio write 2 0 && gpio write 3 0
while true
do gpio write 0 1 && gpio write 3 1
gpio write 3 0 && gpio write 1 1
gpio write 0 0 && gpio write 2 1
gpio write 1 0 && gpio write 3 1
gpio write 2 0
done
@tagroup
tagroup / echoSerial.c
Last active December 17, 2015 16:49
Raspberry serial communication with Arduino serial connection: see full blog at http://thomasloughlin.com
/*
Software serial multple serial test
Receives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.
The circuit:
* RX is digital pin 10 (connect to TX of other device)
* TX is digital pin 11 (connect to RX of other device)
@tagroup
tagroup / recordRequestsLazy.sh
Last active January 2, 2017 04:00
Setup script to view what http traffic is coming to an ip address / server.
#!/bin/bash
apt-get update && apt-get upgrade -y
apt-get install -y apache2 php5
echo '' > /etc/apache2/sites-available/000-default.conf
echo '<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory "/var/www/html">
AllowOverride All
</Directory>
@tagroup
tagroup / RainWaterOutputLogger.pde
Created January 20, 2013 23:23
Arduino Sketch for data logging water flow to an SD card. Project at http://thomasloughlin.com/rain-water-collection/.
#include <SD.h>
/*
This script is a simple combination of two existing example files.
The goal is to measure water flow coming from a rain collection barrel
The project progress can be found at http://thomasloughlin.com/rain-water-collection/.
*/
/**********************************************************
This is example code for using the Adafruit liquid flow meters.