Skip to content

Instantly share code, notes, and snippets.

View SoulFireMage's full-sized avatar

Richard Griffiths SoulFireMage

View GitHub Profile
@ptrelford
ptrelford / SnowflakesEx.fsx
Last active December 15, 2015 19:01
Falling Snowflakes F# script using WriteableBitmapEx
#r "PresentationCore.dll"
#r "PresentationFramework.dll"
#r "WindowsBase.dll"
#r "WriteableBitmapEx.Wpf.dll" // requires custom version with DrawString
open System
open System.Windows
open System.Windows.Controls
open System.Windows.Media
open System.Windows.Media.Imaging
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
/// <summary>
/// Dynamic rules engine, translated from visual basic
/// Demonstration of demonstrating how to build a generic dynamic rules engine.
/// Original purpose: arbitrary classes are generated to reflect types from tables in a database
/// Two databases were being merged and a method of checking arbitrary rows in any table was required
@kolektiv
kolektiv / Snowflake Code Dump
Created December 29, 2014 17:35
Snowflake Generation
module Cells =
// Types
type LifeSpec =
| LifeSpec of GenerationSpec list
and GenerationSpec =
| GenerationSpec of strength: int * liveness: (int -> bool)
@SoulFireMage
SoulFireMage / DynamicRuleEngineBuilder
Last active December 21, 2015 11:39
A generic constrained class that dynamically generates a rule engine based on reflection and specified properties-an expression tree is built for each property, compiled and added to a list of rules - this is generate but once for the lifetime of the instance. This is intended for use with a database migration testing engine.
Imports System.Reflection
Imports System.Linq.Expressions
''' <summary>
'''This generic class encapsulates the main algorithms for building a rule engine and a list of matched source/merge '''"rows"To prove whether a row in source and target are equivalent.
''' A property in the classes we may be using represent columns in a table or query.
'''Say we have an instance thus:
'''SourcePerson = New Person with {.Name = "ommitted db query",
''' .DOB =" ommitted db query"}
'''MergedPerson = New Person with {.Name = "ommitted db query",
''' .DOB =" ommitted db query"}
@adhipg
adhipg / countries.sql
Created January 12, 2012 11:41
Sql dump of all the Countries, Country Codes, Phone codes.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;