Skip to content

Instantly share code, notes, and snippets.

View PureKrome's full-sized avatar
💭
🦘🕺🏻🎶🕹

Justin Adler PureKrome

💭
🦘🕺🏻🎶🕹
View GitHub Profile
@PureKrome
PureKrome / gist:55698e875e6c9028a09096c04691186f
Created March 1, 2017 08:31
Calling google api's in unit tests by providing fake responses
/*
This is a quick example of how to fake out the response for calling a Google API endpoint.
I'm using the QPX Express api as an example, but I'm _assuming_ this could apply accross the board
for other Google API's.
The reason you would want to do this, is so you don't need to hit the internet to get your results
(think, coding on a plane, no internet coverage, no hurting your API allowance, etc).
The main trick here is that we need to do two things:
1. Create a fake HttpMessageHandler
@PureKrome
PureKrome / gist:00e7f2be557e94911fb6b23119639e3e
Last active May 10, 2016 12:58
RavenDb repo with breaking code.
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Raven.Client;
using Raven.Client.Linq;
using Raven.Tests.Helpers;
using Xunit;
namespace ClassLibrary1
{
@PureKrome
PureKrome / ToyRobot.md
Last active March 10, 2016 05:15
Toy Robot Simulator Instructions

Toy Robot Simulator Instructions

Description:

  • The application is a simulation of a toy robot moving on a square tabletop, of dimensions 5 units x 5 units.
  • There are no other obstructions on the table surface.
  • The robot is free to roam around the surface of the table, but must be prevented from falling to destruction. Any movement that would result in the robot falling from the table must be prevented, however further valid movement
@PureKrome
PureKrome / gist:8aa486b0440d4147ccc3
Created February 15, 2016 04:10
Async awaity stuff with Azure queues - props to Ben Adams for the answer
private ConcurrentQueue<Message> _queue = new ConcurrentQueue<Message>();
private SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
public async Task DoTheThing()
{
var tasks = new Task[20];
for (var i = 0; i < tasks.Length; i++)
{
tasks[i] = UploadMessages();
}
@PureKrome
PureKrome / appveyor-build-info.ps
Last active August 6, 2016 13:46
AppVeyor build information
$isPr = "No";
if ($env:APPVEYOR_PULL_REQUEST_NUMBER)
{
$isPr = "Yes = PR #: $env:APPVEYOR_PULL_REQUEST_NUMBER"
}
$isTag = "No";
if ($env:APPVEYOR_REPO_TAG -eq $TRUE)
{
$isTag = "Yes = Tag: $env:APPVEYOR_REPO_TAG_NAME"
@PureKrome
PureKrome / gist:be8967ebc2bc43ac8154
Last active August 29, 2015 14:23
Load testing Redis servers via IIS
using System;
using System.Configuration;
using System.Text;
using System.Threading;
using System.Web.Mvc;
using StackExchange.Redis;
namespace WebApplication2.Controllers
{
public class HomeController : Controller
@PureKrome
PureKrome / gist:61f54b3061fccdfd4c61
Created May 5, 2015 11:43
Class is persisted without the $type property
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Raven.Client.Document;
namespace ConsoleApplication5
{
class Program
@PureKrome
PureKrome / gist:df7b5bdd6582cd99a98a
Created May 5, 2015 11:40
Class is persisted with a $type property.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Raven.Client.Document;
namespace ConsoleApplication5
{
class Program
@PureKrome
PureKrome / gist:d5c5797850f522e15a65
Created March 30, 2015 11:50
How to test abstract classes with FluentValidation?
// How can I create a CatValidator and EagleValidator that both use (inherit) an AnimalValidator?
public abstract class Animal
{
public string Name { get; set; }
}
public class Cat : Animal
{
@PureKrome
PureKrome / error.cs
Created March 13, 2015 10:26
Inconsistent Nancy testing when deserializing some json response.
using System.Collections.Generic;
using System.Linq;
using Nancy;
using Nancy.Testing;
using Newtonsoft.Json;
using Shouldly;
using Xunit;
namespace ConsoleApplication4
{