Skip to content

Instantly share code, notes, and snippets.

@runion
runion / solarSerial.py
Created December 13, 2012 22:20
This program monitors the serial connection between the computer and an attached Arduino. It accepts only the characters 1, 2, 3, or 4, and returns a text file based on which character is read. It normally runs as a background process, so the print statements are ignored. The text files are generated via a separate program, set up as a CRON job,…
import serial, time, os
def main():
pid = os.getpid()
pidFile = open("/home/davidr/solar/solarSerial.pid", "w")
pidFile.truncate()
pidFile.write(str(pid))
pidFile.close()
print "getting started here"
s = serial.Serial('/dev/ttyACM0', 9600)
@runion
runion / solar.ino
Created December 13, 2012 21:55
This is the Arduino code for my solar display controller. It communicates with a computer using Serial Over USB and receives text in response, and displays that text on two serial LCDs attached to the Arduino. The text is generated in a python program running on a webserver, which periodically updates it to reflect current solar conditions. Ther…
#include "Tlc5940.h" // external library for TLC lighting controller
// http://code.google.com/p/tlc5940arduino/
#include <SoftwareSerial.h> // standard/built-in external library for creating virtual serial ports. Used to output to the LCD displays
#define txPin1 2 // name pin 2 on the Arduino "txPin1" for later use
#define txPin2 4 // pin 4 connects to the second LCD display
#define photocellPin 5 // et cetera
#define buttonOne 6 // et cetera
#define buttonTwo 8
@runion
runion / getExpiringDomains.php
Created October 18, 2012 20:14
A CRON job that emails me a list of domains set to expire the next day
<?php
$tomorrow = mktime(0, 0, 0, date("m"), date("d")+1, date("Y"));
$tomorrow_egrep = date('n/j/Y', $tomorrow); # like "10/19/2012" without quotes
$shellCommands= <<<END
rm ~/temp/PoolDeletingDomainsList.zip ~/temp/PoolDeletingDomainsList.txt ~/temp/email_tmp.txt ~/temp/tomorrow.txt;
wget http://www.pool.com/Downloads/PoolDeletingDomainsList.zip -O ~/temp/PoolDeletingDomainsList.zip -q;
unzip -o ~/temp/PoolDeletingDomainsList.zip -d ~/temp/;
egrep -e "{$tomorrow_egrep}" ~/temp/PoolDeletingDomainsList.txt > ~/temp/tomorrow.txt;
@runion
runion / class.caching.php
Created October 1, 2012 16:41
class.caching.php - simple class for caching PHP files
<?php
class caching {
public $useCache = true;
public $hours_cache_remains_valid = 8;
private $curDirectory;
private $cacheFolder; // DOCUMENT_ROOT + this + $cacheFileName == cached_filename
private $serverFilename;
public $cacheFileName; // this is just the filename -- used to test if over 255 characters
public $cached_filename; // this includes the full path
public $saveCache; // boolean