Skip to content

Instantly share code, notes, and snippets.

Avatar

Ayende Rahien ayende

View GitHub Profile
View m5a.2xlarge.md

1 server

~/wrk2/wrk --latency -R 250 -d 3m -c 128 -t 4 -s getAnnotationsForUser_Paged.lua http://172.31.36.34:5000 Running 3m test @ http://172.31.36.34:5000 4 threads and 128 connections Thread calibration: mean lat.: 24.660ms, rate sampling interval: 10ms Thread calibration: mean lat.: 30.325ms, rate sampling interval: 10ms Thread calibration: mean lat.: 7.590ms, rate sampling interval: 10ms Thread calibration: mean lat.: 38.346ms, rate sampling interval: 13ms Thread Stats Avg Stdev Max +/- Stdev

View index.cs
AddMap<Company>(companies => from company in companies
select new
{
CompanyName = company.CompanyName,
UserCount = 0
CompanyId = company.Id
});
AddMap<User>(users => from user in users
from companyId in user.Companies
View index.cs
from o in docs.Orders
select new {
o.State,
o.CreatedAt
}
View anonymous.cs
var user = new
{
AcceptedEula = default(bool?), // set to null, mark the field as bool?
RegisteredAt = DateTime.Today, // set to today, the field is DateTime
Name = default(string), // set to null, mark the field as string
ActiveTasks = 0, // set to 0, the field is an int
};
View index.cs
from e in docs.Events
select new {
Registration = default(object)
}
View Products.Recommendations.cs
// map
from o in docs.Orders
from l in o.Lines
select new {
l.Product,
Related = o.Lines.Select(x=>x.Product)
.Where(x=>x!=l.Product)
.Select(x=>new { Count = 1, Product = x}),
Count = 1
}
View http.cs
try
{
result = await httpClient.Get("/update/status");
}
catch(HttpRequestException e)
{
// handle error
}
View http.cs
try
{
result = await httpClient.Get("/update/status");
}
catch(HttpRequestException e)
{
// handle error
}
View code.c
HANDLE file = CreateFileW((LPCWSTR)path,
GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL
);
View IdentifierMasking.cs
public class IdentifierMasking
{
private static byte[] _key;
public IdentifierMasking(byte[] key = null)
{
_key = key ?? Sodium.SecretBox.GenerateKey();
}
public string RevealIdentifier(string hidden)