Skip to content

Instantly share code, notes, and snippets.

View HerbM's full-sized avatar

Herb Martin HerbM

  • LearnQuick.Com
  • Austin, TX
View GitHub Profile
Function Get-Property {
[CmdletBinding()]param(
[Parameter(ValueFromPipeline)][psobject]$object,
[switch]$AsHash
)
Process {
If ($AsHash) {
$Property = [ordered]@{}
$Object.psobject.get_properties() | ForEach-Object {
$Property += @{ $_.Name = $_.Value }
Function Get-CurrentLineNumber {
$Invocation = Get-Variable MyInvocation -value -ea 0 2>$Null
If (!$Invocation) { $Invocation = $MyInvocation }
$Invocation.ScriptLineNumber
}
Function Get-CurrentFileLine {
if ($MyInvocation.PSCommandPath) {
"$(split-path -leaf $MyInvocation.PSCommandPath):$($MyInvocation.ScriptLineNumber)"
} else {"GLOBAL:$(LINE)"}
@HerbM
HerbM / gist:abd73225cb2dd796350623a928b51e74
Created April 1, 2018 13:28
Old Prompt (2018 Mar 30)
Function Global:prompt {
If (!(Get-Variable MaxPrompt -ea 0 2>$Null)) { $MaxPrompt = 45 }
$loc = "$($executionContext.SessionState.Path.CurrentLocation)"
$Sig = " |>$('>' * $nestedPromptLevel)"
if ($Global:MaxPromptLength) {
$LocLen = $Loc.length; $SigLen = $Sig.Length
$Length = $LocLen + $SigLen
$Excess = $Length - $Global:MaxPromptLength
If ($Excess -gt 0) {
$Excess = [Math]::Min($Excess, $LocLen)
1 subgoal
n, m, p : nat
H : leb n m = true
IHp : leb (p + n) (p + m) = true
______________________________________(1/1)
leb (S p + n) (S p + m) = true
(* How does assumption complete the goal? I agree it's true but don't see how Coq gets that. *)
@HerbM
HerbM / map_fold.ps1
Created June 17, 2017 10:00 — forked from cdhunt/map_fold.ps1
Map and Fold implementations in Powershell
function map([scriptblock]$map, [Collections.IEnumerable]$x, $y) { $x.ForEach({& $map $_ $y}) }
# Two parameters
map { param($x, $y) $x + $y } @(1,2,3) 10
# Anonymous function as a value
$squareIt = { param($x) $x + $x }
map $squareIt @(1,2,3)
# One parameter
open System
open System.Text.RegularExpressions
exception QuitProgram
(* // defining this function causes the initial "> " to not be displayed first
let ProcessInput =
let input = System.Console.ReadLine()
try
let f = System.Single.Parse(input)
@HerbM
HerbM / OXML-1.fs
Created December 16, 2016 06:04
OpenXML-test-errors
// OpenXML-test-errors OXML-1
open System.IO
open System.IO.Packaging
open DocumentFormat.OpenXml.Packaging
open DocumentFormat.OpenXml.Wordprocessing
[<EntryPoint>]
let Main args =
let byteArray = File.ReadAllBytes "Test.docx"
use mem = new MemoryStream()
// Dr. Syme meets Dr. Seuss :slightly_smiling_face:
// Expert FSharp 4.0 p. 165 read aloud:
module public GlobalClock =
type TickTock = Tick | Tock
let mutable private clock = Tick
let private tick = new Event<TickTock>()
let internal oneTick() =
(clock <- match clock with
Tick -> Tock
| Tock -> Tick)
open System
open System.IO
open System.Collections.Generic
open System.Text
open System.Text.RegularExpressions
#load "Library1.fs"
open Library1
// Define your library scripting code here
;; My solution
(defn intervs [s]
(let [sorted (sort (into #{} s))
fs (first sorted)]
(cond (not (seq sorted)) ()
(= 1 (count sorted)) (list [fs fs])
(not= (inc fs) (second sorted)) (cons [fs fs] (intervs (rest sorted)))
:ELSE
(let [pairs (partition 2 1 sorted)]
(let [contig (take-while #(= (inc (first %)) (second %)) pairs)