Skip to content

Instantly share code, notes, and snippets.

@ImaginaryDevelopment
ImaginaryDevelopment / FTargets.proj
Last active December 21, 2015 21:44
Templatus generate F# from sql table
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- for build server primarily -->
<FSharpTargetsPath Condition="'$(FSharpTargetsPath)' == '' And Exists('C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.Targets')">C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
<FSharpTargetsPath Condition="'$(FSharpTargetsPath)' == '' And Exists('C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0')">C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
<FSharpTargetsPath Condition="'$(FSharpTargetsPath)' == '' ">..\3rdParty\Microsoft.FSharp.Targets</FSharpTargetsPath>
<!-- love these option settings, but not required -->
<WarningLevel>5</WarningLevel>
<OtherFlags>--warnon:1182 --warnaserror-:0052</OtherFlags>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@ImaginaryDevelopment
ImaginaryDevelopment / DataModelToF.ttinclude
Last active December 28, 2015 18:06
T4 to generate F# types from a db
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Data" #>
<#@ assembly name="System.Data.Entity.Design" #>
<#@ import namespace="System.Globalization" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Data.Entity.Design.PluralizationServices" #>
<# EnvDTE.DTE Dte;
@ImaginaryDevelopment
ImaginaryDevelopment / Sample.tt
Last active December 28, 2015 18:02
T4 Sql generator for .dbproj files
<#@ template debug="True" language="C#" hostspecific="True" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Data" #>
<#@ assembly name="System.Data.Entity.Design" #>
<#@ import namespace="System.Globalization" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Data.Entity.Design.PluralizationServices" #>
@ImaginaryDevelopment
ImaginaryDevelopment / MultipleOutputHelper.ttinclude
Created December 9, 2015 18:19
MultipleOutputHelper improvements
<#@ assembly name="System.Core"
#><#@ assembly name="System.Data.Linq"
#><#@ assembly name="EnvDTE"
#><#@ assembly name="EnvDTE80"
#><#@ assembly name="System.Xml"
#><#@ assembly name="System.Xml.Linq"
#><#@ import namespace="System"
#><#@ import namespace="System.CodeDom"
#><#@ import namespace="System.CodeDom.Compiler"
#><#@ import namespace="System.Collections.Generic"
@ImaginaryDevelopment
ImaginaryDevelopment / Claims.generated.fs
Created November 17, 2015 18:31
Generator and generated code from new T4 to F#
namespace Pm.Schema.DataModels.Claims // Generated by item in namespace PracticeManagement.Foundation
open System
open System.ComponentModel
open System.Linq.Expressions
/// 59 properties
type IClaim =
abstract member AccidentDate:DateTime Nullable with get
abstract member AccidentState:string with get
let internal save connection apptId apptPatientId apptPatientInfoId apptProviderScheduledId apptFacilityId apptStartTime apptEndTime apptTypeId apptStatus apptBillingStage apptLoS apptCheckInFlag apptCheckInTime apptCheckOutTime apptForeignEhrId apptAccidentRelated apptAccidentId apptAccidentDate apptAccidentState presentingCondition notesToBiller isChecked apptPrimaryGuarantorType admitStatus (admitFacilityId:int Nullable) referralPcp =
let admitStatus = if String.IsNullOrEmpty(admitStatus) then null else admitStatus
getScalar connection false (fun db -> db.UspAppointmentsInsUpd(apptId, apptPatientId, apptPatientInfoId, apptProviderScheduledId, apptFacilityId, apptStartTime, apptEndTime, apptTypeId, apptStatus, apptBillingStage, apptLoS, apptCheckInFlag, apptCheckInTime, apptCheckOutTime, apptForeignEhrId, apptAccidentRelated, apptAccidentId, apptAccidentDate, apptAccidentState, presentingCondition, notesToBiller, isChecked, apptPrimaryGuarantorType,admitStatus=admitStatus,admitFacilit
@ImaginaryDevelopment
ImaginaryDevelopment / Catan.fsx
Created August 9, 2015 02:57
Catan modeling
//catan
// github.com/MichaelLPerry/dof
type Hand = { Wood: byte; Wheat: byte; Sheep: byte; Stone: byte; Gold:byte} with
member x.Values = [x.Wood; x.Wheat; x.Sheep; x.Stone; x.Gold]
member x.IsValid = x.Values |> Seq.forall ((>=) 0uy)
member x.HasAtLeast (resources:Hand) =
let calculated = x.Values |> Seq.map2 (<=) resources.Values
calculated |> Seq.forall id
static member Zero = {Wood = 0uy; Wheat = 0uy; Sheep = 0uy; Stone = 0uy; Gold = 0uy}
@ImaginaryDevelopment
ImaginaryDevelopment / maybe_without_objects.js
Last active December 21, 2015 21:39 — forked from timcharper/maybe_without_objects.js
maybe_without_objects adjusted for prototype calls and what not, in action at http://jsfiddle.net/Maslow/w8Uzw/
function type(obj) {
var obj_type = typeof obj;
return ({
is: function (type) {
return obj_type === type;
},
is_object: function () {
return obj_type === "object";
},
is_func: function () {