Skip to content

Instantly share code, notes, and snippets.

@icook
icook / interblock_time.ipynb
Last active February 24, 2016 19:38
This IPython notebook generates graphs of the moving average inter-block time for a blockchain.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Acting as your own Certificate authority

For securing internal services, acting as your own CA can be very convenient. Buying a wildcard SSL cert might be too expensive, or your internal services span multiple domains, etc. A lot of people will simply use self signed certs, which are definitely better than nothing, but leave you open to MITM attacks and require clicking through warning screens frequently.

By acting as your own CA internal services can be tightly secured by requiring

@icook
icook / hash_test.ipynb
Last active April 6, 2016 14:21
Experiment in reverse video search
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
blocks = list of all the blocks in the current chain
fork_number = the block height we'll fork to new adjustment algorithm at
coins_distributed = 0
for block in blocks:
# This block template doesn't have subsidy information, IE, we don't know
# how much was paid out in the coinbase
if block.height < fork_number:
# using the regular subsidy adjustment schedule and determine what the coinbase would have been at this height
coins_distributed += subsidy for this block
# Easy alias for switching to perform actions as another
# user, even if they have no login shell
as_other() {
pushd `eval echo ~$1`
sudo -H -u $1 -s /bin/bash
popd
}
alias as=as_other
@icook
icook / share_proc_multiprocessing.py
Last active March 18, 2017 00:20
A benchmark for using a Python multiprocessing pool to process pool share submissions
from multiprocessing import Pool
from vtc_scrypt import getPoWHash
from time import sleep
import gevent
import os
import time
def f(x):
return getPoWHash(x)
@icook
icook / sochain_websocket.py
Last active January 24, 2019 19:48
SoChain python example
"""
A simple demo for using https://chain.so/api#realtime-balance-updates with Python.
Install my fork of pusherclient with:
pip install git+https://github.com/icook/PythonPusherClient.git
"""
import pusherclient
import time
import json
import pprint
@icook
icook / secure_wallet.md
Last active August 29, 2015 14:08
How to secure your wallet

Cryptocurrency is powerful because it gives you complete control over your money, but this also puts the responsibility of proper security and procedures completely with you. As part of SimpleCrypto's goal of advancing cryptocurrency accessibility we've put together an educational article on how to properly secure your wallets and ensure that your funds are safe at all times.

Which wallet?

All cryptocurrencies use a "wallet" of some kind. A wallet is a program that allows you to send and recieve cryptocurrency. Well established currencies

@icook
icook / gist:d6532b2de1020e08a32e
Created September 10, 2014 00:18
Fix wrong SQLA polymorphic
+@manager.command
+def fix_credits():
+ from simplecoin.models import CreditExchange
+ credit_table = Credit.__table__
+ credit_exc_table = CreditExchange.__table__
+ for credit in Credit.query.options(db.joinedload('block')).order_by(Credit.id):
+ correct = 1
+ if credit.block and credit.block.currency == credit.currency:
+ correct = 0
+
@icook
icook / gist:a58006b63aefca2f726e
Created September 9, 2014 23:06
Terrible hacky fix
diff --git a/manage.py b/manage.py
index 1619883..ad70f5b 100755
--- a/manage.py
+++ b/manage.py
@@ -9,7 +9,7 @@ from flask.ext.migrate import MigrateCommand
from simplecoin import create_manage_app, db, currencies, powerpools
from simplecoin.scheduler import SchedulerCommand
-from simplecoin.models import Transaction, UserSettings, Credit, ShareSlice, DeviceSlice
+from simplecoin.models import Transaction, UserSettings, Credit, ShareSlice, DeviceSlice, Block