Skip to content

Instantly share code, notes, and snippets.

View waf's full-sized avatar

Will Fuqua waf

View GitHub Profile
@waf
waf / Program.cs
Last active February 7, 2017 01:57
Covariance and Contravariance
using System;
using System.Linq;
using System.Collections.Generic;
public class Program
{
public void Main(string[] args)
{
Apple apple = new Apple();
Orange orange = new Orange();
@waf
waf / ArrayDeconstructionExtensions.cs
Created January 1, 2017 01:14
Add deconstruction (i.e. destructuring) syntax support for arrays for C# 7
using System;
using System.Linq;
namespace Extensions
{
/// <summary>
/// Allow the up to the first eight elements of an array to take part in C# 7's destructuring syntax.
/// </summary>
/// <example>
/// (int first, _, int middle, _, int[] rest) = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
@waf
waf / AsyncMonad.cs
Created September 7, 2016 02:44
async/await behavior without the keywords
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Scratch
{
class Program
{
@waf
waf / Program.cs
Created May 17, 2016 02:01
Pattern matching in C#. This is terrible. Don't actually do this.
namespace PatternMatchTest
{
class Program
{
public static void Main()
{
Animal[] TestCases = {
new Dog(),
new Cat { IsDangerous = true },
new Cat { IsDangerous = false }
@waf
waf / .gitconfig
Last active June 1, 2016 02:42
Zenburn PowerShell git configuration
# in your home directory, add the following to the end of the .gitconfig file:
[color]
ui = true
[color "status"]
changed = cyan bold
untracked = yellow bold
added = green bold
branch = cyan bold
unmerged = red bold
@waf
waf / RemoveWin10Apps.ps1
Last active March 16, 2016 03:27
Remove Windows 10 apps
# get removable packages using: Get-AppxPackage | Select Name, PackageFullName
Remove-AppxPackage 9E2F88E3.Twitter_4.3.4.0_x86__wgeqdkkx372wm
Remove-AppxPackage Microsoft.BingFinance_4.8.268.0_x86__8wekyb3d8bbwe
Remove-AppxPackage Microsoft.BingNews_4.8.268.0_x86__8wekyb3d8bbwe
Remove-AppxPackage Microsoft.BingSports_4.8.268.0_x86__8wekyb3d8bbwe
Remove-AppxPackage Microsoft.BingWeather_4.8.277.0_x86__8wekyb3d8bbwe
Remove-AppxPackage Microsoft.MicrosoftSolitaireCollection_3.8.3092.0_x64__8wekyb3d8bbwe
Remove-AppxPackage Microsoft.Office.Sway_17.6769.45081.0_x64__8wekyb3d8bbwe
Remove-AppxPackage Microsoft.SkypeApp_3.2.1.0_x86__kzf8qxf38zg5c
@waf
waf / Program.cs
Created February 5, 2016 02:38
C# string replacement performance
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace TestRun
{
// sample test run results
@waf
waf / vimrc
Last active December 22, 2016 17:52
Simple Window Vim Configuration: %UserProfile%\_vimrc
" standard vim options
set guifont=Consolas:h14:cANSI
set nocompatible
set backspace=indent,eol,start
set guioptions-=T
syntax enable
set tabstop=4
set shiftwidth=4
set expandtab
set ignorecase
@waf
waf / parse-word-list.py
Created January 3, 2016 17:34
Python 2 script that parses Stuart Jay Raj's "First Words to Learn - Enhanced Wordlist from Fluency Forever Multi Lang"
#!/usr/bin/env python
# Python 2 script that parses Stuart Jay Raj's "First Words to Learn - Enhanced Wordlist from Fluency Forever Multi Lang"
# Input file should be the JSON export here: https://spreadsheets.google.com/feeds/list/1GsNe8GVzgIuOeeEVBCcoIvxVMDO5xnEgGRr8EKtcSGI/1/public/basic?alt=json
# See original spreadsheet here: https://docs.google.com/spreadsheets/d/1GsNe8GVzgIuOeeEVBCcoIvxVMDO5xnEgGRr8EKtcSGI/edit#gid=884321509
import json
import codecs
QUESTION_LANGUAGE = 'thaith'
@waf
waf / websockets.fs
Created October 19, 2015 03:24
F# websocket work-in-progress
type WebSocketResponse =
| Close
| Message of msg : string
let rec readMessagePatternMatch (ws:WebSocket) : Async<WebSocketResponse> =
let buffer : byte array = Array.zeroCreate 1024
let utf8 = new UTF8Encoding()
async {
let! payload = ws.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None) |> Async.AwaitTask
return! match payload.MessageType with