Skip to content

Instantly share code, notes, and snippets.

@arobson
arobson / RingBuffer.cs
Created Jan 24, 2011
This is a very different approach I took from initial attempts that relied on volatile arrays and a crap ton of pointers. This is more fun :)
View RingBuffer.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Machine.Specifications;
namespace ringbuffer
{
@arobson
arobson / OWINFileServer.cs
Created Jan 26, 2011
A contrived but fun example of how to build a OWIN compliant file server using Symbiote.
View OWINFileServer.cs
using System;
using System.Collections.Generic;
using Symbiote.Core;
using Symbiote.Http;
using Symbiote.Http.Impl;
using Symbiote.Http.Owin;
using Symbiote.StructureMap;
using Symbiote.Daemon;
using Symbiote.Messaging;
using Symbiote.Actor;
@arobson
arobson / RiakDemo.cs
Created Feb 8, 2011
A really cheesy example of how the Repository and KeyValue APIs work for Riak.
View RiakDemo.cs
class Program
{
static void Main(string[] args)
{
Assimilate
.Core<StructureMapAdapter>()
.AddConsoleLogger<RiakService>( x => x.Info().MessageLayout( m => m.Message().Newline() ) )
.Messaging()
.Daemon( x => x.Arguments( args ).Name( "Riak Demo" ) )
.Riak( x => x.AddNode( r => r.Address( "192.168.1.100" ) ) )
@arobson
arobson / http_server1
Created Jun 17, 2011
Snippet of the 'Dynamic' HTTP server that accomodates RESTful requests and static content using Misultin.
View http_server1
handle_request(Req) ->
#req{uri={_,Uri}} = Req:raw(),
Ext=filename:extension(Uri),
handle_request(Req, Uri, Ext).
handle_request(Req, _Uri, []) ->
Segments = Req:resource([urldecode]),
Method = get_atom(Req:get(method)),
[Resource|Arguments]=Segments,
ResourceModule = get_atom(Resource),
@arobson
arobson / coffee-pubsub
Created Aug 10, 2011
coffeescript pub/sub demo for rabbitmq
View coffee-pubsub
sys = require "sys"
rabbit = require "amqp"
console.log "Connecting to rabbit..."
connection = rabbit.createConnection { host: "localhost", port: 5672 }
connection.on "ready", () ->
exchangeOptions = { type: "fanout", autoDelete: true }
connection.exchange(
@arobson
arobson / gist:1167335
Created Aug 24, 2011
Improved Approach To Limiting Asynchronous Calls with Rx
View gist:1167335
Action<IList<XElement>> saveAction = SaveChunk;
var loader = new BulkPostLoader(@"e:\stackoverflow\062010 so\posts.xml");
var batches = loader.BufferWithCount(5000);
var results = batches.Select(x => saveAction.BeginInvoke(x, null, null));
results
.Aggregate(new HashSet<IAsyncResult>(), (set, result) =>
{
set.RemoveWhere(x => x.IsCompleted);
set.Add(result);
@arobson
arobson / binder.js
Created Sep 2, 2011
An ugly POC for decoupled 'binding' in Javascript
View binder.js
var DomWriter = function (target, namespace) {
var instance = this;
var template = namespace;
var coalesce = function( value, defaultValue ) {
return typeof(value) != 'undefined' ?
value : defaultValue;
};
this.isObject = function( value ) {
View gist:1586476
zlib = require 'zlib'
module.exports = (robot) ->
robot.respond /(stack|ss) ?(find:.*) ?(tags:.*)/i, (msg)->
query = msg.match[2]
query2 = msg.match[3]
query = query.replace /find:/i, ""
query2 = query2.replace /tags:/i, ""
@arobson
arobson / Dependency URLs
Created Mar 8, 2012
A Cartographer Starter HTML Page
View Dependency URLs
These URLs should be to the actual script files and can be used for to populate tools like JS Fiddle.
Cartographer:
https://raw.github.com/arobson/cartographer.js/master/lib/cartographer.min.js
jQuery:
http://code.jquery.com/jquery-1.7.1.min.js
Underscore:
https://raw.github.com/documentcloud/underscore/master/underscore-min.js
@arobson
arobson / forkjoin-mockjax-defs.js
Created Mar 22, 2012
Mockjax Definitions for my Fork Join Blog post
View forkjoin-mockjax-defs.js
$.mockjax( {
url: "http://api.github.com/users/arobson",
type: "GET",
status: 200,
data: {
"name": "Alex Robson",
"company": "appendTo",
"public_repos": 31,
"followers": 18,
"following": 4,