Skip to content

Instantly share code, notes, and snippets.

Avatar

Aaron Stannard Aaronontheweb

View GitHub Profile
@Aaronontheweb
Aaronontheweb / gist:4ecf3a11de54516163e9
Created Jul 17, 2014
Inline actor - defined solely using lamba functions and delegates
View gist:4ecf3a11de54516163e9
/// <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 Jan 25, 2015
Basic Akka.NET Actor
View BasicActor.cs
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 Aug 29, 2015
ForkJoinDispatcher / DedicatedThreadFiber Spec
View DedicatedThreadFiberSpec.md

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

View gist:f370268b28422800a1af

Akka.NET v1.0 Documentation

Introduction

  • What is Akka.NET?
    • Akka & Typesafe
  • Why Akka.NET?
  • Akka.NET Quickstart
    • C# Quickstart
    • F# Quickstart
@Aaronontheweb
Aaronontheweb / helloworld-node.js
Created Jan 28, 2012
Node.JS: Hello World w/ IP Address
View helloworld-node.js
/* Basic HelloWorld Node.JS example */
var http = require('http');
//Node function called each time our event loop receives a new HTTP request
function onRequest(req, res){
res.writeHead(200, {'Content-Type':'text/plain'});
res.end('Hello ' + req.connection.remoteAddress + '!');
/* Write the IP addresses of our connecting client to console */
console.log('Incoming connection from ' + req.connection.remoteAddress);
@Aaronontheweb
Aaronontheweb / pickup-truck-aircraft-carrier-catapult
Created Feb 1, 2012
How far can an aircraft carrier catapult fling a four-ton pickup truck?
View pickup-truck-aircraft-carrier-catapult
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 Feb 25, 2012
How to structure an Express Controller Module
View routes-post.js
/*
* Module dependencies
*/
var Post = require('../models/post')
, PostValidator = require('../validators/post-validator')
, requiresLogin = require('../helpers/requireLogin').requiresLogin
, marked = require('marked');
View ScreenshotControllerAsync.cs
[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 Apr 11, 2012
everyauth password module
View auth.js
*
* 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
Ninject for MVC4 WebApi
View NinjectWebCommon.cs
/* 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);
You can’t perform that action at this time.