Skip to content

Instantly share code, notes, and snippets.

View JustinJohnWilliams's full-sized avatar
:octocat:

Justin Williams JustinJohnWilliams

:octocat:
  • Concord
  • Dallas
View GitHub Profile
@JustinJohnWilliams
JustinJohnWilliams / FizzBuz.cs
Last active April 20, 2018 20:31
FizzBuzz with Linq and Lambdas
var rules = new Dictionary<Func<int, bool>, Func<int, string>>();
rules.Add(x => x % 3 == 0, x => "Fizz");
rules.Add(x => x % 5 == 0, x => "Buzz");
rules.Add(x => x % 15 != 0, x => x.ToString());
rules.Add(x => true, x => "\n");
var results = (from n in Enumerable.Range(1, 100)
from r in rules
where r.Key(n)
public class MVC
{
public static ActionResult Post(RequestContext context, string url, object thing)
{
var controllerAndAction = url.Split('/');
var controller = CreateController(context, controllerAndAction[0]);
var controllerContext = new ControllerContext(context, controller);
var controllerDescriptor = new ReflectedControllerDescriptor(controller.GetType());
<h2>Clients</h2>
<section>
<div id="alertClientCreated" class="alert alert-info" style="display: none;">
Appointment Time:
<input type="text" id="dateWidget" /><br />
<label id="dateWidgetValue" class="text-info"></label>
<button type="button" class="btn-info">Create Appointment!</button>
</div>
<a href="javascript:;" id="newClient">New Client</a>
//here is a "familiar" test writen in NUnit. given that most developers
//are used to writing tests like this,
//you can see how different MSpec is
[TestFixture]
public class When_creating_a_new_account
{
Account account = new Account();
[Test]
public void Does_not_have_any_subscriptions()
@JustinJohnWilliams
JustinJohnWilliams / gist:9621090
Created March 18, 2014 14:24
integration test cleanup
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using UndeadEarth.Contract;
using UndeadEarth.Test.Dal.Utility;
using Moq;
using UndeadEarth.Dal;
.getignore
# User-specific files
*.suo
*.user
# Build results
[Dd]ebug/
[Rr]elease/
x64/
{
{ new Func<int, bool>(x => x % 3 == 0), new Func<int, string>(x => "Fizz") },
{ new Func<int, bool>(x => x % 5 == 0), new Func<int, string>(x => "Buzz") },
{ new Func<int, bool>(x => x % 3 != 0 && x % 5 != 0), new Func<int, string>(x => x.ToString()) },
{ new Func<int, bool>( x => true), new Func<int, string>(x => "\n" ) }
};
var output = from n in Enumerable.Range(1, 100)
from f in rules
where f.Key(n)
public static class Verify
{
public static void NotEmpty(string value, string parameterName)
{
if (value == string.Empty)
{
throw new ArgumentEmptyException(parameterName);
}
}
@JustinJohnWilliams
JustinJohnWilliams / vimbindingfun.txt
Created August 22, 2016 15:59
how to learn vim bindings
Start by pressing <esc>, that will put you in "command" mode. Now press "j".
See what happend? You're on this line now. "j" means down. Now press "5j".
if you see DASHED lines press "zR", otherwise ignore
if you see DASHED lines press "zR", otherwise ignore
What you did just there is "move down 5". Press "j"
If you mess your cursor position during this tutorial press "gg" to take you back to the top, try that now, next time press "j"
Time to follow the ascii road. press "j", then press the key that's highlighted by the blinking cursor
j <---- press "j" because j is curently under your cursor
module database
open FSharp.Data.Sql
open FSharp.Data.Sql.Common
let [<Literal>] connectionString = "Data Source=.;Initial Catalog=CreditFulfillment;Integrated Security=SSPI;"
type sql = SqlDataProvider<DatabaseProviderTypes.MSSQLSERVER,
connectionString,
CaseSensitivityChange = CaseSensitivityChange.ORIGINAL>