Skip to content

Instantly share code, notes, and snippets.

View omundy's full-sized avatar

Owen Mundy omundy

View GitHub Profile
@omundy
omundy / scraper_bbc_find-replace.php
Created May 16, 2011 11:20
Basic scraping demo with "find-replace" parsing
<?php
/* Basic scraping demo with "find-replace" parsing
* Owen Mundy Copyright 2011 GNU/GPL */
$url = "http://www.bbc.co.uk/news/"; // 0. url to start with
$contents = file_get_contents($url); // 1. get contents of page in a string
// 2. search and replace contents
@omundy
omundy / scraper_bbc_foreach.php
Created May 16, 2011 11:41
Basic scraping demo with "foreach" parsing
<?php
/* Basic scraping demo with "foreach" parsing
* Owen Mundy Copyright 2011 GNU/GPL */
$url = "http://www.bbc.co.uk/news/"; // 0. url to start with
$lines = file($url); // 1. get contents of url in an array
foreach ($lines as $line_num => $line) // 2. loop through each line in page
@omundy
omundy / scraper_bbc_regex_title.php
Created May 16, 2011 11:45
Basic scraping demo with "regex" parsing
<?php
/* Basic scraping demo with "regex" parsing
* Owen Mundy Copyright 2011 GNU/GPL */
$url = "http://www.bbc.co.uk/news/"; // 0. url to start with
$contents = file_get_contents($url); // 1. get contents of url in a string
// 2. match title
@omundy
omundy / scraper_bbc_regex.php
Created May 16, 2011 11:54
Basic scraping demo with "foreach" and "regex" parsing
<?php
/* Basic scraping demo with "foreach" and "regex" parsing
* Owen Mundy Copyright 2011 GNU/GPL */
// url to start
$url = "http://www.bbc.co.uk/news/";
// get contents of url in an array
$lines = file($url);
@omundy
omundy / scraper_weather_regex.php
Created May 16, 2011 12:01
Advanced scraping demo with "regex" parsing
<?php
/* Advanced scraping demo with "regex" parsing. Retrieves current
* weather in any city and colors the background accordingly.
* The math below for normalization could use some work.
* Owen Mundy Copyright 2011 GNU/GPL */
?>
<html>
@omundy
omundy / hello.pde
Created September 11, 2011 02:52
Hello World file for Processing or Processing.js
// Hello World file for Processing or Processing.js
void setup(){
size(1000,700);
background(255);
}
void draw(){
stroke(random(255),random(255), random(255));
line(random(width),random(height), random(width),random(height));
println("Hello World!");
}
@omundy
omundy / analog_test_simple.py
Created May 15, 2012 02:12
Simplified analog input test file for PyBBIO
# analog_test_simple.py by Owen Mundy
# modified from:
# analog_test.py - Alexander Hiam
# Testing analogRead()
#
# *** NOTICE ***
# The maximum ADC input voltage is 1.8v,
# applying greater voltages will likely cause
# permanent damage to the ADC module!
#
@omundy
omundy / analog-test-all-pins.py
Created May 17, 2012 12:46
BeagleBone test and print all analog-in pins
# analog-test-all-pins.py - Owen Mundy
# Print reading from each analog-in pin on a BeagleBone
# with a short delay between each
# This example is in the public domain
import os,time
i = 1
while(True):
os.system("cat /sys/bus/platform/devices/tsc/ain" + str(i))
@omundy
omundy / analog-test-all-pins.py
Created May 17, 2012 15:10
Print reading from each analog-in pin on a BeagleBone using mrBBIO
# analog-test-all-pins.py - Owen Mundy
# Print reading from each analog-in pin on a BeagleBone
# with a short delay between each
# using mrBBIO by Matt Richardson:
# https://github.com/mrichardson23/mrBBIO
# This example is in the public domain
from mrbbio import *
def setup():
@omundy
omundy / analog-read-all.js
Created May 26, 2012 13:52
Use bonescript and node.js to read from all analog pins on a BeagleBone
/*
* analog-read-all.js
* Use bonescript and node.js to read from all analog pins on a BeagleBone
* Found in the wild:
* https://groups.google.com/forum/#!msg/beagleboard/rftH6aqyR5k/n7jQbCNAL3YJ
*/
var bb = require('./bonescript');
var sys = require('util');
var fs = require('fs');