Skip to content

Instantly share code, notes, and snippets.

View MikeMKH's full-sized avatar
:shipit:
Learning about proof theory with Coq

Mike Harris MikeMKH

:shipit:
Learning about proof theory with Coq
  • Milwaukee, WI
  • 23:00 (UTC -05:00)
View GitHub Profile
@MikeMKH
MikeMKH / setup.cs
Last active March 25, 2024 08:33
How to live with a circular reference with AutoFixture
[TestInitialize]
public void BeforeEach()
{
_fixture = new Fixture();
// client has a circular reference from AutoFixture point of view
_fixture.Behaviors.Remove(new ThrowingRecursionBehavior());
_fixture.Behaviors.Add(new OmitOnRecursionBehavior());
}
@MikeMKH
MikeMKH / Demo.cs
Created September 14, 2015 18:11
Example of using Moq with Auto Fixture
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Ploeh.AutoFixture;
using Ploeh.AutoFixture.AutoMoq;
namespace AutoFixtureDemo.MSTest
{
public class Echoer
{
@MikeMKH
MikeMKH / zip.clj
Created April 4, 2015 22:19
Zip example in C#, Clojure, and T-SQL (using an inner join).
(map
#(str %1 ", " %2)
["Hello" "Hi" "Aloha"]
["Mike" "Kelsey" "Jack"])
;; ("Hello, Mike" "Hi, Kelsey" "Aloha, Jack")
@MikeMKH
MikeMKH / Demo.cs
Created September 14, 2015 18:06
Examples from AutoFixture Cheat Sheet with xUnit
using System;
using System.Collections.Generic;
using System.Linq;
using Ploeh.AutoFixture;
using Ploeh.AutoFixture.Xunit2;
using Xunit;
namespace AutoFixtureDemo
{
public class Demo
@MikeMKH
MikeMKH / find_data_changes.sql
Created May 30, 2018 19:14
SQL example of using lag to find the date that a column changes in a time series data
select * from (
select
key_col
,date_col
,data_col
,prev_data_col = lag(data_col, 1) over (partition by key_col order by date_col)
from tbl
) as z
where prev_data_col is not NULL
and data_col <> prev_data_col
@MikeMKH
MikeMKH / Rot13.cs
Created December 6, 2017 13:58
Rot 13 kata in C# with xUnit in one line.
using System;
using System.Linq;
namespace Cipher
{
public class Rot13
{
public static string Encode(string text)
=> new string(
text.ToCharArray()
@MikeMKH
MikeMKH / find_recent_database_changes.sql
Created April 7, 2018 14:24
SQL Server TSQL to find recent database changes
-- https://stackoverflow.com/a/23702332/2370606
select *
from sys.objects
where modify_date > dateadd(d, -1, getdate())
@MikeMKH
MikeMKH / find_data_changes.sql
Created April 5, 2018 20:40
SQL example of using row_number to find the changes on an column in time series data
select
key_col
,startdate
,enddate
,change_col
from (
select distinct
key_col
,startdate = min(date_col) over (partition by group_key, key_col)
,enddate = max(date_col) over (partition by group_key, key_col)
@MikeMKH
MikeMKH / commute.v
Created May 18, 2017 22:09
Proof that subtraction is not commutative using Coq.
Require Import Coq.Arith.Arith.
Require Import Omega.
(* from http://stackoverflow.com/a/44039996/2370606 *)
Lemma subtraction_does_not_commute :
forall a b : nat, a <> b -> a - b <> b - a.
Proof.
induction a. intros b.
- now rewrite Nat.sub_0_r.
- destruct b.
@MikeMKH
MikeMKH / package.json
Last active October 11, 2017 11:30
Example using switchMap
{
"name": "extra",
"version": "1.0.0",
"description": "",
"main": "test.js",
"scripts": {
"test": "mocha"
},
"author": "Mike Harris",
"license": "ISC",