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
  • 06:13 (UTC -05:00)
View GitHub Profile
@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 / 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 / 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 / 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",
@MikeMKH
MikeMKH / Greed.cs
Created September 19, 2017 11:43
Greed kata in C# using the specification pattern along with the factory pattern
using System;
using System.Collections.Generic;
using System.Linq;
namespace library
{
public class Greed
{
public static int Calculate(int [] dice)
{
@MikeMKH
MikeMKH / ExampleTests.cs
Last active September 14, 2017 11:18
Code examples for the talk A Divine Data Comedy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static System.ValueTuple;
using Xunit;
namespace dotnet
{
public class ExampleTests
@MikeMKH
MikeMKH / fizzbuzz.R
Created August 1, 2017 11:44
FizzBuzz kata as a tibble from tidyverse
library(tidyverse)
fb <- tibble(
x = 1:100,
fizzable = ifelse(x %% 3 == 0, TRUE, FALSE),
buzzable = ifelse(x %% 5 == 0, TRUE, FALSE),
formatted = ifelse(fizzable & buzzable, "FizzBuzz",
ifelse(fizzable, "Fizz",
ifelse(buzzable, "Buzz",
x)))
@MikeMKH
MikeMKH / fizzbuzz.R
Created June 28, 2017 11:36
Collection of FizzBuzz katas in R
sapply(rep(0:100),
function(x)
if(x %% 15 == 0) "FizzBuzz"
else if(x %% 3 == 0) "Fizz"
else if(x %% 5 == 0) "Buzz"
else x)
# based on https://gist.github.com/jangorecki/ef2b908a6ad46a13a5e4
fizzy <- seq(0, 100, 3)
buzzy <- seq(0, 100, 5)
@MikeMKH
MikeMKH / fizzbuzz.R
Created June 27, 2017 11:39
FizzBuzz kata in R
fizzy <- seq(0, 100, 3)
buzzy <- seq(0, 100, 5)
fizzbuzzy <- fizzy[fizzy %in% buzzy]
fizzbuzz <- 0:100
fizzbuzz[fizzbuzz %in% fizzbuzzy] <- "FizzBuzz"
fizzbuzz[fizzbuzz %in% fizzy] <- "Fizz"
fizzbuzz[fizzbuzz %in% buzzy] <- "Buzz"