Skip to content

Instantly share code, notes, and snippets.

Ayende Rahien ayende

View GitHub Profile
View parallel.cs
public class TestItem
{
public long A, B;
}
public static class Program
{
public static async Task Main(string[] args)
{
using (var store = new DocumentStore
View writes.cs
public class TestItem
{
public long A, B;
}
public static class Program
{
public static async Task Main(string[] args)
{
View store.init.cs
store.Certificate = new X509Certificate( Convert.FromBase64String( certificateString ) );
View http.cs
static HttpClient client = new HttpClient{ BaseAddres = "http://api.server.url/" };
static async Task<Product> GetProductAsync(string id)
{
Product product = null;
HttpResponseMessage response = await client.GetAsync( $"api/products/{id}");
if (response.IsSuccessStatusCode)
{
product = await response.Content.ReadAsAsync<Product>();
}
View gist:7fbbb32219ee1d4860bb8f2e8b9d724b
// sample showing that we need a way to handle the server not responding to some of the request
// separately from the overall time of the request
var server = new TcpListener(IPAddress.Any, 888);
server.Start();
server.AcceptTcpClientAsync().ContinueWith(x =>
{
var s = x.Result.GetStream();
View cadilhac.cs
public class cadilhac : RavenTestBase
{
public class User
{
public string Name;
public int Age;
}
[Fact]
public void ExploringConcurrencyBehavior()
View WorkflowGraphGenerator.cs
public class WorkflowGraphGenerator : Esprima.Utils.AstVisitor
{
StringBuilder _sb = new StringBuilder();
Stack<string> _current = new Stack<string>();
Stack<string> _conditionals = new Stack<string>();
private string _code;
public string Graph => _sb.ToString() + "\r\n}";
public WorkflowGraphGenerator(string code)
View loan-approval.js
on("init", () => {
var state = {
Status: "New"
};
return state;
});
on("loan-submission", (state, req) => {
state.Amount = req.Amount;
View index2.js
map("MortgageMonthlyStatuses", status => {
return {
Mortgage: status.Mortgage,
PrincipleRemaining: status.PrincipleRemaining,
InterestRemaining: status.InterestRemaining,
AmountPaid: status.AmountPaid,
PastDue: (status.PrincipleRemaining + status.InterestRemaining) > 0 ? 1 : 0
};
});
View index.js
map("PaymentExpected", event => {
return {
Mortgage: event.Mortgage,
DueBy: event.DueBy.substring(0,7),
InterestDue: event.Interest,
PrincipleDue: event.Principle
}
});
map("MortgagePayment", event => {
You can’t perform that action at this time.