This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/local/bin/bash | |
DST_DIR=~/Photos/exports | |
# Organizes files by year/month into the DST_DIR | |
find . -type f | \ | |
while read i; \ | |
do IFS=' ' read -r -a result <<< $(ls -lUTD %Y-%m "$i");\ | |
mkdir -p $DST_DIR/${result[5]};\ | |
mv "$i" $DST_DIR/${result[5]};\ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/local/bin/bash | |
# Sets file modification time to the same as the creation time | |
find . -type f | \ | |
while read i; \ | |
do IFS=' ' read -r -a result <<< $(ls -lUTD %Y%m%d%H%M.%S "$i");\ | |
touch -t ${result[5]} "$i";\ | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smtplib | |
import subprocess | |
my_email = '[email protected]' | |
to_email = '[email protected]' | |
myip = subprocess.check_output(['hostname', '-I']) | |
msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n") % (my_email, to_email, "IP from the Pi") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Non-interactive command-line equivalents to raspi-config | |
# These are not guaranteed to work under all circumstances. | |
# I use them in a fabric script to do unattended setup of a | |
# Raspberry Pi immediately after having booted up a NOOBS | |
# and installed Raspbian. | |
# | |
# 1. Install NOOBS | |
# 2. When the config screen comes up, hit TAB TAB RETURN to exit from it | |
# 3. Type 'sudo service ssh start' at the command line (no quotes). | |
# 4. (Optional) copy a public key to the pi account on the pi. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, render_template, request | |
import math, os, time, serial, time | |
import RPi.GPIO as GPIO | |
# initialize serial port | |
port = serial.Serial("/dev/ttyAMA0", baudrate=19200, timeout=3.0) | |
# wait 2 seconds | |
#time.sleep(2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background-color: white; | |
} | |
#control { | |
width: 512px; height: 512px; | |
background-color: #aaa; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Light Ballet Controls</title> | |
<script type="text/javascript" src="./static/jquery-1.11.1.min.js"></script> | |
<script type="text/javascript" src="./static/foo.js"></script> | |
<link type="text/css" rel="stylesheet" href="./static/foo.css"/> | |
</head> | |
<body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lock keeps requests from piling on top of each other. | |
// without this, you can get requests totally out of order | |
var lock = 0; | |
function mouseMove(event) { | |
var speed = event.pageY / 4; // Just a hack to make the control box bigger | |
if ( lock === 0 ) { | |
lock = 1; | |
$.get('/motors?m1s=' + speed + '&m2s=' + speed +'&m3s=' + speed, | |
function(data) { |