Crypto-currency mining

I’m curious, because I’m a tech enthusiast. But I don’t have free power so it’s not a feasible proposition.

But this current craze is annoying me for another pair of reasons: lack of supply of GPUs and hiked prices.

I’m currently looking at building a small, powerful-but-portable system based around a Ryzen CPU. Because AMD cards don’t do CUDA, I’m stuck buying nVidia. That doesn’t bother me that much… but the 50% price hike I’ve seen the GTX 1070 undergo in the last fortnight is… vexing. In fact, I was so annoyed I was thinking about buying a 1060 instead… oh, wait, they’re all out of stock! So in desperation, I looked at 1080s… which is far more than I wanted to spend… they’re OoS as well.

1050’s aren’t, but they’re not even as powerful as my laptop. I have no pressing desire for a “downgrade”-upgrade.


Headless RaspPi: Tell Me Where You Are

I like several of the little SBC (Single Board Computer) systems that are available, despite having a love/hate relationship with my favourite – the ODROID C2. For the minute I’m stuck with just a Raspberry Pi 3 as a little SBC, so needs must when the devil, etc etc…

Anyway, when you control your own network, as I used to, it doesn’t really matter what IP DHCP decides to assign to each system. I could look it up on the router easily enough, or even fix an IP address based on MAC address.

OK, fine… but what if you don’t control your router?

Well, you could brute-force scan the entire known IP range of the network using NMAP… (nmap -sS xxx.yyy.zzz.0/24) but that seems a little extreme. It works in a pinch, though, and might be the only way of finding it that all important first time.

Once you know where it is, however, how can you keep it? On a network you don’t control, you can get jumped around the IP range depending on how the router is feeling and how many others are connected. Not very useful.

Here’s a little script modified from another one that didn’t work for me… (requires Python 2, not Python 3…)

Ah, and I found where the mods come from…!

This will send you an e-mail telling you your headless systems’ IP when the RPi boots.

Just add this to a file with vi, then chmod +x it:

import subprocess
import smtplib
import socket
from email.mime.text import MIMEText
import datetime
# Change to your own account information
to = ''
gmail_user = ''
gmail_password = 'yourpassword'
smtpserver = smtplib.SMTP('', 587)
smtpserver.login(gmail_user, gmail_password)
today =
# Very Linux Specific
arg='ip route list'
data = p.communicate()
split_data = data[0].split()
ipaddr = split_data[split_data.index('src')+1]
my_ip = 'Your ip is %s' %  ipaddr
msg = MIMEText(my_ip)
msg['Subject'] = 'IP For RaspberryPi on %s' % today.strftime('%b %d %Y')
msg['From'] = gmail_user
msg['To'] = to
smtpserver.sendmail(gmail_user, [to], msg.as_string())

You’ll also need to add python /home/user/bin/scripts/ to your rc.local, just before the exit 0 at the end.

IMPORTANT: Obviously, since you just put your Gmail password in a plain text file (really, really bad security practice!) just set up a gmail account to only do this one thing. Or, if you want, you could set up a mailserver on your Pi.

That may become the topic of a future post. In fact, it probably will, because I can’t believe I just suggested putting a password in plaintext.

Linux Ping Script… (Finally…)

Anyone reading this may remember I was having intermittent – but regular and extremely annoying – network dropouts in my accommodation.

Well, I finally got twenty minutes (and a network switch so I can have more than one thing plugged in to the LAN at once) to get my act together and update my little Raspberry Pi 3 so it can sit and (low power) ping a server and let me know when the network drops out.

Just like the Windows version, this only writes to the log file when it can’t connect – so if your network never drops out, you’ll never even see the log file get created. You can test it by changing the sleep time and what it greps for (if you change sleep to 1 and grep unknown to grep PING, you can check it works…)

Just save it somewhere sensible, like /home/user/bin/scripts or similar, chmod +x it, and run it from the terminal. Force it to the background and you can log out and leave it ticking over.

while true; do
     x=`ping -c1 2>&1 | grep unknown`
     if [ ! "$x" = "" ]; then
         date >> brokentimes-pingtest.txt
sleep 30

Debian 8 Upgrade to Debian 9: Key Error

There is no public key available for the following key IDs:

If you’re getting an error like the above when attempting to upgrade to Debian 9 (the new Stable version), it’s an easy fix:

sudo apt-get install debian-keyring debian-archive-keyring

Complaints about keys scare me something chronic, as it can be a sign that the repo (or worse, your OS) has been compromised… so I always look for a way to solve it.

Fortunately this one was easy.