Saturday, December 26, 2020

Raspberry Pi USB to UART


Instructions on using it can be found here...

Putty is set up as a Serial Connection Type, with the speed set to 115200. The Serial Line can be identified from Device Manager in the ports tab, a the Prolific USB-To-Serial Comm Port.

Note that this doesn't appear to work with Windows 11...

Thursday, December 24, 2020

SQL Joins (MySQL)

Rows from two tables can be combined using joins.

Inner Joins

Inner joins return only the rows that meet the specified condition in both tables.

# keyword INNER is optional
SELECT * FROM toys
INNER JOIN bricks
ON toy_id = brick_id;

# Oracle syntax
SELECT * FROM toys, bricks WHERE toy_id = brick_id;

Outer Joins

Outer joins return all the rows from one table, along with the matching rows from the other. Rows without a matching entry in the outer table return null for the outer table's columns.

An outer join can either be left or right, which determines which side of the join the table returns all rows for.

# keyword OUTER is optional
SELECT * FROM toys
LEFT OUTER JOIN bricks
ON toy_id = brick_id;

SELECT * from toys
RIGHT JOIN bricks
ON toy_id = brick_id;

Full Joins

A full join includes unmatched rows from both tables. This is not supported directly by MariaDB.

SELECT * FROM toys
FULL JOIN bricks
ON toy_id = brick_id;

Cross Joins

A cross join returns every row from the first table matched to every row in the second. This will always return the Cartesian product of the two table's rows: i.e. the number of rows in the first table times the number in the second.

SELECT * FROM toys
CROSS JOIN bricks;

See also here

Wednesday, November 18, 2020

RPi Auto Reconnect

This should reconnect a Raspberry Pi if it drops from the network due to router issues...

*/5 * * * * /bin/ping -q -c10 192.168.1.254 > /dev/null 2>&1 || (sudo /sbin/ifconfig wlan0 down ;sleep 5 ;sudo /sbin/ifconfig wlan0 up ;/usr/bin/logger wifi on wlan0 restarted via crontab)

Monday, September 07, 2020

Photo Sizes


Canon EOS 40D and EOS 77D are both 4x6...

Saturday, August 08, 2020

New Raspberry Pi Set up

First, connect to the pi using the USB to UART cable, following the instructions at Adafruit, and enabling the connection in /boot/config.txt

Then set up wifi following the instructions at raspberrypi.org.

Then change the default password using:

sudo passwd pi

Then enable SSH, and update the hostname using:

sudo raspi-config
# Select Interfacing Options and enable SSH
# Select Network Options and change hostname 

Finally, update the software with:

sudo apt update
sudo apt upgrade

Saturday, May 30, 2020

Windows Terminal

Command Prompt isn't great, so Windows Terminal is welcome.

However, as with VSCode, it feels a little clunky to use and setup, primarily due to the use of a JSON file to hold the settings.This file is (unhelpfully) found at

%USERPROFILE%\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState

Settings are documented at Terminal Documentation, but the key settings are documented here:


{
    ...
 
    "initialCols": 100,
    "initialRows": 64,
    "initialPosition": "80,10",

    "profiles":
    {
        "defaults":
        {
           "fontSize": 9,
           // or consolas...
           "fontFace": "Cascadia Code",
           "useAcrylic" : true,
           "acrylicOpacity" : 0.85,
           "closeOnExit": true
        },
        "list":
        [
            {
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "hidden": false,
                "colorScheme": "One Half Dark"
            },
            {
                "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
                "name": "Ubuntu",
                "source": "Windows.Terminal.Wsl",
                "hidden": false,
                "colorScheme": "Solarized Dark",
                "startingDirectory":"//wsl$/Ubuntu/home/paul/"

            },
            {
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "Command Prompt",
                "commandline": "cmd.exe",
                "hidden": false,
                "fontFace": "consolas",
                "fontSize": "16"
            }
        ]
    }
}

Useful keys are:

  • ctrl+shift+f Search
  • alt+shift++ Create vertical pane
  • alt+shift+- Create horizontal pane
  • alt+arrow Navigate between panes
  • alt+shift+arrow Resize focused pane
  • ctrl+shift+w Close pane

Sunday, March 29, 2020

Stop Motion Animation

There is a great App for Chrome called Stop Motion Animation that is a very simple and straightforward way of creating stop motion videos.

It is straightforward and easy to use, and the kids love it.

However, it does produce files in webm format. These can be played in VLC Media Player but they can't be run in Windows Media Player.

However, they can be converted to mp4 using ffmpeg, which can be installed on either a Raspberry Pi or WSL.

# install if necessary...
sudo apt-get install ffmpeg

# then run
ffmpeg -fflags +genpts -i filename.webm -r 96 filename.mp4

Note sure about the correct frame rate, but this appears to work in this instance...

This article is probably also worth a read (though I haven't yet)...