Skip to content

Instantly share code, notes, and snippets.

👽
Conquering the world

João Evangelista sleepiejohn

👽
Conquering the world
Block or report user

Report or block sleepiejohn

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 install_docker.sh
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
@sleepiejohn
sleepiejohn / EventMachines.md
Created Jan 14, 2020 — forked from eulerfx/EventMachines.md
The relationship between state machines and event sourcing
View EventMachines.md

A state machine is defined as follows:

  • Input - a set of inputs
  • Output - a set of outputs
  • State - a set of states
  • S0 ∈ S - an initial state
  • T : Input * State -> Output * State - a transition function

If you model your services (aggregates, projections, process managers, sagas, whatever) as state machines, one issue to address is management of State. There must be a mechanism to provide State to the state machine, and to persist resulting State for subsequent retrieval. One way to address this is by storing State is a key-value store. Another way is to use a SQL database. Yet another way is event sourcing. The benefit of even sourcing is that you never need to store State itself. Instead, you rely on the Output of a service to reconstitute state. In order to do that, the state machine transition function needs to be factored into two functions as follows:

View ideavimrc
set nru
set incsearch
set clipboard=unnamedplus,unnamed
let mapleader = ","
" Mappings are made of action group prefix - action
" Find
nmap <Leader>f :action Find<CR> " default IDEA search
nmap <Leader>ff :action FindModal<CR>
@sleepiejohn
sleepiejohn / emoji_on_suse
Created Aug 19, 2019
steps to get emoji on suse
View emoji_on_suse
- download & extract from https://github.com/eosrei/twemoji-color-font/releases
- install bitstream with `sudo zypper in bitstream-vera-fonts`
- cd TwitterColorEmoji-SVGinOT-Linux-12.0.1
- chmod +x install.sh && ./install.sh
@sleepiejohn
sleepiejohn / capsctrl.ahk
Created Jul 30, 2019
map capslock to ctrl and esc using autohotkey
View capsctrl.ahk
*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
View akka_http_and_cats_validation.md

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:

View akka_http_and_cats_validation.md

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:

@sleepiejohn
sleepiejohn / gist:da2a7a613e62f3f4372b5590d6a4485f
Created Jun 1, 2019 — forked from pbailis/gist:5660980
Assorted distributed database readings
View gist:da2a7a613e62f3f4372b5590d6a4485f

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

@sleepiejohn
sleepiejohn / Consecutive.exs
Created May 18, 2019
check if two elements are consecutive
View Consecutive.exs
defmodule Consecutive do
defp consecutive([]) do
false
end
defp consecutive([a | [a | _rest]]) do
true
end
@sleepiejohn
sleepiejohn / permutation.exs
Created May 18, 2019
Generate Permutations on List
View permutation.exs
defmodule Permutation do
def permutations([]), do: [[]]
def permutations(list),
do: for(elem <- list, rest <- permutations(list -- [elem]), do: [elem | rest])
end
You can’t perform that action at this time.