Skip to content

Instantly share code, notes, and snippets.

View benjamintanweihao's full-sized avatar

Benjamin Tan Wei Hao benjamintanweihao

View GitHub Profile
require 'complex'
RES = 0.03
ESCAPE_RADIUS = ARGV[0].to_f || 2.0
COLORS = [
"\033[31m",
"\033[32m",
"\033[33m",
"\033[34m",
"\033[35m",
SPC> + Function Calls
mcb alchemist-compile-this-buffer
mel alchemist-eval-current-line
meL alchemist-eval-print-current-line
mer alchemist-eval-region
meR alchemist-eval-print-region
meb alchemist-eval-buffer
meB alchemist-eval-print-buffer
mgt alchemist-project-open-tests-for-current-file
defmodule HttpRequester do
use GenServer.Behaviour
def start_link(_) do
:gen_server.start_link(__MODULE__, nil, [])
end
def fetch(server, url) do
:gen_server.cast(server, {:fetch, url})
end

Questions about Distributed systems by @tsantero.

  1. explain the life of an http request.
  2. what does the FLP result teach us?
  3. what is a byzantine failure?
  4. explain CRDTs
  5. explain linearizability.
  6. how does DNS work?
  7. crash-stop vs crash-recovery?
  8. difference between soft and hard real time
@benjamintanweihao
benjamintanweihao / packages.el
Last active November 20, 2015 13:48 — forked from thunklife/packages.el
elm-mode for Spacemacs
;;; packages.el --- elm Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <[email protected]>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
(defun dotspacemacs/config ()
(setq racer-rust-src-path "/Users/benjamintan/workspace/rust/src/")
(setq racer-cmd "/Users/benjamintan/Desktop/racer/target/release/racer")
(add-to-list 'load-path "/Users/benjamintan/Desktop/racer/editors/emacs")
(eval-after-load "rust-mode" '(require 'racer))
)
Generated blitzy app
** (UndefinedFunctionError) undefined function: Access.List.get/2 (module Access.List is not available)
Access.List.get([app: :blitzy, version: "0.0.1", elixir: "~> 1.0", escript: [main_module: Blitzy.CLI], deps: [httpoison: "~> 0.7", timex: "~> 0.19"], aliases: [], build_per_environment: true, build_embedded: false, default_task: "run", deps_path: "deps", elixirc_paths: ["lib"], erlc_paths: ["src"], erlc_include_path: "include", erlc_options: [:debug_info], lockfile: "mix.lock", preferred_cli_env: [], start_permanent: false], :apps_path)
(mix) lib/mix/project.ex:171: Mix.Project.umbrella?/1
(mix) lib/mix/tasks/app.start.ex:78: Mix.Tasks.App.Start.start/2
(mix) lib/mix/tasks/app.start.ex:68: Mix.Tasks.App.Start.run/1
(mix) lib/mix/tasks/run.ex:63: Mix.Tasks.Run.run/1
(mix) lib/mix/cli.ex:55: Mix.CLI.run_task/2
function get(url) {
return Rx.Observable.create(function(observer) {
var req = new XMLHttpRequest();
req.open('GET', url);
req.onLoad = function() {
if (req.status == 200) {
observer.onNext(req.response);
observer.onCompleted();
}
@benjamintanweihao
benjamintanweihao / navigation_drawer_espresso.java
Last active July 16, 2020 13:38
Testing Navigation Drawer in Espresso
// This works!
onView(withId(R.id.drawer)).perform(swipeUp())
// This doesn't.
onView(withId(R.id.drawer))
.perform( actionOnItemAtPosition(5, click()));
onView(allOf(
withText(R.string.settings),