This is cool...
From here https://earthengine.google.com/timelapse/
Search This Blog
Thursday, December 1, 2016
Wednesday, November 30, 2016
Coding for Amazon Alexa + Amazon Lambda
Bought an Amazon Echo Dot in the Black Friday sales... having a quick play at developing a test application for it using Amazon Lambda.
It's quite easy once you've wired things up.
This link was mega helpful and I used this as a code template to thanks to the original author: http://moduscreate.com/build-an-alexa-skill-with-python-and-aws-lambda/
First I wrote some code in Python on Lamda - excerpts below:
NOTE: If in the UK you must set up the ENGLISH (UK) language tab - not the default English (US) tab - otherwise even though things will work in the online dev test environment your Echo won't respond to voice requests.
The Main setup is the intent schema and sample utterances. The intents must link to those in your code (eg python) and to the sample utterances. You can create slots of various data types (eg dates, lists) and pass those values to your application too.
========
{
"intents": [
{
"intent": "GetNumber"
},
{
"intent": "GetLetter"
},
{
"intent": "GetNumberBetween",
"slots":[
{
"name": "NumberA",
"type": "AMAZON.NUMBER"
},
{
"name": "NumberB",
"type": "AMAZON.NUMBER"
}
]
}
]
}
==========
GetNumber for a number
GetNumber random number
GetNumber for a random number
GetNumber for random number
GetNumber give me an integer
GetNumber number please
GetNumber choose a number
GetNumber pick a number
GetNumber another number
GetNumber choose a number
GetNumber give me a number
GetLetter for a letter
GetLetter for a random letter
GetLetter for random letter
GetLetter choose a letter
GetLetter letter please
GetNumberBetween give me a number between {NumberA} and {NumberB}
GetNumberBetween for a number between {NumberA} and {NumberB}
GetNumberBetween for a random number between {NumberA} and {NumberB}
GetNumberBetween select a random number between {NumberA} and {NumberB}
GetNumberBetween give me a number from {NumberA} and {NumberB}
GetNumberBetween select a random number from {NumberA} and {NumberB}
GetNumberBetween choose a number between {NumberA} and {NumberB}
GetNumberBetween pick a number between {NumberA} and {NumberB}
It's quite easy once you've wired things up.
This link was mega helpful and I used this as a code template to thanks to the original author: http://moduscreate.com/build-an-alexa-skill-with-python-and-aws-lambda/
First I wrote some code in Python on Lamda - excerpts below:
import json
import random
def lambda_handler(event, context):
if event["request"]["type"] == "IntentRequest":
return on_intent(event["request"], event["session"])
def on_intent(intent_request, session):
intent = intent_request["intent"]
intent_name = intent_request["intent"]["name"]
if intent_name == "GetNumber":
return get_number()
elif intent_name == "GetLetter":
return get_letter()
elif intent_name == "GetNumberBetween":
return get_numberbetween(intent)
def get_number():
session_attributes = {}
card_title = "RandomNumber"
r=random.randrange(10)
speech_output = 'the number I chose is '+ str(r)
reprompt_text = "OK"
should_end_session = True
return build_response(session_attributes, build_speechlet_response(
card_title, speech_output, reprompt_text, should_end_session))
def get_letter():
session_attributes = {}
card_title = "RandomNumber"
r=random.randrange(26)
speech_output = 'abcdefghijklmnopqrstuvwyz'[r]
reprompt_text = "OK"
should_end_session = True
return build_response(session_attributes, build_speechlet_response(
card_title, speech_output, reprompt_text, should_end_session))
def get_numberbetween(intent):
if "NumberA" in intent["slots"]:
num_a = intent["slots"]["NumberA"]["value"]
if "NumberB" in intent["slots"]:
num_b = intent["slots"]["NumberB"]["value"]
print (num_a)
session_attributes = {}
card_title = "RandomNumber"
r=random.randrange(int(num_a),int(num_b),1)
speech_output = str(r)
reprompt_text = "OK"
should_end_session = True
return build_response(session_attributes, build_speechlet_response(
card_title, speech_output, reprompt_text, should_end_session))
def build_speechlet_response(title, output, reprompt_text, should_end_session):
return {
"outputSpeech": {
"type": "PlainText",
"text": output
},
"card": {
"type": "Simple",
"title": title,
"content": output
},
"reprompt": {
"outputSpeech": {
"type": "PlainText",
"text": reprompt_text
}
},
"shouldEndSession": should_end_session
}
def build_response(session_attributes, speechlet_response):
return {
"version": "1.0",
"sessionAttributes": session_attributes,
"response": speechlet_response
}
===========
You will need to copy the Application number which should be in the form arn:aws:lambda.....
You can this from the AWS Lambda Dev page - click on functions and in the code view it should be top right of the page.
Then head here to set up the link from AWS Lambda to the Alexa skills kit.
NOTE: If in the UK you must set up the ENGLISH (UK) language tab - not the default English (US) tab - otherwise even though things will work in the online dev test environment your Echo won't respond to voice requests.
The Main setup is the intent schema and sample utterances. The intents must link to those in your code (eg python) and to the sample utterances. You can create slots of various data types (eg dates, lists) and pass those values to your application too.
========
Intent Schema
"intents": [
{
"intent": "GetNumber"
},
{
"intent": "GetLetter"
},
{
"intent": "GetNumberBetween",
"slots":[
{
"name": "NumberA",
"type": "AMAZON.NUMBER"
},
{
"name": "NumberB",
"type": "AMAZON.NUMBER"
}
]
}
]
}
==========
Sample Utterances
GetNumber for a number
GetNumber random number
GetNumber for a random number
GetNumber for random number
GetNumber give me an integer
GetNumber number please
GetNumber choose a number
GetNumber pick a number
GetNumber another number
GetNumber choose a number
GetNumber give me a number
GetLetter for a letter
GetLetter for a random letter
GetLetter for random letter
GetLetter choose a letter
GetLetter letter please
GetNumberBetween give me a number between {NumberA} and {NumberB}
GetNumberBetween for a number between {NumberA} and {NumberB}
GetNumberBetween for a random number between {NumberA} and {NumberB}
GetNumberBetween select a random number between {NumberA} and {NumberB}
GetNumberBetween give me a number from {NumberA} and {NumberB}
GetNumberBetween select a random number from {NumberA} and {NumberB}
GetNumberBetween choose a number between {NumberA} and {NumberB}
GetNumberBetween pick a number between {NumberA} and {NumberB}
Thursday, November 17, 2016
Batch loading OS Highway GML files to a PostgreSQL (+PostGIS) database
With one line at the Command Prompt (Windows) you can load a whole directory of files into a PostgreSQL database
D:\gisdata> for /R %f in (*.gml) do ogr2ogr -f "PostgreSQL" PG:"host=1.2.3.4 port=5432 user=postgres dbname=db password=pass123" %f -append
This will append the converted GML files into PostGIS format in the DB
D:\gisdata> for /R %f in (*.gml) do ogr2ogr -f "PostgreSQL" PG:"host=1.2.3.4 port=5432 user=postgres dbname=db password=pass123" %f -append
This will append the converted GML files into PostGIS format in the DB
Tuesday, November 1, 2016
Writing an ISO image to USB on Mac OSX
First up find which disk the USB is using:
diskutil list
then you will see a list of devices like this
(eg if I wished to target the KINGSTON 16GB USB drive then it'd be /dev/disk3)
diskutil unmountdisk /dev/diskN
then
sudo dd if=/data/yourfile.iso of=/dev/diskN bs=1m
(wait)
should be done!
diskutil list
then you will see a list of devices like this
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *500.3 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_CoreStorage Macintosh HD 499.4 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
/dev/disk1 (internal, virtual):
#: TYPE NAME SIZE IDENTIFIER
0: Apple_HFS Macintosh HD +499.0 GB disk1
Logical Volume on disk0s2
Unencrypted
/dev/disk3 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *15.6 GB disk3
1: Windows_FAT_32 KINGSTON 15.6 GB disk3s1
(eg if I wished to target the KINGSTON 16GB USB drive then it'd be /dev/disk3)
diskutil unmountdisk /dev/diskN
then
sudo dd if=/data/yourfile.iso of=/dev/diskN bs=1m
(wait)
should be done!
Friday, October 7, 2016
Concept Net
Some great work on common sense graphs...
https://github.com/commonsense/conceptnet5/wiki
http://conceptnet5.media.mit.edu/
Example:
https://github.com/commonsense/conceptnet5/wiki
http://conceptnet5.media.mit.edu/
Example:
*Something you find in a park is a playground
*Something you find at a park is a squirrel
*Something you find in a park is a picnic table
A driveway is for parking
Wednesday, September 7, 2016
LINKS to things to check out one day
Links to things I really should find time to check out :
http://mapsurfernet.com/demo/gallery
MapSurfer.NET is a free, modern and advanced framework for producing a cartographic product of a high quality. This full featured framework offers a rich set of tools and techniques to automate various cartographic tasks. MapSurfer.NET is designed to be fast and flexible for being used both in desktop and web applications.
-------
http://openrouteservice.org/
Open least cost paths (car, public transport, walking etc)
------
https://datahub.io/dataset/open-flights
(Flight data, and airport details)
http://mapsurfernet.com/demo/gallery
MapSurfer.NET is a free, modern and advanced framework for producing a cartographic product of a high quality. This full featured framework offers a rich set of tools and techniques to automate various cartographic tasks. MapSurfer.NET is designed to be fast and flexible for being used both in desktop and web applications.
-------
http://openrouteservice.org/
Open least cost paths (car, public transport, walking etc)
------
https://datahub.io/dataset/open-flights
(Flight data, and airport details)
Monday, August 22, 2016
SSL HTTPS on IIS - https://letsencrypt.org/
Google Chrome now blocks access to HTML5 geoocation stuff I need... unless it comes form HTTPS secure server. Here are a few notes - mainly for Windows IIS.
1) SSL is really for 2 things (a) encryption (b) authentication of your server - self-signed certificates are fine for (a) but not (b)
IIS - self certificates are really easy to generate and use on HTTPS site but you will get msg about not being trusted as (b) above
2) There's a relatively new Cert authority trying to make HTTPS free --- https://letsencrypt.org/
they seem to have been set up April 2016
You can download a file and put on server to authenticate you are who you say you are... without FTP you can still do this manually but need to create a file path on your Web server which has folder .well-known which Windows doesn't like but you can make it do it by doing this:
.well-known. (the last dot is important), Windows will create the folder and automatically will remove the last dot.
The certificate can then be downloaded and installed on IIS... you need to import the Cert in Microsoft Management console if on Windows.. then Complete the certificate import in IIS.
ALT to 2) Instead of going the time consuming pain of (2) then this makes life a lot lot easier.. (Windows)
Download the compiled version of this source https://github.com/Lone- Coder/letsencrypt-win-simple from here https://github.com/Lone-Coder /letsencrypt-win-simple/releas es
Run the letsencrypt.exe on your server.. answer the prompts.. it does the authentication using letsencrypt.org and installs the certificate for you on IIS
Job done... :-)
Subscribe to:
Posts (Atom)