Skip to content

Instantly share code, notes, and snippets.

View jawa-the-hutt's full-sized avatar

Gary Gambill jawa-the-hutt

  • Free Agent
  • United States
View GitHub Profile
@jawa-the-hutt
jawa-the-hutt / base64.ts
Created December 12, 2019 12:53 — forked from EddyVerbruggen/base64.ts
base64 encoder (btoa) / decoder (aotb) shim for NativeScript
// base64 encoder (btoa) / decoder (atob) which you can use in your NativeScript app.
//
// Usage (assuming you're in some component and this file is in the same folder:
//
// require('./base64');
//
// const username = "My Usernamé";
// usernameBase64Encoded = btoa(username);
@jawa-the-hutt
jawa-the-hutt / handler-sample1.js
Last active April 17, 2018 21:18
handler-sample1.js
let deviceId = this.event.context.System.device.deviceId;
this.context.log('deviceId = ', deviceId); // will help you find out what the device ID is so you can add it into the global devices object
// get the mapping to the intent object
let intent = this.event.request.intent;
this.context.log('intent - ', intent);
// get the authority that is returning from alexa service. filter it based on your alexa app ID and the Control_List name you gave it
let authority = intent.slots.Control.resolutions.resolutionsPerAuthority.filter(auth => auth.authority.includes(GetEnvironmentVariable('ALEXA_APP_ID') + ".Control_List"));
@jawa-the-hutt
jawa-the-hutt / start-method.js
Last active April 17, 2018 21:42
start-method.js
async start() {
try{
// make the connection async/await capable
return await asyncIt(cb => this.alexa.execute(cb)).then(result => {
this.context.log('result - ', result);
return {
status: 200,
body: result
};
});
@jawa-the-hutt
jawa-the-hutt / alexa-function-constructor.js
Last active April 17, 2018 21:41
alexa-function-constructor.js
constructor(context, req) {
this.context = context;
this.req = req;
this.alexa = alexa;
// setup the connection to the alexa-skill-sdk-for-azure-function library
this.alexa.setup({
azureCtx: context,
azureReq: req,
handlers: [
@jawa-the-hutt
jawa-the-hutt / devices-object-sample.json
Last active April 17, 2018 20:41
devices-object-sample.json
{
"living_room": "amzn1.ask.device.AGE3M3...",
"family_room": "amzn1.ask.device.AGE3M3...",
"master_bedroom": "amzn1.ask.device.AGE3M3...",
"test": "amzn1.ask.device.AGE3M3...",
}
@jawa-the-hutt
jawa-the-hutt / rooms-object-sample.json
Last active April 17, 2018 20:42
rooms-object-sample.json
{
"living_room": "A0722C70200C",
"family_room": 0,
"master_bedroom": "500959F60E3D",
"test": 0
}
@jawa-the-hutt
jawa-the-hutt / function-code-part1.js
Created April 17, 2018 20:37
function-code-part1.js
// setup array of arrays to hold info for conversion into objects later.
let roomArray = new Array();
let deviceArray = new Array();
// get info from function settings and create the array of arrays
for(let i=1; i <= GetEnvironmentVariable('NUMBER_OF_ROOMS'); i++){
roomArray.push([GetEnvironmentVariable('ROOM_' + i + '_NAME'), GetEnvironmentVariable('ROOM_' + i + '_DTV_ADDRESS')]);
deviceArray.push([GetEnvironmentVariable('ROOM_' + i + '_NAME'), GetEnvironmentVariable('ROOM_' + i + '_DEVICE_ID')]);
};
@jawa-the-hutt
jawa-the-hutt / app-settings
Last active April 17, 2018 21:35
app-settings
{
"Values": {
"ALEXA_APP_ID": "amzn1.ask.skill.f4ee...",
"HOSTNAME": "192.168.1.39",
"PORT": "8888",
"USE_SSL": true,
"SELF_SIGNED_SSL": true,
"NUMBER_OF_ROOMS": 4,
"ROOM_1_NAME": "family room",
"ROOM_2_NAME": "living room",
@jawa-the-hutt
jawa-the-hutt / alexa-config-sample4.json
Created April 17, 2018 19:34
alexa-config-sample4.json
{
"id": "ESPN2",
"name": {
"value": "ESPN2",
"synonyms": [
"ESPN 2",
"ESPN two",
"ESPN to",
"ESPN too"
]
@jawa-the-hutt
jawa-the-hutt / alexa-config-sample3.json
Created April 17, 2018 19:33
alexa-config-sample3.json
{
"id": "PAUSE",
"name": {
"value": "pause",
"synonyms": [
"freeze"
]
}
}