Brad Lucas

Programming, Clojure and other interests

Dread Pirate Roberts

August 25, 2017

The other day I overheard a conversation among a small group picking names for a team.

The name of Dread Pirate Roberts was proposed.

Someone asked who is that and another responded with, "he was the guy who created the Silk Road".

As this happened I was thinking wasn't that the name of a character in the movie The Princess Bride.

Continue reading →

Some Pyhon 2 To Python 3 Tips

August 24, 2017

A few thoughts having just tweaked a script to run under Python 3.

The newer print() function syntax works in both 2 and 3. You most likely have print "" statements in your Python 2 script. Update to the new syntax and you'll be able to work in both 2 and 3.

The write statement in the following block throws and error in 3 unless you open the file in binary mode. The following block is the updated one from my script and it runs in 2 and 3.

    with open (filename, 'wb') as handle:
        for block in response.iter_content(1024):
Continue reading →

Run A Command In Each Sub-Directory of a Directory

August 23, 2017

If you ever want to run the same command in each sub-directory of a directory consider the following example.

Replace the value for COMMAND with your own command.

$ for d in `find . -maxdepth 1 -type d`; do pushd > /dev/null $d; $COMMAND; popd > /dev/null; done

Or setup your own command by putting the following in your .bashrc file.

Continue reading →

Wait For An Ethereum Transaction To Be Mined

August 22, 2017

Working with testrpc hides you from one reality in particular when working with a blockchain. That is that sometimes the time to finish a transaction can take some time. The mining to fully realize the transaction not only has a cost in ether (for Ethereum) but a cost in time as you wait for your transaction to complete.

Moving your application to the testnet will show you this right away. Now, when you have this happen you'll start to wonder how to handle something like an update to your screen after the transaction is complete.

Here is a pattern that works using a function listed below that gets the promise of an Ethereum transaction when it is mined.

You call your sendTransaction then pass your transaction hash into getTransactionRecipteMined with a then in which you have your function to update your UI.

Continue reading →

Change Ethereum Account Password

August 21, 2017

If you need to change one of your Ethereum account passwords using Geth you'll find the account update command will work.

If you are running your node on the testnet make sure to pass in the --testnet flag.

Here is a sample session:

$ geth --testnet account list
Account #0: {634b8e79b0155e5ac1303c2fe4b1d30f2fc6b930} keystore:///Users/brad/Library/Ethereum/testnet/keystore/UTC--2017-03-13T18-48-40.744428053Z--634b8e79b0155e5ac1303c2fe4b1d30f2fc6b930

$ geth --testnet account update 634b8e79b0155e5ac1303c2fe4b1d30f2fc6b930
Unlocking account 634b8e79b0155e5ac1303c2fe4b1d30f2fc6b930 | Attempt 1/3
INFO [08-22|11:40:45] Unlocked account                         address=0x634b8e79b0155e5ac1303c2fe4b1d30f2fc6b930
Please give a new password. Do not forget this password.
Repeat passphrase: 
Continue reading →