Version: 1.9.8
Platform: x86_64
First, install or update to the latest system software.
sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
| # https://medium.com/crypto-currently/lets-build-the-tiniest-blockchain-e70965a248b | |
| # http://ruby-for-beginners.rubymonstas.org/writing_classes/self.html | |
| # https://stackoverflow.com/questions/33768598/ruby-sha-256-hexidigest-values-are-different-from-what-python-generates | |
| require 'rubygems' | |
| require 'digest' | |
| class Block | |
| def initialize(index, timestamp, data, previous_hash) | |
| @index = index |
| # Run this script with `$ ruby has_much_fun.rb` | |
| require 'sqlite3' | |
| require 'active_record' | |
| # Use `binding.pry` anywhere in this script for easy debugging | |
| require 'pry' | |
| # Connect to an in-memory sqlite3 database | |
| ActiveRecord::Base.establish_connection( | |
| adapter: 'sqlite3', |
| def humanize secs | |
| [[60, :seconds], [60, :minutes], [24, :hours], [1000, :days]].inject([]){ |s, (count, name)| | |
| if secs > 0 | |
| secs, n = secs.divmod(count) | |
| s.unshift "#{n.to_i} #{name}" | |
| end | |
| s | |
| }.join(' ') | |
| end |