Skip to content

Instantly share code, notes, and snippets.

View MidnightLightning's full-sized avatar

Brooks Boyd MidnightLightning

View GitHub Profile
@MidnightLightning
MidnightLightning / compress.php
Created February 10, 2016 19:41
Comparison of compress and deflate
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>PHP compressions</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="content-style-type" content="text/css" />
<style type="text/css">
th { text-align:right; }
.line_number { font-weight:bold; }
@MidnightLightning
MidnightLightning / pi.php
Created February 10, 2016 19:42
Compute PI
<?php
echo bcpi(12000);
function bcpi($precision){
bcscale($precision+6);
$a = bcsqrt(2);
$b = 0;
$p = bcadd(2, $a);
$i = 0;
$count = ceil(log($precision+6)/log(2))-1;
@MidnightLightning
MidnightLightning / keybase.md
Last active September 11, 2019 02:30
Proof of KeyBase identity

Keybase proof

I hereby claim:

  • I am midnightlightning on github.
  • I am midnight (https://keybase.io/midnight) on keybase.
  • I have a public key whose fingerprint is E614 FD43 CA0B 4F67 4BA9 C12A ED5D 1DD5 55C5 F46F

To claim this, I am signing this object:

@MidnightLightning
MidnightLightning / app.js
Created March 14, 2017 18:39
ESLint Atom issue
function hello () {
console.log("Hello World!");
}
hello()
pragma solidity ^0.4.11;
contract CardboardUnicorns {
address public owner;
function mint(address who, uint value);
function changeOwner(address _newOwner);
function withdraw();
function withdrawForeignTokens(address _tokenContract);
}
contract RealUnicornCongress {

Mooncats have a unique situation where each and every one of them are uniquely identified and distinct from all the other Mooncats. In most smart-contract-based voting systems/DAOs, Ethereum addresses hold some number of tokens/shares and get some proportional voting weight. But then care has to be taken that in a given voting period for any proposal, that someone cannot vote with their shares, transfer the shares to another address, and then vote again. By having the cats be the voting unit rather than the addresses, MoonCats can solve this issue very neatly.

MoonCat Clubs

Mooncats have Red, Green, and Blue values that range from 0-255. Based on those parameters, they can be separated into different groups and vote as a unit.

Three MoonCat Clubs, one for each of Red, Green, and Blue. They each act as a DAO, where the voting rights on proposals are determined by the Red/Green/Blue values of the Cats.

The Club contracts operate like a DAO in that any member can put forth a proposal (in the form of a t

@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)
@MidnightLightning
MidnightLightning / app.html
Last active May 2, 2018 20:39
React component for frozen-paned table
<html>
<head>
<meta charset="UTF-8" />
<title>Table scrolling</title>
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<style>
/* Global styles that apply to all Datatables */
.datatable-container.scrolled-vertically .datatable-body-container {
@MidnightLightning
MidnightLightning / add-folder-to-ipfs.sh
Created July 30, 2018 23:00
Add folder of content to IPFS
#!/bin/bash
DOCKERCMD="docker exec -it ipfs.service"
echo "Adding folder $1 to IPFS..."
HASHES=$($DOCKERCMD ipfs add -r -q "$1" | tr -s [:space:] ' ') # Add the folder, and strip out odd characters from result output
echo $HASHES
HASHES=($HASHES) # Convert into a set
FOLDERHASH=${HASHES[-1]} # The enclosing folder's hash is the last one in the list
@MidnightLightning
MidnightLightning / Sampler.sol
Last active September 20, 2018 19:46
Sample Solidity contract
pragma solidity ^0.4.25;
contract Sampler {
string public name = "Sample Contract";
address public owner = msg.sender;
event NewOwner(address indexed newOwner);
modifier onlyOwner {
require(msg.sender == owner, "Sender is not the Owner");