Skip to content

Instantly share code, notes, and snippets.

View darrencauthon's full-sized avatar

Darren Cauthon darrencauthon

View GitHub Profile
@darrencauthon
darrencauthon / Testing.feature
Created October 11, 2011 03:44
Loose Guid support in SpecFlow?
Feature: Loose Guids
Scenario: Sample loose guid
Given the account repository has the following accounts
| Id | LastName |
| 1 | Galt |
| 2 | Roark |
When I press the delete account '1' button
Then I should have the following accounts
| Id | LastName |
@darrencauthon
darrencauthon / DropDownList.ascx
Created January 11, 2012 13:02
Dropdowns in ASP.Net MVC (with MVC Turbine)
<% Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="System.Linq" %>
<%
var items = ViewData.ModelMetadata.AdditionalValues["SelectList"] as IList<SelectListItem>;
<select id="<%=ViewData.ModelMetadata.PropertyName %>" name="<%=ViewData.ModelMetadata.PropertyName %>" <%=(ViewData.ModelState.ContainsKey(ViewData.ModelMetadata.PropertyName) && ViewData.ModelState[ViewData.ModelMetadata.PropertyName].Errors.Any()) ? "class=\"input-validation-error\"" : string.Empty %>>
<%foreach (var item in items)
{%>
<option value="<%=HttpUtility.HtmlEncode(item.Value)%>" <%=item.Value == ViewData.Model.ToNullSafeString() ? " selected" : ""%>>
<%=Html.Encode(item.Text)%></option>
@darrencauthon
darrencauthon / test.js
Created February 4, 2018 20:21
Demoable agent that uses DataSet
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.vis=e():t.vis=e()}(this,function(){return function(t){function e(o){if(i[o])return i[o].exports;var n=i[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,e),n.l=!0,n.exports}var i={};return e.m=t,e.c=i,e.d=function(t,i,o){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=123)}([function(t,e,i){e.__esModule=!0,e.default=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e,i){e.__esModule=!0;var o=i(169),n=function(t){return t&&t.__esModule?t:{default:t}}(o);e.default=function(){function t(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.c
##########################################
# To run:
# curl -sSL https://gist.githubusercontent.com/sirkkalap/e87cd580a47b180a7d32/raw/d9c9ebae4f5cf64eed4676e8aedac265b5a51bfa/Install-Docker-on-Linux-Mint.sh | bash -x
##########################################
# Check that HTTPS transport is available to APT
if [ ! -e /usr/lib/apt/methods/https ]; then
sudo apt-get update
sudo apt-get install -y apt-transport-https
fi
@darrencauthon
darrencauthon / example.cs
Created August 3, 2016 11:14
Testing each usage of ?.
void Main()
{
It_should_return_the_name_from_the_person_on_the_invoice_on_the_order();
It_should_return_nothing_if_the_person_is_not_set();
It_should_return_nothing_if_the_invoice_is_not_set();
It_should_return_nothing_if_given_nothing();
}
public static string GetNameFrom(Order order)
{
@darrencauthon
darrencauthon / AModel.cs
Last active June 3, 2016 04:56 — forked from srakowski/AModel.cs
Example of Dynamic Proxy ViewModel in C#?
using System;
namespace VMSandbox
{
class AModel
{
public DateTime Date { get; set; } = DateTime.UtcNow;
public int MyLifeForTheCodeDownloads { get; set; } = Int32.MaxValue;
}
@darrencauthon
darrencauthon / sample_code.txt
Created March 13, 2016 17:48
Loading a gem via IRB
# https://github.com/banzsolt/wargaming_api/
wargaming_api git:(master) bundle exec irb
2.0.0-p647 :001 > WargamingApi::Accounts
NameError: uninitialized constant WargamingApi::Accounts
from (irb):1
from /Users/darrencauthon/.rvm/rubies/ruby-2.0.0-p647/bin/irb:12:in `<main>'
2.0.0-p647 :002 > require_relative 'lib/wargaming_api'
accounts -> Players loaded.
@darrencauthon
darrencauthon / testing.cs
Last active February 11, 2016 19:12
Testing samples, strict or loose
using System;
using AutoMoq.Helpers;
using Moq;
using NUnit.Framework;
namespace JamesDemo
{
public class Presenter
{
private readonly IRepository repository;
@darrencauthon
darrencauthon / view_model.rb
Created February 4, 2016 20:07
Simple view model in Ruby
class ViewModel
def initialize subject
@subject = subject
end
def method_missing meth, _, _
@subject.send meth
end
end
@darrencauthon
darrencauthon / branch_trimmer.rb
Last active January 2, 2016 14:39
Remove all merged branches (through IRB)
`git branch --merged`
.split("\n")
.map { |x| x.gsub('*', '')
.strip }.select { |x| x != 'master' }
.each do |b|
`git branch -d #{b}`
end
`git branch --merged`.split("\n").map { |x| x.gsub('*', '').strip }.select { |x| x != 'master' }.each { |b| `git branch -d #{b}` }