Skip to content

Instantly share code, notes, and snippets.

View ascjones's full-sized avatar

Andrew Jones ascjones

View GitHub Profile
@ascjones
ascjones / about.md
Created November 28, 2012 12:50 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@ascjones
ascjones / tour.go
Last active December 28, 2015 18:19
tour.golang.org solutions
/ ***********************************************************/
/ * Exercise: Fibonacci closure, http://tour.golang.org/#44 */
/ ***********************************************************/
package main
import "fmt"
func fibonacci() func() int {
x, y := 0, 1
[<AutoOpen>]
module JsonExtensions =
open System
open Fleece
open Fleece.Operators
open FSharpPlus
open System.Globalization
type FromJSONClass with
Verifying that +ascjones is my Bitcoin username. You can send me #bitcoin here: https://onename.io/ascjones
@ascjones
ascjones / Bowling
Created November 25, 2014 16:50
Super Strongly Typed Bowling Kata
open System
// THE MODEL represents only allowed states
// ========================================
type Game =
{ F1 : Frame; F2 : Frame; F3 : Frame; F4 : Frame; F5 : Frame; F6 : Frame; F7 : Frame; F8 : Frame; F9 : Frame; F10 : FinalFrame } // todo: add extra frames, and FinalFrame type?
and Frame =
| Strike
| Spare of PinCount
@ascjones
ascjones / EventStoreHelpers.fs
Created January 9, 2015 16:15
Connect to EventStore Cluster
module EventStoreHelpers =
open System
open System.Net
open EventStore.ClientAPI
let inline private (!>) (x:^a) : ^b = ((^a or ^b) : (static member op_Implicit : ^a -> ^b) x)
let private dnsLookup (host : string) =
let hostEntry = Dns.GetHostEntry(host)
@ascjones
ascjones / $profile
Created January 16, 2015 14:42
Powershell Prompt
function prompt {
# Admin ?
if( (
New-Object Security.Principal.WindowsPrincipal (
[Security.Principal.WindowsIdentity]::GetCurrent())
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
{
# Admin-mark in WindowTitle
$Host.UI.RawUI.WindowTitle = "[Admin] " + $Host.UI.RawUI.WindowTitle
@ascjones
ascjones / FiniteSets
Created January 16, 2015 16:12
C# Finite Sets
interface IFin
{
int Ordinal { get; }
}
class Fin3 { }
class Fin2 : Fin3 { }
class Fin1 : Fin2 { }
class Fin0 : Fin1 { }
class Foo
@ascjones
ascjones / GetSystemFileCache.ps1
Created January 19, 2015 14:22
Windows File Cache Scripts
$source = @"
using System;
using System.Runtime.InteropServices;
namespace MyTools
{
public static class cache
{
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)]
@ascjones
ascjones / YesOrNo.cs
Last active August 29, 2015 14:13
Yes Or No
class YesOrNo<TState>
{
private readonly TState state;
private readonly bool keepGoing;
public bool Success { get { return keepGoing; } }
public YesOrNo(TState state = default (TState), bool keepGoing = true)
{
this.state = state;