Skip to content

Instantly share code, notes, and snippets.

View timReynolds's full-sized avatar

Tim Reynolds timReynolds

View GitHub Profile
@timReynolds
timReynolds / VerifyContainer.cs
Created April 21, 2016 10:02
Verify SimpleInjector NUnit test
using System.Web.Http;
using NUnit.Framework;
using PF.Presentation.Api.Extensions.ContainerExtensions;
using SimpleInjector;
namespace PF.Presentation.Api.UnitTests.Extensions
{
[TestFixture]
public class VerifyContainer
{
var consoleLine = "<p class=\"console-line\"></p>";
console = {
log: function (text) {
$("#console-log").append($(consoleLine).html(text));
}
};
// New function called compose
// works from right to left
@timReynolds
timReynolds / build.fsx
Created December 10, 2015 16:25
FAKE Build Process to create NuGet Packages
// include Fake lib
#r @"packages/FAKE/tools/FakeLib.dll"
#r @"System.Xml.Linq"
open Fake
open System
open System.IO
open System.Xml.Linq
open Fake.DotCover
open Fake.NuGet
@timReynolds
timReynolds / Startup.cs
Created December 4, 2015 11:27
SimpleInjector ASP.NET vNext Setup
public class Startup
{
private Container container = new SimpleInjector.Container();
public Startup(IHostingEnvironment env) {
// ASP.NET default stuff here
}
// This method gets called by the runtime.
public void ConfigureServices(IServiceCollection services) {
// ASP.NET default stuff here
@timReynolds
timReynolds / index.js
Created November 18, 2015 23:01
Code dojo pairing names
const people = ["TT", "ME", "FE", "TR", "JE", "DE", "AD"];
Array.prototype.group = group;
function group(size = 2, sizingFunc) {
const tmp = this.slice();
const output = [];
while(tmp.length) {
const groupSize = sizingFunc(tmp.length, size);
@timReynolds
timReynolds / example
Last active August 29, 2015 14:06
Laravel Message Bag to vinaskrucas/notification method
protected function errorsToNotification(Illuminate\Support\MessageBag $errors)
{
if($errors && $errors->has()){
Notification::container(null, function($container) use ($errors)
{
foreach ($errors->all() as $error)
{
$container->error($error);
}
});
@timReynolds
timReynolds / gist:5526268
Created May 6, 2013 16:35
Mocha Makefile
REPORTER = dot
test:
@NODE_ENV=test ./node_modules/.bin/mocha \
--reporter $(REPORTER) \
test-w:
@NODE_ENV=test ./node_modules/.bin/mocha \
--reporter $(REPORTER) \
--growl \
@timReynolds
timReynolds / increment-string.js
Last active December 10, 2015 21:48
JavaScript Increment string function based on @dandoescode php inc function for Scrapyrd. Original inc function can be found here https://github.com/dandoescode/scrapyrd/blob/master/fuel/app/classes/scrapyrd.php
function setCharAt(str,index,chr) {
if(index > str.length-1) return str;
return str.substr(0,index) + chr + str.substr(index+1);
}
function incString(n, pos) {
if(!pos) {pos = 0};