Skip to content

Instantly share code, notes, and snippets.

View StringCompare.cs
void Main()
{
string firstEffectName = "Shot";
string secondEffectName = "Boom";
var sw = System.Diagnostics.Stopwatch.StartNew();
for(int i = 0; i< 1000000; i++)
{
var a = string.Compare(firstEffectName, secondEffectName, StringComparison.InvariantCultureIgnoreCase) == 0;
}
sw.Stop();
@trollsic
trollsic / ReplaceAppSettings.ps1
Created Mar 16, 2015
PowerShell script to replace appSettings values on the fly
View ReplaceAppSettings.ps1
Param
(
$configFilePath,
$configKey,
$configValue
)
if(Test-Path -Path $configFilePath -PathType Leaf)
{
[System.Xml.XmlDocument]$document = New-Object System.Xml.XmlDocument
@trollsic
trollsic / NancyExtensions.cs
Created May 25, 2014
LinqToQuerystring.Nancy Query Count for MongoDB queries (possible will work with EF queries)
View NancyExtensions.cs
using System.Collections.Generic;
using System.Linq;
using LinqToQuerystring;
namespace LinqToQuerystring.Nancy
{
public static class NancyExtensions
{
public static dynamic LinqToQuerystring<T>(this IQueryable<T> query, IDictionary<string, object> queryDictionary, bool forceDynamicProperties = false, int maxPageSize = -1)
{
View ko-convenience.js
(function (ko, handlers, unwrap, extend) {
"use strict";
extend(handlers, {
href: {
update: function (element, valueAccessor) {
handlers.attr.update(element, function () {
return { href: valueAccessor() };
});
}
},
@trollsic
trollsic / gist:9112291
Created Feb 20, 2014
Normalize and distribute Double remainders below 2 decimals after decimal point in list of objects
View gist:9112291
private void NormalizeFte(List<Estimation> estimations, List<BudgetLine> budgetLines)
{
double remainingSum = 0;
foreach (BudgetLine line in budgetLines)
{
NormalizeLineSmallRemainder(line, ref remainingSum);
}
}
private void NormalizeLineSmallRemainder(BudgetLine line, ref double remainingSum)