Skip to content

Instantly share code, notes, and snippets.

View LeslieRG's full-sized avatar
🎯
Focusing

Leslie Ramirez LeslieRG

🎯
Focusing
View GitHub Profile
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:64645",
"sslPort": 44366
}
},
"profiles": {
public class UnicornTest
{
private int topUnicorn=0;
List <int> elements = new List<int>();
public int Size()
{
return  topUnicorn;
}
public void Push(int element)
@LeslieRG
LeslieRG / TestMethod.cs
Created December 17, 2019 22:57
Methods differents Parameters
BeFabulous(name, age)
BeFabulous(name)
@LeslieRG
LeslieRG / cleanCode.cs
Created December 17, 2019 22:53
Methods Example
//comprobar que es un unicornio con derecho a todos los accesos
If((unircon.flags == true )&&(unicorn.age<100))
If(unicorn.IsElegibleForBenefits())
private async Task DispatchToTopIntentAsync(ITurnContext<IMessageActivity> turnContext, string intent, RecognizerResult recognizerResult, CancellationToken cancellationToken)
{
switch (intent)
{
case "l_HomeAutomation":
await ProcessHomeAutomationAsync(turnContext, recognizerResult.Properties["luisResult"] as LuisResult, cancellationToken);
break;
case "l_Weather":
await ProcessWeatherAsync(turnContext, recognizerResult.Properties["luisResult"] as LuisResult, cancellationToken);
break;
protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
// First, we use the dispatch model to determine which cognitive service (LUIS or QnA) to use.
var recognizerResult = await _botServices.Dispatch.RecognizeAsync(turnContext, cancellationToken);
// Top intent tell us which cognitive service to use.
var topIntent = recognizerResult.GetTopScoringIntent();
// Next, we call the dispatcher with the top intent.
await DispatchToTopIntentAsync(turnContext, topIntent.intent, recognizerResult, cancellationToken);
@LeslieRG
LeslieRG / BotService.cs
Created October 10, 2019 16:31
La información contenida con el archivo de configuración de appsettings.json es usada para conectar tu bot. Entre los servicios Dispatch SampleQnA. Los constructores usan estos valores para realizar la conexion.
public BotServices(IConfiguration configuration)
{
// Read the setting for cognitive services (LUIS, QnA) from the appsettings.json
Dispatch = new LuisRecognizer(new LuisApplication(
configuration["LuisAppId"],
configuration["LuisAPIKey"],
$"https://{configuration["LuisAPIHostName"]}.api.cognitive.microsoft.com"),
new LuisPredictionOptions { IncludeAllIntents = true, IncludeInstanceData = true },
true);
"MicrosoftAppId": "",
"MicrosoftAppPassword": "",
"QnAKnowledgebaseId": "<knowledge-base-id>",
"QnAEndpointKey": "<qna-maker-resource-key>",
"QnAEndpointHostName": "<your-hostname>",
"LuisAppId": "<app-id-for-dispatch-app>",
"LuisAPIKey": "<your-luis-endpoint-key>",
"LuisAPIHostName": "<your-dispatch-app-region>",
@LeslieRG
LeslieRG / DispatchCommands.rb
Created October 10, 2019 16:02
DispatchCommands
#Abre la linea de comando en la carpeta destino
npm i -g npm
npm i -g botdispatch
#usa dispatch init para inicializar, para crear usa el archivo (.dispact) para tu modelo dispatch.
dispatch init -n <filename-to-create> --luisAuthoringKey "<your-luis-authoring-key>" --luisAuthoringRegion <your-region>
#Usa *dispactch add* para agregar tus aplicaciones LUIS y QNA maker basado en el archivo .dispatch
dispatch add -t luis -i "<app-id-for-weather-app>" -n "<name-of-weather-app>" -v <app-version-number> -k "<your-luis-authoring-key>" --intentName l_Weather
dispatch add -t luis -i "<app-id-for-home-automation-app>" -n "<name-of-home-automation-app>" -v <app-version-number> -k "<your-luis-authoring-key>" --intentName l_HomeAutomation
@LeslieRG
LeslieRG / UnmanagedWrappper.cs
Created May 10, 2019 15:29
Implementing IDsposable and finalizer
using System;
using System.IO;
class UnmanagedWrappper : IDisposable
{
public FileStream Stream {get; private set;}
public UnmanagedWrappper()
{
this.Stream = File.Open("temp.dat", FileMode.Create);