Skip to content

Instantly share code, notes, and snippets.

@Saanch
Saanch / npmregistry.md
Last active March 6, 2016 08:05
Publishing to npm registry

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "[email protected]"
npm set init.author.url "http://yourblog.com"

npm adduser

Then create a package.json and publish it:

@Saanch
Saanch / ToCamelCase.cs
Created March 4, 2016 11:07
convert snake_case to camelCase in c#
"foo_bar".Split(new[] { "_" }, StringSplitOptions.RemoveEmptyEntries).Select(s => char.ToUpperInvariant(s[0]) + s.Substring(1, s.Length - 1)).Aggregate(string.Empty, (s1, s2) => s1 + s2);
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
namespace Headspring
{
[Serializable]
[DebuggerDisplay("{DisplayName} - {Value}")]
@Saanch
Saanch / structuremap.owin
Created July 16, 2015 01:41
structuremap OWIN middleware to handle the container per owin context
StructureMapOWINMiddleware in remplacement of the IHttpModule :
//basic draft
public class StructureMapOWINMiddleware : OwinMiddleware
{
public StructureMapOWINMiddleware(OwinMiddleware next)
: base(next)
{
}
@Saanch
Saanch / newguid
Created April 15, 2015 04:09
Generate GUID at SQL Server side
DECLARE @myid uniqueidentifier
SET @myid = NEWID()
PRINT 'Value of @myid is: '+ CONVERT(varchar(255), @myid)
@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])
public class BootstrapService : ServiceControl
{
private readonly HostSettings _settings;
private Container _container;
private CaseMonitor _monitor;
public BootstrapService(HostSettings settings)
{
_settings = settings;
}
@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;
@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 / 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: