Skip to content

Instantly share code, notes, and snippets.

@andrewn
andrewn / config.ru
Created October 8, 2013 13:43
Run PHP scripts via pow.cx
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
INDEXES = ['index.html','index.php', 'index.cgi']
base_path = Dir.getwd
base_path = "/Users/andrew/Projects/oss/tal/talexample"
use Rack::Rewrite do
@andrewn
andrewn / app.css
Last active December 24, 2015 11:39
Attempt at blink detection
canvas {
margin: 0 auto;
-moz-transform: scale(-1, 1);
-o-transform: scale(-1, 1);
-webkit-transform: scale(-1, 1);
filter: FlipH;
transform: scale(-1, 1);
}
@andrewn
andrewn / gist:6352695
Last active December 21, 2015 19:09
USB Soundcard default
To make a USB souncard default:
1. Open `sudo nano /etc/modprobe.d/alsa-base.conf`
2. Comment out the following line: `#options snd-usb-audio index=-2`
3. Reboot
4. Check that USB audio is at the top of this list `cat /proc/asound/modules`
@andrewn
andrewn / gist:6320683
Last active December 21, 2015 14:38
HTTP 511Network authentication required
<html>
<head>
<title>Network Authentication Required</title>
<meta http-equiv="refresh"
content="0; url=http://raspberrypi.local/">
</head>
<body>
<p>You need to <a href="http://raspberrypi.local/">
configure a Wi-Fi network</a> to gain access.</p>
</body>
@andrewn
andrewn / instructions.md
Created August 21, 2013 16:23
Starting services as daemons on Raspbian
  • Save the script as /etc/init.d/raspi-printer
  • Make it executable chmod +x /etc/init.d/raspi-printer
  • Start by doing service raspi-printer start

To run automatically, you run the update-rc.d script:

sudo update-rc.d -f raspi-printer defaults

See: http://jimmyg.org/blog/2010/python-daemon-init-script.html

<!DOCTYPE html>
<html>
<head>
<title>Remote</title>
<style type="text/css">
body {
font-family: sans-serif;
font-size: 4em;
}
#wrapper {
@andrewn
andrewn / fading-background.html
Created July 3, 2013 10:19
Fading backgrounds in reveal.js
<div class="slides">
<section data-background="assets/image1.png">
<h2></h2>
</section>
<section data-background="assets/image2.png">
<h2></h2>
</section>
<section data-background="assets/image1.png">
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'X-Requested-With, Accept, Origin, Referer, User-Agent, Content-Type, Authorization');
// intercept OPTIONS method
if ('OPTIONS' == req.method) {
res.send(200);
}
else {
next();
# This is a very basic script to backup oyster card data to a scraperwiki vault
# Notes:
# 1) You need an oyster card that has been registered on tfl.gov.uk
# 2) This script requires you to enter your username and password (this about what that means before progressing, and do so at your own risk)
# 3) This script should be run in a PRIVATE SCRAPERWIKI VAULT ONLY https://scraperwiki.com/pricing/ not a public scraper, or the world will know your password
import scraperwiki
import mechanize
import lxml.html
from lxml.etree import tostring