Skip to content

Instantly share code, notes, and snippets.

@busypeoples
busypeoples / PhantomTypeReasonML.md
Last active February 6, 2024 21:29
Phantom types in ReasonML

Phantom types in ReasonML

Introduction

"A phantom type is a parametrised type whose parameters do not all appear on the right-hand side of its definition..." Haskell Wiki, PhantomType

The following write-up is intended as an introduction into using phantom types in ReasonML.

Taking a look at the above definition from the Haskell wiki, it states that phantom types are parametrised types where not all parameters appear on the right-hand side. Let's try to see if we can implement a similar example as in said wiki.

@MidnightLightning
MidnightLightning / MoonCat Staking.md
Created August 28, 2017 13:25
MoonCat Staked asset

Mooncats have Red, Green, and Blue values that range from 0-255. Based on those parameters, they have the capacity to have their colors "mined" by staking the cat for a time in a custom-purposed extractor, producing Red Kristallum, Green Kristallum, Blue Kristallum, and Dark Kristallum.

Capacity

How much Kristallum of each color a cat can produce depends on their associated Red/Green/Blue values:

  • White-colored Genesis cats have a capacity of 5000 for all three colors.
  • Black-colored Genesis cats have a capacity of zero for all three colors.

For all other cats:

  • Base capacity is 4 times the cat's color value (so, 0-1024)
@heimdallrj
heimdallrj / snakecoin-js.js
Last active October 11, 2018 02:33
JS/nodejs version for aunyks/snakecoin.py
// JS/nodejs version for aunyks/snakecoin.py
// Original: https://gist.github.com/aunyks/8f2c2fd51cc17f342737917e1c2582e2
const sha256 = require('js-sha256');
// Define the Block Class
class Block {
constructor(index, data, previousHash) {
this.index = index;
this.timestamp = new Date();

Setup

Static files and 404 pages.

{{ mkdir "build" }}
{{ copy "static/*" "build" }}
{{ render "404" | write "build/404.html" }}
@aunyks
aunyks / snakecoin-server-full-code.py
Last active May 19, 2025 01:22
The code in this gist isn't as succinct as I'd like it to be. Please bare with me and ask plenty of questions that you may have about it.
from flask import Flask
from flask import request
import json
import requests
import hashlib as hasher
import datetime as date
node = Flask(__name__)
# Define what a Snakecoin block is
class Block:
@chrisallick
chrisallick / blockchain.rb
Created July 18, 2017 14:31
tiny blockchain in ruby
#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
#import hashlib as hasher
require "rubygems"
require "digest"
# class Block:
# def __init__(self, index, timestamp, data, previous_hash):
@okonet
okonet / lightning_talk_proposal.md
Last active April 10, 2018 10:09
Make linting great again! -- ReactiveConf 2017 ⚡️talk proposal

Please 🌟 this gist to vote for this proposal!

Make linting great again!

tabs vs spaces

No other topic in software development probably has so much controversy as linting.

With a wrong workflow linting can be really a pain and will slow you and your team down. With a proper setup, though, it can save you hours of manual work reformatting the code and reducing the code-review overhead.

import hashlib as hasher
import datetime as date
# Define what a Snakecoin block is
class Block:
def __init__(self, index, timestamp, data, previous_hash):
self.index = index
self.timestamp = timestamp
self.data = data
self.previous_hash = previous_hash
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"