Skip to content

Instantly share code, notes, and snippets.

View hugodahl's full-sized avatar

Hugo Dahl hugodahl

View GitHub Profile
@hugodahl
hugodahl / JSONPBehavior.cs
Last active September 26, 2015 08:08
Adding JSONP Behavior support to WCF Data Services/OData
using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using System.Text;
using System.Xml;
//Gotten from sample project, located at: http://archive.msdn.microsoft.com/DataServicesJSONP
@hugodahl
hugodahl / gist:1427356
Created December 3, 2011 15:18
Error adding Corresponence.Model reference
Error 1 Running transformation: System.IO.FileNotFoundException: Could not find file 'C:\Projects\Correspondence.Tests\Correspondence.Tests\Model.fact'.
File name: 'C:\Projects\Correspondence.Tests\Correspondence.Tests\Model.fact'
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path)
at Microsoft.VisualStudio.TextTemplating406A29BF7AB941DD5E9410D83FFA55C8.GeneratedTextTransformation.TransformText() in c:\Projects\Correspondence.Tes
@hugodahl
hugodahl / gist:1607210
Created January 13, 2012 16:04
Visual Studio 2010 Dark Theme
<UserSettings>
<ApplicationIdentity version="10.0"/>
<ToolsOptions>
<ToolsOptionsCategory name="Environment" RegisteredName="Environment"/>
</ToolsOptions>
<Category name="Environment_Group" RegisteredName="Environment_Group">
<Category name="Environment_FontsAndColors" Category="{1EDA5DD4-927A-43a7-810E-7FD247D0DA1D}" Package="{DA9FB551-C724-11d0-AE1F-00A0C90FFFC3}" RegisteredName="Environment_FontsAndColors" PackageName="Visual Studio Environment Package">
<PropertyValue name="Version">2</PropertyValue>
<FontsAndColors Version="2.0">
<Categories>
// Disclaimer, was written in LINQpad, so may need a bit of tweaking on Main() to run in Visual Studio
// but the general idea is there. Can just call this Main() from VS's generated Main().
void Main()
{
// Returns an int, and we're happy
var x = GetCachedValue("Int", new object(), () => {return 1;});
Console.WriteLine(x);
// Returns a string, and it's all good still
@hugodahl
hugodahl / gist:30068c9d82259c3564d3
Created January 23, 2012 18:34
Make ignorable elements & attributes in Markup (XML/XAML/XSL/etc)
<BaseElement xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ignore="http://ignore.domain.com/ignore"
mc:Ignorable="ignore">
<Element attrib="value" ignore:attrib="ignored">Value</Element>
<ignore:Element attrib="value2" attrib2="fullyIgnored>Ignored Element</ignore:Element>
</BaseElement>
@hugodahl
hugodahl / app.cs
Created January 24, 2012 04:54
Constructor confusion
void Main()
{
var b = new B(1);
}
class A
{
protected A()
{
Console.WriteLine ("A()");
@echo off
rem
rem ****************************************************************************
rem
rem Copyright (c) Microsoft Corporation. All rights reserved.
rem This code is licensed under the Microsoft Public License.
rem THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
rem ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
rem IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
rem PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
@hugodahl
hugodahl / DateTimeSpan.cs
Created October 9, 2014 19:48
DateTimeSpan calculations (Timespan with more than minutes)
//From: http://stackoverflow.com/questions/4638993/difference-in-months-between-two-dates
public struct DateTimeSpan
{
private readonly int years;
private readonly int months;
private readonly int days;
private readonly int hours;
private readonly int minutes;
private readonly int seconds;
private readonly int milliseconds;
@hugodahl
hugodahl / BoxStarter.Work.txt
Last active September 18, 2018 19:43
Boxstarter Script for Work PCs
#Setup environment
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtensions -EnableShowFullPathInTitleBar -EnableShowProtectedOSFiles
Enable-RemoteDesktop
choco feature enable -n=allowGlobalConfirmation
choco feature enable -n=autoUninstaller
choco feature enable -n=failOnAutoUninstaller
choco feature enable -n=removePackageInformationOnUninstall
choco feature enable -n=useRememberedArgumentsForUpgrades

Keybase proof

I hereby claim:

  • I am hugodahl on github.
  • I am hugodahl (https://keybase.io/hugodahl) on keybase.
  • I have a public key ASA07txfeSK0w7UcMSL_3tZilJZze0Hp03PPPBZ456DvSQo

To claim this, I am signing this object: