Skip to content

Instantly share code, notes, and snippets.

View PatrickMcDonald's full-sized avatar

Patrick McDonald PatrickMcDonald

View GitHub Profile
(ns week1.core
(:gen-class))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Hello, World!"))
(defn sum-x
"desc"
<PropertyGroup>
<_EnableCleanOnBuildForMvcViews Condition=" '$(_EnableCleanOnBuildForMvcViews)'=='' ">true</_EnableCleanOnBuildForMvcViews>
</PropertyGroup>
<Target Name="CleanupForBuildMvcViews" Condition=" '$(_EnableCleanOnBuildForMvcViews)'=='true' and '$(MVCBuildViews)'=='true' " BeforeTargets="MvcBuildViews">
<ItemGroup>
<_TempWebConfigToDelete Include="$(BaseIntermediateOutputPath)**\Package\**\*" />
<_TempWebConfigToDelete Include="$(BaseIntermediateOutputPath)**\TransformWebConfig\**\*" />
<_TempWebConfigToDelete Include="$(BaseIntermediateOutputPath)**\CSAutoParameterize\**\*" />
<_TempWebConfigToDelete Include="$(BaseIntermediateOutputPath)**\TempPE\**\*" />
</ItemGroup>
Import-Module ActiveDirectory
# List members of a group
Get-ADGroupMember "Domain Admins" -recursive | Select-Object name
# list group memberships for user
Get-ADPrincipalGroupMembership "username" | Select-Object name
let date year month day = new System.DateTime(year, month, day)
type DayOfWeek = | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday
exception DayOfWeekError
let dayOfWeek (date: System.DateTime) =
match date.DayOfWeek with
| System.DayOfWeek.Monday -> Monday
| System.DayOfWeek.Tuesday -> Tuesday
let combine ys xs =
let zipi x = ys |> List.map (fun y -> (x, y))
xs |> List.collect zipi
@PatrickMcDonald
PatrickMcDonald / Fibonacci.fsx
Last active August 29, 2015 14:04
Generate Fibonacci numbers
let fibs() =
let rec fibs' a b =
seq {
yield b
yield! fibs' b (a+b)
}
fibs' 1L 1L
fibs() |> Seq.take 10 |> List.ofSeq;;
#r "System.Numerics"
open System.Numerics
/// Find the roots of ax² + bx + c
let quadraticRoots a b c =
let ``√ B² - 4ac`` = sqrt (b * b - 4.0 * a * c)
let ``2a`` = 2.0 * a
(-b + ``√ B² - 4ac``) / ``2a``, (-b - ``√ B² - 4ac``) / ``2a``
namespace StringTimes
{
using System;
public class Program
{
private static void Main(string[] args)
{
const int Iterations = 10000000;
let foldBack folder seq state =
let arr = Seq.toArray seq
Array.foldBack folder arr state
let folder a b =
let res = a + b
//printfn "fold %A and %A giving %A" a b res
res
let list = seq [1..1000000]
let createTimer() =
let sw = System.Diagnostics.Stopwatch.StartNew()
fun () ->
sw.Elapsed
let timer = createTimer()
// Do some stuff to time
timer();;