Skip to content

Instantly share code, notes, and snippets.

View OnorioCatenacci's full-sized avatar

Onorio Catenacci OnorioCatenacci

View GitHub Profile
@OnorioCatenacci
OnorioCatenacci / githelpers.ps1
Created April 8, 2013 16:00
Everyday Git Aliases For Powershell (Github For Windows)
#Adjust these values for your own installation.
Set-Variable -Name defaultDirectory -option Readonly -value "c:/mydev"
Set-Variable -Name defaultRepository -option Readonly -value "myrepo"
Set-Variable -Name defaultBranch -option Readonly -value "workbranch"
#Per "Everyday git-aliases", do a rebase as opposed to a merge
function gpurr($repository=$defaultRepository, $branch=$defaultBranch)
{
& 'git' pull --rebase $repository $branch
}
@OnorioCatenacci
OnorioCatenacci / StartST2.fsx
Created February 29, 2012 16:18
Start Sublime Text 2 With Git Plugin
#nowarn "62"
//Note this is running on Win7 x64 but git is 32 bit.
let pathEnvVar = "Path"
let gitBin = @"\Program Files (x86)\Git\bin"
let st2Bin = @"\Program Files\Sublime Text 2"
let currentPath = System.Environment.GetEnvironmentVariable(pathEnvVar)
let modifiedPath = gitBin ^ ";" ^ st2Bin ^ ";" ^ currentPath
System.Environment.SetEnvironmentVariable (pathEnvVar,modifiedPath)
@OnorioCatenacci
OnorioCatenacci / ExecFsx.ps1
Created November 11, 2011 20:11
Quick Powershell Script For Running Fsharp Shell Scripts
#11 November 2011
#ExecFsx.ps1
#Onorio Catenacci
#Insure we get all the error checking from Powershell itself that we can
set-strictmode -version latest
#Set this to point at the location of fsi.exe on your machine.
set-variable -name fsi -value """$env:ProgramFiles\Microsoft F#\v4.0\fsi.exe""" -option constant
#This is where I put all of my .fsx files. Change this to your favorite location
@OnorioCatenacci
OnorioCatenacci / FilterTextFile.fsx
Created October 24, 2011 01:19
A quick and dirty F# Shell Script to filter a text file for all lines which match a certain string
(*
* Filter a specified file into a second file
* Onorio Catenacci
* 21 October 2011
*)
#r "System.dll"
open System.IO
//Remember:
@OnorioCatenacci
OnorioCatenacci / UnitsOfMeasure2.fs
Created August 1, 2011 15:51
F# Units of Measure and Interfaces
module measures
type ILinear =
interface
end
[<Measure>] type inch =
@OnorioCatenacci
OnorioCatenacci / ReturnRandomString.fs
Created December 9, 2010 12:58
Return a random string from an array of strings
// Copy/paste this into the FSI to see what it does.
open System
let a = [|"a";"b";"c";"d"|]
let randstring (arr:string[]) =
let r = new Random()
arr.[r.Next(arr.Length)]
let resultstring = randstring a;;
@OnorioCatenacci
OnorioCatenacci / SmallJSONDemo.fs
Created July 16, 2010 00:42
F# fragment for JSON Serialize/Deserialize
(* Borrowed very liberally from
https://blogs.msdn.com/b/jomo_fisher/archive/2010/03/06/neat-samples-f-freebase-and-dgml.aspx
and
http://cs.hubfs.net/forums/permalink/11096/11096/ShowThread.aspx#11096
Many thanks to both those posters for giving me 99% of the starting code