Skip to content

Instantly share code, notes, and snippets.

View ayende's full-sized avatar

Ayende Rahien ayende

View GitHub Profile
using System;
using System.Linq;
using Raven.Abstractions.Indexing;
using Raven.Client;
using Raven.Client.Indexes;
using Xunit;
namespace Raven.Tests.MailingList
{
public class NullableIssue : RavenTest
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Controllers;
using Raven.Client;
using Raven.Client.Document;
namespace Webinars.Controllers
@ayende
ayende / test.cpp
Created March 26, 2013 21:24
Two code samples showing differences between shift operators in C# & C++ Any idea why?
uint32_t x = 25426435u;
std::cout << x << std::endl;
uint32_t a = (x >> 17);
uint32_t b = (x << 15);
std::cout <<a << " " << b << " " << (a | b) << std::endl;
//OUTPUT:
// 25426435
// 193 4244733952 4244734145
using System;
using System.Linq;
using Raven.Abstractions.Smuggler;
using Raven.Client.Indexes;
using Raven.Database.Smuggler;
using Raven.Tests.Helpers;
using Xunit;
namespace RavenTests
{
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
public class ProperlyFlushFileStream : FileStream
{
[DllImport("kernel32.dll")]
static extern bool FlushFileBuffers(IntPtr hFile);
public void FSync()
{
base.Flush(false);
if(!FlushFileBuffers(SafeFileHandle))
@ayende
ayende / Program.cs
Last active December 28, 2015 11:49
Reproducing a crazy issue with memory mapped files and unbufferred writes in Win32 API
using System;
using System.ComponentModel;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Win32.SafeHandles;
namespace ConsoleApplication3
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace Voron.Util
{
public class LinkedDictionary<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>
where TValue : class, new()
{
private readonly TValue _deleteMarker = new TValue();
using System;
using System.Collections.Generic;
using System.Linq;
namespace Voron.Util
{
/// <summary>
/// A list that can be used by readers as a true immutable read-only list
/// and that supports relatively efficient "append to the end" and "remove
/// from the front" operations, by sharing the underlying array whenever
@ayende
ayende / ExternalSorter.cs
Created December 23, 2013 06:14
A single file that implements an external sorter
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;