Skip to content

Instantly share code, notes, and snippets.

public static class EnumUtils
{
public static IEnumerable<T> Values<T>()
{
CheckTypeParamIsEnum<T>();
return Enum.GetValues(typeof(T)).Cast<T>();
}
public static T ToEnum<T>(int value)
@chillitom
chillitom / msbuild.targets
Created December 17, 2012 22:37
XSLT to convert OpenCover xml to NCover 1.x format for use with Bamboo
<!-- example msbuild target -->
<Target Name="TranslateCoverageXml">
<ItemGroup>
<CoverageFiles Include="$(TestsDir)\*.opencover" />
</ItemGroup>
<XslTransformation XmlInputPaths="%(CoverageFiles.Identity)"
XslInputPath="$(MSBuildProjectDirectory)\opencover_to_ncover.xslt"
OutputPaths="$(TestsDir)\%(CoverageFiles.FileName).ncover.xml" />
@chillitom
chillitom / combine-with-suffix.clj
Last active December 21, 2015 03:09
trying to wrap combine and adjust and getting exceptions
(defn combine-with-suffix
"same as riemann.streams/combine but takes a suffix argument to append to the service name"
[f suffix & children]
(combine f (adjust [:service str suffix] children)))
;java.lang.ClassCastException: clojure.lang.ArraySeq cannot be cast to clojure.lang.IFn
; at riemann.streams$combine$stream__8140$fn__8150.invoke(streams.clj:132)
; at riemann.streams$combine$stream__8140.invoke(streams.clj:132)
; at riemann.streams$moving_event_window$stream__8293$fn__8305.invoke(streams.clj:242)
; at riemann.streams$moving_event_window$stream__8293.invoke(streams.clj:242)
@chillitom
chillitom / rot47.ps1
Last active January 2, 2016 17:09
Powershell Rot47 implementation.. for when Rot13 just isn't secure enough.
function Rot47 { param ([string] $in)
$table = @{}
for ($i = 0; $i -lt 94; $i++) {
$table.Add(
"!`"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_``abcdefghijklmnopqrstuvwxyz{|}~"[$i],
"PQRSTUVWXYZ[\]^_``abcdefghijklmnopqrstuvwxyz{|}~!`"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO"[$i])
}
$out = New-Object System.Text.StringBuilder
$in.ToCharArray() | %{
@chillitom
chillitom / gist:19afc0a7383374b31c4f
Created May 1, 2015 22:14
F# Markov chain first attempt
open System
open System.IO
open System.Text.RegularExpressions
let inputText = File.ReadAllText(__SOURCE_DIRECTORY__ + "/frankenstein.txt")
type Prefix = string list
type Suffix = string
@chillitom
chillitom / AkkaPersistentViewUpdate.fs
Created November 20, 2015 11:53
playing with Akka.Persistence.FSharp's persistent view's manual updates
open System
open Akka.FSharp
open Akka.Persistence
open Akka.Persistence.FSharp
let system = System.create "sys" (Configuration.parse("""
akka.persistence.view.auto-update = off
"""))
@chillitom
chillitom / persistence2.fsx
Created November 23, 2015 14:26
Trying to use obj as message type for persistent actor in Akkling 0.2
open System
open Akkling
open Akkling.Persistence
type CounterChangedEvent =
{ Delta : int }
type CounterCommand =
| Inc
| Dec