Skip to content

Instantly share code, notes, and snippets.

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 March 16, 2015 18:35
PowerShell script to replace appSettings values on the fly
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 14:36
LinqToQuerystring.Nancy Query Count for MongoDB queries (possible will work with EF queries)
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)
{
(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 February 20, 2014 12:19
Normalize and distribute Double remainders below 2 decimals after decimal point in list of objects
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)