Skip to content

Instantly share code, notes, and snippets.

Gauthier Segay smoothdeveloper

  • ·
View GitHub Profile
@smoothdeveloper
smoothdeveloper / byref.samples.fs
Created Apr 5, 2020
Samples from Matt Ellis "Writing Allocation Free Code in C#" talk
View byref.samples.fs
// replicating same techniques as
// https://youtu.be/1ZJ8ROVS5gk?t=1435
[<Struct>]
type Point =
val mutable X : int
val mutable Y : int
new(x, y) = { X = x; Y = y }
type Enemy(location: Point) =
@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
You can’t perform that action at this time.