Skip to content

Instantly share code, notes, and snippets.

--------------------------------------------------------------------------------
-- Multi HINCRBY via a LUA script
-- Increments a list of fields in a hash stored at key.
-- KEYS : key of the hash
-- ARGS : list of field/increment
-- Note : Because a script is executed in an atomic way, you should always use this script to increment fields values.
-- ex via cli : redis-cli --eval hmincr.lua myhash , 1 10 2 20
--------------------------------------------------------------------------------
-- gets multiple fields from a redis hash as a dictionary
@cybermaxs
cybermaxs / CustomServiceHost.cs
Last active April 21, 2016 15:55
an attempt to StructureMap4 and nested containers in WCF
using StructureMap;
using System;
using System.ServiceModel;
namespace MyWcfService.Classes
{
public class CustomServiceHost : ServiceHost
{
public CustomServiceHost(IContainer container, Type serviceType, params Uri[] baseAddresses)
: base(serviceType, baseAddresses)
@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2024 17:56
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@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
@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;
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
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
@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;
@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.
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]+$";