Alexa Skills: project structure

I couldn’t find anything mandating project structure. So I have taken the “speechAssets, src” pattern that you see (mostly) on the Amazon Alexa github repo, and adapted for my own wants:

For example…

 

Advertisements

Visual Studio Code: code snippets

Found this (admittedly staring me in the face right now… but it wasn’t a while back, I’m sure)

So looking in VSCode:

So lest I make a mess of it, quick back up of the text:

{
// Place your snippets for C# here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, ${id} and ${id:label} and ${1:label} for variables. Variables with the same id are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
}

Then add a simple property snippet, using a slightly different shortcut than [prop], as that automatically gets picked up, I’ll find out how another time.

You don’t need to restart VSCode to get this working. It updates on the fly. The ONE thing this lacks right now is the ReSharper type macro language that is very useful for doing the private backing field/public property thing (I know what I mean 🙂 )

"Simple Property by Dennis": {
"prefix": "propdennis",
"body": [
"public ${type:string} ${name} {get;set;}"
],
"description": "Create a Dennis simple property"
}


In fact I will show you exactly what I mean...

My standards say that a private variable starts with an underscore followed by a lower case character, as shown above. However, the best that I can achieve with this snippet manager, with the minimum number of keystrokes, is this, because unlike ReSharper, there is no macro language or mechanism to achieve the above, so I get this:

CodeSnippetsinVsCode11

And this is how you achieve the immediately above anyway:

CodeSnippetsinVsCode12

In the docs, they talk about using $1 etc to represent tab-stops, but that doesn’t work for me, and they have not included a working example. This is good enough:

"Simple Property by Dennis": {
"prefix": "propWithBacker",
"body": [
"\t\tprivate ${type:string} _${name};\n",
"\t\tpublic ${type:string} ${name} {",
"\t\t\tget {",
"\t\t\t\treturn _${name};",
"\t\t\t}",
"\t\t\tset { ",
"\t\t\t\t_${name} = ${name};",
"\t\t\t}",
"\t\t}\n"
],
"description": "Create a property with backing field"
}

Hm, actually you don’t need that string of tabs. The snippet placement is sensitive to the position of your cursor, so this will do:

"Simple Property by Dennis": {
"prefix": "propWithBacker",
"body": [
"private ${type:string} _${name};\n",
"public ${type:string} ${name} {",
"\tget {",
"\t\treturn _${name};",
"\t}",
"\tset { ",
"\t\t_${name} = ${name};",
"\t}",
"}\n"
],
"description": "Create a property with backing field"
}


May 2016...
I didn't want to start a new page, but this is a good starting set of Angular and BootStrap er things, to get started (in Emmet and VSC - this goes in the html.json page)

{
 "Basic HTML boilerplate": {
 "prefix": "BasicHtml",
 "body": [
 "<!DOCTYPE html>",
 "<html>",
 "\t<head>",
 "\t\t<title>From the snippets location in Visual Studio Code</title>",
 "\t\t<meta charset=\"utf-8\">",
 "\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">",
 "\t\thttps://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.jsx",
 "\t\t<link rel=\"stylesheet\" href=\"http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css\"></link>",
 "\t\thttp://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js",
 "\t\thttp://BasicStuff.js",
 "\t</head>",
 "\t<body>",
 "\t\t<input type=\"button\" value=\"Press me\" id=\"BasicHtmlPressMeId\">",
 "\t\t<input type=\"text\" value=\"Press mex\" id=\"BasicHtmlCapacityId\">",
 "\t</body>",
 "</html>",
 "<!-- https://validator.w3.org/nu/#textarea -->",
 "<!-- Location is [file:///e:/sandbox/javascript/test.html] -->"
 ],
 "description": "A basic snippet of HTML"
 },
 "BSButtons": {
 "prefix": "B01",
 "body": [
 "
“, “\t

A bunch of big Bootstrap buttons

“, ”

“, “<p>”, “\t<button type=\”button\” class=\”btn btn-lg btn-default\”>Default</button>”, “\t<button type=\”button\” class=\”btn btn-lg btn-primary\”>Primary</button>”, “\t<button type=\”button\” class=\”btn btn-lg btn-success\”>Success</button>”, “\t<button type=\”button\” class=\”btn btn-lg btn-info\”>Info</button>”, “\t<button type=\”button\” class=\”btn btn-lg btn-warning\”>Warning</button>”, “\t<button type=\”button\” class=\”btn btn-lg btn-danger\”>Danger</button>”, “</p>” ], “description”: “Initial bootstrap buttons” }, “Ang01”: { “prefix”: “Ang01”, “body”: [ “\thttps://ajax.googleapis.com/ajax/libs/angularjs/1.5.1/angular.js” ], “description”: “Angular CDN” }, “BSScriptTags”: { “prefix”: “BSScript”, “body”: [ “\t\thttps://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.jsx“, “\t\t<link rel=\”stylesheet\” href=\”http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css\”></link>”, “\t\thttp://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js” ], “description”: “The Bootstrap src, css and jquery bits” } }