Skip to content

Instantly share code, notes, and snippets.

@jadwigo
jadwigo / nvidiachecks.md
Created November 13, 2023 10:23
different ways to check for nvidia jetpack versions

old version - check for existing file

cat /etc/nv_tegra_release

later versions (check L4T verions)

dpkg-query --show nvidia-l4t-core

dpkg -l | grep 'nvidia-l4t-core'

@jadwigo
jadwigo / autoupdates.sh
Last active October 31, 2023 06:56
Ubuntu autoupdates (nala)
#!/bin/sh
echo "== Check required programs =="
if ! [ -x "$(command -v nala)" ]; then
echo 'Error: NALA is not installed. Please install it with "apt install nala"' >&2
exit 1
fi
if ! [ -x "$(command -v snap)" ]; then
echo 'Error: SNAP is not installed. Please install it with "nala install snap"' >&2
apt purge wolfram-engine scratch scratch2 nuscratch sonic-pi idle3 -y
apt purge smartsim java-common minecraft-pi libreoffice* geany -y
apt clean
apt autoremove -y
echo "deb http://packages.azlux.fr/debian/ bullseye main" | sudo tee /etc/apt/sources.list.d/azlux.list
wget -qO - https://azlux.fr/repo.gpg.key | sudo apt-key add -
apt update
apt install unclutter xscreensaver ssmtp mailutils ufw log2ram
@jadwigo
jadwigo / pictureframe-setup.md
Last active October 31, 2022 08:21
Installation procedure for the pictureframe

Picture screen installation

cleanup installation and remove unused big programs

sudo apt purge wolfram-engine scratch scratch2 nuscratch sonic-pi idle3 -y
sudo apt purge smartsim java-common minecraft-pi libreoffice* geany -y
sudo apt clean
sudo apt autoremove -y
@jadwigo
jadwigo / locationquery.sql
Last active April 28, 2020 20:59
Query locations in a circle of $max_distance around $input_latitude, $input_longitude
SELECT
l.*,
(
6371
* acos(
cos(
radians( $input_latitude )
)
* cos(
radians( l.latitude )
@jadwigo
jadwigo / switch-php-version.sh
Created April 5, 2020 10:05
How to switch PHP version in ubuntu 18.04
#!/bin/sh
# Show a dialog to switch between available php versions on your ubuntu 18.04 linux system
# found at https://www.ostechnix.com/how-to-switch-between-multiple-php-versions-in-ubuntu/
sudo update-alternatives --config php
-- anonymize the following tables
UPDATE `users`
SET
name = CONCAT('Anonymized ', id),
email = CONCAT('anonymized+', id, "@example.com"),
password = SHA1(CONCAT('secret', id, RAND()))
WHERE 1;
UPDATE `ls_sponsors`
@jadwigo
jadwigo / mysql_convert_blocksource_to_target.sql
Created January 29, 2020 16:05
Convert block type CMS entries to Rich HTML Textarea entries - with JSON objects too
-- # Convert block type CMS entries to Rich HTML Textarea entries - with JSON objects too #
-- Because there will be large joins make this size ridiculous
SET SESSION group_concat_max_len = 6000000;
-- String variable replacement in mysql is handy
SET @uploads_target_path = CAST('/storage/uploads/' AS CHAR CHARACTER SET utf8);
-- this inserts rows with concatenated formatted blocks
-- from source_db.page and source_db.block
@jadwigo
jadwigo / mysql_split_magic.sql
Last active January 15, 2020 20:19
Mysql split
-- https://stackoverflow.com/a/22669310/1531963
-- Assuming that the comma separated list is in table data.list,
-- and it contains listing of codes from other table classification.code, you can do something like:
SELECT
d.id, d.list, c.code
FROM
classification c
JOIN data d
ON d.list REGEXP CONCAT('[[:<:]]', c.code, '[[:>:]]');
@jadwigo
jadwigo / fix-digitalocean-composer-memory-problems.md
Last active October 1, 2023 17:07
Composer memory problems on digital ocean

If composer runs out of memory on digitalocean or another RAM limited cloud VM You need to create a swap drive

Create and activate the swapdrive as superuser And get back to the normal shell

sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=8192
sudo chmod 600 /var/swap.1
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1