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
/// T4 file to generate some basic methods for a datalayer class. I like to keep Entity Framework inside of the Datalayer only and leave a fairly simple set of methods exposed outside of it. | |
///Works with my Generic save class | |
<#@ template language="C#" debug="false" hostspecific="true" compilerOptions="/langversion:6" #> | |
<#@ assembly name="System.Data.Entity" #> | |
<#@ assembly name="System.Data.Entity.Design" #> | |
<#@ import namespace="System.Text.RegularExpressions" #> | |
<#@ include file="EF6.Utility.CS.ttinclude"#> | |
<#@ import namespace="System.Data.Entity.Design" #> | |
<#@ import namespace="System.Data.Entity.Design.PluralizationServices" #> |
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
///Generic Save class for use in the Datalayer where I'm reluctant to couple the Model layer to EF! | |
///Please see the T4 generator for creating files that work with this. | |
namespace DataLayer.Data | |
{ | |
public class GenericSave<T> where T : ICrud | |
{ | |
public static T Update(T item) | |
{ |
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
'''I work with a lot of legacy projects that use Linq to Sql and a DBML file. They are typically one layer that I turn into two layers. | |
'''As they are large winforms projects that are in daily use in business systems, there isn't a need to force the project into the latest | |
'''architectural trends - whether that be moving to WPF or migrating to Entity Framework. | |
'''Instead I have this generic central class for the datalayer merely to centralise where ALL the context work happens. | |
'''Then using a mix of T4 templates, reflection and old fashioned code generation (in LinqPad!), I'll generate all the gruntwork classes. | |
'''In the same move, basic tests can be generated. | |
'''This allows me to have a win-win scenario in such projects - either A)I've centralised the logic for the database access, context lifetime and thus | |
'''left myself with a reasonable to maintain datalayer class. | |
'''Or B)I've made it far simpler to work through the Winforms layer and make decisions on whether to migrate stuff to WPF or something |
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
//Might be the world's simplest HTML page generator, however, I got fedup of tracking all the markup I needed to make one of my typical pages. | |
let NL = System.Environment.NewLine | |
let Tab = " " | |
[<Literal>] | |
let head = """<!--Template for blog --> | |
<!DOCTYPE html5> | |
<html> | |
<head> |
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
//By Daniel Fabian | |
open FSharp.InteropServices.Dynamic | |
let user32 = Library("user32.dll") | |
(user32?MessageBox(0, "Hello world", "MyTitle", 0) : unit) | |
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
<script> | |
//Day 2 learning Javascript | |
//Very simple evaluation of a power rule - note, it's NOT a true evaluation: you can't check the answer correctly in the code this way. | |
function Calculation(){ | |
let base = Math.floor((Math.random() * 100) + 1); | |
let exp = Math.floor((Math.random() * 20) + 1); | |
this.printQuestion = function(){ | |
let calcString = `$$f(x)=${base}x^{${exp}}$$`; | |
document.writeln(calcString); | |
}; |
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
//The flakes need to be a stream. Remember to dispose bitmaps :) | |
let bitmapSave (bitmap :Bitmap) = | |
let stream = new System.IO.MemoryStream() | |
bitmap.Save(stream, Imaging.ImageFormat.Png) | |
bitmap.Dispose() | |
stream.Position <- 0L | |
stream | |
//we need a graphics object to draw with and a bitmap to save onto. | |
//Return a tuple of graphics with its associated bitmmap |
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 "WriteableBitmapEx.Wpf.dll" // requires custom version with DrawString | |
//Email me if you want the custom dll - if I haven't already dumped it on Github! | |
module flake | |
open System | |
open System.Windows | |
open System.Windows.Controls | |
open System.Windows.Media | |
open System.Windows.Media.Imaging | |
open System.Windows.Threading |
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
let computeShader = | |
let code = @" | |
RWTexture2D<float4> Output; | |
[numthreads(32, 32, 1)] | |
void main( uint3 threadID : SV_DispatchThreadID ) | |
{ | |
for (int i = 1.0f; i <= 1280.0f; i+=320.0f){ | |
Output[threadID.xy] = float4(threadID.xy / i, 0, 1); | |
} |
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 SlimDX | |
open SlimDX.D3DCompiler | |
open SlimDX.Direct3D11 | |
open SlimDX.Windows | |
open SlimDX.DXGI | |
open System.Windows.Forms | |
open System.Drawing | |
[<EntryPoint>] | |
let main args = | |
let form = new RenderForm("Test Window") |