Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jadeallenx on github.
  • I am jadeallenx (https://keybase.io/jadeallenx) on keybase.
  • I have a public key ASCzYgteA70jTBW7BkqBoqpn-Le6zVZCKrCki8nSsaL9MAo

To claim this, I am signing this object:

@jadeallenx
jadeallenx / discussion.md
Last active April 21, 2023 17:13
When does terminate/2 get called in a gen_server?

When does terminate/2 get called in a gen_server?

This is what the [official documentation][1] says about the terminate/2 callback for a gen_server:

This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.

Reason is a term denoting the stop reason and State is the internal state of the gen_server.

Reason depends on why the gen_server is terminating. If it is because another callback function has returned a stop tuple {stop,..}, Reason will have the value specified in that tuple. If it is due to a failure, Reason is the error reason.

Keybase proof

I hereby claim:

  • I am jadeallenx on github.
  • I am mrallen1 (https://keybase.io/mrallen1) on keybase.
  • I have a public key ASCa8v4tZDbyfDBVFnCHukL_19ck6mPJ4o7eiAIxfymcyAo

To claim this, I am signing this object:

@jadeallenx
jadeallenx / surface2.md
Created December 12, 2017 05:54
Developing on SurfaceBook 2

I recently made the switch back to Windows 10 after spending 15 years using a Mac as my personal laptop. I won't go into all of the rationale behind that decision but the most succinct answer is that I have felt like Apple's doing me a favor by buying their products, not the other way around for the past three releases of macOS. As a rather committed vi partisan, removing the ESC key from the high end Mac Book Pros was kind of the final straw.

In any case, I bought my Surface Book 2 about two weeks ago. This past weekend, I took part in [Spawnfest][1], a 48 hour programming contest aimed at Erlang/Elixir. I wrote all of the code on the Surface Book 2 and I know some people are interested in my experience.

So keeping with the usual trite cliches, I'll use the "Good", "Bad" and "Ugly."

Good

  • Windows Subsystem for Linux was flawless during my work. I used it exclusively to develop code. Git and Erlang and every other tool I needed Just Worked, and worked well.
@jadeallenx
jadeallenx / build.md
Last active June 10, 2021 06:38
Building Erlang on WSL/Ubuntu 16.04(LTS)

Building Erlang on Windows Subsystem for Linux (WSL)

WSL Overview

WSL is a driver shim for Windows 10 that enables you to run native Linux code on Windows without recompiling or running a Docker/VM. It currently supports Ubuntu 16.04 LTS - but more distribution support has been announced.

Building Erlang

From a "clean" install of Ubuntu such as the kind you would get from a fresh install of WSL, you need to preinstall these debs to enable kerl to compile a working Erlang:

@jadeallenx
jadeallenx / thai_tofu.md
Last active April 27, 2021 00:59
thai peanut crispy fried tofu on zoodles

Thai peanut sauce crispy tofu over zucchini noodles

  • 1 pkg extra firm tofu
  • 1 T olive oil
  • 1/4 c peanut butter
  • 2 T tamari
  • 1 1/2 T rice wine vinegar
  • 1 t minced garlic
  • 1 t minced ginger
@jadeallenx
jadeallenx / ss.erl
Created August 21, 2019 21:58
Self Stabilizing Systems in Spite of Distributed Control
%% @doc
%% This Erlang module implements the ideas illustrated in Edsger Dijkstra's
%% famous paper "Self Stabilizing Systems in Spite of Distributed Control"
%% http://courses.csail.mit.edu/6.852/05/papers/p643-Dijkstra.pdf
%% @end
-module(ss).
-export([stop/1, show/1, start/1]).
-define(DELAY, 1000).
-define(THRESHOLD, 0.90).
@jadeallenx
jadeallenx / unicode-test.pl
Created August 11, 2011 23:01
Perl unicode
#!/usr/bin/env perl
use warnings;
use strict;
use v5.14;
use utf8;
my $number = "௪";
my $letter = "த்";
@jadeallenx
jadeallenx / twitter-zk.md
Last active March 7, 2019 07:59
Using Twitter's ZK client

Using Twitter's ZK client

Introduction

I'm a Scala noob.

I am deploying some Spark jobs which need to talk to various services in our production environment. These services are managed by a ZooKeeper installation that registers their host and ports for service discovery. Hence, our Scala code needs to interact with ZooKeeper to discover the host and ports to use when making HTTPS calls to these internal services.

There is some ScalaDoc for util-zk that describes the classes, objects and function signatures but those don't help me very much since I'm a newb and none of it really makes a ton of sense right now.

So I am writing this document with my discoveries about how the util-zk library behaves empirically.

@jadeallenx
jadeallenx / t.erl
Created February 10, 2012 22:56
Erlang parameter validation
% Post/Query string parameter validation.
%
% Mark Allen, mrallen1@yahoo.com
%
% Specs [{{name, "param_name"}, {required, true}, {type, function}}, ... ]
% Input [{"name", "value}, ...] just you'd get from post or query string parameters
-module(t).
-export([test/0, test1/0, test2/0]).