Skip to content

Instantly share code, notes, and snippets.

View Aaronontheweb's full-sized avatar
🚀
Shipping!

Aaron Stannard Aaronontheweb

🚀
Shipping!
View GitHub Profile
@Aaronontheweb
Aaronontheweb / gist:4ecf3a11de54516163e9
Created July 17, 2014 23:26
Inline actor - defined solely using lamba functions and delegates
/// <summary>
/// A simple actor implementation that can be defined solely using lamba functions and delegates
/// </summary>
public class Actor : UntypedActor
{
public Actor()
{
Receive = message => base.Unhandled(message);
OnPreStart = () => base.PreStart();
OnPostStop = () => base.PostStop();
@Aaronontheweb
Aaronontheweb / BasicActor.cs
Created January 25, 2015 00:18
Basic Akka.NET Actor
using System;
using Akka.Actor;
namespace ActorsSendingMessages
{
/// <summary>
/// See http://akkadotnet.github.io/wiki/Actors for more details about
/// Akka.NET actors
/// </summary>
public class BasicActor : UntypedActor
@Aaronontheweb
Aaronontheweb / DedicatedThreadFiberSpec.md
Last active August 29, 2015 14:16
ForkJoinDispatcher / DedicatedThreadFiber Spec

ForkJoinDispatcher

Abstract

The goal of a ForkJoinDispatcher is to provide a group of dedicated threads managed outside the CLR ThreadPool that can be shared by many actors / callers to concurrently. In an ideal world, the CLR would provide us with a way of creating instances of ThreadPool and we would happily wrap one of those inside the ForkJoinDispatcher and call UnsafeQueueUserWorkItem(wc, null) for each piece of asynchronous work we need done.

However, since this isn't the case - we have to build one. We need a way to manage multiple threads and have them cooperatively and efficiently peform queued work like the ThreadPool would.

Why ForkJoinDispatcher is Necessary

@Aaronontheweb
Aaronontheweb / gist:f370268b28422800a1af
Last active August 29, 2015 14:18
Akka.NET Doc TOC

Akka.NET v1.0 Documentation

Introduction

  • What is Akka.NET?
    • Akka & Typesafe
  • Why Akka.NET?
  • Akka.NET Quickstart
    • C# Quickstart
    • F# Quickstart
@Aaronontheweb
Aaronontheweb / pickup-truck-aircraft-carrier-catapult
Created February 1, 2012 07:51
How far can an aircraft carrier catapult fling a four-ton pickup truck?
How far can a pickup truck be flung off of an aircraft carrier?
333m - length of aircraft carrier deck (Nimitz Class - http://en.wikipedia.org/wiki/Aircraft_carrier)
20,411.6567 - weight of jet in kilos
2 = number of seconds a jet is active on the catapult (assume it clears all 333ms)
165mph takeoff speed = 265.54176 Km/h = 73.7616 m/s
Force = weight * (333/4) - Newton's second law of motion (F = MA | F = kg (m/s^2))
1,699,270.420 Netwons
@Aaronontheweb
Aaronontheweb / routes-post.js
Created February 25, 2012 21:12
How to structure an Express Controller Module
/*
* Module dependencies
*/
var Post = require('../models/post')
, PostValidator = require('../validators/post-validator')
, requiresLogin = require('../helpers/requireLogin').requiresLogin
, marked = require('marked');
@Aaronontheweb
Aaronontheweb / ScreenshotControllerAsync.cs
Created February 26, 2012 20:19
HttpPostFileBase in MVC3
[Authorize]
[HttpPost]
public void ScreenshotsAsync(string appName, HttpPostedFileBase files)
{
AsyncManager.OutstandingOperations.Increment();
var fileModel = new UploadedFileModel();
var result = UploadedFileResult.NoFile;
@Aaronontheweb
Aaronontheweb / auth.js
Created April 11, 2012 03:53
everyauth password module
*
* Module dependencies
*/
var User = require('../models/user')
, UserValidator = require('../validators/user-validator')
, Promise = require('everyauth').Promise;
//Everyauth configuration
module.exports = function(everyauth, repository){
@Aaronontheweb
Aaronontheweb / NinjectWebCommon.cs
Created May 17, 2012 19:46
Ninject for MVC4 WebApi
/* This is part of the file that is generated automatically when you install Ninject.MVC3 -pre via Nuget */
/// <summary>
/// Creates the kernel that will manage your application.
/// </summary>
/// <returns>The created kernel.</returns>
private static IKernel CreateKernel()
{
var kernel = new StandardKernel();
kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
@Aaronontheweb
Aaronontheweb / App.xaml.cs
Created August 21, 2012 07:59
Windows Phone 7 Last-Chance Exception Handling with LittleWatson
// Code to execute on Unhandled Exceptions
private void Application_UnhandledException(object sender,
ApplicationUnhandledExceptionEventArgs e)
{
if (System.Diagnostics.Debugger.IsAttached)
{
// An unhandled exception has occurred;
// break into the debugger
System.Diagnostics.Debugger.Break();
}