Skip to content

Instantly share code, notes, and snippets.

View dleonard00's full-sized avatar

Doug Leonard dleonard00

View GitHub Profile
@dleonard00
dleonard00 / MainframeTokenDistribution.sol
Created July 10, 2018 15:30
Flattened MainframeTokenDistribution
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
dleonard00 / sync_progress.js
Created June 20, 2018 14:08
show geth sync progress
var lastPercentage = 0;var lastBlocksToGo = 0;var timeInterval = 10000;
setInterval(function(){
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
dleonard00 / Append.go
Created June 14, 2018 20:22
Mutable Resources Scratch Pad
// 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)
}
admin.addPeer("enode://0f740f471e876020566c2ce331c81b4128b9a18f636b1d4757c4eaea7f077f4b15597a743f163280293b0a7e35092064be11c4ec199b9905541852a36be9004b@206.221.178.149:30303");
admin.addPeer("enode://16d92fc94f4ec4386aca44d255853c27cbe97a4274c0df98d2b642b0cc4b2f2330e99b00b46db8a031da1a631c85e2b4742d52f5eaeca46612cd28db41fb1d7f@91.223.175.173:30303");
admin.addPeer("enode://1d70e87a2ee28a2762f1b2cd56f1b9134824a84264030539bba297f67a5bc9ec7ae3016b5f900dc59b1c27b4e258a63fc282a37b2dd6e25a8377473530513394@208.88.169.151:30303");
admin.addPeer("enode://561014f4725f2793a3ec18ae48c3524517004518454052327cfa4bb78216b774271a17db61121f6a23a51420626aacecdd177be3990e0bec34627dbf8434d806@108.232.148.241:30303");
admin.addPeer("enode://9ba1bdeed84efec70f4caa6d94be303e6d659eebbe9ba293d38a3c2242aa3f59ba6e436f83971a241c23149c0f2eab963b21b65c29ff1f9407082233204004f9@104.192.88.96:30303");
admin.addPeer("enode://cd626999588e7dba545258872c3e42f1278b9f51b70706286380558f9da93247d5b25b9d2ca0668c76e23f78a499690ab26092bb6ef56c6145fe29b1
@dleonard00
dleonard00 / MainframeToken.sol
Created June 4, 2018 20:29
Flattened MainframeToken.sol
pragma solidity ^0.4.21;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
@dleonard00
dleonard00 / swap_notes.txt
Last active May 22, 2018 14:18
Notes for swap changes
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.
@dleonard00
dleonard00 / swap_progress.md
Created April 24, 2018 22:49
swap progress.md

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
dleonard00 / golang_on_rpi.md
Created October 17, 2017 17:05 — forked from konradko/golang_on_rpi.md
Install Golang 1.7 on Raspberry Pi
wget https://storage.googleapis.com/golang/go1.7.linux-armv6l.tar.gz
tar -C /usr/local -xzf go1.7.linux-armv6l.tar.gz
export PATH=$PATH:/usr/local/go/bin
@dleonard00
dleonard00 / Bull.swift
Created June 7, 2017 18:54
Fat finger bool literal aliases
//
// Bull.swift
//
// Created by doug on 6/7/17.
//
import Foundation
let ture: BooleanLiteralType = true
let rtue: BooleanLiteralType = true
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)
return