Skip to content

Instantly share code, notes, and snippets.

View Westlad's full-sized avatar

Duncan Westland Westlad

View GitHub Profile
@Westlad
Westlad / echo.php
Created January 4, 2017 09:28
PHP script to receive JSON from Amazon Echo and run a simple on/off script (with thanks to Ghostbit for the original code https://gist.github.com/ghostbitmeta/824474ceea327da629c7)
<?php
$EchoJArray = json_decode(file_get_contents('php://input'));
$RequestType = $EchoJArray->request->type;
$JsonOut = GetJsonMessageResponse($RequestType,$EchoJArray);
$size = strlen($JsonOut);
header('Content-Type: application/json');
header("Content-length: $size");
echo $JsonOut;
@Westlad
Westlad / heater.py
Created January 4, 2017 09:36
A simple Python script to turn on or off an output for a PiFace Digital board
#!/usr/bin/python
# By Duncan Westland
# Programme to control a heater via command line switches.
# Uses a Raspberry Pi
import sys
import pifacedigitalio
piFace = pifacedigitalio.PiFaceDigital() #creat piface digital object
@Westlad
Westlad / control.py
Created January 15, 2017 20:30
Lambda function for controlling a Raspberry Pi enabled Alexa Smart Home Skill
import requests
def lambda_handler(event, context):
if event['header']['namespace'] == 'Alexa.ConnectedHome.Discovery':
return handleDiscovery(context, event)
elif event['header']['namespace'] == 'Alexa.ConnectedHome.Control':
return handleControl(context, event)
@Westlad
Westlad / heater.php
Created January 15, 2017 20:44
A simple script to receive a JSON object with "on and "off" directives and call a python script to turn a heater on or off.
<?php
$EchoJArray = json_decode(file_get_contents('php://input'));
$RequestType = $EchoJArray->request; // I don't use this yet
// ******************** Get state ********************;
$action = $EchoJArray->power;
if(empty($action)) {
$action = "off";
}
@Westlad
Westlad / test.txt
Created May 4, 2018 14:11
sha256 test vector
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1 1 0 0 0 0 1 1 0 0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