Skip to content

Instantly share code, notes, and snippets.

View ayende's full-sized avatar

Ayende Rahien ayende

View GitHub Profile
class Program
{
static void Main(string[] args)
{
Sync();
Async().Wait();
}
const int len = 1024 * 16;
static void Proxy()
{
var tcpListener = new TcpListener(IPAddress.Loopback, 9000);
tcpListener.Start();
var buffer = new byte[1024];
while (true)
{
var incomingConnection = tcpListener.AcceptTcpClient();
var tcpClient = new TcpClient();
tcpClient.Connect(IPAddress.Loopback, 9999);
dotnet test -xml test-timings.xml
[xml]$tests = Get-Content test-timings.xml
$tests.assemblies.assembly.collection.test |
sort @{e={$_.time -as [double]} } -descending |
select time, name -first 10
#define _GNU_SOURCE
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <malloc.h>
#include <sys/uio.h>
#include <sys/file.h>
#include <unistd.h>
#include "stdafx.h"
#include <Windows.h>
#define FILE_SIZE (1024 * 1024 * 1024L)
#define CHUNK_SIZE (16 * 1024)
void simulate_journal_writes(HANDLE file, char* desc, int use_fsync)
{
public async Task WatchDocuments(TcpClient client)
{
try
{
using (client)
using (var stream = client.GetStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
{
var idToWatch = await reader.ReadLineAsync();
public async Task WatchDocuments(TcpClient client)
{
try
{
using (client)
using (var stream = client.GetStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
{
public static class TimeoutManager
{
private static TaskCompletionSource<object> _nextTimeout = new TaskCompletionSource<object>();
private static Timer _timer;
static TimeoutManager()
{
_timer = new Timer(TimerCallback, null, 1000, 1000);
}
var orders = store.Subscriptions.Open<Order>(ordersSubscription, new SubscriptionConnectionOptions());
orders.Subscribe(order =>
{
GenerateInvoice(order);
});
orders.Subscribe(order =>
{
if(order.State == OrderState.Invalid)
@ayende
ayende / tcp-race.cs
Last active November 27, 2018 02:36
class Program
{
private static TcpListener _listener;
private static readonly byte[] ShortMessageBuffer = Encoding.UTF8.GetBytes("Hello\r\n");
private static readonly byte[] LongMessageBuffer = Encoding.UTF8.GetBytes("Be my friend, please?\r\n");
static readonly byte[] HeartbeatBuffer = Encoding.UTF8.GetBytes("\r\n");
static void Main()
{
_listener = new TcpListener(IPAddress.Loopback, 9090);