Skip to content

Instantly share code, notes, and snippets.

Blockchain 101

Transactions are bundled into a Block. Blocks are then chained together into a "blockchain".

The way the chain of transactions and linked blocks are verified is what we call consensus algorithms. The consensus algorithm varies based on the incentives for the network operators/participants: Proof of Work, Proof of Stake etc.

Not every transaction has a recipient; in this case, this is a smart contract, which is basically a script deployed on the blockchain. In most cases, every blockchain transaction is a script but the execution/decryption of this script is tied to someone (recipient's) secret key. So for smart contracts, usually there is no recipient.

If you're not familiar with blockchains, I would advise that you don't dig into the technical implementation as it's quite complicated. Think of the datasets as regular databases tables connected by primary keys (in this case, fields). Focus on high-level constructs as below:

@rpip
rpip / ml.org
Created May 6, 2016 02:38
Machine learning, data science etc
@rpip
rpip / arithmetic_protocol.ex
Last active August 13, 2024 10:50
Arithmetic protocol for Elixir
defprotocol Arithmetic.Add do
@moduledoc """
The Arithmetic.Add protocol is responsible for adding items.
The only function required to be implemented is
`__add__` which does the addition.
"""
def __add__(left, right)
end
@rpip
rpip / passwd.py
Last active August 29, 2015 14:09
Generate passwords for KeePass database. Output: (password, hash)
#!/usr/bin/env python
# USAGE: ./bin/passwd $password_prefix $dbpath $inventory_hostname -w
import sys, os
import string
import random
from datetime import datetime
from keepass import kpdb
from passlib.hash import sha256_crypt
@rpip
rpip / asm-notes.md
Last active August 29, 2015 14:05
my study notes ASM x86/i386

x86 / IA-32 registers

  • register is 32 bit wide

general registers

  1. eax - accumulator
  2. ebx - base
  3. ecx - counter
  4. edx - data
  5. esi - source index
@rpip
rpip / emacs-notes.md
Last active August 29, 2015 14:04
Notes on learning Emacs

Notes on learning Emacs

basics

C-x f => open file

C-x s => save file

C-x C-w => save to a new file

@rpip
rpip / edfs.md
Last active August 29, 2015 14:04

Design

The new eDFS architecture is designed with the assumption that a single master system has a single point of failure. In a single-point-of-failure system, the failure of the master node will result in the termination of jobs and the loss of access to the entire system. This will not happen in a cluster where the master node is dynamically elected.

Therefore, each node in the cluster will be a self-containing full copy of eDFS. On startup, the system reads the cluster configuration and sets up the node cluster. All nodes start as followers; one node is elected to be a leader at the start. During normal operation, the leader maintains a heartbeat which allows the followers to detect if the leader fails or becomes partitioned.

defmodule DefStructPlusPlus do
@doc """
Macro for defining structs
## Examples
defmodule Models do
import DefStructPlusPlus