Monday, September 07, 2020
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)...
Wednesday, November 27, 2019
Raspberry Pi NTP Time...
Some versions of the Raspberry Pi/ Raspbian have NTP disabled
# to check status
timedatectl status
# to enable NTP...
sudo timedatectl set-ntp True
Saturday, November 02, 2019
Formatting Code on Blogs...
Finally found at how to do this using prism.js from the excellent blog post here.
This is done by adding a link to the CSS in <head>, and a link to the JS before closing the <body> tag. The theme is specified with the css name, e.g. prism.min.css or prism-tomrrow.min.css. For Blogger, this has to be done by updating the Blog Theme.
<head>
...
<link
href='https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/themes/prism-tomorrow.min.css'
rel='stylesheet'/>
</head>
<body>
...
<script
src='https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/prism.min.js'/>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/plugins/autoloader/prism-autoloader.min.js"/>
</body>
There is a full list of the CDN files here, and a full list of supported languages here.
Code is enclosed within the <pre> tag to preserve formatting; and within the <code> tags, also specifying the language for highlighting:
<pre><code class="language-java">class App { public static void main(String[] args) { System.out.println("Hello World!"); } }</code></pre>
Formatting can also be done inline.
Note that to display HTML or PHP some of the symbols will need to be escaped so the browser doesn't try to parse the code. An online converter like Free Online HTML Escape Tool can do this.
Wednesday, October 09, 2019
Installing MicroPython on the ESP8266
Open a Command Prompt and do the following:
pip install esptool
# erase the flash
esptool.py --chip esp8266 erase_flash
# For the HUZZAH ESP8266 breakout buttons for GPIO0 and RESET are built in to the board
# Hold GPIO0 down, then press and release RESET (while still holding GPIO0),
# and finally release GPIO0
# install the firmware
esptool.py --chip esp8266 --port COM3 write_flash --flash_mode dio \
--flash_size detect 0x0 esp8266-20190529-v1.11.bin
Full info on the Adafruit HUZZAH ESP8266 breakout on the Adafruit website.Full info on MicroPython here.
Connection to the REPL over the serial prompt is at baudrate 115200 using Putty.
Note that the USB to UART serial console cable is connected as follows:
- n/a
- White - Tx
- Green - Rx
- Red - V+
- n/a
- Black - GND
Sunday, January 06, 2019
VirtualBox: Creating a Centos VM...
Create the VM from the DVD ISO, including GNOME.
Make sure on Settings -> System -> Pointing Device is set to USB Tablet.
Then...
'visudo' and add the following: 'paul ALL=(ALL) NOPASSWD: ALL'
sudo yum install VBoxAdditions, gcc kernel-devel dkms perl, make
cd /run/media/****/VBOXADDITIONS*
sudo ./VBoxLiuxAdditions
sudo yum install java java-1.8-openjdk-devel git
in /etc/sysconfig/network-scripts/ifcfg-enp0s3 (or the appropriate network adaptor) set 'ONBOOT=yes'
mkdir ~/git
cd ~/git
git clone -u 'sh gup.sh' paulp@*****:d:/Users/****/Documents/git-server/miscellany.git
ln -sf ~/git/miscellany/vimrc ~/.vimrc
ln -sf ~/git/miscellany/bash_aliases ~/.bash_aliases
ln -sf ~/git/miscellany/gitconfig ~/.gitconfig
Set Terminal Custom Font to DejaVu Sans Mono Book (10 or 9)
Wednesday, December 19, 2018
Instagram Download Links
Hmmm..... this no longer appears to work. Needs reworking, and check here.
To view a full size Instagram picture, append
media/?size=l, e.g.
https://www.instagram.com/p/B3hoo93BLA1UtIa4QJvMu1iyBPvX1PGbeH5XfI0/
should be updated to:
https://www.instagram.com/p/B3hoo93BLA1UtIa4QJvMu1iyBPvX1PGbeH5XfI0/media/?size=l
A simple Tampermonkey script to add a link to an Instagram page to allow the image to be downloaded.
// ==UserScript==
// @name Instagram Download Link
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Add a link to download photos....
// @author Me
// @match https://www.instagram.com/*
// @grant none
// @require https://code.jquery.com/jquery-3.3.1.min.js
// ==/UserScript==
var currentPage;
var domChangeTimer = '';
var listenerInstalled = false;
$(window).bind('load', MainAction);
function MainAction() {
// add a listener to the page so this function is run each time the page changes...
if (!listenerInstalled) {
document.addEventListener("DOMSubtreeModified", HandleDomChange, false);
listenerInstalled = true;
}
// check the current URL. This will change as AJAX changes the page...
if (currentPage != window.location.href) {
currentPage = window.location.href;
// is the link to the image available...?
var link = $('meta[property="og:image"]').attr('content');
// if not, and the page is just of a single image
// e.g. https://www.instagram.com/p/BuRxiC5Hr4i/
// then reload the page so the link is available...
// this is clumsy, but can't find another way to get at the DOM as updated by AJAX
if (window.location.href.match(/\/p\//) && link == undefined) {
window.location.reload();
} else if (!window.location.href.match(/\/p\//) && link != undefined) {
// and if we've just mmoved off a single image page
// reload again to get rid of the image metadata from our copy of the DOM
// that has since been updated by AJAX
window.location.reload();
}
console.log("Download link : " + link);
// if the link is available, add it to the page...
if (link != undefined) {
$("article").append("Download Link");
}
}
}
function HandleDomChange(zEvent) {
// why do we do this here...?
if (typeof domChangeTimer == "number") {
clearTimeout(domChangeTimer);
domChangeTimer = '';
}
// DOM has changed, so set a timer...
// Note that this may be updated numerous times, but the function
// will only be called when the timer hasn't been set for x ms
domChangeTimer = setTimeout (function() {
MainAction();
}, 500); // in ms
}
Wednesday, November 28, 2018
Counting Files
A quick bash script to count the number of files in a set of directories:
DIRS=`ls -d */`
for D in $DIRS;
do
printf "$D "
find $D -type f|wc -l
done
