Skip to content

Instantly share code, notes, and snippets.

View hagbarddenstore's full-sized avatar

Kim Johansson hagbarddenstore

View GitHub Profile
public abstract class Database
{
public Database(string connectionString)
{
ConnectionString = connectionString;
}
protected string ConnectionString { get; private set; }
public IEnumerable<IDictionary<string, object>> Query(string query, object parameters = null)
<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="ClearBinObjFolders">
<PropertyGroup>
<DirectoriesToClean>
src\tests\ProjectName\bin;
src\tests\ProjectName\obj;
</DirectoriesToClean>
</PropertyGroup>
<RemoveDir Directories="$(DirectoriesToClean)" />
void Main()
{
var root = new FamilyItem
{
Name = "A",
FamilyItems = new List<FamilyItem>
{
new FamilyItem
{
Name = "B",
public void Update()
{
try
{
var user = db.Users.SingleOrDefault(x => x.UserId == userId);
if (user == null)
{
throw new UserNotFoundException(userId);
}
var allServices = new Dictionary<string, string[]>
{
{ "6.3", new[] { "Appmgmt", "bthserv", "PeerDistSvc", "NfsClnt", "TrkWks", "WPCSvc",
"vmickvpexchange", "vmicguestinterface", "vmicshutdown", "vmicheartbeat",
"vmicrdv", "vmictimesync", "vmicvss", "IEEtwCollectorService", "iphlpsvc",
"Netlogon", "Netlogon", "CscService", "RpcLocator", "MSiSCSI", "SensrSvc",
"ScDeviceEnum", "SCPolicySvc", "SNMPTRAP", "StorSvc", "WbioSrvc",
"wcncsvc", "fsvc", "WMPNetworkSvc" } },
{ "6.2", new[] { "WMPNetworkSvc", "wcncsvc", "WbioSrvc", "StorSvc", "SNMPTRAP",
"SCPolicySvc", "SensrSvc", "RpcLocator", "CscService", "Netlogon", "MSiSCSI",
@hagbarddenstore
hagbarddenstore / Example.csproj
Last active August 29, 2015 14:01
Performs config transformations on build in Visual Studio while keeping compatibility with OctoDeploy which performs config transformations on release.
<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<Target Name="BeforeBuild" Condition="$(BuildingInsideVisualStudio)">
<Move SourceFiles="App.config" DestinationFiles="App.Base.config" />
<TransformXml Source="App.Base.config" Transform="App.$(Configuration).config" Destination="App.config" />
</Target>
<Target Name="AfterBuild" Condition="$(BuildingInsideVisualStudio)">
<Move SourceFiles="App.Base.config" DestinationFiles="App.config" />
@hagbarddenstore
hagbarddenstore / JingleBells.txt
Created May 6, 2014 06:49
A RouterOS script which plays Jingle Bells.
:beep frequency=659 length=150ms
:delay 300ms;
:beep frequency=659 length=150ms
:delay 300ms;
:beep frequency=659 length=300ms
:delay 600ms;
:beep frequency=659 length=150ms
:delay 300ms;
:beep frequency=659 length=150ms
:delay 300ms;
@hagbarddenstore
hagbarddenstore / ImperialMarch.txt
Created May 6, 2014 06:48
A RouterOS script which plays the Imperial March.
:beep frequency=500 length=500ms;
:delay 500ms;
:beep frequency=500 length=500ms;
:delay 500ms;
:beep frequency=500 length=500ms;
:delay 500ms;
:beep frequency=400 length=500ms;
<Project>
<ItemGroup>
<Compile Include="$(OutputPath)\MyFile.cs">
<Link>MyFile.cs</Link>
</Compile>
</ItemGroup>
</Project>
@hagbarddenstore
hagbarddenstore / StructureMapDependencyResolver.cs
Created April 2, 2014 07:48
An implementation of the System.Web.Mvc.IDependencyResolver interface with StructureMap.
namespace Hagbarddenstore.Mvc
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using StructureMap;
/// <summary>