Skip to content

Instantly share code, notes, and snippets.

View b0urb4k1's full-sized avatar
🐮
Shaving Yaks

Nicolas Bourbaki b0urb4k1

🐮
Shaving Yaks
View GitHub Profile
public static class WinErrors
{
#region definitions
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr LocalFree(IntPtr hMem);
[DllImport("kernel32.dll", SetLastError = true)]
static extern int FormatMessage(FormatMessageFlags dwFlags, IntPtr lpSource, uint dwMessageId, uint dwLanguageId, ref IntPtr lpBuffer, uint nSize, IntPtr Arguments);
[Flags]
@b0urb4k1
b0urb4k1 / ReadingPortableExecutable_PE_header.cs
Created January 8, 2018 12:09 — forked from augustoproiete/ReadingPortableExecutable_PE_header.cs
Reading the Portable Executable (PE) header in C#
// Credits: John Stewien
// From: http://code.cheesydesign.com/?p=572
/*
Reading the Portable Executable (PE) header in C#
My job consists of writing fully custom applications for groups of people. The time pressure of these projects is quite high, so generally people start using the application while I’m still writing it, which means I write it modularly and add features as I go along. I also fix bugs as they are discovered. My clients are 2 tiered where expert users get a new build first, they test if for a while, and if they think it’s acceptable they then pass it on to others.
This method of distribution is quite ad-hoc so when a client rings me up and asks me to view their screen to look at something, it’s useful to know what build they are running. To facillitate this I print the link date in the main Window Title so I instantly have an idea about how old the version is that I am looking at. This date is calculated at run time. To do this requires reading in the Portable Executable (PE) header from th
@b0urb4k1
b0urb4k1 / links
Last active November 4, 2017 11:11
State of the .NET Performance - Adam Sitnik
https://www.youtube.com/watch?v=CSPSvBeqJ9c&index=142&list=PL03Lrmd9CiGewi0lbnahxEpisoP5WZocX
http://adamsitnik.com/
https://github.com/dotnet/BenchmarkDotNet
https://www.nuget.org/packages/System.Runtime.CompilerServices.Unsafe/4.4.0-preview2-25405-01
https://www.nuget.org/packages/System.Memory/4.4.0-preview2-25405-01
https://www.nuget.org/packages/System.Buffers/4.4.0-preview2-25405-01
type Directory =
| Directory of string * string list * Directory list
let getFiles (Directory _, files, _) =
files
let getDirectories (Directory _, _, directories) =
directories
let rec private _pathToTree (path : string) =
let split = path.Split ([|'/'|], 2)
let headSplit = Array.head split
// This code is inspired from the Gallio project and modified a bit to suit our needs better.
// Copyright 2005-2010 Gallio Project - http://www.gallio.org/
// Portions Copyright 2000-2004 Jonathan de Halleux
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
#r "./packages/FSharp.Control.Reactive/lib/net45/FSharp.Control.Reactive.dll"
#r "./packages/System.Reactive.Interfaces/lib/net45/System.Reactive.Interfaces.dll"
#r "./packages/System.Reactive.Linq/lib/net45/System.Reactive.Linq.dll"
#r "./packages/System.Reactive.Core/lib/net45/System.Reactive.Core.dll"
open System
open System.Windows.Forms
open System.Drawing
open FSharp.Control.Reactive
open System
type TurtleProgram<'a> =
| Stop of 'a
| PenUp of TurtleProgram<'a>
| PenDown of TurtleProgram<'a>
let returnT x =
Stop x
open System
open System.Text.RegularExpressions
open System.IO
open System.Collections.Generic
type ProjectType =
| Folder
| CSharp
| CPP
| Unknown