Skip to content

Instantly share code, notes, and snippets.

// Original code by Joachim Lykke Andersen; http://devtalk.dk/2011/02/16/Workaround+EF+Code+First+On+AppHabour.aspx
using System.Data.Entity;
using System.Data.Entity.Database;
using System.Data.Entity.Design;
using System.Data.Entity.Infrastructure;
using System.Data.Metadata.Edm;
using System.Data.Objects;
using System.Globalization;
using System.Linq;
@Saanch
Saanch / StructureMapJobFactory.cs
Last active December 6, 2018 11:27
StructureMapJobFactory Quartz.net IoC using StructureMap
public class StructureMapJobFactory : IJobFactory
{
private static readonly ILog Logger = LogProvider.GetCurrentClassLogger();
private readonly IContainer _container;
public StructureMapJobFactory(IContainer container)
{
this._container = container;
}
[color]
branch = auto
interactive = auto
diff = auto
status = auto
[user]
name = ####
email = ######
[remote "origin"]
receivepack = git receive-pack
@Saanch
Saanch / windowsservice_install.md
Created November 22, 2014 06:01
Windows service install steps
  1. Move to the dotnet framework path cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319
  2. Get the service path C:\Services\XXXX.exe
  3. Run command InstallUtil.exe C:\Services\XXXX.exe
@Saanch
Saanch / ConsoleWriter.cs
Last active August 29, 2015 14:10
Console Writer
public static void Info(string message, params object[] args)
{
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine(message, args);
Console.ResetColor();
}
public static void Debug(string message, params object[] args)
{
Console.ForegroundColor = ConsoleColor.Yellow;
@Saanch
Saanch / pr.md
Last active August 29, 2015 14:10 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@Saanch
Saanch / .README.md
Last active August 29, 2015 14:10 — forked from gnarf/..git-pr.md

Install

Either copy the aliases from the .gitconfig or run the commands in add-pr-alias.sh

Usage

Easily checkout local copies of pull requests from GitHub remotes:

  • git pr 4 - creates local branch pr/4 from the origin remote and checks it out
  • git pr 4 upstream - creates local branch pr/4 from upstream remote and checks it out
@Saanch
Saanch / ConfigReload.cs
Created December 3, 2014 11:44
Updating config value from the db at application initialization
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
IDictionary<string, string> staticAppSettings = ConfigService.GetStaticAppSettings();
foreach (var setting in staticAppSettings)
{
if (ConfigurationManager.AppSettings[setting.Key] == null)
config.AppSettings.Settings.Add(setting.Key, setting.Value);
else
ConfigurationManager.AppSettings[setting.Key] = setting.Value;
public class BootstrapService : ServiceControl
{
private readonly HostSettings _settings;
private Container _container;
private CaseMonitor _monitor;
public BootstrapService(HostSettings settings)
{
_settings = settings;
}
@Saanch
Saanch / MsSQL_Duplicate_Removal.sql
Created April 9, 2015 01:29
MSSQL Query to delete duplicate rows from a TABLE leaving the first occurance
DELETE FROM [tableName] WHERE [UniqueId] NOT IN
(SELECT Min([UniqueId]) FROM [tableName] GROUP BY [fieldName])