This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void serializeDataTable(NpgsqlCopySerializer serializer, DataTable datatable, string[] columnNamesInFixedOrder) | |
{ | |
var serializeRow = new List<Action<DataRow>>(); | |
var serializeByType = new Dictionary<Type, Action<object>>(); | |
serializeByType[typeof (bool)] = (o => { if (o == null) serializer.AddNull(); else serializer.AddBool((bool)o); }); | |
serializeByType[typeof (string)] = (o => { if (o == null) serializer.AddNull(); else serializer.AddString((string)o); }); | |
serializeByType[typeof (DateTime)] = (o => { if (o == null) serializer.AddNull(); else serializer.AddDateTime((DateTime)o); }); | |
serializeByType[typeof(byte)] = (o => { if (o == null) serializer.AddNull(); else serializer.AddInt32((byte)o); }); | |
serializeByType[typeof (int)] = (o => { if (o == null) serializer.AddNull(); else serializer.AddInt32((int)o); }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static Point Negate(this Point point) | |
{ | |
return new Point(-point.X, -point.Y); | |
} | |
static Point CursorPositionWithinControl(this Control control) | |
{ | |
var cursorPosition = Cursor.Position; | |
var offset = control.PointToScreen(Point.Empty); | |
cursorPosition.Offset(offset.Negate()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LatchedActionsQueue { | |
private List<KeyValuePair<object, Action>> actionsQueue = new List<KeyValuePair<object, Action>>(); | |
public void Enlist(Action action) { | |
enlist(action, action); | |
} | |
public void Enlist<T1>(Action<T1> action, T1 p1) { | |
enlist(action, () => action(p1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 -> "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// thing that hold state | |
public interface ISwitchableBehaviourState<TThingToAlter> | |
{ | |
void RegisterThingToAlterWithReversibleAction(TThingToAlter thingToAlter, Func<TThingToAlter, Action<TThingToAlter>> reversibleAction); | |
} | |
// thing that will be manipulated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
-- http://www.f13g.com/%A5%D7%A5%ED%A5%B0%A5%E9%A5%DF%A5%F3%A5%B0/Haskell/GLUT/#content_1_7 | |
import System.Random | |
import Graphics.Gloss | |
import Graphics.Gloss.Interface.Pure.Simulate | |
data Particle | |
= Particle { position :: Point |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Data.Aeson | |
import qualified Data.ByteString as BS | |
import qualified Data.ByteString.Lazy as LBS | |
import Data.Text.Encoding (decodeUtf8) | |
import Text.Blaze.Html (Html, preEscapedToHtml) | |
lazyToStrictBS :: LBS.ByteString -> BS.ByteString | |
lazyToStrictBS x = BS.concat $ LBS.toChunks x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
OlderNewer