Skip to content

Instantly share code, notes, and snippets.

View seankearon's full-sized avatar
💭
coding up a storm!

seankearon

💭
coding up a storm!
View GitHub Profile
@seankearon
seankearon / original-code-for-review.fs
Last active August 29, 2015 14:03
Parsing sections from a log file using F#
// Code for review posted here: http://codereview.stackexchange.com/questions/55554/parsing-sections-from-a-log-file-using-f
// Here are the "lines" from my "log file".
let lines = [1 .. 25] |> List.map (fun x -> x.ToString())
// For this exercise, section criteria is divisibility by 5.
// val DivisibleByFive : s:string -> bool
let DivisibleByFive (s:string) =
System.Int32.Parse(s) % 5 = 0
@seankearon
seankearon / get-script-folder.ps1
Last active August 29, 2015 14:03
ps: useful snippets
# Get the script's folder
function get_script_directory # http://blogs.msdn.com/b/powershell/archive/2007/06/19/get-scriptdirectory.aspx
{
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
}
$scriptpath = get_script_directory
cd $scriptpath
# Pause for user to press a key
@seankearon
seankearon / Typescript Jasmine Knockout Setup
Last active August 29, 2015 14:05
Set up for testing a TypeScript Knockout model in Visual Studio with Jasmine
Install-Package knockoutjs
Install-Package knockout.typescript.DefinitelyTyped
Install-Package JasmineTest
Install-Package jasmine.typescript.DefinitelyTyped
@seankearon
seankearon / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@seankearon
seankearon / gist:2638423
Created May 8, 2012 18:47
Tobi's Embedded RavenDB Dumper with Attachments
// Based on original by Tobi: https://gist.github.com/617852830394aaaa7160
public class RavenDBDumper
{
#region Static Methods
private static void Read(JsonReader jsonReader, string arrayName, Action<RavenJToken> process)
{
if (jsonReader.Read() == false)
return;
if (jsonReader.TokenType != JsonToken.PropertyName)
void Main()
{
var file = @"C:\Users\Me\Desktop\Certificates.txt";
var a = JObject.Parse(File.ReadAllText(file));
var cert = a["Certificates"][0];
// Get the UIDs for the existing boards and circuits.
var boards = cert["Boards"].Select (x => (Guid)x["UniqueId"]).ToArray();
var circuits = cert["Boards"].SelectMany (x => x["Circuits"]).Select (x => (Guid)x["UniqueId"]).ToArray();
@seankearon
seankearon / CreateAndQuery.cs
Last active September 7, 2016 21:36
Marten Queries
using System;
using System.Collections.Generic;
using System.Linq;
using Marten;
using Xunit;
namespace marten_test
{
public class CreateAndQuery
{
# PLUS: npm install --global --production windows-build-tools
choco install spotify -y
choco install visualstudiocode -y
choco install microsoftazurestorageexplorer -y
choco install sourcetree --version 1.9.10.0 -y
choco install webstorm -y
choco install jetbrainstoolbox -y
# not updated choco install jetbrains-rider -y
choco install balsamiqmockups3 -y
@seankearon
seankearon / gist:de261ac578de1a735b26f23b0ce78155
Created August 31, 2017 07:29 — forked from robertpi/gist:2964793
F# record implementing an interface
namespace MyNamespace
type IMyInterface =
abstract GetValue: unit -> string
type MyRecord =
{ MyField1: int
MyField2: string }
interface IMyInterface with
member x.GetValue() = x.MyField2
Deployment steps for this blog post:
http://kearon.blogspot.co.uk/2015/01/installing-service-using-topshelf-with.html