Skip to content

Instantly share code, notes, and snippets.

View john-evangelist's full-sized avatar

Evangelista john-evangelist

View GitHub Profile
@john-evangelist
john-evangelist / capsctrl.ahk
Created July 30, 2019 15:00
map capslock to ctrl and esc using autohotkey
*CapsLock::
Send {Blind}{Ctrl Down}
cDown := A_TickCount
Return
*CapsLock up::
; Modify the threshold time (in milliseconds) as necessary
If ((A_TickCount-cDown) < 210)
Send {Blind}{Ctrl Up}{Esc}
Else
@john-evangelist
john-evangelist / akka_http_and_cats_validation.md
Created June 30, 2019 04:18 — forked from melvic-ybanez/akka_http_and_cats_validation.md
Request Validation with Akka-HTTP and Cats

Request Validation with Akka-HTTP and Cats

Greg Beech wrote an article on Akka HTTP Entity Validation. This post is on the same topic, except we are going to use typeclass instances, as opposed to subtyping, for form validations.

Sample Problem: User Regsitration

To start with, let us suppose that we are working on some sort of user management service using Scala/Akka. However, here we are only going to focus on the registration part, in which the client is expected to send a user data, in JSON format; and the server needs to validate them, and save the user if the validations succeed, or reject the request with all the errors detected. That said, we should keep in mind that our validations may be used through out the entire codebase, not just in the user registration endpoint.

The rules for our validation are as follows:

@john-evangelist
john-evangelist / akka_http_and_cats_validation.md
Created June 30, 2019 04:18 — forked from melvic-ybanez/akka_http_and_cats_validation.md
Request Validation with Akka-HTTP and Cats

Request Validation with Akka-HTTP and Cats

Greg Beech wrote an article on Akka HTTP Entity Validation. This post is on the same topic, except we are going to use typeclass instances, as opposed to subtyping, for form validations.

Sample Problem: User Regsitration

To start with, let us suppose that we are working on some sort of user management service using Scala/Akka. However, here we are only going to focus on the registration part, in which the client is expected to send a user data, in JSON format; and the server needs to validate them, and save the user if the validations succeed, or reject the request with all the errors detected. That said, we should keep in mind that our validations may be used through out the entire codebase, not just in the user registration endpoint.

The rules for our validation are as follows:

@john-evangelist
john-evangelist / gist:da2a7a613e62f3f4372b5590d6a4485f
Created June 1, 2019 04:30 — forked from pbailis/gist:5660980
Assorted distributed database readings

Context: I was asked for a list of interesting reading relating to "distributed databases, behavior under partitions and failures, failure detection." Here's what I came up with in about an hour.

For textbooks, "Introduction to Reliable and Secure Distributed Programming" is a superb introduction to distributed computing from a formal perspective; it's really not about "programming" or "engineering" but about distributed system fundamentals like consensus, distributed registers, and broadcast. Used in Berkeley's Distributed Computing course (and HT to @lalithsuresh) Book Site

Notes from courses like Lorenzo Alvisi's Distributed Computing class can be great.

There are a bunch of classics on causality, [Paxos](ht

@john-evangelist
john-evangelist / Consecutive.exs
Created May 18, 2019 18:38
check if two elements are consecutive
defmodule Consecutive do
defp consecutive([]) do
false
end
defp consecutive([a | [a | _rest]]) do
true
end
@john-evangelist
john-evangelist / permutation.exs
Created May 18, 2019 18:35
Generate Permutations on List
defmodule Permutation do
def permutations([]), do: [[]]
def permutations(list),
do: for(elem <- list, rest <- permutations(list -- [elem]), do: [elem | rest])
end
@john-evangelist
john-evangelist / inventory.exs
Created May 18, 2019 18:12
Freecodecamp Inventory Update in Elixir
defmodule FCCL.Algos.Inventory do
@doc """
## Examples
iex> current = [[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]]
iex> new = [[2, "Hair Pin"], [3, "Half-Eaten Apple"], [67, "Bowling Ball"], [7, "Toothpaste"]]
iex> FCCL.Algos.Inventory.update(current, new)
[[88, "Bowling Ball"], [2, "Dirty Sock"], [3, "Hair Pin"], [3, "Half-Eaten Apple"], [5, "Microphone"], [7, "Toothpaste"]]
"""
def update(current, new) do
[credential]
helper = manager
[user]
name = João Pedro de Carvalho
email = [email protected]
[core]
excludesfile = ~/dotgit/.gitignore
[commit]
template = ~/dotgit/.gitmessage
@john-evangelist
john-evangelist / vscode.css
Created April 30, 2019 19:59
custom vscode files
.windows {
/* looking good: Roboto */
font-family: "Work Sans" !important;
}
@john-evangelist
john-evangelist / .spacemacs
Last active June 7, 2020 18:13
Poor Spacemacs
;; -*- mode: emacs-lisp; lexical-binding: t -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Layer configuration:
This function should only modify configuration layer settings."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
;; `+distribution'. For now available distributions are `spacemacs-base'