Skip to content

Instantly share code, notes, and snippets.


Doug Leonard dleonard00

View GitHub Profile
dleonard00 / MainframeTokenDistribution.sol
Created Jul 10, 2018
Flattened MainframeTokenDistribution
View MainframeTokenDistribution.sol
pragma solidity ^0.4.21;
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
contract Ownable {
address public owner;
dleonard00 / sync_progress.js
Created Jun 20, 2018
show geth sync progress
View sync_progress.js
var lastPercentage = 0;var lastBlocksToGo = 0;var timeInterval = 10000;
var percentage = eth.syncing.currentBlock/eth.syncing.highestBlock*100;
var percentagePerTime = percentage - lastPercentage;
var blocksToGo = eth.syncing.highestBlock - eth.syncing.currentBlock;
var bps = (lastBlocksToGo - blocksToGo) / (timeInterval / 1000)
var etas = 100 / percentagePerTime * (timeInterval / 1000)
var etaM = parseInt(etas/60,10);
console.log(parseInt(percentage,10)+'% ETA: '+etaM+' minutes @ '+bps+'bps');
dleonard00 / Append.go
Created Jun 14, 2018
Mutable Resources Scratch Pad
View Append.go
// Add this function to the bottom of swarm/storage/filestore.go
func (f *FileStore) Append(addr Address, data io.Reader, toEncrypt bool) (newAddr Address, wait func(), err error) {
putter := NewHasherStore(f.ChunkStore, f.hashFunc, toEncrypt)
return PyramidAppend(addr, data, putter, putter)
View lightclient-peers-mainnet-latest.txt
dleonard00 / MainframeToken.sol
Created Jun 4, 2018
Flattened MainframeToken.sol
View MainframeToken.sol
pragma solidity ^0.4.21;
* @title SafeMath
* @dev Math operations with safety checks that throw on error
library SafeMath {
dleonard00 / swap_notes.txt
Last active May 22, 2018
Notes for swap changes
View swap_notes.txt
Peer should implement a send method. (as a p2p/Protocol msg Type)
Swap should be a protocol (p2p/Protocol) that the peer implements.
Swap protocol should have 2 messages (payment request, and payment)
Eliminate the 'proto' interface e.g. `self.proto.Pay(-self.balance, promise)`
This next section basically is to say, don't let the cheqbook deployment and interface logic get in the way of the developement of implementing Swap.
Leave cheque book deployment alone.
Could draft how to simplify the cheqbook.
A simplified version of the cheqbook will be deployed.

Some significant changes that impact the swap implementation are the restructuring of protocols found in swarm/network/protocol.go So far I have added back swap specific properties to the Bzz Struct and Peer Struct.

Right now, everything compiles and runs - but when I connect two swarm peers there is not any swap accounting happening. This is to be expected because I haven't yet implemented the swap instances on the Bzz or Peer Structs. I am planning to begin implementing this here

Would you mind taking a quick look at what's been done so far and help me understand if I'm headed the right direction, or if I'm way off in my approach thus far. And

dleonard00 /
Created Oct 17, 2017 — forked from konradko/
Install Golang 1.7 on Raspberry Pi
tar -C /usr/local -xzf go1.7.linux-armv6l.tar.gz
export PATH=$PATH:/usr/local/go/bin
dleonard00 / Bull.swift
Created Jun 7, 2017
Fat finger bool literal aliases
View Bull.swift
// Bull.swift
// Created by doug on 6/7/17.
import Foundation
let ture: BooleanLiteralType = true
let rtue: BooleanLiteralType = true
View all contacts.swift
lazy var contacts: [CNContact] = {
let contactStore = CNContactStore()
contactStore.requestAccess(for: .contacts, completionHandler: { (granted, error) in
guard granted else {
let alert = UIAlertController(title: "Can't access contact", message: "Please go to Settings to enable contact permissions.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
//TODO: link directly to settings app here.
self.present(alert, animated: true, completion: nil)