This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type internal AsyncCallableHandler(messageHandler) = | |
inherit DelegatingHandler(messageHandler) | |
member internal x.CallSendAsync(request, cancellationToken) = | |
base.SendAsync(request, cancellationToken) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyService : StatefulService | |
{ | |
private Task<IReliableDictionary<int, string>> AccountNames => StateManager.GetOrAddAsync<IReliableDictionary<int, string>>("AccountNames"); | |
private Task<IReliableDictionary<int, string>> AccountData => StateManager.GetOrAddAsync<IReliableDictionary<int, string>>("AccountData"); | |
public async Task<List<Account>> SearchAccountsByNameAsync(string name) | |
{ | |
using (var txn = StateManager.CreateTransaction()) | |
{ | |
var accountNames = await AccountNames; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<!-- #1 Place this line at the top of any msbuild script (ie, csproj, etc) --> | |
<PropertyGroup><PowerShell># 2>nul || type %~df0|find /v "setlocal"|find /v "errorlevel"|powershell.exe -noninteractive -& exit %errorlevel% || #</PowerShell></PropertyGroup> | |
<!-- #2 in any target you want to run a script --> | |
<Target Name="default" > | |
<PropertyGroup> <!-- #3 prefix your powershell script with the $(PowerShell) variable, then code as normal! --> | |
<myscript>$(PowerShell) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2015 Mårten Rånge | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This function generates ordered, base36 alpha-numeric ids similar to Slack's ID scheme. | |
-- | |
-- I wanted a primary key scheme that had the following features: | |
-- 1) Lexical order, so that `ORDER BY` works as expected. | |
-- 2) Prevents sampling an auto-incrementing primary key to determine growth over time. | |
-- 3) Shorter and more human-friendly than BIGINT and UUID keys. | |
-- 4) Has a prefix such that table can be inferred from any record's primary or foreign key. | |
-- | |
-- It is suitable for use as primary key, provided a few assumptions are true: | |
-- 1) You do not attempt to genereate more than 10M hids per second (system-time). |