This file contains 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
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) |
This file contains 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
public class AuthenticateController : TwilioApiController | |
{ | |
public HttpResponseMessage Post(VoiceRequest request) | |
{ | |
var pin = request.Digits; | |
var authenticated = AuthenticationService.Authenticate(pin); | |
if (!authenticated) | |
{ |
This file contains 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
public abstract class TwilioApiController : ApiController | |
{ | |
protected HttpResponseMessage TwiMLResponse(TwilioResponse response) | |
{ | |
return this.Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter()); | |
} | |
} |
This file contains 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
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); | |
} |
This file contains 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
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. | |
This file contains 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
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 |
This file contains 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
Retry-Command -Command 'Get-Process' -Args @{ Id = "8156" } -Verbose |
This file contains 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 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 |
This file contains 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
var streamOverTime = Observable.Interval(TimeSpan.FromSeconds(1)); | |
var squaredStreamOverTime = streamOverTime.Select(value => Math.Pow(value, 2)); | |
squaredStreamOverTime.Subscribe(Console.WriteLine); |
This file contains 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
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 |