Skip to content

Instantly share code, notes, and snippets.

View davidjmemmett's full-sized avatar

David JM Emmett davidjmemmett

View GitHub Profile
<?php
function getPageTitle($url, $to_encoding)
{
$fh = fopen($url, 'r');
$content = "";
$title = "";
while (!feof($fh))
{
$content .= fread($fh, 8192);
/* Richard's Traffic Light Program */
int pinRedLed = 2;
int pinYelLed = 3;
int pinGrnLed = 4;
int lightState = 0;
void setup() {
pinMode(pinRedLed, OUTPUT); /* Set the LED pins to output */
pinMode(pinYelLed, OUTPUT);
@davidjmemmett
davidjmemmett / fibonnaci.php
Created January 27, 2011 20:50
FibonnaciSequence class and PhiApproximator class
<?php
class FibonnaciSequence implements Iterator {
private $index = 0;
protected $oldnum = 0;
private $currnum = 1;
private $nextnum = 1;
public function current() {
return $this->currnum;
}
<script src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script src="geocoder.test.js"></script>
program HelloWorld
write (*,*) 'Hello, world!'
end program
<?php
class SlowClockCalculator {
private $target_hour = 0;
private $target_minute = 0;
private $slow = 0;
private $difference = 0;
private $result = 0;
<?php
class Vehicle {
private $speed;
private $distance_travelled;
private $time_taken;
public function setSpeed($speed) {
$this->speed = $speed;
}
public function travelTime($time) {
@davidjmemmett
davidjmemmett / insanity.php
Created October 27, 2011 15:34
Can't believe PHP lets you do this...
<?php
$foo = 'This, yes, is insane...';
${$foo} = 1;
${'This gets worse...'} = 1;
@davidjmemmett
davidjmemmett / actual_migration.sql
Created December 8, 2011 18:46
multiple aggregate_column behaviours in Propel
ALTER TABLE `table_1` ADD
(
`nb_something_else` INTEGER
);
operands = {
'+': lambda a, b: a + b,
'-': lambda a, b: a - b,
'x': lambda a, b: a * b,
'/': lambda a, b: a / b
}
def parse(eq):
bits = []