Skip to content

Instantly share code, notes, and snippets.

@melcloud
melcloud / AsyncLoop.cs
Created May 28, 2017 09:44
Async event loop in C#
private static async Task EventLoop(BufferBlock<object> bufferBlock, CancellationToken cancellationToken)
{
while (true)
{
object msg;
try
{
msg = await bufferBlock.ReceiveAsync(TimeSpan.FromSeconds(3), cancellationToken);
}
catch (TimeoutException)
@melcloud
melcloud / elixir.md
Created July 12, 2016 11:22
Elixir Study Note

iex

  • h or h() for help do. The number following the slash is the number of arguments (cd/1)
  • usage h IO or h(IO)
  • i which displays information for value. E.g. i 3
  • IEx.configure ​ colors: ​ [ ​ eval_result: ​ [ ​ :cyan ​, ​ :bright ​ ] ]
  • These files will typically have the extension .ex or .exs . This is a convention—files ending in .ex are intended to be compiled into bytecodes and then run, whereas those ending in .exs are more like programs in scripting languages—they are effectively interpreted at the source level. When we come to write tests for our Elixir programs, you’ll see that the application files have .ex extensions, whereas the tests have .exs because we don’t need to keep compiled versions of the tests lying around.