Skip to content

Instantly share code, notes, and snippets.

@joncloud
joncloud / Controller.cs
Last active September 8, 2016 17:21
Range query parameter
[Route("api/[controller]")]
public class ValuesController : Controller
{
// GET api/values
[HttpGet]
public IActionResult Get([FromQuery]Criteria criteria)
{
if (criteria == null)
{
return NotFound();

Minion's bored game

There you have it. Yet another pointless "bored" game created by the bored minions of Professor Boolean.

The game is a single player game, played on a board with n squares in a horizontal row. The minion places a token on the left-most square and rolls a special three-sided die.

If the die rolls a "Left", the minion moves the token to a square one space to the left of where it is currently. If there is no square to the left, the game is invalid, and you start again.

If the die rolls a "Stay", the token stays where it is.

@joncloud
joncloud / DataModel.cs
Last active October 13, 2016 19:19
EF Core Joining
public class TestDbContext : DbContext
{
public DbSet<Child> Children { get; set; }
public DbSet<Parent> Parents { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
optionsBuilder.UseSqlServer("Data Source=.;Initial Catalog=ConsoleApp12;Integrated Security=true;");
@joncloud
joncloud / 01-ValidCall
Last active November 2, 2016 15:25
Model State Validation
C:\Users\jberube>http get localhost:53043/api/MyModels/10
HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Length: 12
Content-Type: application/json; charset=utf-8
Date: Tue, 01 Nov 2016 20:50:32 GMT
Expires: -1
Pragma: no-cache
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
@joncloud
joncloud / 01-Valid.sh
Created November 1, 2016 23:06
ASMX Validation Testing
C:\Users\jberube>http -f POST webapplication1720161101035312.azurewebsites.net/WebService1.asmx/HelloWorld value=3
HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Encoding: gzip
Content-Length: 207
Content-Type: text/xml; charset=utf-8
Date: Tue, 01 Nov 2016 23:05:14 GMT
Server: Microsoft-IIS/8.0
Set-Cookie: ARRAffinity=285bc567c6481ca66c5f08029c563f66111719cb927bc7752fb1492dc8679956;Path=/;Domain=webapplication1720161101035312.azurewebsites.net
Vary: Accept-Encoding
BenchmarkDotNet=v0.10.0
OS=Microsoft Windows NT 6.2.9200.0
Processor=Intel(R) Xeon(R) CPU E5-2673 v3 2.40GHzIntel(R) Xeon(R) CPU E5-2673 v3 2.40GHz, ProcessorCount=16
Frequency=10000000 Hz, Resolution=100.0000 ns, Timer=UNKNOWN
Host Runtime=Clr 4.0.30319.42000, Arch=32-bit RELEASE
GC=Concurrent Workstation
JitModules=clrjit-v4.6.1073.0
Job Runtime(s):
 Clr 4.0.30319.42000, Arch=32-bit RELEASE
@joncloud
joncloud / 01-Results.md
Last active December 9, 2016 15:32
Dictionary/SortedList Memory
BenchmarkDotNet=v0.10.0
OS=Microsoft Windows NT 6.2.9200.0
Processor=Intel(R) Xeon(R) CPU E5-2673 v3 2.40GHzIntel(R) Xeon(R) CPU E5-2673 v3 2.40GHz, ProcessorCount=16
Frequency=10000000 Hz, Resolution=100.0000 ns, Timer=UNKNOWN
Host Runtime=Clr 4.0.30319.42000, Arch=32-bit RELEASE
GC=Concurrent Workstation
JitModules=clrjit-v4.6.1073.0
Job Runtime(s):
 Clr 4.0.30319.42000, Arch=32-bit RELEASE
@joncloud
joncloud / perf.js
Last active December 6, 2016 15:01
(function (total) {
times = []
function time(name, fn) {
var t0 = performance.now();
fn();
var t1 = performance.now();
times.push(name + " took " + (t1 - t0));
}
@joncloud
joncloud / 01-Summary.md
Last active December 9, 2016 15:31
JWT Perf
BenchmarkDotNet=v0.10.1, OS=Windows
Processor=?, ProcessorCount=8
Frequency=2435775 Hz, Resolution=410.5470 ns, Timer=TSC
dotnet cli version=1.0.0-preview2-003131
  [Host]     : .NET Core 4.6.24628.01, 64bit RyuJIT
  DefaultJob : .NET Core 4.6.24628.01, 64bit RyuJIT

Method | Mean | StdErr | StdDev | Gen 0 | Allocated |

@joncloud
joncloud / Constructor.cs
Created January 5, 2017 16:53
ASP.NET Core Services
[Route("api/applications")]
public class ApplicationsController : Controller
{
private IApplicationService applicationService;
public ApplicationsController(IApplicationService applicationService)
{
this.applicationService = applicationService;
}
[HttpGet("{key}")]
public async Task<IActionResult> Get(string key)