Skip to content

Instantly share code, notes, and snippets.

View jeremiahredekop's full-sized avatar
😀
life is good.

Jeremiah Redekop jeremiahredekop

😀
life is good.
View GitHub Profile
@srkirkland
srkirkland / deploy.ps1
Created September 10, 2012 22:18
TeamCity CI Deploy Azure PowerShell Script
#Modified and simplified version of https://www.windowsazure.com/en-us/develop/net/common-tasks/continuous-delivery/
$subscription = "[Your Subscription Name]"
$service = "[Your Azure Service Name]"
$slot = "staging" #staging or production
$package = "[ProjectName]\bin\[BuildConfigName]\app.publish\[ProjectName].cspkg"
$configuration = "[ProjectName]\bin\[BuildConfigName]\app.publish\ServiceConfiguration.Cloud.cscfg"
$timeStampFormat = "g"
$deploymentLabel = "ContinuousDeploy to $service v%build.number%"
Write-Output "Running Azure Imports"
public abstract class AggregateRoot : IAggregateRoot
{
private const int DefaultVersion = 0;
private readonly Dictionary<Type, Action<IEvent>> handlers = new Dictionary<Type, Action<IEvent>>();
private List<IEvent> _uncommitedChanges = new List<IEvent>();
public Guid Id { get; protected set; }
public int Version { get; private set; }
@jogleasonjr
jogleasonjr / SlackClient.cs
Last active October 20, 2023 15:54
A simple C# class to post messages to a Slack channel. You must have the Incoming WebHooks Integration enabled. This class uses the Newtonsoft Json.NET serializer available via NuGet. Scroll down for an example test method and a LinqPad snippet. Enjoy!
using Newtonsoft.Json;
using System;
using System.Collections.Specialized;
using System.Net;
using System.Text;
//A simple C# class to post messages to a Slack channel
//Note: This class uses the Newtonsoft Json.NET serializer available via NuGet
public class SlackClient
{
@eulerfx
eulerfx / EventStore.fsi
Last active August 29, 2015 14:03
F# EventStore API
type Stream = string
type EventType = string
type ExpectedVersion = int
type EventData = byte[]
type EventMetadata = byte[]
type ResolveLinks = bool
type From = int
type BatchSize = int
type BufferSize = int
type CheckpointStore = (unit -> Async<int option>) * (int -> Async<unit>)
@isaacabraham
isaacabraham / 1 - StorageQueueMailboxProcessor.fs
Last active August 15, 2020 09:36
Demonstrates how to use F# mailbox processors in conjunction with Azure Storage Queues.
/// Code to bind mailbox processors to azure storage queues.
module AzureMailboxProcessor
open System
module private Async =
let AwaitTaskEmpty = Async.AwaitIAsyncResult >> Async.Ignore
module private Option =
let fromNullable (nullable:Nullable<_>) = if nullable.HasValue then Some nullable.Value else None
let toNullable = function
@isaacabraham
isaacabraham / CloudAgent-1.fs
Last active June 13, 2021 20:38
Local Mailbox Processor
// Our simple domain model
type Priority =
| Low
| Normal
| High
type Message = {
Text : string
Priority : Priority
}
@isaacabraham
isaacabraham / CloudAgent-2.fs
Last active August 29, 2015 14:10
How to bind a Mailbox Processor to CloudAgent
// A connection to a Azure Service Bus-backed CloudAgent actor pool
let cloudConnection = CloudConnection.ActorCloudConnection(ServiceBusConnection "Endpoint=sb://myservicebus.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=fsdoifsm0983m29048098dfs", Connections.Queue "myqueue")
(* Posting messages - run this code on every producer *)
let sendTo = ConnectionFactory.SendToActorPool CloudConnection
let sendToIsaac = sendTo (ActorKey "isaac")
sendToIsaac Clear |> Async.RunSynchronously // send a message to Clear the file to the Isaac actor
sendToIsaac(Record { Text = "Hello"; Priority = Priority.Low }) |> Async.RunSynchronously // Send a new message to Isaac
(* Consuming messages - run this code on every consumer *)
@isaacabraham
isaacabraham / CloudAgent-3.fs
Last active January 15, 2016 23:40
Mailbox Processor in Cloud Agent with automatic dead lettering and at-least-once processing.
let CreateActor (ActorKey name) =
MailboxProcessor.Start(fun mailbox ->
let messageStore = GetMessageStore name
let rec loop data =
async {
// Wait asynchronously until we get a message + reply channel
let! message, replyWith = mailbox.Receive()
match message with
| Clear ->
@akimboyko
akimboyko / 01_SayHello.fsx
Last active May 28, 2023 13:00
Samples from "Actor-based Concurrency with F# and Akka.NET" http://bit.ly/FSharpAkkaNET
#time "on"
#load "Bootstrap.fsx"
open System
open Akka.Actor
open Akka.Configuration
open Akka.FSharp
open Akka.TestKit
// #Using Actor
@jeremiahredekop
jeremiahredekop / PipingExtensions.cs
Last active July 21, 2017 17:50
Piping c# extension methods
public static class PipingExtensions
{
/// <summary>
/// Take an object, pipe it into a function, and return the result.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="T2"></typeparam>
/// <param name="obj"></param>
/// <param name="f"></param>
/// <returns></returns>