Skip to content

Instantly share code, notes, and snippets.

View DominicFinn's full-sized avatar

Dominic Finn DominicFinn

View GitHub Profile
@DominicFinn
DominicFinn / case.sql
Created March 7, 2014 16:13
Case statement for Wilf
declare @number int
set @number = 1
select case @number when 1
then 'yes'
else 'no'
end as NumberOrYes
@DominicFinn
DominicFinn / owin.cs
Created May 30, 2014 15:05 — forked from serialseb/owinfx
dsfg
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nancy;
using Nancy.Owin;
using Nowin;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nancy;
using Nancy.Owin;
using Nowin;
public class Appointment : IAggregateRoot
{
public Appointment(Guid id, AppointmentType type, .....)
{
switch type
{
case: AppointmentType.TypeOne
Apply(new TypeOneAppointmentCreated());
case: AppointmentType.TypeTwo
Apply(new TypeTwoAppointmentCreated());
@DominicFinn
DominicFinn / nancy.fs
Created July 4, 2014 14:03
Nancy F# Example with parameter
open System
open Nancy
open Nancy.Hosting.Self
let (?) (parameters:obj) param =
(parameters :?> Nancy.DynamicDictionary).[param]
let sayHello(name) =
"hello " + name
@DominicFinn
DominicFinn / regexTwoChars.fsx
Created July 7, 2014 08:50
Match exactly two numerical characters
open System
open System.Text.RegularExpressions
let matcher(s) =
let regex = new Regex("^[0-9]{2}$")
let matched = regex.Match(s)
matched.Success
let stringOne = matcher "dom" // false
let stringTwo = matcher "12" // true
@DominicFinn
DominicFinn / SqlTypeProvider.fsx
Created July 10, 2014 09:48
Enough to get a hold of your database in F#
#r "FSharp.Data.TypeProviders.dll"
#r "System.Data.Linq.dll"
open System
open System.Linq
open System.Data
open Microsoft.FSharp.Data.TypeProviders
open System.Text.RegularExpressions
[<Literal>]
@DominicFinn
DominicFinn / FormWithTasks.fsx
Created August 15, 2014 12:52
Accessing the UI Thread in the right context in tasks
open System.Windows.Forms
open System.Threading.Tasks
let createForm() =
let form = new Form()
let button = new Button()
button.Text <- "Start"
form.Controls.Add(button)
@DominicFinn
DominicFinn / FooDeleter.js
Last active August 29, 2015 14:05
Delete Files called foo, deletes files that end in foo from a folder called tmp
var fs = require('fs');
function fileEndsWith(fileName, suffix) {
return fileName.indexOf(suffix, fileName.length - suffix.length) !== -1;
};
var dir = './tmp/';
fs.readdir(dir, function(err, files) {
if (err) throw err;
@DominicFinn
DominicFinn / PeopleFilter.js
Last active August 29, 2015 14:05
Map / Reducing in Javascript yourself.
var people = [
{ name:"dom", age:22}
, { name:"paddy", age:22}
, { name:"pete", age:22}
, { name:"dick", age:100}
]
var query1 = { field: "age", found: function(field) {
if(field > 50) {
return true;