Skip to content

Instantly share code, notes, and snippets.

View BenGriffiths's full-sized avatar

Ben BenGriffiths

View GitHub Profile
@BenGriffiths
BenGriffiths / Hack - Generics
Last active August 29, 2015 13:57
Hack - Generics Example
<?hh
class Box<T>
{
protected T $data;
public function __construct(T $data)
{
$this->data = $data;
}
@BenGriffiths
BenGriffiths / Hack - Type Annotations
Created March 22, 2014 17:47
Hack - Type Annotations Example
<?hh
class AnnotatedClass
{
public int $x;
private string $s;
protected array $arr;
public AnotherClass $ac;
function bar(string $str, bool $b): float
@BenGriffiths
BenGriffiths / Hack - Nullable
Last active August 29, 2015 13:57
Hack - Nullable Example
<?hh
function check_not_null(?int $x): int
{
if ($x === null)
{
return -1;
}
else
{
@BenGriffiths
BenGriffiths / Hack - Lambda Expressions
Last active August 29, 2015 13:57
Lambda Expressions
<?hh
$foo = $x ==> $x + 1;
$foo(12);
// returns 13
bar = ($a, $b) ==> $a + $b;
$bar(3, 8);
#include <LiquidCrystal.h>
#include <SPI.h>
#include <Ethernet.h>
#include <string.h>
LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[] = "www.mysite.com";
IPAddress ip(192,168,0,56);
#include <LiquidCrystal.h>
#include <SPI.h>
#include <Ethernet.h>
#include <string.h>
LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[] = "www.mysite.com";
IPAddress ip(192,168,0,56);
void setup() {
Serial.begin(9600);
lcd.clear();
lcd.begin(16, 2);
lcd.setCursor(0,0); lcd.print("Temperature");
lcd.setCursor(0,1); lcd.print("Monitor Tool");
delay(3000);
void loop() {
lcd.setCursor(0,0);
lcd.print("Next Upload: ");
lcd.setCursor(13,0);
lcd.print(timer); lcd.print(" ");
if(sinceLastSend <= 0){
sinceLastSend = sendAfter;
timer = sendAfter;
void sendData() {
lcd.clear();
lcd.setCursor(0,0); lcd.print("Connecting...");
// Turn the float to a string
dtostrf(tempCurrent, 4, 2, tempBuffer);
// Build the GET request
String getRequest = "GET /homemonitor/log.php?temperature=";
{
"err":"",
"suc":"new key 5f72253b673eb49fc64dd34439531b5cca05327f has been set.",
"key":"5f72253b673eb49fc64dd34439531b5cca05327f"
}