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
function Parse-String([ref]$lines, $indent) | |
{ | |
$sb = New-Object System.Text.StringBuilder | |
while($lines.Value[0] -match "(?<indent>^\t*)(?<value>.*)" -and $matches.indent.Length -eq $indent) | |
{ | |
$lines.Value = $lines.Value[1..($lines.Value.Length)] | |
$sb.AppendLine($matches.value) | Out-Null | |
} | |
return $sb.ToString() | |
} |
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
<# | |
.DESCRIPTION | |
Create a database connection and add extension methods (script methods) that can load and | |
save a System.Data.Dataset | |
.PARAMETER ConnectionString | |
Connection string to database. | |
.EXAMPLE | |
Open connection, load data, update and create new records. |
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
// Learn more about F# at http://fsharp.net | |
// See the 'F# Tutorial' project for more help. | |
type Network = { mutable s : array<int>; w : double[,]; n : int } | |
with | |
static member create (n : int) (patterns : seq<array<int>>) = | |
{ | |
n = n | |
s = Array.create n 0 | |
w = Array2D.init n n (fun i j -> |
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
function Prompt | |
{ | |
$pwdshort = $pwd | |
$maxLen = 50 | |
if ($pwd.Path.Length -gt $maxLen) | |
{ | |
$pwdshort = $pwd.Path.Substring($pwd.Path.Length-$maxLen+5) | |
$i = $pwdshort.IndexOf('\') | |
if ($i -ge 0) | |
{ |
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 Huffman | |
// ref: http://cs.hubfs.net/topic/None/56608 | |
open BinomialHeap | |
type private Tree = Leaf of char | Branch of Tree*Tree | |
let private initialForest (stringData : string) = | |
// ref: http://www.fssnip.net/n5 | |
let createHistogram = |
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
var hron = require('hron.js'); | |
var settings = { | |
environment: "test", | |
dbconnection: [ | |
"Data Source=localhost; Initial Catalog=MyDB; Integrated security=true", | |
{ server: "192.168.1.20", timeout: 19 } | |
], | |
appserver: "192.168.1.21" | |
}; |
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
import Data.Char(isDigit) | |
data Parser a = Parser (String -> Maybe (String,a)) | |
instance Monad Parser where | |
return x = Parser (\s -> Just (s,x)) | |
(Parser p) >>= f = | |
Parser $ \s -> | |
case p s of | |
Nothing -> Nothing |
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
$cred = Get-Credential | |
$serverip = "192.168.1.1" | |
$serverTime = Invoke-Command -ComputerName $serverip -Credential $cred -ScriptBlock { Get-Date } | |
$localTime = Get-Date | |
Write-host "Server time: $serverTime" | |
Write-host "Local time: $localTime" | |
$timeDiff = $serverTime - $localTime | |
$timeDiffSecs = [Math]::abs($timeDiff.TotalSeconds) |
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
function print(M, msg) { | |
console.log("======" + msg + "=========") | |
for(var k=0; k<M.length; ++k) { | |
console.log(M[k]); | |
} | |
console.log("==========================") | |
} | |
function diagonalize(M) { | |
var m = M.length; |
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
-- http://codegolf.stackexchange.com/questions/69442/make-a-simple-pretty-comment-tool | |
-- package: https://hackage.haskell.org/package/regex-applicative-0.2.1/docs/Text-Regex-Applicative.html | |
-- example: https://github.com/feuerbach/regex-applicative/wiki/Examples | |
-- cabal install regex-applicative | |
-- ghci overloadedStrings -> :set -XOverloadedStrings | |
--{-# LANGUAGE OverloadedStrings #-} |
OlderNewer