Skip to content

Instantly share code, notes, and snippets.

public class AzureFriendlyReplicationInformer : ReplicationInformer
{
public AzureFriendlyReplicationInformer(DocumentConvention conventions)
: base(conventions)
{
}
public override bool ShouldExecuteUsing(string operationUrl, int currentRequest, string method, bool primary)
{
if (primary == false)
@hyrmn
hyrmn / PatchThing.cs
Created May 11, 2015 02:41
Batch patching with Raven 2.5
var patchCommands = new List<ScriptedPatchCommandData>();
foreach (var relatedDocument in relatedDocuments)
{
var photo = new Photo
{
Url = imageMetadata.Id,
Title = imageMetadata.Title,
Description = imageMetadata.Description,
SortOrder = relatedDocument.Value,
};
public class ReservationLetterTransformer : AbstractTransformerCreationTask<Reservation>
{
public ReservationLetterTransformer()
{
TransformResults = reservations => from res in reservations
let person = LoadDocument<Person>(res.PrimaryPersonId)
let members = LoadDocument<Person>(res.Group.MemberPersonIds)
let assignments = LoadDocument<ReservationUnitAssignment>(res.UnitAssignmentIds)
let units = LoadDocument<Unit>(assignments.Select(assign => assign.UnitId).Distinct())
let invoices = LoadDocument<Invoice>(res.InvoiceIds)
@hyrmn
hyrmn / HowWeReallyWriteForLoopsNow.cs
Last active August 29, 2015 14:25
Goal: In C#, convert a string to lower case. e.g. "TEST STRING" becomes "test string"
internal class Program
{
private static void Main()
{
var s = "TEST STRING";
var lower = s.Aggregate(string.Empty, (current, c) => current + char.ToLower(c));
Debug.Assert(lower == "test string");
}
}
public static class AzureConManagerSqlPersistenceWireupExtensions
{
public static SqlPersistenceWireup UseInAzureConfiguredSqlPersistence(this Wireup wireup, string connectionName)
{
var factory = new AzureConfigurationConnectionFactory(connectionName);
return new SqlPersistenceWireup(wireup, factory);
}
}
public class AzureConfigurationConnectionFactory : ConfigurationConnectionFactory
using System;
using System.Collections.Generic;
namespace ConsoleApplication28
{
internal class Program
{
public delegate bool GetNum(string prompt, out int val);
private static readonly Dictionary<GuessAnswerKey, Func<int, string>> answerMap = new Dictionary
#<localhost>
127.0.0.1 localhost
127.0.0.1 localhost.localdomain
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 local
127.0.0.1 goatse.cx # More information on sites such as
127.0.0.1 www.goatse.cx # these can be found in this article
127.0.0.1 oralse.cx # en.wikipedia.org/wiki/List_of_shock_sites
127.0.0.1 www.oralse.cx
public static class IDocumentSessionExtensions
{
private static readonly Policy RetryPolicy = Policy
.Handle<WebException>(ex => TransientErrors.Contains(ex.Status))
.WaitAndRetry(new[]
{
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(2),
TimeSpan.FromSeconds(3)
});
function prompt
{
$(get-location) + "> "
}
function Get-Batchfile ($file) {
$cmd = "`"$file`" & set"
cmd /c $cmd | Foreach-Object {
$p, $v = $_.split('=')
Set-Item -path env:$p -value $v
public class Office
{
public string Id { get; set; }
public string CompanyName { get; set; }
}
public class OfficeIndex : AbstractIndexCreationTask<Office>
{
public OfficeIndex()
{