Will Cosgrove

I’m bad at writing these things

Read this first

A Tale of two Phlexes

There are two types of components you can write in Phlex. The standard component exposes a “builder” style API. The second type is a component that uses DeferredRender, which fully consumes the render block before its own template is rendered.

Let’s take a look at both types by building two different Table components.

The first component will use a builder style API.

class Table < Phlex::HTML
  def template
    table do
      yield
    end
  end

  def head
    thead do
      tr do
        yield
      end
    end
  end

  def column_heading
    th { yield }
  end

  def body
    tbody { yield }
  end

  def row
    tr { yield }
  end

  def cell
    td { yield }
  end
end

And we can imagine how we might use it:

render Table.new do |t|
  t.head do
    t.column_heading { "Name" }
    t.column_heading { "Age" }
  end

  t.body do
    t.row do
      t.cell { "Alice" }
      t.cell {
...

Continue reading →


On Scarcity and Value

DALL·E 2023-01-30 11.50.46 - an empty beer bottle with a sticker on it that says _free_ sitting next to a bitcoin.png

I had dinner with some friends recently and the topic of Bitcoin came up, as it does when I’m a part of these sorts of things. Someone asked me why I thought bitcoin was valuable. I said, because it is scarce. We were on round three of our drinks at this point in the evening so I tried to keep my answer brief. Another friend then set his empty beer bottle down on the table and proclaimed: “This bottle is one of a kind. Why isn’t it valuable?” I fumbled an answer that was trying to make the point that I had another one in my fridge that I could drink that would be indistinguishable from his, casting shadows on his “one of a kind” claim. It wasn’t the clearest question, but I also didn’t give a great answer in return.

If I could distill his question down to something a bit more straightforward, I would state it as: Why does scarcity make something valuable? There are plenty of things...

Continue reading →


Misconceptions About Bitcoin Exchanges

There is a common misconception I hear when talking to people who are newer to bitcoin. It concerns exchanges and how they fit into Bitcoin. People hear about the blockchain, and how transactions go on it; they assume that when they log on to their exchange of choice and make a purchase of some bitcoin, that a transaction has been added to the blockchain ledger.

This isn’t an unreasonable assumption. But in reality, exchanges have nothing to do with Bitcoin, the network, or the protocol. They are their own entity, operating however they please. That isn’t to say that an exchange couldn’t operate in a way so that every trade that happened on their platform had some corresponding entry in the blockchain. But it would be slow and costly to do so.

When you buy bitcoin on an exchange, what is happening? I’m going to generalize; some exchanges may work differently than this. But on the...

Continue reading →


An Exploration of Bitcoin Transactions, the Blockchain, and Miners

What will follow is a walk-through of bitcoin’s circular lifecycle as it gets transacted from person to person. Because of the circular nature, there’s not an ideal starting point, because you must always know what came before to truly make sense of where you currently are. So we will start with some unexplained givens, and work our way around the circle from there until we finally understand what we at first had to take for granted.

Bitcoin Lifecycle

We will be working our way around this circle, starting at Build, and taking some detours along the way to explain certain concepts in more detail.

What’s in a Transaction? (Build)

Wallet vs Address

Addresses are a surprisingly complex topic, and I won’t be covering exactly how they work here. But the distinction between a wallet and an address is important. An address is where bitcoin is sent, and a wallet has many addresses. When you view your...

Continue reading →


A Beginners Guide to Using a Hardware Wallet

Preface

The terminology can get a bit confusing, especially with the overuse of the word “wallet” which means different things in different contexts. Just a quick glossary:

  • Wallet - Some data that can be used to generate receive addresses, and sign transactions. It can be serialized into a “backup phrase” or “seed words”, these or variations of these are used around the internet to describe the same thing.
  • Hardware Wallet - A device that generates and stores a wallet using some kind of secure element.
  • Software Wallet - Software running on a computer or phone that can generate/store/recover a wallet.
  • Steel Wallet - a cute name for a very durable recording of the seed words of a wallet, usually in actual steel.

The terminology is not great. People hear “wallet” and imagine the thing they store in their pocket, and this is conceptually quite a bit more complex than the folded dead cow...

Continue reading →