Published

Setting up Laravel Valet + MySQL via Homebrew

After far too much delay, I’ve finally ditched MAMP Pro. 🎉

I’m now trying Laravel Valet + MySQL via Homebrew for local PHP development on my MacBook Pro. The notes below are an account of the steps I took for future reference. There were some fiddly points getting started and I expect there to be more, but I’m pretty pleased with the swap overall.


0. Back up databases

The pre-step is to back up any preexisting databases so that you can set them up later if needed. Personally, I use Sequel Pro for all local and some remote database management, so I pulled my necessary exports from there.

1. Install and configure Laravel Valet

The first step is to install Laravel Valet. Their installation docs are pretty much all that is needed. The only caveat is that I’d be a little careful about updating Homebrew or Composer willy nilly, just be wary if you already have it installed and need your preexisting version for any reason. While completing the installation steps, pay attention to the warnings! Complete any recommended steps if you can, they pop up for a reason.

If all went well, at this point you should have an Apache server so you’d be ready to work on a file-based website such as one that uses Kirby CMS or a static site generator (Hugo, Gatsby, Jekyll, etc).

2. Install and configure MySQL with Homebrew

To work on a database-driven site like a Craft CMS or WordPress build, the next step is to install MySQL via Homebrew.

The Laravel Valet docs mention this step, but for me it was nowhere *near* as simple as their two-command recommendation. I think there was likely a conflict with my preexisting MAMP-specific MySQL setup and possibly an old Homebrew installation. I ran the commands from the Valet docs to install MySQL v5.7 and run it, but I would get the error The server requested authentication method unknown to the client [caching_sha2_password] on the front-end. This error indicated that it was actually running MySQL v8 (read more). Sure enough, mysql --version returned mysql Ver 8.0.16 for osx10.14 on x86_64 (Homebrew). To sort it out, I had to reinstall and restart the MySQL service.

To remove MySQL, I followed these instructions. (Be careful with those commands, they remove a lot of stuff.)

After I’d gotten rid of MySQL, I ran the Homebrew commands below to install, link, and start the service.

brew install mysql@5.7
brew link --force mysql@5.7
brew services start mysql@5.7

Note that I tried doing this without the link but consistently ran in to the error Can't connect to local MySQL server through socket '/tmp/mysql.sock' when trying to connect in the next steps. Linking seemed to sort it.

The Homebrew installation command recommended a step involving mysql_secure_installation which sets the root user’s password. We need this for phpMyAdmin and Sequel Pro (coming up below), so I completed this step as well.

3. Set up and / import databases

Once MySQL is set up and running, it’s time to set up your databases. Check out this article for some useful instructions on how to create a user and database on the command line. To import one of your SQL exports from earlier, run mysql -u [username] -p [databasename] < [filename.sql] replacing the bits in brackets with your username, database, and filename. When prompted, enter the password you set up via mysql_secure_installation.

Otherwise, you can do add your database via a UI such as phpMyAdmin (see Laravel Valet-friendly steps) or Sequel Pro.

4. Adjust PHP settings (optional)

I usually adjust my PHP settings (e.g. memory_limit, max_execution_time, post_max_size, etc.) to something that is similar most of my sites’ production hosting environments. Ideally this would be less manual (Docker? Ansible?), but that’s exploration for another day.

I thought that changing the PHP settings would be as simple as adjusting the php.ini file that is specified in the “Loaded Configuration File” value returned by phpinfo(). I edited /usr/local/etc/php/7.2/php.ini and then ran valet restart to restart the server and… it didn’t work. One of my changes was respected according to phpinfo(), but the rest weren’t.

I checked the “Additional .ini files parsed” value and saw that the file /usr/local/etc/php/7.2/conf.d/php-memory-limits.ini was also in use. After I edited this file to include my preferred settings and restarted Valet, all was well.

5. Adjust Nginx config (optional)

Valet’s default Nginx config should normally be sufficient, but you might have to tweak it for certain edge cases.

My edge case was the British Earways site (read more). I was working with it locally and suddenly ran in to a 413 Request Entity Too Large error when attempting to upload a very large audio file. To get around this, I needed to raise the client_max_body_size Nginx directive.

To adjust the Nginx configuration, I first had a look at the main config file by running /usr/local/etc/nginx/nginx.conf. Scanning through that, I saw a few includes:

include "/Users/[username]/.config/valet/Nginx/*";
include servers/*;
include valet/valet.conf;

I had a look at /Users/[username]/.config/valet/Nginx/valet.conf, found client_max_body_size and changed that value to suit my requirements, and then restarted the server by running valet restart.

Other useful things

Run brew services list to find out which services are running. This is useful for troubleshooting if you’re having PHP or mySQL errors.

If you’re adjusting the PHP settings in a .ini file, run valet restart, and then suddenly start seeing only an “It works!” screen where your site should be, you probably have to stop Apache first before restarting Valet. Most guidance online recommends running apachectl stop, but I had trouble with this (see related StackOverflow thread). Instead, I ran valet stop, sudo killall httpd, then valet start. This worked smoothly.

Here’s a list of MySQL commands.

For more info about what $PATH is and why it’s important, see this Unix & Linux Stack Exchange thread or notes on the command line geared towards beginners.

I usually use redirect rules to use media from production when developing locally, for example when working on the WordPress theme that powers this site. Laravel Valet doesn’t seem to play nice with the normal .htaccess method, maybe because it’s actually an Nginx server. See “Proxying images to a remote host on Laravel Valet” for an effective alternative using a local driver.

On an image-heavy project using Craft CMS, I ran in to a 504 error brick wall at one point. Could not for the life of me figure out the problem, even after pouring over the error logs. Ultimately I uninstalled and then reinstalled valet, and that seemed to do the trick.


Edit 10 July 2019 – Added further notes based on working with Laravel Valet the past few days, including the PHP and Nginx config adjustments.

Edit 04 October 2019 – Various small wording adjustments and additional reference links. Used these notes for reference when working with SB to adjust his own setup, and it was clear that some bits could use clarification.

Edit 18 October 2019 – Added note regarding 504 errors.

Published

Preventing email spoofing

Been getting a bunch of targeted phishing emails recently. They’re pretending to be my domain registrar, saying that payment is overdue and they’re going to delete my domain permanently. I’ve received similar things before, but this one of the more convincing and aggressive attempts I’ve seen.

This reminded me about a task on my backlog of TODOs, sorting out my domain’s SPF and DKIM. Both are email authentication methods designed to detect forged sender addresses in emails, a.k.a. email spoofing. SPF + DKIM won’t prevent inbound phishing emails, but they do help prevent my own domain from being spoofed in shady outbound emails.

I’d forgotten to add a SPF record so sorted that out. I made sure to add include values for both my email provider and my web host since the web host is responsible for sending things such as password reset emails from the CMS. Unfortunately, my email host Gandi doesn’t support DKIM. 🙁 So that’s a non-starter.

I’ve been considering switching to Proton though, and happily they offer SPF, DKIM, and DMARC. Maybe I’ll make the switch a bigger priority. Gandi has mentioned that they’re working on implementing DKIM though, so maybe I’ll just check back later this year

Eventually I’ll look in to a DMARC policy, but that’s going to come a little later.

A few links that may be useful:


Edit 21.02.20 – Added link to EasyEngine tutorial b/c I previously was using ?all and received a spoofed email from my domain on another email address I have. *facepalm*

Published

britishearways.com

Screenshot of britishearways.com

Last month, I completed a major overhaul of the British Earways website. The design by Valerio di Lucente of Julia is almost entirely unchanged, the adjustments were largely performance-related and under the hood, geared towards modern browsers. Here’s brief rundown of the changes:

  • Style the full-window player layouts using CSS Grid Layout + 100% height (not 100vh since that can lead to unexpected behaviour on mobile browsers), and use CSS Scroll Snap w/ polyfill for scroll behaviour
  • Achieve flexible typography and spacing with “CSS Locks
  • On non-touch screens, implement invisible DragDealer instances so that each player’s scrubber can be dragged
  • On touch screens, add click event listeners that advance the relevant scrubber to the click target
  • Use styled HTML5 progress elements for each player since these are easily manipulated via their max and value attributes and don’t require adjustment if the window is resized
  • Use the Web Audio API to initialise each audio file and trigger the necessary state changes as the time updates
  • Switch the audio preload attribute from auto to metadata to reduce the size of the page when it initially loads
  • Update CMS to Kirby 3 (this was a joy, IMO the panel layout options make v3 much more client-friendly)
  • Adjust post_max_size, memory_limit, max_execution_time, and upload_max_filesize to allow upload of large (150MB+) audio files

I ran in to one issue that isn’t yet resolved. Kirby copies all uploaded media from the private /content folder to the publicly-accessible /media folder. This copying normally happens almost instantly, even with very large files. On the BE site however, the copy is pretty slow. Since the site pulls the audio duration from the audio file itself via the Web Audio API, the displayed duration is incorrect until the file has finished copying. This is almost certainly related to some rate limiting done by the shared hosting company, a legacy from the preexisting site. It isn’t a huge deal since the copying always finishes eventually, but it isn’t the best behaviour. I’d like to raise the issue with the hosting company but don’t have high hopes, shared hosting providers use rate limiting for a reason.

At any rate, I’m really looking forward to seeing how DB uses the site over the next year and listening to the new mixes.

Published

Setting up a Raspberry server + daemonized Homebase for pinning Dat websites

This suite of tutorials is the result of a recent Agorama Server Co-op workshop day. They cover how to set up a Raspberry Pi, how to use an Ansible playbook to easily get a Pi set up as a server, and how to run Homebase on a Raspberry server.

A Raspberry Pi 3 Model B+


Introduction

Mise en scène

For almost all of the tutorials below, you’ll need: a computer, a Raspberry Pi, a power supply for your Pi (read more), an SD card appropriate to your requirements (read more), and an SD card reader. You may also find an ethernet cable useful if your Pi has an ethernet port.

Personally, I’m working with: a 15ʺ MacBook Pro with an SD card port; a Raspberry Pi 3 Model B+; a SanDisk Ultra 16GB micro SD card with an 80Mbps read speed that came with a microSD adapter; and the charger from an old Android phone.

Glossary

Some of these tutorials are like a mini crash course in server administration. You don’t need to know much to get started and mess around, but it is useful to be aware of a few terms. If you’re unfamiliar with any of the terms used, see below for very brief explanations.

Ansible
An IT automation tool
Beaker
Primarily a browser for Dat and HTTP/S websites; also offers website seeding and other features
booting
The startup sequence that happens when you turn on a computer
command line
A text interface where you can write in commands for your computer; on a Mac, you can open the command line by firing up the Terminal application
daemon
A computer program that runs as a background process; most people pronounce it “DEE-muhn”
Dat
A peer-to-peer protocol for sharing websites, files, and other data over the internet
Etcher
Software that can be used to flash OS images on to SD cards or USB drives; a free and open-source Electron app developed by Balena
flashing
To update a drive with a new program such as an operating system
Git
A version control system widely used by programmers and web developers
Homebase
“A self-deployable tool for managing websites published with the Dat protocol”; by the Beaker team
image
A serialized copy of an entire computer system stored safely in a file
IP address
A series of numbers separated by periods that is assigned to each computer connected to a network
mount
Making a drive such as an SD card or an external hard drive accessible to your computer; in theory, all you should usually have to do to mount a drive is plug it in to your computer
Nano
A simple command line text editor; for more complex editing, emacs or vi may be preferable
operating system (OS)
System software that manages a computer’s software and hardware; if you compared all of the software on a computer to a house, the OS would be the foundations
pinning
Synonymous with seeding or hosting for Dat sites; read more in the Beaker documentation
pip
Python package manager
playbook
A defined set of scripts and variables used by Ansible for server configuration
Python
A programming language
Raspbian
The Raspberry Pi Foundation’s officially supported operating system
root (directory)
The top-level directory in a filesystem; if you compared the filesystem to a family tree, the root would be the oldest ancestor at the very top of the tree
root (user)
The user with administrative privileges; it’s a powerful user so should be kept very secure
SD card
A memory card often used in portable devices; SD stands for “secure digital”
service
With computers, a service is usually a program that runs in the background; if you were to compare a computer with a human, you might compare a service to breathing
SSH
A protocol for connecting to a server securely over a potentially insecure network; SSH stands for “Secure Shell”
SSH key
An SSH key is used to log in to SSH; it is considered much more secure than a simple username + password combo
user
With servers, a “user” is an account with a particular set of privileges and permissions
wpa_supplicant
Cross-platform software that implements WiFi security protocols including WPA and WPA2; the wpa_supplicant.conf file configures wpa_supplicant

Set up a Raspberry Pi for the first time

Flash Raspbian on an SD card using Etcher
  1. If you don’t already have it installed, download and install Etcher.
  2. Download your preferred Raspbian image as a .zip file. If you will only be using the Raspberry Pi as a server, such as with Homebase, you may wish to go with Raspbian Lite.
  3. Plug your SD card in to your card reader so that it mounts on your computer.
  4. Flash the Raspbian image on to your SD card by opening the downloaded image in Etcher, selecting your mounted SD card, and then clicking flash. Use caution. Flashing will overwrite anything on the selected drive. If you accidentally select an external hard drive instead of your SD, you’re going to have a bad time.
  5. When Etcher is done, remove the SD card. It should have been unmounted as part of the flashing process, but double-check before you pull it out of the card reader.

Flashing the Raspbian image on to an SD can be done manually instead of using Etcher. For further info, see the base of the “Installing operating system images” page on raspberrypi.org.

If you want to connect the Pi to a WiFi network or enable SSH, complete those steps before booting the Pi.

Connect a Raspberry Pi to WiFi on the command line

This tutorial assumes you have flashed Raspbian on an SD card but have not yet booted the Pi. If you have already booted the Pi, see instructions on how to change the existing WiFi configuration on the command line.

Plug your SD card in to your card reader so that it mounts on your computer.

Open the command line and run:

nano /Volumes/boot/wpa_supplicant.conf

This will open a blank file using nano. Paste in the configuration below:

country=gb
update_config=1
ctrl_interface=/var/run/wpa_supplicant

network={
  scan_ssid=1
  ssid="YOUR_NETWORK_NAME"
  psk="YOUR_NETWORK_PASSWORD"
}

Be sure to change the ssid and psk values to your WiFi network name and password respectively. The country value should be set to the ISO 3166-1 alpha-2 code for the country the Pi is in.

If you are planning to use the Raspberry Pi on a few networks, you should add any other required networks to this file as so:

country=gb
update_config=1
ctrl_interface=/var/run/wpa_supplicant

network={
  scan_ssid=1
  ssid="YOUR_NETWORK_NAME_1"
  psk="YOUR_NETWORK_PASSWORD_1"
  priority = 1
}

network={
  scan_ssid=1
  ssid="YOUR_NETWORK_NAME_2"
  psk="YOUR_NETWORK_PASSWORD_2"
  priority = 2
}

When you are done editing the credentials, save the wpa_supplicant.conf file and close Nano.

If you want to enable SSH but haven’t yet done so, complete that step before you boot the Pi for the first time.

When you are ready to boot the Pi for the first time and test the WiFi connection, insert the SD card in the Raspberry Pi and plug the Pi in to a power source. Give it a minute or two, then view the devices on the network. If the Pi shows up, you’re ready to go.

If you are planning to use the Raspberry Pi as a server, such as to run Homebase, you may wish to keep it plugged in to the ethernet for a more stable connection.

Enable SSH on a Raspberry Pi

As of late 2016, Raspbian has SSH disabled by default. This is to protect users from accidentally making their Pi accessible to the internet with default credentials. This tutorial assumes you have flashed Raspbian on an SD card but have not yet booted the Pi.

Plug your SD card in to your card reader so that it mounts on your computer.

Next, open the command line and run

touch /Volumes/boot/ssh

This will create a new empty file titled ssh in the root of your SD card. This empty file will allow you to connect via SSH when the Pi is first booted.

If you get an error after running the touch command that says No such file or directory, check that your SD card has mounted correctly and check that Raspbian is installed on the SD card.

If you want to connect the Pi to a WiFi network but haven’t yet done so, complete that step before you boot the Pi for the first time.

Log in to a Raspberry Pi via SSH as the root user pi

This tutorial assumes you have already flashed Raspbian on an SD card, have enabled SSH, have connected the Pi to the internet via WiFi or ethernet, and have booted the Pi.

Open the command line and run:

ssh pi@raspberrypi.local

If this is the first time you are connecting via SSH then type in the default password raspberry. If you don’t plan to use Agorama’s Ansible playbook to configure your SSH credentials, you must change your default password by using the passwd command (read more). Keeping the default password in place and enabling SSH just invites bad guys to do shady things with your Pi.

If this is not the first time you are connecting via SSH, use the password you configured with passwd or the password you added to the Ansible playbook.

For security reasons, nothing will show on the screen while you are typing your password.

If nothing happens when you attempt to log in, your Pi may not be connected to the internet.

If you receive a Permission denied error, you will need to find the Pi’s IP address. View the devices on the network to determine the IP. Once you have the Pi’s IP address, try logging in as instructed above but replace raspberrypi.local with your Pi’s IP address. If you had to take this step, you may want to write down your Pi’s IP address for use in other steps on this page.

If you receive an error relating to the ECDSA host key changing, see the guidance below guidance below related to ECDSA errors.


Use Ansible playbook to configure Raspberry Pi server

About Agorama’s Ansible playbook

Agorama’s Ansible Raspberry server playbook automates a number of fiddly tasks that are required to get a Raspberry Pi set up as a server geared towards use with Homebase. You can get a feel for the tasks that will be performed by the playbook by browsing the files within the playbook, working backwards from all.yml.

As of late April 2019, the tasks performed by the playbook include:

  • Set up user accounts and apply basic updates & security
  • Prepare Raspberry Pi to run Node.js apps
    • Run nodesource.node
    • Create global package directory
    • Add global package directory to .npmrc
    • Add global package directory to PATH
  • Install nginx web server

Future tasks planned for the playbook include DNS configuration and HTTPS support.

Regardless of what method you use to set up a server, and no matter where the server “lives” – on a Raspberry Pi, a DigitalOcean droplet, or anywhere else – the most important thing to remember is that it is your responsibility to keep it secure and up-to-date.

Install Ansible and get the playbook

This tutorial assumes you have Python, pip, and git installed on your computer.

Open the command line.

Install the Python packages Ansible and Passlib by running:

pip install ansible passlib

Next, clone Agorama’s ansible-raspberry-server repository:

git clone https://github.com/agoramaHub/ansible-raspberry-server.git

and change directories in to the root of that repository by running:

cd ansible-raspberry-server

Now you are ready to add your SSH credentials to this Ansible playbook and configure a Raspberry Pi.

Add your SSH credentials and timezone to the playbook

This tutorial assumes you have already set up Ansible and the playbook. It also assumes that you have set up SSH keys (see tutorial on DigitalOcean).

Open the command line and change directories to the root directory of the cloned Ansible playbook by running the command below. Replace the path with the correct path on your computer.

cd /path/to/your/ansible-raspberry-server

To add your SSH key and change the password for the root pi user, run the command:

ansible-playbook 01-auth.yml

You will be prompted to add your public key path and set a password for the root user. The default key path should be fine unless you placed your public key somewhere other than the default path when you created it. Set the password to the password you would prefer to use when you log in to the root pi user via SSH. Note that you will not need to use this password often since you are adding your SSH key, however you will need it when you first run the playbook.

When you have finished answering each prompt, the output will be saved to vars/auth.yml with the password encrypted by passlib.

To check and edit the timezone, run:

nano vars/base.yml

to open the base variables file with nano. If you need to change the timezone, edit the ntp_timezone value and save this file.

Run the playbook

This tutorial assumes you have already set up Ansible and the playbook, have configured your SSH credentials in the playbook, have flashed Raspbian, have enabled SSH, have connected the Pi to the internet via WiFi or ethernet, and have booted the Pi.

Open the command line and change directories to the root directory of the cloned Ansible playbook by running the command below. Replace the path with the correct path on your computer.

cd /path/to/your/ansible-raspberry-server

When you’re ready, run the playbook:

ansible-playbook all.yml --ask-pass

If the command fails because it cannot find the Pi, you need to change the hosts file so that the script can find the Pi via its IP address. View the devices on the network to determine the IP, then run:

nano hosts

to open the hosts file with nano. Replace raspberrypi.local with your Raspberry Pi’s IP address. You may add additional Raspberry Pi IP addresses to this file if you want to run the playbook on multiple Pis. When you are done editing, save and close this file and then run the ansible-playbook command above again.

You will be prompted for the password you added to the playbook. If your SSH key is added and you can log in successfully then the playbook will proceed to configure the Raspberry Pi, logging tasks as they are performed.

Note: if you configured a passphrase for your SSH key when you set it up, you will be asked for this as well and will be asked for it each time you connect to your Raspberry Pi via SSH in the future. See this StackExchange thread for a few suggestions on how to avoid being asked for the passphrase every time.


Run Homebase on a Raspberry Pi server

Install dat and homebase

This tutorial assumes that you have set up a Raspberry Pi and have configured it for use as a server using Agorama’s Ansible playbook or via other means. It also assumes that your configured Raspberry Pi is on and connected to the internet and that you have logged in via SSH.

For security purposes, the Ansible playbook configures worker user on Raspberry server so that we’re not using the root user pi to install and run software. When you first log in with SSH you are logged in as the root user, so we need to switch to worker by running:

sudo su worker

Next, install dat:

npm install -g dat

Test whether or not the dat installation works with the Pi configuration by running:

dat doctor

When prompted, select the peer-to-peer test and send the command it returns to a friend that has dat installed. Ask the friend to run the command. If dat doctor returns successful, then you’re all good. Disconnect from dat doctor by typing ctrl + c.

Install homebase by running:

npm install -g @beaker/homebase

Change directory to the user root:

cd

and then create a Homebase config. Run:

nano .homebase.yml

to open up the Homebase config with nano, then paste in:

dats:
  - url: dat://01cd482f39eb729cdcbb479b03b0c76c6def9cfc9cff276a564a17c99c4432f4/
  - url: dat://b0bc462c23e3ca1fee7731d0a1a2dc38bd9b9385daa413520e25aea0a26237a6/
  - url: dat://f707397e8dacc1893dced5afa285bab1715b70fe40135c2e14aac7de52f2c6bb/

directory: ~/.homebase        # where your data will be stored

# For API service. Establish API endpoint through port 80 (http)
ports:
  http: 8080                  # HTTP port for redirects or non-TLS serving

This config will set up a pinning service without DNS support that pins three Agorama-related URLs. Feel free to replace them with URLs of your choice. Save and close the file when you’re done editing.

Next, run homebase:

homebase

The response should indicate success and that your URLs from the .homebase.yml file are being pinned.

If you get an error message here or when you ran dat doctor, you may need to check the configuration of your Raspberry Pi.

Daemonize homebase with systemd

This tutorial assumes that you have set up a Raspberry Pi, have configured it with Agorama’s Ansible Raspberry playbook according to the instructions above, and have installed dat and homebase on the Pi. It also assumes that your configured Raspberry Pi is on and connected to the internet and that you have logged in via SSH.

Daemonizing homebase means that it will constantly run in the background as long as the service hasn’t failed, the server is on, and the server is connected to the internet. This is important because the whole point is that we want the Dat sites specified in .homebase.yml to run in perpetuity.

First, add a service configuration for homebase. As the root user pi, run:

nano /etc/systemd/system/homebase.service

to open a new file with nano. Paste in:

[Unit]
Description=homebase

[Service]
Type=simple
ExecStart=/usr/bin/env .npm-packages/bin/homebase
WorkingDirectory=/home/worker/
Restart=on-failure
StandardInput=null
StandardOutput=syslog
StandardError=syslog
Restart=always
SyslogIdentifier=homebase
User=worker
Group=worker

[Install]
WantedBy=multi-user.target

This configuration file indicates (amongst other things) which user will run the service, where to find homebase, and whether or not to restart when the system is rebooted.

To start the service, run:

sudo service homebase start

To stop the service, run:

sudo service homebase stop

To read the logs, run:

journalctl -u homebase

If the service is running and is working as it should, you should be able to visit any of the URLs you added to your .homebase.yml config file in Beaker Browser.

NOTE
A few friendly folks have suggested pm2 for daemonizing Homebase (see Twitter thread). This is also what is suggested in the Homebase readme, and it’s what I used previously when getting Homebase set up on DigitalOcean. It worked great for me, but this time round we used systemd because two people at the workshop had rough experiences using pm2 with Homebase on a Raspberry Pi. I think it had something to do with a crazy amount of memory usage? Not 100% sure, I think we may cover this in a future workshop.


Related tasks, troubleshooting, and edits

Useful commands

These are very basic examples of some useful commands. Have a search online for more powerful examples.

To change directory:

cd preferred/directory

To list the files in a directory (omit directoryname if you want to list the files in the current directory):

ls directoryname

To display the contents of a file:

cat filename

To edit a file using nano (the file will be created in the current directory if it doesn’t exist):

nano filename

To reboot a Raspberry Pi, be sure you are connected via SSH as the pi root user and then run:

sudo reboot

To disconnect from an SSH session, type ctrl + d

It isn’t a great idea to just pull the plug on a Raspberry Pi to turn it off since it can cause problems with your SD card or the file system. To shut down a Raspberry Pi:

sudo shutdown -h now
View all devices connected to a network

It can be useful to view all devices connected to a network if you want to check your Raspberry Pi’s WiFi connection or need to identify its IP address.

You can use your router’s admin interface, the mobile app Fing, or the network scanning tool nmap to view a list of the devices connected to your network.

If you are trying to find a Raspberry Pi’s IP address and there are a lot of devices connected, you may need to use the list of devices and the process of elimination (i.e. turn devices on and off and see what disappears).

If the SD card will not mount

If you plug in an SD card and it will not mount, try to use your system tools such as Disk Utility to check for the drive. If that doesn’t work, try restarting your computer. If that doesn’t work, try different hardware such as a friend’s computer or an external card reader. I know at least four people with Macbook Pros that have dealt with defective card reader ports.

Fixing ECDSA error triggered at SSH login when a Raspberry Pi has been connected to a new network

If you added your SSH key using Agorama’s Ansible Raspberry playbook and then move your Pi on to a new network, you will probably receive an error relating to the ECDSA host key changing. The base of the warning message should indicate that you can fix this by adding the correct host key in ~/.ssh/known_hosts.

One way to resolve this is to re-add your SSH credentials to the Ansible playbook and then run the playbook so that your SSH keys are added again.

Changing the WiFi configuration for an existing Raspberry Pi on the command line

If you did not add your new network to your wpa_supplicant.config file when you first set up WiFi on your Pi, you will need to add your new network to this file.

If your Raspberry Pi does not have an ethernet port, it may be easiest to start from scratch (flash Raspbian on to the SD card and configure the wpa_supplicant.conf file).

If your Raspberry Pi has an ethernet port, connect it to the network via ethernet. Open the command line and connect via SSH, then run:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

This will open up the wpa_supplicant.conf with nano. Scroll down the file and edit the network details as per the WiFi connection instructions above.

When you are done editing, save and close the file then disconnect your Raspberry Pi from the ethernet. To test the connection, check for the Raspberry Pi by viewing all of the devices connected to the network. If the Pi is not connected after a couple minutes, try rebooting the Raspberry Pi.

List of edits
  • 03.03.19 – Added note about pm2 to “Daemonize homebase with systemd” tutorial

Next steps include configuring HTTPS support, DNS support, and getting more familiar with the maintenance involved in this setup. I think there is also some complication involving DMZ and routers, but I’m very unfamiliar with those implications at this point. I have a feeling we’ll dig in to a lot of this during the upcoming Agorama Server Co-op evenings and workshops. See the Agorama site and their Twitter account for dates.

Thanks to the Agorama folks – organisers and fellow attendees – for a very fun workshop.

Published

Site update: a new taxonomy index and a11y improvements

Just pushed an update to this site.

The Browse page is now mainly an index of taxonomies and archives (years, post formats, categories, tags). This new index replaces the opacity-based tag cloud. I kind of miss it, but it was problematic. Very hard to digest, and the lighter greys were way too low-contrast.

Besides the index, most of the changes are related to accessibility. I focused on making the tabbing experience a bit better, introducing a couple skip links. Note that I haven’t totally ironed out the tabbing… Most of my manual testing for this update was done in Chrome. I checked it briefly in Safari and it’s pretty weird, but I think it may have to do with the default Safari settings. I haven’t adjusted these yet, read more about Safari tab settings on a11yproject.com. Besides the tabbing, I also had a handful of links that weren’t suitably descriptive, particularly on the new term index. I added more aria-label attributes where I could. See the “Using aria-label for link purpose” page on the WCAG wiki for more info.

I’m trying to work on accessibility a bit more on an ongoing basis. Need to take a little dive in to this Hacker News thread, via this tweet.

See also:

There are probably a million a11y optimisations I can / should still make on this site. Suggestions are very welcome.

Edit 08.11.19 – Added Mozilla accessibility blog post

Published

Richard Hollis’s book on Henry van de Velde, and a note on the index

Spread from book on Henry van de Velde by Richard Hollis

Richard Hollis’s Henry van de Velde: The Artist as Designer is out at long last. A lot of love, sweat, and tears has gone in to that book. It is absolutely jam packed, covering pretty much all of HvdV’s life with over 400 images. As part of Occasional Papers, I worked on the permissions, a bit of editing, and compiled the index.

Read about how the index was compiled

Published

“the insistence in any of them will necessarily lead to suffering”

The experience of the Self that is given in the existence of a personality comprises five conditioned attributes, namely, corporeal form (rûpa), sensations (vedanâ), perceptions (saññâ), emotions (sankhâra) and consciousness (viññâna). These five clusters (pañca khandha) determine all the body and mental phenomena of our contingent and finite experience. The North–American Buddhist philosopher Robert Thurman gives us vivid images of each of the mentioned elements:

We begin by looking at the body. We can […] thump our chests and say, ‘I’m me’, but surely we are not just a bunch of ribs. We look in the mirror and say, ‘There I am’, but we say the same thing when we see old snapshots of ourselves […] We can explore cells, axons, and dendrites; molecules, DNA, and RNA; atoms, subatomic quantum particles, unnameable forces and energies. Nowhere we can find anything still, static, independent. […]

We can move on to our minds and begin by sifting through our feelings, sensations, pleasures, pains, or numbnesses. […] I investigate my sensory surfaces and, after some time, give up finding any stable, self–sufficient ‘I’ anywhere along them.

Then we can move into images, words, symbols, ideas, concepts, mental pictures. This at first seems promising. ‘I’ is a word, after all. The names ‘Alice’, ‘Joe’, ‘Carol’, and ‘Shakyamuni’ all are nouns. When I pronounce my own name, ‘Bob’, does an image of myself arise in my mind? Is it a recent snapshot of my face? […] A curriculum vitae? A biography? Is it a favorite logo? A trademark? A symbol? […] None touches the essence of ‘me’. […]

We can move deeper into the motions of the mind, into emotions. When ‘I’ love or am in love, I feel powerfully present, even in the moment of feeling that solidity melting. When ‘I’ hate, I am carried away by destructive impulses […] – all these energies seem to take hold of ‘me’, or seem to emanate from ‘I’. But as I think them through, observe them in actuality or in memory, they seem fully bound in relationships. […]

At last we come to awareness itself, to look at our very consciousness […] But to turn toward my center of awareness, I have to tell my awareness to turn back on itself.

Thurman, Robert, Inner Revolution: Life, Liberty, and the Pursuit of Real Happiness, New York: Riverhead Books, 1998 (pp.74–79)

What we can say is that our personality is but the result of a combination of those five elements – to the point that the belief in its autonomy and permanence ends up being a suffering–causing illusion. In none of the mentioned clusters would we be able to detect the presence of an autonomous and unconditioned subject; therefore, the insistence in any of them will necessarily lead to suffering.

Correia, Carlos João, Personal Identity and Eastern Thought”, Filozofija i Društvo, vol 20 no 3, Belgrade: University of Belgrade, 2009 (pp.74–75)


I came across Prof. Correia’s paper when doing a bit of research on western vs. eastern perspectives on identity and the self. Side note: I don’t think I’ve ever seen such a strong profile photo as the one on Bob Thurman’s site.

Published

Agorama ~#5: distributed web, quantum, crypto, and a dash of CS history

70’s wallpaper in Rebecca’s Flat at Raven Row, London

Last night was my third Agorama Server Co-op meet up in Rebecca’s Flat, a delightfully dilapidated space at Raven Row. I think it was actually the fifth though, I missed the last two due to illness which was a real bummer. The weekend jam sounded particularly great.

This particular meetup was more informal and a little smaller than usual. It ended up being a really nice, wandering conversation on the multifaceted possibilities of the distributed web, what it could look like.

The notes below are a sort of a prompt dump, snippets I wrote down at the time because I didn’t want to forget it or wanted to look in to it more. See all Server Co-op write-ups here.


Dark Crystal is now up and running on Patchbay (ssb client). Got Samsung funding, woohoo! Possible to create bot that receives shard? Think they’re trying to avoid that, the human element is kind of critical.

What about physical crypto? Microdots are worth checking out. Microdot tattoos?

Asked what ppl think about potential threat of quantum computing to modern cryptography methods, response was a little not as I expected (this is why I come to these things!). Personally I’ve been feeling a little tin-foil-hat-y, but general consensus from the other voices in the room seemed to be pretty ambivalent since the theory far outstrips the practicalities currently. Which is true, but it also just feels kind of like an arms race (particularly since it involves hardware / infrastructure). Whoever cracks it first wins the golden goose unless we can come up with cryptography that works against it. GP then mentioned the post-quantum crypto contest with NIST due to end pretty soon, looks pretty promising. I didn’t realise there was that much going on with quantum resistant algorithm research, so that makes me feel a bit better. I guess my concern is still there though, to a big degree. Banks, for example, are on notoriously crappy tech that is rarely overhauled. What of them, and the other institutions we rely on? Oh lord, and voting tech…

Got talking about what I’d been up to (not much, see first para…) and mentioned that I ultimately decided not to move my site on to Dat, partly due to scale issues w/ static site generators (read more on this) but more to do with the fact that I think I’d rather use Dat for something new and neato, rather than just repurpose something that already exists and is doing ok in it’s current form. Then we started talking about static site generators more generally and someone mentioned Pelican, which I hadn’t come across before. It’s written in Python and originally released in 2010 (!), so up there with Jekyll as one of the earlier static site generators.

HL demoed his mother-of-all-apps for us, it looks *so great*! Absolutely something I would use. Really excited to see where he takes it. I need to look in to Hypercore and Expo a bit more. The first I’d heard of, the second not so much. Apparently Expo is a cross platform app framework built around React Native. Ppl could not say enough good things about it and honestly, it does look fantastic. Particularly as a tool to dip your toe in to app waters, so to speak.

Towards the end of the demo, the conversation wound through lots of different topics. Blockchain, platforms vs aggregators, a bunch of CS history (need to read more about that…), the sustainability of open source, etc. The rest of this note details snippets from this part of the conversation that I need to look in to more.

Services / apps / platforms I’d like to look in to a bit:

  • Mapeo, an “open source, offline-first map editor”
  • Manyverse, kind of Scuttlebutt for your phone but better (shouldn’t suck the life out of your phone trying to sync)
  • Node.js for mobile apps
  • Webrecorder, like a personal Wayback Machine; also, did you know you can sometimes find YouTube vids that have been taken down archived on the Wayback Machine?
  • TMYK

A reading list. (Some of these links are painful to open, some orgs really need to cool their jets on the pop-ups and trackers):

Some soundbites. These are paraphrased points made by others that I found super-relevant. Bits in square brackets are added by me for clarity:

  • “Ordering is the toughest thing to sort out” [when it comes to ledgers / append-only logs]
  • “Biggest problem with blockchain is the definition of consensus, and how to establish consensus”
  • Article 13 [aka the “upload filter” provision] is forcing people’s hand, we’re going to see a lot more of this.”
  • “So much of this bullshit has come from chasing the technology and not the needs.” Related: “But seriously… does it need to be an app?”
  • “The future of the web will be much more about interoperability than a black-and-white, decentralised vs centralised approach.”
  • “Porn is a canary in the coal mine for whether a piece of tech is ready for primetime.” [Is someone using it for porn? Ok, it’s going to gain traction.]
  • “Could we ever have another Xerox PARC?” “Probably not, research now is just too results-driven. A report every week, and sometimes the funder has already indicated what they’d prefer your results to be.”

So many distributed / decentralised web conversations get quasi-evangelical about how this or that tech will save the world. Why does it have to be winner takes it all? Different needs require different technologies.

We recognise biodiversity as a fundamental requirement of a healthy, thriving biosphere. Why don’t we champion technodiversity in the same way? Embrace the chaos.

Published

moreish

“Moreish” is a word that doesn’t exist in American English, but it should.

We were discussing moreish-ness in relation to oatmeal cookies the other day. What makes a food moreish, something that hits the spot but also leaves a void, leaves you wanting a little more?

At the time, I felt that it requires multi-dimensionality, just enough contrast. When something is too on-the-nose, it isn’t moreish. Cookies without a pinch of salt, tomato sauce without a little sweetness.

Since then I’ve been thinking about moreish-ness a lot outside of the context of food, and the contrast idea stands up.

Outfits, websites, books, relationships. Requires more exploration.