Skip to content

Instantly share code, notes, and snippets.

View dburriss's full-sized avatar

Devon Burriss dburriss

View GitHub Profile
@dburriss
dburriss / FactResharper
Created June 28, 2017 05:40
An XUnit fact snippet for Resharper.
[Fact]
public void $Unit$_$Scenario$_$Expected$()
{
$END$
}
@dburriss
dburriss / proc.fsx
Last active November 2, 2022 12:19
Finding and running a process in F# in a reliable way.
// ========================================================
// String: String module
// Helpers for working with strings
// ========================================================
module String =
let isNotEmpty s = not (String.IsNullOrEmpty s)
let join (ss: string seq) = String.Join("", ss)
let lower (s: string) = s.ToLowerInvariant()
let trim (s: string) = s.Trim()
@dburriss
dburriss / String.fsx
Created November 2, 2022 12:04
Collection of F# string functions
let isNotEmpty s = not (String.IsNullOrEmpty s)
let join (ss: string seq) = String.Join("", ss)
let lower (s: string) = s.ToLowerInvariant()
let trim (s: string) = s.Trim()
let replace (oldValue: string) newValue (s: string) = s.Replace(oldValue,newValue)
let split (by: string) (s: string) = s.Split(by)
let endsWith (tail: string) (s: string) = s.EndsWith(tail)
let startsWith (head: string) (s: string) = s.StartsWith(head)
let contains (search: string) (s: string) = s.Contains(search)
@dburriss
dburriss / Install-Paket.ps1
Last active April 4, 2022 19:31
A Powershell script to install Paket dependency manager in current folder (sub-folder .paket)
New-Item -ItemType directory -Path ".paket"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$tag = (Invoke-WebRequest -Uri https://api.github.com/repos/fsprojects/Paket/releases | ConvertFrom-Json)[0].tag_name
$uri = " https://github.com/fsprojects/Paket/releases/download/" + $tag + "/paket.bootstrapper.exe"
Invoke-WebRequest $uri -OutFile .paket/paket.exe
@dburriss
dburriss / java_class_loc.java
Last active March 1, 2022 17:00
Files with examples of grammar generated in rust-code-analysis project using tree-sitter along with logical lines of code counts
// Program
public class Person {
// ClassDeclaration
// Modifiers
// Public
// Class
// Identifier
// ClassBody
// LBRACE
private String name;
@dburriss
dburriss / NoNullString.cs
Last active November 6, 2021 09:26
Code required to create a model binder that sets or empty or no strings to empty string during binding
//In Startup.cs file
services.AddMvc(config =>
config.ModelBinderProviders.Insert(0, new NoNullStringModelBinderProvider())
);
//model binder provider
public class NoNullStringModelBinderProvider : IModelBinderProvider
{
public IModelBinder GetBinder(ModelBinderProviderContext context)
{
@dburriss
dburriss / list-check.sh
Created November 1, 2021 20:55
Can be used to check markdown files in a repository for valid links and will check the description if it looks like it represents a filepath.
#!/bin/bash
#
# This script checks the markdown links in all markdown files.
# param 1: [optioal] [flag] -v or -vv to enable debugging or tracing
# param 2: [optional] path to a specific file to check. If not present, will search for *.md
# It will match all [desc](https?...) patterns in markdown files.
# 'desc' can be a directory or file and it will check it exists.
# exist code 1 if and files or links not found.
# Examples:
@dburriss
dburriss / Git.fsx
Last active October 17, 2020 08:32
Some files for a proof of concept that makes recommendations based on code and the git history. The original uses code complexity but has a dependency on a SonarQube report. This is completely standalone but uses LoC as a proxy. Not the best but it is a PoC. It also takes things like bus factor into account in the recommendations. See comments f…
#load "StringX.fsx"
#load "Result.fsx"
open System
open System.Diagnostics
type Commit = | Commit of string
type Author = | Author of string
type Lines = string list
(* QUEUES
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.queue-1
*)
// 1.0 Basic queue - hand-rolled
let q = System.Collections.Generic.Queue<string>()
q.Enqueue "Hello"
@dburriss
dburriss / maintainable-unit-tests-1.cs
Created July 17, 2020 11:23
Blog | Maintainable unit tests | Snippet 1
// tests
// test for invalid name omitted...
[Fact]
public void CreatingPerson_WithValidPerson_CallsIsValid()
{
var name = "Bob";
var people = Substitute.For<IPersonRepository>();
var validator = Substitute.For<IPersonValidator>();
var createPerson = new CreatePerson(people, validator);