Skip to content

Instantly share code, notes, and snippets.

View solon's full-sized avatar
🐝

Brian Solon solon

🐝
View GitHub Profile
@solon
solon / ecb_rates.php
Created March 27, 2011 12:05
Print out the current Euro value for a currency, based on ECB daily rates
<?php
// for a list of all supported currencies, view the source code of this page:
// http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml
$x = simplexml_load_file("http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml");
function getEuroRate($symbol,$xml) {
$xml->registerXPathNamespace("ecb", "http://www.ecb.int/vocabulary/2002-08-01/eurofxref");
$array = $xml->xpath("//ecb:Cube[@currency='".$symbol."']/@rate");
$rate = (string) $array[0]['rate'];
return $rate;
}
@solon
solon / ecb_rates.php
Created March 27, 2011 04:39
Print out the current Euro value for a currency, based on ECB daily rates
<?php
// for a list of all supported currencies, view the source code of this page:
// http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml
function getEuroRate($symbol) {
$xml = simplexml_load_file("http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml");
$xml->registerXPathNamespace("ecb", "http://www.ecb.int/vocabulary/2002-08-01/eurofxref");
$array = $xml->xpath("//ecb:Cube[@currency='".$symbol."']/@rate");
$rate = (string) $array[0]['rate'];
return $rate;
}
@solon
solon / AnalogSelectWav.pde
Created February 7, 2011 15:07
Arduino program to divide an analog sensor into a number of discrete ranges and trigger a different WAV file when the sensor value enters one of the ranges.
// these are constants that won't change while the code is running
const int lowerBound = 0;
const int threshold1 = 350;
const int threshold2 = 700;
const int upperBound = 1024;
// these variables will change
int sensorValue = 0;
int lastRange = 0;
require 'rubygems'
require 'sinatra'
require 'data_mapper'
require 'carrierwave'
require 'carrierwave/orm/datamapper'
ROOT = Dir.pwd
class ImageUploader < CarrierWave::Uploader::Base
storage :file
/*
* skype_status.pde
* Turns on an LED when a Skype user is online and vice versa
* See http://apps.pachube.com/onlinestatus/online-status.php for more info and setup instructions.
*/
/* ==============================
* This code, which assumes you're using the official Arduino Ethernet shield,
* updates a Pachube feed with your analog-in values and grabs values from a Pachube
* feed - basically it enables you to have both "local" and "remote" sensors.
/*
* light_mirror.pde
* Turns on an LED when it's bright in a remote location and vice versa
* Remote location is set to the Pachube office feed but this can easily be changed
*/
/* ==============================
* This code, which assumes you're using the official Arduino Ethernet shield,
* updates a Pachube feed with your analog-in values and grabs values from a Pachube
* feed - basically it enables you to have both "local" and "remote" sensors.
char pachube_data[70];
boolean found_status_200 = false;
boolean found_session_id = false;
boolean found_CSV = false;
char *found;
unsigned int successes = 0;
unsigned int failures = 0;
boolean ready_to_update = true;
boolean reading_pachube = false;
<?php
/*
* sendTweet.php
*
* To send a tweet, request the URL of this script with a status parameter like this:
* http://localhost/sendTweet.php?status=this is a test tweet
*/
$status = $_GET['status'];
$username = "YOUR_TWITTER_USERNAME";
We couldn’t find that file to show.
<html>
<head>
<title>Changing webpage contents in response to a light sensor</title>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<style type="text/css">
body {
margin:0;
padding:50px;
text-align:center;
background-color:#ccc;