Skip to content

Instantly share code, notes, and snippets.

View seansu4you87's full-sized avatar

Sean Yu seansu4you87

  • Evenly
  • San Francisco, CA
View GitHub Profile
@seansu4you87
seansu4you87 / VitessDeadMasterRecovery2.tla
Created December 7, 2020 21:11
Vitess Dead Master Recovery
--------------------- MODULE VitessDeadMasterRecovery2 ---------------------
EXTENDS Integers, TLC, FiniteSets, Sequences
CONSTANTS NULL
\* Orc state machine
CONSTANTS ORC_RECV,
\* Send <disconnect_ssr, replica: 1> messages to replicas
\* - Replica should change ssr_master to NULL
\* - process_write_storage_request needs to response a NULL value in ssr_master
const parachuteMachine = Machine({
"id": "parachute",
"initial": "fresh",
"states": {
"fresh": {
"on": {
"transition_to_auth": "auth",
"transition_to_loan_application": "loan_application",
"transition_to_active": "active"
}
@seansu4you87
seansu4you87 / keybase.md
Created June 20, 2020 19:26
Keybase Verification

Keybase proof

I hereby claim:

  • I am seansu4you87 on github.
  • I am seansu4you87 (https://keybase.io/seansu4you87) on keybase.
  • I have a public key ASBKrLo6EelPkJ4CplXhQTbpVUrELwmYf0gYTPM2HQUwzgo

To claim this, I am signing this object:

@seansu4you87
seansu4you87 / chaos.rb
Created June 17, 2020 01:37
Chaos example
describe "Replica Reads Resilience" do
it "can survive replica failure" do
shard_1_query = User.where(id: 1)
shard_2_query = User.where(id: 2)
expect(shard_1_query.count).to eq(1)
expect(shard_2_query.count).to eq(1)
task = pod_failure :create, "vttablet-shard1-replica2"
task.join
@seansu4you87
seansu4you87 / checkout.py
Created June 12, 2017 22:14
Refactoring Interview v0.0.1
import time
import uuid
class Cart:
@classmethod
def get(cls, id):
return Cart()
def __init__(self):
@seansu4you87
seansu4you87 / chatbot.rb
Created April 16, 2017 20:40
Interface for blackbox chatbot
class Parser
end
class ChatEngine
# Jordan's Black Box
class State
attr_reader :raw
def initialize(raw)
@seansu4you87
seansu4you87 / gen_server.rb
Created August 10, 2016 23:09
A naive implementation of gen_server in Ruby, for demonstration purposes.
require "ostruct"
require "securerandom"
module GenServer
class << self
def call(pid, method, *args)
entry = fetch_entry(pid)
value, state = entry.module.send(method, entry.state, *args)
entry.state = state
update_entry(pid, entry)
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module ParserCombinators where
{-
We'll build a set of parser combinators from scratch demonstrating how
they arise as a monad transformer stack. Actually, how they arise as a
choice between two different monad transformer stacks!
@seansu4you87
seansu4you87 / io.md
Last active August 29, 2015 14:07
IO

IO

  • Input/Output, generally referred to as I/O, is a term that covers the ways that a computer interest with the outside world. Screens, keyboards, files, and networks are all forms of I/O.
  • Unix-like systems treat all external devices as files. We can see these under the /dev directory.
  • I/O streams are located under /dev/fd. Files there are given a number, known as a file descriptor. There are three default streams:
  • Standard input /dev/fd/0
  • Standard output /dev/fd/1
  • Standard error /dev/fd/2

Three Variables for GC

  1. Throughput: The amount of work done by an application as a ratio of time spent in GC.
‑XX:GCTimeRatio=99

means 99% of time spent on application computation, 1% spent in GC