Skip to content

Instantly share code, notes, and snippets.

Gauthier Segay smoothdeveloper

  • ·
Block or report user

Report or block smoothdeveloper

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@smoothdeveloper
smoothdeveloper / sqlconnection.statistics.fs
Created Jul 19, 2019
a bit of F# code handling sql connection statistics
View sqlconnection.statistics.fs
open System
open System.Data.SqlClient
type EntryType =
| BuffersReceived
| BuffersSent
| BytesSent
| ConnectionTime
| CursorOpens
| IduCount
@smoothdeveloper
smoothdeveloper / ironfunctions.test.fs
Created Dec 7, 2016
IronFunctions help Seif Lotfy
View ironfunctions.test.fs
// code converted for http://seif.codes/playing-with-net-dotnet-and-ironfunctions/
// https://twitter.com/SeifLotfy/status/805901527659540480
open System
open System.IO
open System.Security.Cryptography
open System.Text
let downloadRemoteImageFile (url: string) =
let request = url |> System.Net.WebRequest.CreateHttp
@smoothdeveloper
smoothdeveloper / create.table.based.on.existing.schema.sql
Created Jul 26, 2016
create table based on existing table schema
View create.table.based.on.existing.schema.sql
declare
@templateSchemaName nvarchar(max)
, @templateTableName nvarchar(max)
, @newSchemaName nvarchar(max)
, @newTableName nvarchar(max)
with columninfo as (
select
t.name table_name
, c.name column_name
View DataTableMaker.fsx
open System
open System.Data
module DataTableMaker =
type ColumnMaker<'t> = { Name: string; Type: Type; GetValue: 't -> obj }
let makeColumn name (f: _ -> 'c) =
{ Name = name; Type = typeof<'c>; GetValue = f >> box }
View CsvDistinctValuesProvider.fs
namespace MyTypeProviders
open System
open System.IO
open System.Reflection
open ProviderImplementation.ProvidedTypes
open Microsoft.FSharp.Core.CompilerServices
open CsvHelper
open System.Collections.Generic
open Microsoft.FSharp.Quotations
@smoothdeveloper
smoothdeveloper / package.devexpress.fsx
Created Feb 11, 2016
Package devexpress assemblies as nuget packages
View package.devexpress.fsx
#r "../../../../packages/Mono.Cecil/lib/net40/Mono.Cecil.dll"
#r "../../../../packages/QuickGraph/lib/net4/QuickGraph.dll"
#r "../../../../packages/FAKE/tools/FakeLib.dll"
open Mono.Cecil
open System.IO
open QuickGraph
open System.Linq
open System.Reflection
let folder = @"C:\testing\DevExpress 15.2\Components\Bin\Framework"
@smoothdeveloper
smoothdeveloper / generate_add_and_drop_all_constraints.sql
Created Feb 27, 2015
SqlServer: Generate alter add / drop for all type of constraints (foreign key, unique and check)
View generate_add_and_drop_all_constraints.sql
with
unique_constraint_infos (schemaname, tablename, constraintname, columnname)
as (
select
quotename(tc.table_schema)
, quotename(tc.table_name)
, quotename(tc.constraint_name)
, quotename(cc.column_name)
from
information_schema.table_constraints tc
@smoothdeveloper
smoothdeveloper / format-timespan.fsx
Created Feb 27, 2015
System.TimeSpan user-friendly formatting
View format-timespan.fsx
open System
type Part = Days of int
| Hours of int
| Minutes of int
| Seconds of int
| Milliseconds of int
let bigPartString p =
match p with
| Days 0 -> ""
@smoothdeveloper
smoothdeveloper / extract_all_bitmap_resources_from_all_assemblies_in_folder.fsx
Last active Aug 29, 2015
Extract all bitmap resources from all assemblies in folder
View extract_all_bitmap_resources_from_all_assemblies_in_folder.fsx
// annoyed with resources embedded in resources in assemblies?
// extract all images from all assemblies in a folder
// see call commented at the end
#r "System.Drawing"
#r "System.Windows.Forms"
open System.Collections
open System.Drawing
open System.Linq
open System.IO
open System.Resources
@smoothdeveloper
smoothdeveloper / SimpleUnionCaseInfoReflection.fs
Created Feb 11, 2015
F# simple UnionCase info reflection helper
View SimpleUnionCaseInfoReflection.fs
open Microsoft.FSharp.Reflection
module SimpleUnionCaseInfoReflection =
// will crash if 'T contains members which aren't only tags
let Construct<'T> (caseInfo: UnionCaseInfo) = FSharpValue.MakeUnion(caseInfo, [||]) :?> 'T
let GetUnionCaseInfoAndInstance<'T> (caseInfo: UnionCaseInfo) = (caseInfo, Construct<'T> caseInfo)
let AllCases<'T> =
You can’t perform that action at this time.