View restore.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE procedure [dbo].[db_restore](@Dbname nvarchar(200), @File nvarchar(max)) | |
AS | |
BEGIN | |
declare @sql nvarchar(max) | |
declare @rowsPath nvarchar(max) | |
declare @logPath nvarchar(max) | |
declare @dbRows nvarchar(255) | |
declare @dbLog nvarchar(255) | |
IF (SELECT COUNT(*) FROM sys.databases WHERE name = @Dbname) = 0 |
View taskExtract.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[ValidateScript({Test-Path $_ -PathType 'Container'})] | |
[string]$path | |
) | |
Add-Type -AssemblyName System.Web | |
$files = ls -R -Path $path -Filter *.cs | |
$tasks = @() |
View gist:612352a76fb4829682c4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Functional Friday - Introduction | |
// Mateusz Stasch <mstasch@future-processing.com> | |
// 2014.12.12 | |
// Links: | |
// http://fsharp.org | |
// http://tryfsharp.org | |
// http://fsharpforfunandprofit.com | |
// F# is a mature, open source, cross-platform, functional-first programming language |
View unzip3.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec unzip3<'a, 'b, 'c> ((A: 'a list), (B: 'b list), (C: 'c list)) (tuples: (('a * 'b * 'c) list)) : ('a list) * ('b list) * ('c list) = | |
match tuples with | |
| (a: 'a, b: 'b, c: 'c)::tail -> unzip3 (a ++ A, b ++ B, c ++ C) tail | |
| [] -> (A, B, C) | |
let rec unzip3 (A, B, C) tuples = | |
match tuples with | |
| (a: 'a, b: 'b, c: 'c)::tail -> unzip3 (a :: A, b :: B, c :: C) tail | |
| [] -> (A, B, C) |
View kMeans.Tests.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module kMeans | |
open NUnit.Framework | |
let distance = (fun a b -> abs(a - b)) | |
let avg = Seq.average | |
[<Test>] | |
let ``Should generate random subset`` () = | |
let data = seq [1..10] |
View gist:b3f785998d244df0fff7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Verbosity = Silent | Normal | Verbose | |
type Url = string | |
type Depth = int | |
let (|IsDepth|_|) str = | |
match System.Int32.TryParse(str) with | |
| (true, int) when int > 0 -> Some int | |
| _ -> None | |
let (|IsUrl|_|) url = |
View gol.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Cell = int * int | |
let exists_in element = | |
Seq.exists ((=) element) | |
let vicinity (x, y) = | |
seq { | |
for px in -1..1 do | |
for py in -1..1 do | |
yield (x+px, y+py) |
View gol.fsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//*** | |
//*X* | |
//*** | |
let vicinity (cx, cy) = | |
seq { | |
for x in -1..1 do | |
for y in -1..1 do | |
yield (cx + x, cy + y) |
View TronAI.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Direction = | North | East | South | West | |
type Position = int * int | |
type Size = int * int | |
type Player = int | |
type World = { Taken : Position list; Heads : (Player * Position) list } | |
type Bot = Player -> Position -> World -> Direction | |
let skipLast list = | |
// TODO: Ultra inefficient |
View Disjoint.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
namespace MergeLinks | |
{ | |
public class Disjoint<T> | |
{ | |
private readonly Dictionary<int, HashSet<T>> _groups; | |
private int _lastGroupKey = 0; |
OlderNewer