Skip to content

Instantly share code, notes, and snippets.

Greg Young gregoryyoung

Block or report user

Report or block gregoryyoung

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:a6bc2fccdbb55be9123c3f7d34d57c54
There are no "full stack developers". Its a silly buzzword. Sadly working on kernel issues, a real time networked embedded system, or implementing a TCP stack is a different world than building an advertising website in PHP on MySQL.
Even if they did exist there are so many things to know that they would not have the depth required to actually solve an issue in any.
View gist:e7ea27292b83f48109b6b29c78bcb6f0
new FSMDefinition<State>().CompletesWith<Completed>().
InState(State.Initial).With((state, x) => {
//dosomething
return State.Middle;
}).
InState(State.Middle).With((state, x) => {
//do something else
Send(new NextMessage(...));
return State.Ending;
}).
View gist:938a8945803e8c3560765dd50dff057a
commit 273e4c4bca3ff94106eb4a75dfe2f8f829f052a4
Author: Greg Young <gregoryyoung1@gmail.com>
Date: Mon Apr 18 15:20:14 2016 +0100
add TTL to httpsend messages
commit bc2d462fadec1d7a8e00260936e70bd73185c568
Author: James Nugent <james.nugent@bathasu.com>
Date: Mon Jul 7 11:25:36 2014 +0100
View gist:a6f69f20e888fffaa90181cf3cd8392b
#endif
/* Time counting */
#define MONO_PROFILER_GET_CURRENT_TIME(t) {\
struct timeval current_time;\
gettimeofday (&current_time, NULL);\
(t) = (((guint64)current_time.tv_sec) * 1000000) + current_time.tv_usec;\
} while (0)
static gboolean use_fast_timer = FALSE;
View gist:2c8c4c26f476339bd38fce8aa8a2119c
#Cheating
The patterns Copy-Replace, Stream-Split, and Join-Stream the last chapter are quite intense. Getting them to work on a running system is non-trivial. There will be times that they might need to be used however most of the time they can be avoided.
The patterns will work in any scenario. It does not matter whether it is a system that is doing 5000 transactions per second with TB of data or one doing seconds per transaction with 1 GB of data. They work in the same way.
There exist however "cheats" that can be used to avoid the use of the more complicated patterns. Depending on the scenario they may or may not apply, the trade offs associated with them may be better or worse than the complexity associated with the other patterns.
This chapter we will look at some of these "cheats" and where and when they might be applicable. Some are adding code complexity to avoid the need to versioning, others look at different deployment options. If possible you should generally prefer a pattern from this chap
View gist:5f465f3145bc56793a0e8da9a1ee7b01
The performance implications of try are more severe than I had thought. I thought it was just code within the try block that isn’t optimized. It turns out it’s everything around the block too. Take this code:
object syncObject = new Object();
[System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.NoInlining)]
public int Member ( )
{
View gist:02acd10276599f62db8357716548d4f5
var lowest = _outstandingMessages.GetLowestPosition();
var lowestBufferedRetry = _streamBuffer.GetLowestRetry();
Log.Debug("Lowest from outstanding is " + lowest);
Log.Debug("Lowest from streambuffer is " + lowestBufferedRetry);
lowest = Math.Min(lowest, lowestBufferedRetry);
if (lowest == int.MinValue) lowest = _lastKnownMessage;
//no outstanding messages. in this case we can say that the last known
//event would be our checkpoint place (we have already completed it)
var difference = lowest - _lastCheckPoint;
Log.Debug("lastCheckPoint is " + _lastCheckPoint);
View gist:7cb050ddfa3ced44707ecc31c4fbc096
By the Jurassic, the sophisticated aerial webs of the orb-weaver spiders had already developed to take advantage of the rapidly diversifying groups of insects. A spider web preserved in amber, thought to be 110 million years old, shows evidence of a perfect "orb" web, the most famous, circular kind one thinks of when imagining spider webs. An examination of the drift of those genes thought to be used to produce the web-spinning behavior suggests that orb spinning was in an advanced state as many as 136 million years ago. One of these, the araneid Mongolarachne jurassica, from about 165 million years ago, recorded from Daohuogo, Inner Mongolia in China, is the largest known fossil spider.
View gist:09f5d8799f4425d6d7717b81cfc678c7
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
#include <errno.h>
#include <stdbool.h>
#include <string.h>
View gist:54c79b1472edc660ccbb302fb156ea1a
mmap_write flush=false doing 524288 iterations of 4096 size for 2147483648 total
Total time 3783.905000
Value Percentile TotalCount 1/(1-Percentile)
0.000 0.000000 524070 1.00
0.000 0.100000 524070 1.11
0.000 0.200000 524070 1.25
0.000 0.300000 524070 1.43
0.000 0.400000 524070 1.67
0.000 0.500000 524070 2.00
You can’t perform that action at this time.