Skip to content

Instantly share code, notes, and snippets.

View akimboyko's full-sized avatar
🙃

Akim Boyko akimboyko

🙃
View GitHub Profile
@robertmilne
robertmilne / ProfiledSql2008ClientDriver.cs
Created July 27, 2011 19:20
MiniProfiler: NHibernate profiling with batching support
using System.Data;
using System.Data.Common;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Proxies;
using MvcMiniProfiler;
using MvcMiniProfiler.Data;
using NHibernate.Driver;
namespace YourNamespaceHere
{
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using FluentAssertions;
using NUnit.Framework;
using Nancy.Helpers;
namespace NancySelfHosting
@jboner
jboner / latency.txt
Last active April 25, 2024 01:18
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 24, 2024 12:19
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@alexbeletsky
alexbeletsky / Feedback.js
Created December 18, 2012 19:07
Backbone.View done with TDD
var Feedback = Backbone.Model.extend({
url: '/feedback',
validate: function (attrs) {
var errors = [];
if (!attrs.email || attrs.email === '') {
errors.push({name: 'email', message: 'Please fill email field.'});
}
@skalinets
skalinets / AutoNSubstituteDemo.cs
Last active February 29, 2024 02:46
AutoFixture + NSubstitute Demo
using NSubstitute;
using Ploeh.AutoFixture;
using Ploeh.AutoFixture.AutoNSubstitute;
using Ploeh.AutoFixture.Xunit;
using Xunit.Extensions;
namespace AutofixtureDemo
{
public class AutoNSubstituteDemo
{
@vansha
vansha / DapperQueryHierarchy.cs
Created February 24, 2013 21:25
Querying complex object hierarchies with dapper.
public class Order {
public int Id { get; set; }
public DateTime OrderedAt { get; set }
public IList<OrderLine> OrderLines { get; set }
public Person Customer { get; set }
}
public class OrderLine {
public int Id { get; set; }
public int Count { get; set; }
using System;
using System.IO;
using System.Web.Http;
using System.Web.Http.SelfHost;
var address = "http://localhost:8080";
var conf = new HttpSelfHostConfiguration(new Uri(address));
conf.Routes.MapHttpRoute(name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
@glennblock
glennblock / app.csx
Created March 10, 2013 00:02
Nancy scriptcs sample
using System;
using System.Collections.Generic;
using Autofac;
using Nancy;
using Nancy.Bootstrapper;
using Nancy.Bootstrappers.Autofac;
using Nancy.Hosting.Self;
using Nancy.Routing;
public class Bootstrapper : AutofacNancyBootstrapper
@mausch
mausch / CSharpIterator.cs
Last active December 15, 2015 09:49
Anonymous iterators in C# with Ix
var hello = "";
var enumerable =
EnumerableEx.Create<int>(async Yield => {
await Yield.Return(100);
await Yield.Return(200);
hello = "hello world";
await Yield.Return(300);
});
Console.WriteLine(enumerable.ElementAt(1)); // 200
Console.WriteLine(hello); // empty