Skip to content

Instantly share code, notes, and snippets.

View timReynolds's full-sized avatar

Tim Reynolds timReynolds

View GitHub Profile
@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};
@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 / 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 / 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 / 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 / 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
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 / 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
{
@timReynolds
timReynolds / Constants
Last active October 20, 2016 10:01
NServiceBus Notification FailedMessageResponder
public const string FailedMessageResponderNotResponding = "No failed message response defined for {0}";
public const string FailedMessageResponderResponding = "Creating {0} for failed message {1}";
@timReynolds
timReynolds / example.js
Created June 17, 2017 12:04
Segment.com with next.js
<Head>
<script dangerouslySetInnerHTML={{ __html: `
var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t){var e=document.createElement("script");e.type="text/javascript";e.async=!0;e.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};analytics.SNIPPET_VERSION="4.0.0";