Some versions of the Raspberry Pi/ Raspbian have NTP disabled
# to check status
timedatectl status
# to enable NTP...
sudo timedatectl set-ntp True
Some versions of the Raspberry Pi/ Raspbian have NTP disabled
# to check status
timedatectl status
# to enable NTP...
sudo timedatectl set-ntp True
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.
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.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)
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
}
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
Switch on the event scheduler in the database
SET GLOBAL event_scheduler=on;
To set it on startup, it is necessary to update "/etc/mysql/my.cnf" to add the following:
[mysqld]
event_scheduler = on
Create event to periodically update the database
USE temperatures;
CREATE DEFINER = 'root'@'localhost' event
IF NOT EXISTS snapshot
ON SCHEDULE EVERY 15 minute STARTS '2018-11-27 00:00:00'
DO
INSERT INTO temperatures.minmax
SELECT curdate(), round(min(outside_temp), 1) as min, round(max(outside_temp), 1) AS max
FROM temperatures.readings WHERE datetime > curdate()
ON DUPLICATE KEY UPDATE
min = min, max = max;
Show and delete events
SHOW EVENTS;
SHOW CREATE EVENT snapshot;
DROP EVENT snapshot;
SHOW PROCESSLIST;
Note that code blocks may need the delimiter to change to allow the client to accept nested statements:
DELIMITER //
BEGIN
SELECT * FROM mytable;
END //
To show all events:
SHOW EVENTS;
To show existing event scripts for a given event
SHOW CREATE EVENT snapshot;
And to alter event scripts
ALTER EVENT snapshot
DO
[new code];
To get rid of the annoying Ctrl+c issue use mysql -u root -p --sigint-ignore
SELECT user, host FROM mysql.user;
CREATE USER 'user'@'server' IDENTIFIED BY 'mypassword';
SHOW GRANTS FOR 'user'@'server';
GRANT INSERT, SELECT, UPDATE ON stuff.* TO 'user'@'server';
REVOKE INSERT ON stuff.* from 'user'@'server';
DROP USER 'user'@'server';
CREATE DATABASE stuff;
SHOW DATABASES;
USE stuff;
DROP DATABASE stuff;
CREATE TABLE music (
id INT unsigned NOT NULL AUTO_INCREMENT,
artist VARCHAR(50) NOT NULL,
title VARCHAR(50) NOT NULL,
PRIMARY KEY (id)
);
SHOW TABLES;
DESCRIBE music;
ALTER TABLE music ADD release_date DATETIME AFTER title;
ALTER TABLE music CHANGE COLUMN release_date rel_d DATE NOT NULL;
ALTER TABLE music DROP COLUMN rel_d, RENAME TO media;
DROP TABLE music;
INSERT INTO music (artist, title) VALUES
('Prefab Sprout', 'Steve McQueen'),
('Elbow', 'Asleep at the Back');
SELECT COUNT(*) AS total FROM music WHERE artist LIKE 'Elb%';
SELECT * FROM music WHERE release_date IS NULL ORDER BY artist;
SELECT * FROM stuff WHERE datetime > curdate() - INTERVAL 1 DAY;
SELECT * FROM temperatures.readings
WHERE pressure=(SELECT min(pressure) FROM temperatures.readings);
UPDATE music SET title='Cast of Thousands' WHERE title='Asleep at the Back';
DELETE FROM music WHERE artist='Elbow';
systemd is a system management daemon that replaces init.d and is available on most distributions./etc/systemd/system/foo.service (note that absolute path names are required, even for interpreters etc.):
[Unit]
Description=My service
Requires=network.target mysql.service
[Service]
Type=simple
ExecStart=/usr/bin/java -Dapp.properties=/home/pi/clock.properties -jar /home/pi/clock-1.1.jar
[Install]
WantedBy=multi-user.target
sudo systemctl start foosudo systemctl enable foosudo systemctl is-enabled foo