James Ball

Web Developer

PI Cluster

As of writing this is simply a hobby project at the moment and doesn’t dive into server configuration.

Hardware

Requirements

Install Pi Images

Follow this tutorial from Raspberry Pi to install your images to each of the SD cards.

SSH keys

We need a SSH key in order to connect to the cluster without having to type the password every time we access.

In case you don’t have any, run this command and follow the steps.

ssh-keygen -t rsa -b 4096 -C "[email protected]"

`Add the key to your ssh agent, assuming our keys generated are id_rsa and id_rsa.pub

ssh-add ~/.ssh/id_rsa

The enable ssh if it isn’t running:

1
2
sudo systemctl enable ssh
sudo systemctl start ssh

Wifi Setup Script

Next we’ll need to set up Wifi on the Master Node only:

1
2
3
4
5
6
7
8
9
SSID="YOUR-WIFI-SSID"
PSK="YOUR-WIFI-PASSWORD"

echo "network={
   ssid=\"$SSID\"
   psk=\"$PSK\"
}" >> /etc/wpa_supplicant/wpa_supplicant.conf

sudo shutdown -r now

Running Commands On Multiple Instances

This can be done by iterating of the NODES list (modify as required) on the Master Node. Then you can add the required command calls in this mock example, I’ll clear all the data in the /var/www/ directory:

1
2
3
4
5
6
7
8
9
10
11
declare NODES=("localhost
192.168.0.1
192.168.0.2
192.168.0.3
192.168.0.4
")

for $NODE in $NODES
do
    rsync -v -r --delete -e ssh /var/www/ "www-data@{$NODE}:/var/www/"
done

In Conclusion

This is just the foundation for setting up pi cluster hardware without diving into server configuration as this is just a hobby project at the moment. I may research Kubernetes in the future, of which I may create a follow up article on.

Magic the Gathering: Arena; on Linux With Wine

  1. Download the latest .msi file, here
  2. Execute the following from the terminal: wine start MTGAInstaller_0.1.3213.823095.msi.
  3. Follow the Setup Wizard prompts. It will look something like this:

  1. Once installation is complete, go to your Wine path then enter Wizards of the Coast and run chmod +x MTGA.exe.
  2. And finally launch it via wine MTGA.exe.

Xscreensaver Wallpaper

Install Xwinwrap

This article assumes you already have Xscreensaver installed.

Note for a full list of backgrounds run ls /usr/lib/xscreensaver/.

  1. git clone https://github.com/ujjwal96/xwinwrap.git
  2. cd xwinwrap
  3. make
  4. sudo make install
  5. make clean
1
2
#!/bin/bash
xwinwrap -b -fs -sp -fs -nf -ov  -- /usr/lib/xscreensaver/cubicgrid -root -window-id WID &

Source

Install Google Webfont on Debian

Download desired fonts

  • https://fonts.google.com/specimen/Raleway

Install Google Fonts on Debian

  • cd /usr/share/fonts
  • sudo mkdir googlefonts
  • cd googlefonts
  • sudo unzip -d . ~/Downloads/Raleway.zip
  • sudo chmod -R --reference=/usr/share/fonts/opentype /usr/share/fonts/googlefonts

Register fonts

  • sudo fc-cache -fv

Check if font installed

  • fc-match Raleway (Name is camelcased if name has spaces)

PHP Lambda Functions Approved!

1
2
3
4
5
6
$extended = function ($c) use ($callable, $factory) {
    return $callable($factory($c), $c);
};

// with arrow function
$extended = fn($c) => $callable($factory($c), $c);
1
2
3
4
5
6
7
// Laravel collection example
$users->map(function($user) {
    return $user->first_name . ' ' . $user->last_name;
});

// with arrow function
$users->map(fn($user) => $user->first_name . ' ' . $user->last_name);