Skip to content

Instantly share code, notes, and snippets.

@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 () {
@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}
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 / 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
@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 / 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 / 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 / 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 / BReusable.fs
Last active February 2, 2016 22:24
Helpful F# snippets
module BReusable
open System
open System.Text
let trim (s:string) = if isNull s then null else s.Trim()
let after (delimiter:string) (s:string) = s.Substring(s.IndexOf delimiter + delimiter.Length)
let before (delimiter:string) (s:string) = s.Substring(0,s.IndexOf delimiter)
let beforeI (delimiter:string) (s:string) = s.Substring(0,s.IndexOf(delimiter, StringComparison.CurrentCultureIgnoreCase))
let capture (pattern:string) (s:string) = Regex.Match(s, pattern).Groups.[1].Value
let isNullOrEmptyToOpt s = if String.IsNullOrEmpty s then None else Some s
@ImaginaryDevelopment
ImaginaryDevelopment / AdoHelper.fs
Created January 12, 2016 19:34
my ado helper reusable library attempt
module Pm.Dal.AdoHelper
// desired features
// "do we have a connectionstring or connection?" ignorance-capable coding
// "are we in a transaction?" ignorance-capable coding
// massive reduction in using blocks necessary
// remove any reliance/requirement to refer directly to System.Data in layers that need not
// conventions:
// pascal cased functions if they are specially crafted to be easier for C# to consume