Skip to content

Instantly share code, notes, and snippets.

@cybermaxs
cybermaxs / NinjectWebCommon.cs
Created September 24, 2013 12:00
Measure and report performance of asp.net MVC Action Filters using asp.net MiniProfiler. Warning : default namespace is MyApp
[assembly: WebActivator.PreApplicationStartMethod(typeof(MyApp.App_Start.NinjectWebCommon), "Start")]
[assembly: WebActivator.ApplicationShutdownMethodAttribute(typeof(MyApp.App_Start.NinjectWebCommon), "Stop")]
// please add a reference to NInject.MVC3
namespace MyApp.App_Start
{
using System;
using System.Web;
using System.Web.Mvc;
@cybermaxs
cybermaxs / loadspeedv2.js
Created September 8, 2014 11:29
Compares page load time between HTML5 Navigation timings and basic computation using Date.now() (examples/loadspeed.js). Requires PhantomJS 2.0
var page = require('webpage').create(),
system = require('system'),
t, address;
if (system.args.length === 1) {
console.log('Usage: loadspeedv2.js <some URL>');
phantom.exit(1);
} else {
t = Date.now();
address = system.args[1];
@cybermaxs
cybermaxs / Benckmark.cs
Last active August 29, 2015 14:07
Yet another fast Enum.ToString() Implementation. Read explanations http://cybermaxs.wordpress.com/2014/10/03/the-importance-of-useless-micro-optimization/
using Ideafixxxer.Generics;
using System;
using System.Diagnostics;
using System.Text;
namespace EnumBenchmarks
{
public enum MyEnum
{
Undefined = 0,
using System;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
namespace RegexOptims
{
public static class RegexComparer
{
private const string REGEX_PATTERN = @"^[\w\d]+$";
@cybermaxs
cybermaxs / Statup.cs
Created December 19, 2014 11:23
Batch requests experiments in Web Api. Like the async & parallel processing on server-side
using Owin;
using System.Web.Http;
using System.Web.Http.Batch;
namespace BatchRequestDemo
{
public class Startup
{
// This code configures Web API. The Startup class is specified as a type
// parameter in the WebApp.Start method.
@cybermaxs
cybermaxs / DateTimeExtensions.cs
Created April 28, 2015 15:59
Yet another C# datetime extensions to convert DateTime to Unix timestamps.
using System;
namespace MyExtensions
{
public static class DateTimeExtensions
{
public const long EpochTicks = 621355968000000000;
public const long TicksPeriod = 10000000;
public const long TicksPeriodMs = 10000;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace Syntheticks.Tests.Designs
{
public class DataPoint : TableEntity
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace Syntheticks.Tests.Designs
{
public class TimeSeries_AdvancedDesign
@cybermaxs
cybermaxs / PerfStatsExtensions.cs
Created June 4, 2015 08:57
Extension methods for performance statistics (avg, median, centiles)
using System;
using System.Linq;
namespace MyNamespace
{
public static class PerfStatsExtensions
{
public static double? Avg(this double[] values)
{
if (values == null) return null;
@cybermaxs
cybermaxs / cleanup.ps1
Last active August 29, 2015 14:28
Clean up your .net solutions folders with powershell. Delete bin, obj, packages and TestResults
Write-Host "Deleting bin, obj, packages,TestResults folders ..." -nonewline
Get-ChildItem -inc bin,obj,TestResults,packages -rec | Remove-Item -rec -force
Write-Host "Done" -ForegroundColor Yellow