Skip to content

Instantly share code, notes, and snippets.

View bricelam's full-sized avatar

Brice Lambson bricelam

View GitHub Profile
@bricelam
bricelam / gist:5878021
Last active December 21, 2020 12:02
Normalize line endings using C#
var dir = @"C:\Projects\EntityFramework";
var buffer2 = new char[1];
var buffer1 = new byte[3];
var bom = new byte[] { 0xEF, 0xBB, 0xBF };
foreach (var file in Directory.EnumerateFiles(dir, "*", SearchOption.AllDirectories))
{
if (file.Contains(@".git\")
|| file.Contains(@".vs\"))
continue;
@bricelam
bricelam / RemoveInternalDocComments.cs
Created January 28, 2014 18:20
Roslyn syntax rewriter to remove internal doc comments
namespace RemoveInternalDocComments
{
using System;
using System.IO;
using System.Linq;
using Roslyn.Compilers.CSharp;
class Program
{
static void Main()
@bricelam
bricelam / ConsoleTheme.reg
Last active August 29, 2015 14:03
A Command Prompt Theme
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Console]
"ColorTable00"=dword:00000000
"ColorTable01"=dword:00aa0000
"ColorTable02"=dword:0000aa00
"ColorTable03"=dword:00aaaa00
"ColorTable04"=dword:000000aa
"ColorTable05"=dword:00aa00aa
"ColorTable06"=dword:000055aa
@bricelam
bricelam / LoadEdmx.cs
Created July 16, 2014 16:14
Load an *.edmx file
MetadataWorkspace LoadEdmx(string path)
{
var runtime = XElement.Load(path).Elements().First(e => e.Name.LocalName == "Runtime");
EdmItemCollection edmCollection;
var csdl = runtime.Elements().First(e => e.Name.LocalName == "ConceptualModels")
.Elements().First(e => e.Name.LocalName == "Schema");
using (var reader = csdl.CreateReader())
{
edmCollection = new EdmItemCollection(new[] { reader });
@bricelam
bricelam / Unsize.reg
Created August 4, 2014 22:32
Reset various application windows to their default size
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\MediaPlayer\Preferences]
"XV11"=-
"YV11"=-
"WidthV11"=-
"HeightV11"=-
[HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Office Explorer]
"Frame"=-
@bricelam
bricelam / Merge-Tokens.ps1
Created August 8, 2014 01:21
A simple token-replacement template engine for PowerShell
function Merge-Tokens($template, $tokens)
{
return [regex]::Replace(
$template,
'\$(?<tokenName>\w+)\$',
{
param($match)
$tokenName = $match.Groups['tokenName'].Value
@bricelam
bricelam / .gitconfig
Last active January 7, 2020 16:58
Git Configuration
[user]
name = Brice Lambson
email = brice@bricelam.net
[alias]
logg = log --graph -35
[commit]
gpgsign = true
[core]
editor = notepad
pager = less -E
[WinMerge]
Backup/EnableFile=0
DefaultSyntaxColors/Bold07=0
Font/FaceName=Consolas
Font/OutPrecision=3
Font/Specified=1
Merge7z/ProbeSignature=1
Settings/AllowMixedEOL=1
Settings/AutomaticRescan=1
Settings/BreakOnWords=0
[Notepad2]
[Settings]
TabWidth=4
MarkLongLines=1
LongLinesLimit=120
ShowLineNumbers=0
FileWatchingMode=2
ResetFileWatching=0
ShowToolbar=0
@bricelam
bricelam / ParallelEx.cs
Last active August 29, 2015 14:22
ForEachAsync
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
class ParallelEx
{
public static Task ForEachAsync<TSource>(
IEnumerable<TSource> source,