Skip to content

Instantly share code, notes, and snippets.

View kerslake's full-sized avatar

Richard Kerslake kerslake

View GitHub Profile
public class AuthenticationService
{
private static readonly List<User> Users = new List<User>
{
new User { Id = 1, Pin = "123", Name = "Pascal" },
new User { Id = 2, Pin = "234", Name = "Mike" },
new User { Id = 3, Pin = "345", Name = "Howard" },
};
public static bool Authenticate(string pin)
public class AuthenticateController : TwilioApiController
{
public HttpResponseMessage Post(VoiceRequest request)
{
var pin = request.Digits;
var authenticated = AuthenticationService.Authenticate(pin);
if (!authenticated)
{
public abstract class TwilioApiController : ApiController
{
protected HttpResponseMessage TwiMLResponse(TwilioResponse response)
{
return this.Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter());
}
}
public class WelcomeController : TwilioApiController
{
public HttpResponseMessage Post(VoiceRequest request)
{
var response = new TwilioResponse();
response.Say("Welcome to this Twilio demo app. Please enter your 3 digit pin code.");
response.Gather(new { numDigits = 3, action = string.Format("/api/Authenticate") });
return this.TwiMLResponse(response);
}
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
4197 559 1103124 1238548 2052 426.22 8156 devenv
VERBOSE: Command [Get-Process] succeeded.
VERBOSE: Command [Get-Process] failed. Retrying in 2 seconds.
VERBOSE: Command [Get-Process] failed. Retrying in 2 seconds.
VERBOSE: Command [Get-Process] failed. Retrying in 2 seconds.
VERBOSE: Command [Get-Process] failed. Retrying in 2 seconds.
VERBOSE: Command [Get-Process] failed. Retrying in 2 seconds.
VERBOSE: Command [Get-Process] failed the maximum number of 5 times.
Cannot find a process with the process identifier 8156999.
At C:\Retry-Command-usage.ps1:line:19 char:13
+ & <<<< $command @args
Retry-Command -Command 'Get-Process' -Args @{ Id = "8156" } -Verbose
function Retry-Command
{
param (
[Parameter(Mandatory=$true)][string]$command,
[Parameter(Mandatory=$true)][hashtable]$args,
[Parameter(Mandatory=$false)][int]$retries = 5,
[Parameter(Mandatory=$false)][int]$secondsDelay = 2
)
# Setting ErrorAction to Stop is important. This ensures any errors that occur in the command are
var streamOverTime = Observable.Interval(TimeSpan.FromSeconds(1));
var squaredStreamOverTime = streamOverTime.Select(value => Math.Pow(value, 2));
squaredStreamOverTime.Subscribe(Console.WriteLine);
logman.exe create trace my-trace-session -p Company-EventLog
logman.exe start my-trace-session
logman.exe stop my-trace-session
logman.exe delete my-trace-session