This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.datasets import load_iris | |
from sklearn.model_selection import train_test_split | |
from sklearn.neighbors import KNeighborsClassifier | |
import numpy as np |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async Task SuccessfulLogin (IDialogContext context, IAwaitable<GetTokenResponse> tokenResponse) { | |
var token = await tokenResponse; | |
var client = new SimpleGraphClient (token.Token); | |
var me = await client.GetMe (); | |
await context.PostAsync ($”Login successful — welcome {me.DisplayName}”); | |
} | |
public static async Task Signout (IDialogContext context) { | |
await context.SignOutUserAsync (ConnectionName); | |
await context.PostAsync ($”You have been signed out.”); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[LuisIntent (“adauthentication”)] | |
public async Task ADAuthentication (IDialogContext context, LuisResult result) { | |
context.Call (CreateGetTokenDialog (), SuccessfulLogin); | |
} | |
[LuisIntent (“whoami”)] | |
public async Task WhoAmI (IDialogContext context, LuisResult result) { | |
context.Call (CreateGetTokenDialog (), ListMe); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[LuisModel("endpointID", "endpointPassword")] | |
[Serializable] | |
public class LUISDialog : LuisDialog<ProjectCreator> { | |
private readonly BuildFormDelegate<ProjectCreator> TouchProject; | |
private static string ConnectionName = ConfigurationManager.AppSettings["ConnectionName"]; | |
public LUISDialog(BuildFormDelegate<ProjectCreator> touchProject) { | |
this.TouchProject = touchProject; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function maybeInstantiateStreaming(path, ...opts) { | |
// Start the download asap. | |
const f = fetch(path); | |
try { | |
// This will throw either if `instantiateStreaming` is | |
// undefined or the `Content-Type` header is wrong. | |
return WebAssembly.instantiateStreaming( | |
f, | |
...opts | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function run() { | |
const {instance} = await WebAssembly.instantiateStreaming( | |
fetch("./add.wasm"), | |
env: { abort: () => console.log("Abort!") } | |
); | |
const r = instance.exports.add(1, 2); | |
console.log(r); | |
} | |
run(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//retrieve image pixels (4 bytes per pixel: RBGA) | |
const data = imageData.data; | |
//copy to bytes to shared memory | |
mem.set(data); | |
//invoque 'fn' Wasm filter. We need to inform of the image byte size | |
const byteSize = data.length; | |
instance.exports[fn](byteSize, ...args); | |
//copy the response from the shared memory into the canvas imageData |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//A memory created by JavaScript or in WebAssembly code will be accessible and mutable from both JavaScript and WebAssembly. | |
const memory = new WebAssembly.Memory({ initial:initial * 2 }); | |
//Instantiating Wasm module | |
const importObject = { env: { memory, abort: () => console.log("Abort!") }}; | |
const {instance} = await WebAssembly.instantiateStreaming( | |
fetch("./build/untouched.wasm"), | |
importObject |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference path="../node_modules/assemblyscript/dist/assemblyscript.d.ts" /> | |
export function invert(byteSize: i32): i32 { | |
for (var i = 0; i < byteSize; i += 4) { | |
let pos = i + byteSize; | |
store<u8>(pos, 255 - load<u8>(i)); | |
store<u8>(pos + 1, 255 - load<u8>(i + 1)); | |
store<u8>(pos + 2, 255 - load<u8>(i + 2)); | |
store<u8>(pos + 3, 255); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function invert(data) { | |
for (var i = 0; i < data.length; i += 4) { | |
data[i] = 255 - data[i]; | |
data[i + 1] = 255 - data[i + 1]; | |
data[i + 2] = 255 - data[i + 2]; | |
} | |
}; | |
function grayscale(data){ | |
for (var i = 0; i < data.length; i += 4) { |