Skip to content

Instantly share code, notes, and snippets.

View gonzaloruizdevilla's full-sized avatar

Gonzalo Ruiz de Villa gonzaloruizdevilla

  • GFT
  • Madrid, Spain
View GitHub Profile
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
import numpy as np
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.”);
[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);
}
[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;
}
}
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
);
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();
//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
//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
/// <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);
}
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) {