Skip to content

Instantly share code, notes, and snippets.

@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 / 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)
{
}
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
namespace Headspring
{
[Serializable]
[DebuggerDisplay("{DisplayName} - {Value}")]
@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);
@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 / editcsproj.cs
Created March 6, 2016 21:51
Edit csproj file via C#
private static void AddFilesToUnitTestProject(FileInfo[] files, string measureBaseDirPath, string measureDataDirSuffix)
{
var unitTestProjectPath = measureBaseDirPath + _unitTestProjectFile;
var unitTestProjectFile = XDocument.Load(unitTestProjectPath);
var itemGroup = unitTestProjectFile.Nodes()
.OfType<XElement>()
.DescendantNodes()
.OfType<XElement>().First(xy => xy.Name.LocalName == "ItemGroup");
foreach (var fileInfo in files)
@Saanch
Saanch / gitcommands.sh
Created March 12, 2016 02:24
Git Commands
//To view the content of the commits
git cat-file -p SHA -p
//add tag
git tag -a $tagname$ -m "$tag message$"
@Saanch
Saanch / nuget-restore.cmd
Created March 29, 2016 02:07 — forked from FeodorFitsner/nuget-restore.cmd
Batch file to reliably restore nuget packages with retries
@echo off
rem initiate the retry number
set errorCode=1
set retryNumber=0
set maxRetries=3
:RESTORE
nuget restore %*
rem problem?
@Saanch
Saanch / gist:575928875f56d97da0e4b239ac508742
Created March 31, 2016 03:00
Sample HTML page with Twitter's Bootstrap, Ryan Fait's Sticky Footer, and a full-width footer
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="author" content="Martin Bean" />
<title>Twitter&rsquo;s Bootstrap with Ryan Fait&rsquo;s Sticky Footer</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<style>
html, body {
height: 100%;
@Saanch
Saanch / npmupdate.md
Last active March 31, 2016 05:20
To Update npm package withoput editing package.json file

To update one dependency to its lastest version without having to manually open the package.json and change it, you can run

npm install {package-name}@* {save flags?} i.e.

npm install express@* --save For reference, npm-install