Skip to content

Instantly share code, notes, and snippets.

View rpip's full-sized avatar

Yao rpip

View GitHub Profile

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 / tictactoe.py
Last active October 23, 2021 01:49
Simple Python implementation of the classic Tic Tac Toe game. Goal : Unbeatable AI.
#!/usr/bin/env python
#--------------------------------------------------------------------------
# Tic Tac Toe game in Python
# Author: Mawuli Adzaku <mawuli@mawuli.me>
# Date: 20-05-2013
# Tested with Python 2.7
# TO RUN:
# sudo chmod a+x tictactoe.py
# ./tictactoe.py
# OR JUST RUN : python tictactoe.py
@rpip
rpip / ml.org
Created May 6, 2016 02:38
Machine learning, data science etc
@rpip
rpip / zotonic_demoserver_interface.erl
Last active December 31, 2015 20:39
An example webserver interface for Zotonic, similar to the File Service API.
-module(zotonic_demoserver_interface).
-behaviour(zotonic_webserver_interface).
-export([start/1, stop/0, restart/0]).
start(Config) ->
demoserver:start(Config).
stop() ->
demoserver:stop().
@rpip
rpip / events.erl
Last active December 21, 2015 03:09
A simple events hooks and callbacks module. This is my Erlang port of https://github.com/facine/Events
%%%-------------------------------------------------------------------
%%% @author Mawuli Adzaku <mawuli@mawuli.me>
%%% @copyright (C) 2013, Mawuli Adzaku
%%% @doc
%%% A simple events hooks and callbacks module.
%%% @end
%%% Created : 14 Aug 2013 by Mawuli Adzaku <mawuli@mawuli.me>
%%%-------------------------------------------------------------------
-module(events).
%% @doc Install the given module
install({Name, Repository}, Context) ->
Site = m_site:get(site, Context),
PrivDir = z_utils:lib_dir(priv),
SiteModulesDir = filename:join([PrivDir, "sites", Site, "modules"]),
ModuleDirname = SiteModulesDir ++ Site ++ Name,
case filelib:is_file(ModuleDirname) of
true ->
z_render:growl(?__("***ERROR: " ++ Name ++ " already installed.", Context), Context);
false ->
The responses attached to the examples were taken from the Params part of the events method arguments
in the controller as in:
event({_Event, Params, _TriggerId, _TargetId}, Context) ->
io:format("Mod_Buffer Event params : ~p", [Params]).
# 1
{% wire id="delete-{{ buffer.id }}" action={growl text="buffer deleted"} %}
<a id="delete-{{ buffer.id }}" href="#delete-{{ buffer.id }}"><i class="icon-trash"></i>Delete</a>
@rpip
rpip / arithmetic_protocol.ex
Last active December 10, 2015 17:18
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