Skip to content

Instantly share code, notes, and snippets.

View jkantr's full-sized avatar

Jared Kantrowitz jkantr

  • The Witzend Group
  • Metro NY Area
View GitHub Profile
@joepie91
joepie91 / blockchain.md
Last active June 25, 2023 08:40
Is my blockchain a blockchain?

Your blockchain must have all of the following properties:

  • It's a merkle tree, or a construct with equivalent properties.
  • There is no single point of trust or authority; nodes are operated by different parties.
  • Multiple 'forks' of the blockchain may exist - that is, nodes may disagree on what the full sequence of blocks looks like.
  • In the case of such a fork, there must exist a deterministic consensus algorithm of some sort to decide what the "real" blockchain looks like (ie. which fork is "correct").
  • The consensus algorithm must be executable with only the information contained in the blockchain (or its forks), and no external input (eg. no decisionmaking from a centralized 'trust node').

If your blockchain is missing any of the above properties, it is not a blockchain, it is just a ledger.

@pstef
pstef / Postgres-json-output.txt
Last active October 21, 2018 07:58
Showing of Postgres's features
WITH
manufacturers (name, headquarters) AS (VALUES
('BMW', 'Munich'), ('Toyota', 'Toyota'), ('Fiat', 'Turin')
),
models (manufacturer, name, year) AS (VALUES
('BMW', 'm4', 2000), ('BMW', 'm5', 2000),
('Toyota', 'corolla', 2000), ('Toyota', 'yaris', 2000),
('Fiat', 'panda', 2000), ('Fiat', 'uno', 2000)
),
products (manufacturer, model, color, quantity, pretax) AS (VALUES
@pstef
pstef / recursive CTE tree
Last active May 28, 2017 19:36
Representing an adjacency list as a tree, using a recursive CTE
WITH RECURSIVE
categories_rel (id, parent_id) AS (VALUES
(1, NULL), (2, NULL),
(11, 1), (12, 1), (23, 2),
(119, 11), (121, 12),
(1193, 119), (1193, 1)
),
tree (id, parent_id, r, path) AS (
SELECT id, parent_id, 0, ARRAY[id]::int[]
FROM categories_rel