Thursday, October 24, 2024

Upgrading a dot net + Wordpress server from Ubuntu 22.04 to 24.04

Instead of a fresh install on a fresh server, I tried the alternate method of upgrading in-place for our AWS server running a dot net app and a couple of Wordpress instances. A snapshot was taken by PB just before the upgrade, to be able to roll back in case of a failed upgrade. The snapshot took around half an hour to complete. 

Running do-release-upgrade resulted in the error "Please install all available updates for your release before upgrading"
Apparently, just apt upgrade is not enough, we have to do a dist-upgrade to upgrade the packages which have been "held back". https://itsfoss.com/apt-get-upgrade-vs-dist-upgrade/
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
sudo apt autoremove
sudo do-release-upgrade

During the upgrade, it warned that the upgrade is being done over ssh, and that it is starting an ssh daemon on port 1022 also. But I didn't have to use that port or request PB to open that port in the AWS firewall. There were several warnings about configuration files existing, and the default was to not overwrite them - which is what I chose. The upgrade itself completed in ten minutes, and a reboot was uneventful except for an apache error.

service apache2 status
showed that the web server was down, an error in the conf file, php8.1 module not found. Now, I knew that 24.04 had php8.3 and not 8.1, so the error was understandable. I thought I would need to again follow the LAMP stack install - https://www.digitalocean.com/community/tutorials/how-to-install-lamp-stack-on-ubuntu - but no - just had to do
 sudo a2dismod php8.1
 sudo a2enmod php8.3
and 
 sudo systemctl restart apache2

The next issue was that the dot net service was not running. It was stuck in a restart loop. Disabled the service we had created as per this post - https://hnsws.blogspot.com/2023/05/dot-net-core-ubuntu-linux-server.html

Running the command to be executed on the command line  
dotnet --version
Command 'dotnet' not found, but can be installed with:
sudo snap install dotnet-sdk       # version 8.0.403, or
sudo apt  install dotnet-host-8.0  # version 8.0.10-0ubuntu1~24.04.1
sudo apt  install dotnet-host      # version 6.0.135-0ubuntu1~22.04.1
sudo apt  install dotnet-host-7.0  # version 7.0.119-0ubuntu1~22.04.1


Also, we had earlier pinned dot net to install from Microsoft's servers, but with Ubuntu 24, we're supposed to use Ubuntu's repositories. So, deleted the lines mentioned in this post,
sudo nano /etc/apt/preferences
Package: dotnet-* aspnetcore-* netstandard-*
Pin: origin "packages.microsoft.com"
Pin-Priority: 999
(deleted those lines)

sudo apt-get install -y aspnetcore-runtime-8.0
/usr/bin/dotnet /home/path/to/OurWebApi.dll
This gave the error
You must install or update .NET to run this application.
F
ramework: 'Microsoft.NETCore.App', version '7.0.0' (x64)
.NET location: /usr/lib/dotnet/
The following frameworks were found:
  8.0.10

which said framework 7 had reached end of life. So, requested the maintainers to target dot net 8.0 instead of 7.0, which they did in a few hours, after which I restarted the service, and the app was running again.

Tuesday, October 22, 2024

Deleting many GBs of course content from Moodle

Deleting large courses had a tendency to make one of our Moodle instances time out. As I found out by trial and error, and as mentioned at https://moodle.org/mod/forum/discuss.php?d=207712
in such cases, we have to delete module by module, I guess. That worked, but found that for one of our instances, there were still many GB of data in the moodledata filedir, so probably it was data which was not referenced in the database, due to earlier site cloning. 

cd /the/moodle/directory
moosh file-dbcheck > /path/to/filestodelete.txt

Then I just edited the filestodelete.txt to pre-pend sudo rm -f to each filename in the list, and ran it to get rid of around 8 GB. Completed in less than a minute. 

checking ssd size

After purchasing some SSDs at a 50% discount on Amazon, I wanted to check if they are really 256 GB SSDs. 

With the aim of filling up at least 100 GB of space on the disk, I just tried
truncate --size 1G foo
shred --iterations 1 foo

That completed in less than a minute. But the same thing with 100G instead of 1G - truncate completed instantly, but shred was going to take time. After ten minutes or so, I cancelled it. Then tried copying over the 100 GB file from one disk to another etc, that was also not complaining, so I concluded that the disk was fine. 

Thursday, October 17, 2024

Moodle - Activity Completion Restriction not visible

There was a request for support, that on one of our Moodle instances, we do not see the 'Activity Completion' as an option in 'Restriction'.

From the documentation page,
In Site administration > Plugins > Availability restrictions > Manage restrictions you can enable or disable (Hide/Show) any of the individual restriction types for use throughout the site. This was already enabled for the Moodle instance.

Maybe if you choose the first activity of a course, this option may not be available. Or if the activity is of type forum?

If I choose the second activity of this course, I see this as an option.

Another possibility for a newly created activity might be: 
it might need to be saved once before the condition appears, --or--
the completion condition might need to be added to the activity and saved before the condition appears, --or--
maybe you can save changes, log out and log in again and then it becomes visible.

Doing all of the above definitely seems to work.

Wednesday, October 16, 2024

H5P on moodle - core activity vs mod_hvp plugin

Since mod_hvp plugin is not yet updated for Moodle version 4.5, we have deferred our upgrade. Looking at options, whether to use the built-in H5P support in Moodle, there's a discussion at 
and the auto-translated German forum discussion is at

The main points seem to be: the built-in plugin does not have H5P Hub support, and also is "low priority" in Moodle development. But then, some Moodle developers say that is not the case, as in this discussion - 

There is a migration tool, 

But then it seems to have some open issues like

So, it may be better to maintain status quo and wait for the mod_hvp plugin to be updated in a few months.

Moodle - change course backup location

 Exploring if we could change the "manual backup" location for courses, to put the backups in another directory rather than along with all the other files in moodledata/filedir, tried changing in Site Admin --> Courses --> Backups --> Automated backup setup -

But it looks like the path set there in backup_auto_destination seems to be valid only for automated backups. The manual backups initiated from the course are still saved in filedir. So, while taking backups of the entire server's moodledata directory, we are forced to take backups of backups.

Moodle plugin upgrade - click to upgrade not available

On one of our newly migrated Moodle instances, the "Click to update" button to update plugins for which updates are available, was not seen - only the button allowing us to download and then manually update the plugin was visible. As mentioned in this discussion,

https://moodle.org/mod/forum/discuss.php?d=434830

it was a permissions issue.

sudo chown -R azureuser:www-data .
sudo chmod -R 775 .


and hey presto - the install button came back when I went back to the plugins overview page.

Tuesday, October 15, 2024

rclone authentication by tunneling port did not work the second time

On one server, we used the method
https://hnsws.blogspot.com/2023/01/backing-up-mysql-databases-to-google.html
to set up an rclone remote with a shared google drive.


sudo dpkg -i rclone-current-linux-amd64.deb
to install latest rclone, tunnel port 53682 with putty so that we can authorize with browser.

When we tried with another server, exactly the same way, error that localhost refused to connect. That is, the port 53682 tunneling and authentication for rclone was not happening. 

Tried things like rebooting the local Windows machine, trying another browser and so on. But the only thing which worked was to do the "headless" option in rclone - first downloaded the latest rclone exe file, overwrote the version in C:\Windows which I had used earlier, and followed the online prompts.
https://rclone.org/remote_setup/

Maybe this is due to some sort of caching? But persisting after reboots? No idea. More probable might be some typo in configuring the tunnel in putty, I guess. Or maybe the port was being tunneled elsewhere or something like that.

Monday, October 14, 2024

default behaviour for unattended-upgrades

Since we had used Ubuntu 24.04 minimal images for some new servers, we had to check if unattended upgrades were installed and enabled -

Basically we have to check if an auto-upgrades file is present in /etc/apt/apt.conf.d/ and check if the Allowed-Origins are appropriate. In the case of this Ubuntu 24.04 minimal Azure image, the allowed origins not commented out were:
       "${distro_id}:${distro_codename}";
        "${distro_id}:${distro_codename}-security";
        // Extended Security Maintenance; doesn't necessarily exist for
        // every release and this system may not have it installed, but if
        // available, the policy for updates is such that unattended-upgrades
        // should also install from here by default.
        "${distro_id}ESMApps:${distro_codename}-apps-security";
        "${distro_id}ESM:${distro_codename}-infra-security";

So, all is good.

optimizing mysql for Moodle

Following

https://docs.moodle.org/405/en/Performance_recommendations#MySQL_Performance

That page pointed to
https://dev.mysql.com/doc/refman/5.7/en/innodb-buffer-pool-resize.html

SELECT @@innodb_buffer_pool_size/1024/1024/1024;
+------------------------------------------+
| @@innodb_buffer_pool_size/1024/1024/1024 |
+------------------------------------------+
|                           0.125000000000 |
+------------------------------------------+
1 row in set (0.00 sec)

mysql> \q


Can increase at least to 2G.

https://stackoverflow.com/questions/19534144/how-to-set-global-innodb-buffer-pool-size
mysql -u root -p
SET GLOBAL innodb_buffer_pool_size=2G;
ERROR 1232 (42000): Incorrect argument type to variable 'innodb_buffer_pool_size'


https://convertlive.com/u/convert/gigabytes/to/bytes#2

SET GLOBAL innodb_buffer_pool_size=2147483648;
Query OK, 0 rows affected (0.01 sec)


Running mysqltuner
https://www.linode.com/docs/guides/how-to-optimize-mysql-performance-using-mysqltuner/

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Check warning line(s) in /var/log/mysql/error.log file
    Check error line(s) in /var/log/mysql/error.log file
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=ON
    We will suggest raising the 'join_buffer_size' until JOINs not using indexes are found.
             See https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_join_buffer_size
    Be careful, increasing innodb_redo_log_capacity means higher crash recovery mean time
Variables to adjust:
    skip-name-resolve=ON
    join_buffer_size (> 256.0K, or always use indexes with JOINs)
    table_definition_cache (2000) > 3098 or -1 (autosizing if supported)
    innodb_buffer_pool_size (>= 12.4G) if possible.
    innodb_redo_log_capacity should be (=512M) if possible, so InnoDB Redo log Capacity equals 25% of buffer pool size.
    innodb_buffer_pool_instances(=2)
    innodb_log_buffer_size (> 16M)


So, on our Ubuntu 24.04 server,

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf


skip-name-resolve=ON is not found
    join_buffer_size (> 256.0K, or always use indexes with JOINs) is not found

Tried editing my.cnf directly and restarted.
But restart failed. Need to enter with spaces between = ?
innodb_buffer_pool_size = 2G
This change worked OK on restarting mysql.


innodb_buffer_pool_size         = 2G
#join_buffer_size               = 256.0K this crashes.
innodb_redo_log_capacity        = 512M
innodb_buffer_pool_instances    = 2
innodb_log_buffer_size          = 16M


The above worked. Not doing the other recommendations, as a mysql restart crashes.

Some more recommendations, which we have not done:

Consider using postgresql instead.

Optimize your tables weekly and after upgrading Moodle. It is good practice to also optimize your tables after performing a large data deletion exercise, e.g. at the end of your semester or academic year. This will ensure that index files are up to date. Backup your database first and then use:
mysql>CHECK TABLE mdl_tablename;
mysql>OPTIMIZE TABLE mdl_tablename;

    The common tables in Moodle to check are mdl_course_sections, mdl_forum_posts, mdl_log and mdl_sessions (if using dbsessions). Any errors need to be corrected using REPAIR TABLE (see the MySQL manual and this forum script).

    Maintain the key distribution. Every month or so it is a good idea to stop the mysql server and run these myisamchk commands.

#myisamchk -a -S /pathtomysql/data/moodledir/*.MYI


    Warning: You must stop the mysql database process (mysqld) before running any myisamchk command. If you do not, you risk data loss.

Saturday, October 12, 2024

understanding 'load average' in Linux

When we run the top command in Linux, we see three numbers depicting "Load average". What are they? and how much should they be?

https://scoutapm.com/blog/understanding-load-averages

1. The three numbers are one-minute, five-minute and fifteen-minute averages.

2. For a server, the load average should be 0.7 or below for a single CPU.

3. We can do cat /proc/cpuinfo to find the number of CPU cores. For a 2-core machine, below 2*0.7=1.4 would be healthy.


Tuesday, October 01, 2024

Monday, September 30, 2024

render multiple cameras simultaneously in Blender

 I didn't try this out - Render Multiple Cameras Simultaneously in Blender! (youtube.com)

using stereoscopy -> multi view  in output properties.

fulldome render with eevee and cycles

 This is an old post on blendernation about eevee on Blender v2.8 - Rendering Stereoscopic 360 footage with EEVEE - https://www.blendernation.com/2020/08/25/rendering-stereoscopic-360-footage-with-eevee/

(doesn't work with Blender 4.2 for me)

Rendering fulldome images in Cycles on Blender - 

Double-click the camera icon under camera to make its properties show up. Choosing Panoramic - Equisolid gives me good results.

Friday, September 27, 2024

google street view to video of trip

I had an idea of using google street view imagery and converting it to a video using google apps script or something similar. Obviously, many people have thought of this earlier.

https://github.com/TeehanLax/Hyperlapse.js
from
https://www.geographyrealm.com/create-videos-using-google-streetview-hyperlapse/

And the way to make it work seems to be to add an API key,
https://github.com/TeehanLax/Hyperlapse.js/issues/40#issuecomment-642969953

And apparently the API key now needs a billable account.
Mentioned here,
https://github.com/jblsmith/street-view-movie-maker
and forked for python3 here,
https://github.com/vardhman/street-view-movie-maker/tree/python3-support

So, currently no plans to try it out.

Google Sheets charts "add a series to start visualising your data" error and solution

Generally, we just select a range in Google Sheets and choose Insert -> Chart to get a chart automatically created from that range. But while debugging this issue, I had imported data from a text file which I had saved as csv after find/replace of spaces with commas, but google would not create a chart, instead showing "add a series to start visualising your data" and when I would add a range, it would say improper format.

It turned out that Google sheets had treated the numbers as text. So, the solution was to select the relevant ranges, Format -> Number -> Scientific (and then change back to Number or Automatic if required) . Once that was done, the automatic creation of charts worked.

Wednesday, September 25, 2024

video texture UV unwrapping

 https://www.youtube.com/watch?v=E1COCnMUIhQ - Import Any Video Into Blender With Animated Image Texture or Video Texture

https://www.youtube.com/watch?v=ZqsDjCVBkiw - Blender 3.4X: How to use a video as a texture

This one gives how to easily get UV right. 

Choose front view -- unwrap -- project from view.

Edit - https://docs.blender.org/manual/en/latest/editors/uv/controls/snapping.html

Hold Ctrl to snap UV to edges? - finally did not use, as we wanted cubes and the video was 16x9, so snapping the video to edges would have distorted.

dvddecrypter on wine etc - did not work

 For making dvd visible on wine,

https://ubuntuforums.org/showthread.php?t=1946371

check the path which is getting auto added

https://forum.winehq.org/viewtopic.php?t=32891

first run winecfg to make sure correct drive is mapped AFTER putting in the DVD, then run the application. Also may need to check the .wine/dosdevices directory and verify that spurious drives are not linked there.

wine faq - https://gitlab.winehq.org/wine/wine/-/wikis/FAQ

winecfg - was showing ejected drives also. must use wine eject, I guess.

https://gitlab.winehq.org/wine/wine/-/wikis/FAQ#removable-media

also this error

https://forum.winehq.org/viewtopic.php?t=37602

But still,

I/O error D:

Request not supported.

Interpretation: Inquiry

Since this says changed to nt4 and it worked,

https://forum.winehq.org/viewtopic.php?t=8448

tried with winecfg. But only options are Win XP and above. NT4 is not an option.

Did not work with XP or Win7 or Win10.

Tuesday, September 17, 2024

H5P error on Moodle 4.1

An error was reported in an H5P module in one of our Moodle instances. Copy-pasting from my response - 

The error says, undefined function str_contains()

From this page:
https://stackoverflow.com/questions/66519169/call-to-undefined-function-str-contains-php

"str_contains() was introduced in PHP 8 and is not supported in lower versions."

 Currently we're running Moodle 4.1 LTS (Long Term Support) which runs on PHP 7.4. We have an upgrade plan to upgrade to Moodle 4.5 LTS in October or so, when we would also upgrade the PHP version as well as the MySQL database version, along with the server Linux kernel version. We're waiting for October so that the LTS version of Moodle as well as the Linux kernel will be out - https://moodledev.io/general/releases .

I've explained the rationale for the upgrade here,

https://hnsws.blogspot.com/2024/04/moodle-upgrade-path-41-to-45.html

After the upgrade, this issue should be sorted.


Friday, September 13, 2024

circuit breaker numbers

 How to read the numbers on a miniature circuit breaker (MCB) -
https://www.electricaltechnology.org/2015/08/how-to-read-mcb-nameplate-data-rating.html

First letter in the rating stands for the type of curve.
B curve for sensitive electronics - short circuit rating of 3-5 times the standard rated current
C curve for motors - 5-10 times
D curve for highly inductive / capacitive loads - 10-20 times.

Numerical part indicates safe current. And we should use a load 80% of this rating. Like 16A load --> 20A breaker.

Example:

C60H <-- product number
B25    <-- B curve 25A breaker.

Thursday, September 12, 2024

revisiting dvd backups

Someone had been gifted a box set of 16 DVDs, but they were unable to play them due to region restrictions. They asked me for help. So, revisited DVD Decrypter after more than 15 years. Still works fine on Windows, except that with Win10, while exiting, it gives a few error dialog boxes, 'Failed to set data for '' ' and so on. 

On Linux, DVD Decrypter under Wine is supposed to work with SCSI emulation, but I was unable to get it to recognize the DVD drive - the links in ~/.wine/dosdevices  f:: and f: are being automatically assigned correctly to link to the device /dev/sr0 in my case and the mount point respectively, so probably the need is to go to nt40 mode. But my .wine directory did not have a config file, as mentioned in the howto section at

https://appdb.winehq.org/objectManager.php?sClass=version&iId=2587

and even creating a config file did not solve the issue. Probably someone who knows more about wine can get it to work. There are also other options as mentioned in the old wiki page at

https://help.ubuntu.com/community/RestrictedFormats/RippingDVDs

But my purpose was served by dvdbackup. Handbrake also worked, but I wanted a decrypted copy which I would encode later, so I used dvdbackup instead.

sudo apt install libdvdcss2

sudo apt install handbrake

sudo apt install dvdbackup 

mkdir new12

cd new12

 dvdbackup -i /dev/sr0 -M -v

and in another window, 

 watch du -sh new12

to see the progress as the GBs get added.

The macbook's DVD drive worked fine, as also the Windows desktop's drive. But the Lenovo laptop's DVD drive seemed to be more sensitive to scratches. The macbook's drive was probably the best. Decrypting and writing to hard drive was probably limited by DVD drive's speed, around 4x, taking 20-25 minutes per disc.

Encoding with handbrake directly from DVD on the macbook was going at approx 23 fps for the "Fast 576p" encoding method, while on the newer Samsung Galaxy Book2, handbrake encoding with the decrypted files on hard disk was going at 130 fps for "Fast 576p" and 250 fps for "Very fast 576p" - and so I went for the latter, reasonable quality. With such speeds, each disc would get encoded in under 10 minutes.


 

Tuesday, September 10, 2024

handbrake etc for DVD to hard disk

On Linux, writing a DVD's contents to hard disk (ripping a video DVD) - https://www.howtogeek.com/102886/how-to-decrypt-dvds-with-hardbrake-so-you-can-rip-them/

handbrake with libdvdcss2 installed worked, but takes time.

dvdbackup works

watch -n 10 du -sh nameofdirectory

for use with dvdbackup -M -i /dev/sr0

Apparently dvd decrypter works with Macrovision also

dvd decrypter with wine - https://ubuntuforums.org/showthread.php?t=27369

Note: https://hnsws.blogspot.com/2024/09/dvddecrypter-on-wine-etc-did-not-work.html

Sunday, September 08, 2024

revive corrupt sdcard for raspberry pi

According to the section on reviving corrupt SD cards in this page,

https://thelinuxcode.com/format-sd-card-raspberry-pi/

I tried out F3 to check for corruption.


https://medium.com/@drawn_stories/how-to-find-if-your-thumb-drive-sd-card-is-fake-with-f3-linux-tutorial-f0109bef63ea

sudo apt install f3

(I didn't need to use lsblk since I knew the sdcard was /dev/sdc for me.)

(instead of sudo umount, I used GParted to repartition to a single Fat32 partition first, and then unmounted within GParted.)

sudo f3probe --destructive --time-ops /dev/sdc

reported that everything was fine, finished in around 2 minutes.

Then, disconnected and re-connected to mount the drive, and then

f3write /media/myusername/mymountpoint

showed it would take 50 minutes for this 32 GB drive. Again, no errors.Then, 

f3read /media/myusername/mymountpoint

Also no errors. Took around 20-25 minutes. 

Then, tried cloning the working sdcard image again, into this sdcard which had failed last time

gunzip -c my-root-boot.image.gz | dd of=/dev/sdc conv=noerror status=progress

This took a bit over three hours.

31914983424 bytes (32 GB, 30 GiB) copied, 11300.6 s, 2.8 MB/s

(3.13 hours)

Completed successfully.

 



 


Saturday, September 07, 2024

deleting a Microsoft account linked to an Azure free trial

After a month of the free trial, an email reminded me to upgrade to 'pay as you go' and add a payment method (credit card) to continue to use the free services for a year. I did so. But I did not have much use for the free trial - I had tested it out for downloading from 1and1's cloud platform IONOS which some collaborators had used, and which was timing out using BSNL fiber due to downloading at around 30 Mbps. Similarly, Google Drive shared files also would time out after an hour or so.

I had found that the workaround of using rclone was a better and easier alternative to (a) create a free trial (b) create a VM (c) download on the VM (d) download from the VM to my local machine. 

So, when I got an email from Microsoft saying that all Azure logins would need multi-factor authentication (MFA), I thought I would just delete the Azure free trial subscription and the associated microsoft account.

For this, 

and Microsoft account -
 
Just going to the 'close account' link in the above support page, first tried after 'Cancel'ling the Azure subscription. Apparently, that is not enough. 30 minutes after we 'cancel' the subscription, a 'Delete' subscription button become active - we have to 'Delete' the subscription.
 
It is only after we delete the azure subscription that we can exit the tenant - had to delete tenant and not exit the tenant because this account was the sole user and hence the 'Global Administrator' for this tenant - before it allowed to close microsoft account -
https://learn.microsoft.com/en-us/entra/identity/users/directory-delete-howto
 
After the 'delete microsoft account' page completed, it just dropped me into login.live.com which asks me to log in - no confirmation page that the account has been marked for deletion etc.

If I try to log in with the account marked for deletion, it says that this account is marked for deletion, and logging in will unmark it for deletion, so we need to choose 'Cancel'.  
 
So, in short, the steps were:
1. Cancel the subscription from Azure portal
2. Wait 30+ minutes, then delete the subscription from Azure portal
3. Wait for a few minutes for their servers to update, then delete the tenant from Entra Admin Centre
4. (Wait a few minutes for their servers to update?), then delete the microsoft account from the link on the support page.
 
 

Monday, September 02, 2024

raspberry pi not booting, error writing to SD card when reflashing with dd

One of the Raspberry Pis we use for video play-out in the waiting area was not booting. Simplest test was to use the other Pi's SD card and try booting with that one - worked. So, wanted to image that mini SD card to the one which was not booting. 

https://www.cyberciti.biz/faq/unix-linux-dd-create-make-disk-image-commands/
sudo dd if=/dev/sdc conv=sync,noerror bs=64K | gzip -c > my-root.image.gz
took around 45 minutes -
32 GB SD card with 5.5 GB used with df -h, due to gz it became 7.7 GB

Could monitor through watch -
https://www.baeldung.com/linux/dd-monitor-progress

watch -d ls -alh my-root.image.gz

But when trying to write back to the sdcard which was not booting (file system tests showed no errors after 'repairing'), 

sudo su -
# gunzip -c my-root-boot.image.gz | dd of=/dev/sdc status=progress

But after 10 minutes or so,

dd: writing to '/dev/sdc': Input/output error

https://superuser.com/questions/35349/dd-clone-hard-drive-input-output-error-though-chkdsk-says-ok

Tried conv=noerror -

gunzip -c my-root-boot.image.gz | dd of=/dev/sdc conv=noerror status=progress

Still the same error.

Then tried writing the disk image to another (64 GB) mini-sdcard which happened to be here. That worked without errors, and the R Pi booted up fine. So, maybe there are some physical errors, we might need to reformat (full format) and copy the files back (instead of cloning.)

Wednesday, August 28, 2024

displaying info about whether a package is installed or not on Linux command line

Earlier, I had used apt show for info on whether a package is installed or not. Another way - more concise - is to use apt-cache policy - 

$ apt-cache policy unattended-upgrades
unattended-upgrades:
  Installed: 2.3ubuntu0.3
  Candidate: 2.3ubuntu0.3
  Version table:
 *** 2.3ubuntu0.3 500
        500 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     2.3 500
        500 http://azure.archive.ubuntu.com/ubuntu focal/main amd64 Packages

Sunday, August 25, 2024

show seek bar when paused - Android mp3 player app

There was a requirement for displaying the seek bar during playback and when paused, for mp3 files playing locally from a Nord CE4 Android phone. Trying out various players, it was not VLC, not simple music player, not the built-in media player - Files by Google alone shows seek bar for audio. The additional problem of "audio stopping when screen turned off" also seems to be fixed after installing this.

Friday, August 23, 2024

Azure - Transition from Azure classic administrator roles to RBAC roles

There was an email from Microsoft, asking admins to transition from Azure classic administrator roles to RBAC roles. 

I checked the "classic admin roles" for all our Microsoft tenants - found that those users who had classic admin roles have already been assigned 'Owner' RBAC roles, so probably nothing further needs to be done.

Thursday, August 22, 2024

Microsoft Azure - enable MFA - multi-factor authentication

Microsoft has sent an email asking Azure admins to enable MFA - multi-factor authentication - for all users of the Azure portal (and Entra, and Intune admin panels).

https://learn.microsoft.com/en-us/entra/identity/authentication/concept-mandatory-multifactor-authentication

But in the document above, they don't give a direct link to enable MFA, nor a direct link to enforce MFA. Probably because there are multiple ways to do it.

After a lot of searches, found the following. First we have to add sign-in methods for the MFA, then we can enable MFA.

Going to portal.azure.com
Home > Users > (my username) > Manage > Authentication methods
came to

https://mysignins.microsoft.com/security-info
 

Here, we can choose "Add sign in method" to add SMS, phone call, Microsoft Authenticator app or "Other authenticator app" like Google Authenticator which uses TOTP (time-based one-time password).

Then to enable or enforce 2FA (two-factor authentication) for admin users, we can go to portal.azure.com
(Just a note: Azure Entra ID is the new name for Azure Active Directory for translating from old tutorials.)

Users > Per user MFA (button on top of the page) > (which redirects to the page https://account.activedirectory.windowsazure.com/usermanagement/multifactorverification.aspx?tenantId=theRelevantTenantID for "legacy experience")

choose the relevant username, and then choose the "Enable" link on the right-hand pane. Confirm that you want to enable MFA for that user, then you are done.

If not "legacy experience", then the per user MFA page has a different look - with buttons to enable, disable or enforce MFA for the selected users, and also User MFA settings:


 

Monday, August 19, 2024

raspberry pi LibreElec Kodi playout issues and solution

Doing playout using Kodi and LibreElec, we had issues of disk corruption when using a FAT32 USB flash drive for the content - the first time we play a playlist there would be no issues, but when we go back to the beginning of the playlist using the page-down key, or using x to stop playback and open the playlist again, there would be random jumps during subsequent playout. 

Tried various workarounds like using a different USB flash drive, shutting down and restarting the Pi between shows (takes 5 minutes), "safely remove" the drive and re-plug it in between shows.

For a more durable solution, tried
(a) adding a powered USB hub for the Lexicon Alpha sound device
(b) using a USB drive formatted with NTFS instead of FAT32

With this configuration, the Pi seems to recognize the Lexicon Alpha without having to plug it in after the Pi boots up as noted in the previous post, and the playlist playout also doesn't skip. So, perhaps both these points helped.

Sunday, August 18, 2024

finding old files and disk space used - with Linux command line

 Following 

https://askubuntu.com/questions/413529/delete-files-older-than-one-year-on-linux

 and 

https://stackoverflow.com/questions/17419337/calculate-total-used-disk-space-by-files-older-than-180-days-using-find

 sudo su -

cd /the/relevant/directory

 find . -type f  -printf '%s\n' | wc -l  # for just the total number of files

find . -type f -mtime +365 -printf '%s\n' | wc -l  # for the number of files older than a year

find . -type f -mtime +365 -printf '%s\n' | awk '{total=total+$1}END{print total/(1024*1024*1024)}' # total disk space used by files older than 365 days, in GB

Saturday, August 17, 2024

using Wiz remote for fade in and out of lights

Using a Wiz remote and Wiz LED lamps and LED strips in the cove for fade-in, fade-out at our Theatre - only the setup required the mobile app - thereafter, it works with bluetooth, so doesn't need an internet connection. The app also allows us to add another user as an owner by just scanning a QR code from the app.

Tuesday, August 13, 2024

LIC 'Life certificate' via App

Senior citizens having LIC pension plans need to submit 'Life certificates' every year or so. According to the email they send, this can be done by submitting a form in the attached format duly filled, signed and witnessed, either by email or to a branch office or customer service cell, or via their 'LIC Digital' app.

Earlier, (maybe one year ago?) LIC had a separate app called "Jeevan Sakshya" - now the 'LIC Digital' app has the 'jeevan sakshya' feature at the bottom of the home screen.

Three verification methods are available in the app - Digilocker, offline Aadhaar and Central KYC. Offline Aadhaar xml does not seem to be available any more from the link given in the app. Digilocker method worked well for parents. (no need to install anything - just "give permission for digilocker to get your Aadhaar/PAN details" with Aadhaar OTP, then take a selfie.

Edit March 2025 - The app showed 'No data' though an SMS arrived asking for life certificate. Called up and asked the LIC Customer Zone - they said, yes, certificate is due. So I thought it might be due to Android removing data from unused app, so uninstalled it and reinstalled it. Then, 

  • Jeevan Sakshya at the bottom of the home screen
  • Register - with their registered mobile number 93*******
  • Then the policies for which life certificates were due were listed, and proceeded with Digilocker as above.

Friday, August 09, 2024

Force 5G on Any Android Device, find cell towers 5G strength etc

How to Force 5G on Any Android Device | 5G only Samsung -  https://youtu.be/Ea7XwM8W2_M

Net Monitor app, https://play.google.com/store/apps/details?id=com.parizene.netmonitor

(shows towers near you, shows 5G strength etc)

From home screen > service menu > Phone info > 
(Select Phone index 0 for SIM1 etc)

Scroll down to set preferred network type, and choose NR only (Network Radio).

(Airtel doesn't seem to work with NR only mode, even at office where 5G strength is high. Jio seems to work.)

Tuesday, July 30, 2024

headless raspberry pi - changing VNC desktop resolution

In order to set up a headless raspberry pi with VNC, we can first follow this - https://raspberrytips.com/raspberry-pi-headless-setup/

I used the Raspberry Pi Imager method - under Advanced Options in Pi Imager.

Then, as suggested in this video for an older version, I could connect to the VNC desktop on the Pi and change the resolution using

Start -> Preferences -> Screen configuration

Then Layout Menu -> Screens -> NOOP1 -> Resolution -> 1920x1080

Monday, July 29, 2024

Raspberry Pi 4 - setting static IP and checking CPU temp

How to Set a Static IP Address on Raspberry Pi
https://www.tomshardware.com/how-to/static-ip-raspberry-pi
(did it via vnc, had to install realvnc client as tightvnc client did not support)

How to check CPU temperature on Raspberry Pi - Linux Tutorials - Learn Linux Configuration
https://linuxconfig.org/how-to-check-cpu-temperature-on-raspberry-pi

ffmpeg 25 fps to 24 fps

Due to this issue with OCVWarp and frame sequences, needed to change the fps for a video from 25 fps to 24 fps.

We can do it with re-encoding using Avisynth, under 

Video -> Filters -> Transform -> Change FPS

 - useful if we want to change the codec -

or without re-encoding with ffmpeg with a command similar to the one in my earlier post,

ffmpeg -itsscale 0.834167501 -i input-25fps.mp4 -vcodec copy output-24fps.mp4

Sunday, July 28, 2024

mp3 encoding for dot net application

We got a request to install NAudio and NAudio.Lame on the production server of one of our dot net apps. But the prod server runs Linux, and NAudio uses DirectSound, hence is Windows-only. The developers were informed, and they decided to use ffmpeg instead. We used /etc/environment to add the env variable FFMPEG_PATH they wanted to create, using whereis to find the location of the executable.

Notes:

https://www.nuget.org/packages/NAudio/
dotnet add package NAudio --version 2.2.1
run inside project folder, or else error
Could not find any project in `/home/ubuntu/`.

as the relevant user in the directory also, same error.

https://stackoverflow.com/questions/56062228/error-dotnet-could-not-find-any-project-in-c-when-running-dotnet-add

But dotnet add package--help indicates that this would just add a reference to the nuget package to the project.

So, anyway nuget would need to be installed.

sudo apt install nuget
and then ...
Oh!
https://github.com/naudio/NAudio/issues/1077
NAudio does not have linux support due to directsound dependency.

Thursday, July 25, 2024

rclone and RCloneBrowser for uploading 30 GB files to Google Drive

As noted earlier, rclone is the preferred solution to transfer large files to and from Google Drive.

A point to note is that mounting and then copying seems to result in errors for Google Drive if transfer times are greater than an hour or two, so we should preferably use just rclone copy or copyto.

In the case of a Windows machine, here were my steps:

choco install rclone
rclone config

(to create the gdrive remote)
(choose everything as the defaults.)
rclone lsd gdrivemydrivename:
(to list directories)
rclone copy myfilename.mp4 gdrivemydrivename:mydirname --progress

Unfortunately, RCloneBrowser doesn't show bandwidth or time to completion with the latest rclone. So, the commandline, or browser UI might be better.

chocolatey install

Many open-source projects can be easily installed on Windows using chocolatey - and it's scriptable, too. Installing chocolatey itself took a few steps.

I should have done with this,

https://docs.chocolatey.org/en-us/choco/setup/#installing-chocolatey-cli

but I ended up doing the powershell install,

https://docs.chocolatey.org/en-us/choco/setup/#install-with-powershellexe

So, running powershell as administrator, checking powershell version with

$PSVersionTable

(it was v5, so chocolatey is supported) and then  

Get-ExecutionPolicy

returned Restricted, so then ran 

Set-ExecutionPolicy AllSigned

and then the install script with

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))


Opening a cmd window (as administrator) after this, and 

choco install ffmpeg 

worked fine.

Tuesday, July 23, 2024

VNC scraping server

Looking to reinstall some sort of VNC on an old Lenovo Thinkpad (where the built-in keyboard has issues with some crucial keys like <space> and <enter>) - found this useful thread about installing Tiger VNC scraping server, for making screen 0 available - so that works well with cinnamon desktop, unlike other VNC solutions - 

https://forums.linuxmint.com/viewtopic.php?t=351208

 sudo apt-get install tigervnc-scraping-server

We need to use the -localhost no option also, if not tunnelling over SSH, as mentioned in the last part of that thread. So, the way I've implemented is to create a startvnc.sh with the following command,

x0vncserver -PasswordFile=/home/user/.vnc/passwd -localhost no

where the pw file was created by running

vncpasswd

Then, in Linux Mint, there is the "Startup Applications" Menu item, where we can add this script startvnc.sh with an appropriate delay if required - I've put in a 5 second delay.

booting from secondary SSD - /dev/sdb

At first, installed on the secondary drive (SSD), and Linux Mint automatically wrote grub to the SSD. But when booted, grub was loaded from the primary drive. First, I tried update-grub which worked - the new install was also seen. But when I reformatted the primary hard disk, a grub rescue> prompt was seen. In my case, I did not really need to do the grub rescue - instead, I needed to go into the bios by pressing enter on a USB keyboard during boot (since the built-in keyboard enter key was broken), then Startup --> Boot --> make the SSD the primary boot device, then save and reboot.

Tuesday, July 16, 2024

write to csv from Python

 Python Write Array To CSV [4 Methods] - Python Guides

Of the four options,
pandas.to_csv()
csv.writerow()
numpy.savetxt
numpy.tofile()

the tofile() method was what I used for the spline in OSREC-interp.

Monday, July 15, 2024

deployment-target in cordova moodle app config.xml file

Initially, I thought the 

<preference name="deployment-target" value="13.0" />

in the moodle app's config.xml file referred to Android version, so it should be updated to 14.0 for the SDK target 34 upgrade.

But as pointed out by @dpalou, this refers to iOS version, nothing to do with Android. 

Checking for 5G coverage

Following this video, could find that there is 5G coverage for Airtel at my location, using the Ookla Speedtest app, by going to the Maps button at the bottom of the home screen.

Wednesday, July 10, 2024

node version change in building customized Moodle app

Node version change, as we can see from this line in package.json for the moodle app,

so, changed this line in our build workflow.

Tuesday, July 09, 2024

Moodle Mysql database CPU usage at 200%

Originally, the issue raised was that an ad-hoc query was taking a long time to run. But checking the server, found that mysqld was using 200% CPU.

Checking why the database usage is so high, I tried to check which queries are taking more time on the db - 

Found that some ad hoc tasks are the culprit.
# Time: 2024-07-08T08:07:05.163875Z
# User@Host: db_admin[db_admin] @  [::1]  Id:  8699
# Query_time: 7.503725  Lock_time: 0.000050 Rows_sent: 3  Rows_examined: 384225
SET timestamp=1720426017;
SELECT classname FROM task_adhoc WHERE nextruntime < '1720426017' GROUP BY classname;
# Time: 2024-07-08T08:07:05.193117Z
# User@Host: db_admin[db_admin] @  [::1]  Id:  8551
# Query_time: 5.819065  Lock_time: 0.000049 Rows_sent: 3  Rows_examined: 384225
SET timestamp=1720426019;
SELECT classname FROM task_adhoc WHERE nextruntime < '1720426019' GROUP BY classname;
 
Checking under tasks,
https://ourserver.org/admin/tool/task/runningtasks.php
I see that an ad-hoc task of course_delete_modules has been running for 5+ hours

This is what is causing the db to become unresponsive.
From this page,
https://ourserver.org/admin/category.php?category=taskconfig
I see that the task is not supposed to take so long. Max lifetime is supposed to be 30 minutes.
 
Rebooting didn't help.

I had to go to the database and delete the relevant row from the adhoc_tasks table in the database.

So that task is now gone from the "Tasks running now" screen. 

But other tasks are running, which is normal. What is not normal is the extremely high CPU usage of the mysql database on the database server.  

The CPU 200% issues seems to be related to adhoc tasks being run by mod_forum

The task_adhoc table for this instance is filled with entries created by
\mod_forum\task\send_user_notifications
tasks - the other moodle instances don't have these.
 
From
checked
mdl_forum_queue table.

Found 45 rows, starting July 2, just like the adhoc
timemodified 1719909620

Could not find the relevant forum posts, so blindly deleted. 

Currently the cpu usage of mysql database has come down to < 1% - for which the following were done:
  • deleted the mod_forum notification ad hoc tasks from task_adhoc table - around 385,000 rows! dating from July 2
  • deleted the vv_forum_queue notification queue - around 45 rows, dating from July 2.
I'm leaving this for now, since I'm not sure what exactly we can do to prevent this sort of behaviour in future.
 
 

optimizing SQL code with help from ChatGPT

I had asked PB for help with optimizing the SQL code at
https://github.com/hn-88/ad-hoc-moodle-database-queries/blob/main/Feedback%20for%20all%20courses.sql

since it would time out for anything more than just a few lines of results, taking more than half an hour and slowing down the database. 

His response was to ask ChatGPT.

ChatGPT gives the following suggestion:
  1. Reduce Subqueries: Instead of running multiple subqueries for each feedback item, we join the feedback_value and feedback_item tables multiple times to get the necessary values.
  2. Conditional Aggregation: We use MAX(CASE WHEN ...) to fetch the appropriate values for each feedback item type.
  3. Grouping: We group by the relevant fields to ensure distinct results.

This approach reduces the number of scans and joins, potentially speeding up the query execution.



SQL STATEMENT

___________________________________________________
SELECT
    FROM_UNIXTIME(fc.timemodified) AS Time,
    fc.userid,
    u.idnumber,
    u.username,
    u.firstname,
    u.lastname,
    u.email,
    u.institution,
    fv.value AS "Email entered",
    c.fullname AS BSS,
    MAX(CASE WHEN fi2.name LIKE '%Chapter%' AND fi2.typ = 'textfield' THEN fv2.value ELSE NULL END) AS "Chapter name",
    MAX(CASE WHEN fi3.name LIKE '%Main%Script%' THEN fv3.value ELSE NULL END) AS "MainScript",
    MAX(CASE WHEN fi4.name LIKE '%Inquisit%uestion%' THEN fv4.value ELSE NULL END) AS "IQ",
    MAX(CASE WHEN fi5.name LIKE '%Suggested%ctivity%' THEN fv5.value ELSE NULL END) AS "SA",
    MAX(CASE WHEN fi6.name LIKE '%Assessment%' THEN fv6.value ELSE NULL END) AS "QA",
    MAX(CASE WHEN fi7.name LIKE '%Day%day%elevan%' THEN fv7.value ELSE NULL END) AS "DD",
    MAX(CASE WHEN fi8.name LIKE '%Value%ontent%gained.' THEN fv8.value ELSE NULL END) AS "VC",
    MAX(CASE WHEN fi9.name LIKE '%Interest%side%' THEN fv9.value ELSE NULL END) AS "IA"
FROM
    {feedback_value} fv
    LEFT JOIN {feedback_completed} fc ON fc.id = fv.completed
    LEFT JOIN {user} u ON fc.userid = u.id
    LEFT JOIN {feedback_item} fi ON fi.id = fv.item
    LEFT JOIN {feedback} f ON f.id = fi.feedback
    LEFT JOIN {course} c ON c.id = f.course
    LEFT JOIN {feedback_value} fv2 ON fc.id = fv2.completed
    LEFT JOIN {feedback_item} fi2 ON fi2.id = fv2.item
    LEFT JOIN {feedback_value} fv3 ON fc.id = fv3.completed
    LEFT JOIN {feedback_item} fi3 ON fi3.id = fv3.item
    LEFT JOIN {feedback_value} fv4 ON fc.id = fv4.completed
    LEFT JOIN {feedback_item} fi4 ON fi4.id = fv4.item
    LEFT JOIN {feedback_value} fv5 ON fc.id = fv5.completed
    LEFT JOIN {feedback_item} fi5 ON fi5.id = fv5.item
    LEFT JOIN {feedback_value} fv6 ON fc.id = fv6.completed
    LEFT JOIN {feedback_item} fi6 ON fi6.id = fv6.item
    LEFT JOIN {feedback_value} fv7 ON fc.id = fv7.completed
    LEFT JOIN {feedback_item} fi7 ON fi7.id = fv7.item
    LEFT JOIN {feedback_value} fv8 ON fc.id = fv8.completed
    LEFT JOIN {feedback_item} fi8 ON fi8.id = fv8.item
    LEFT JOIN {feedback_value} fv9 ON fc.id = fv9.completed
    LEFT JOIN {feedback_item} fi9 ON fi9.id = fv9.item
WHERE
    fc.timemodified > :fromdate
    AND fc.timemodified < :todate
    AND u.idnumber LIKE :paramidnumber
    AND fi.name LIKE '%Email%'
GROUP BY
    FROM_UNIXTIME(fc.timemodified),
    fc.userid,
    u.idnumber,
    u.username,
    u.firstname,
    u.lastname,
    u.email,
    u.institution,
    fv.value,
    c.fullname
___________________________________________________

Please check if this suggestion helps.

My response to this was, after trying out the code suggested by ChatGPT and then modifying it:

The code shown [above] did not work - my earlier code was producing 5 rows in around 5-10 minutes, the chatgpt code ran for 30 minutes without any result. Looking at the code, there are some possible mistakes like the lines like 
LEFT JOIN {feedback_value} fv3 ON fc.id = fv3.completed

Corrected the code as
c.fullname AS BSS,
    MAX(CASE WHEN fi2.name LIKE '%Chapter%' AND fi2.typ = 'textfield' THEN fv2.value ELSE NULL END) AS "Chapter name",
    MAX(CASE WHEN fi2.name LIKE '%Main%Script%' THEN fv2.value ELSE NULL END) AS "MainScript",
    MAX(CASE WHEN fi2.name LIKE '%Inquisit%uestion%' THEN fv2.value ELSE NULL END) AS "IQ",
    MAX(CASE WHEN fi2.name LIKE '%Suggested%ctivity%' THEN fv2.value ELSE NULL END) AS "SA"
, etc etc

instead of fi3, fi4, fi5, fi6 etc, and now the code runs much faster. 6 rows in 6 seconds.

https://github.com/hn-88/ad-hoc-moodle-database-queries/blob/main/Feedback%20for%20all%20courses%20revised.sql

Thanks once again. :)

(Some references I looked up, but could not find immediate solutions to my problem:

How to fix MySQL high CPU usage (bobcares.com)



)

Thursday, July 04, 2024

link from div to open in new window

We wanted a "click here" image link for one of our websites, but the image was actually a background in CSS and not a simple img html tag. So, basically we needed to make the entire div into a clickable link. Following these,

https://stackoverflow.com/questions/7185044/change-the-mouse-cursor-on-mouse-over-to-anchor-like-style

https://stackoverflow.com/questions/5141910/javascript-location-href-to-open-in-new-window-tab

https://stackoverflow.com/questions/8524470/click-anywhere-on-div-instead-of-directly-on-link

what we used was something like this:

<div class="our-class-name" style="cursor: pointer" onclick="window.open('ourpage.html', '_blank');">

Tuesday, July 02, 2024

Microsoft Teams for new users

One of our institutions wanted to add a large number of new users to Microsoft Teams. Initial plan was to create email ids in Google Workspace and then add them as Guest users in Microsoft Admin console. But then, it would be much easier for the users, and also retain all the functionality of sharing meeting id via email etc if the users were created within Microsoft Admin console instead. So, finally, that was the way it was done. 



 

Saturday, June 29, 2024

Azure - Update firewall configurations to allow Logic Apps IP addresses

We got an email from Microsoft Azure, asking us to update firewall configurations to allow Logic Apps IP addresses by 28 September 2024.

Verified in all our accounts that the only logic apps we used were the VM automatic start/stop apps which are currently disabled. So, no action to be taken for this.

Friday, June 28, 2024

quaternion tutorial

https://www.opengl-tutorial.org/intermediate-tutorials/tutorial-17-quaternions/#how-do-i-create-a-quaternion-in-c-

It turned out that I did not need to include glm etc, as in the page above, since simple linear interpolation followed by normalization was sufficient for my use case. Apparently linear interpolation is close, though not exact - this discussion.

Wednesday, June 26, 2024

unable to see old assets after email change

One of our websites had an issue, described as below:

... User was accessing the system using old@gmail.com. She had some issues with that id and she edited her profile on CMS and changed it to new@gmail.com While the system allows her to login using her new email address, she is unable to see the assets assigned to her as editor in the new id. Even when she creates an asset, even though she logs in with her new email, the asset gets created under her old email id ...
Solution was:

In the users table of the Postgres database, only the "email" field is editable by users - now updated the "username" field to
new@gmail.com
from
old@gmail.com

(The updating of username field by users is not enabled since back-end changes to the CMS data sheet are needed when such a change happens.)

additional spam protection for forms using Cloudflare turnstile

One of our forms, which had first level protection using a hidden field, occasionally got bursts of spam submissions. Added Cloudflare turnstile as an additional layer of protection.

In the <head> section of the web page which had the form, 

<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" defer></script>

Inside the form,

<div class="cf-turnstile" data-sitekey="0x4OUR-SITE-KEY0-"></div> 

and in the done function, handling the "failed captcha" situation - 

 $.ajax({
                        method: "POST",
                        url: url,
                        data: user
                    }).done(function (msg) {

                        // When the request is successful
                        if(msg=="Success") {
                        $('span').html('<strong>Thank you for submitting your details. We will get back to you shortly, in a week or so.</strong>');
                        $("form").trigger("reset");
                        }
                        if(msg=="Failed captcha.") {
                            $('span').html('<strong>Please resubmit after the captcha loads, checking the box to confirm you are human if necessary.</strong>');
                        }
                    }).fail(function (err, textstatus, error) {
                        $('span').text(textstatus);
                    });

              

Then, we need to add some back-end code. Since we're using Google Apps Scripts, this looked like:

function doPost(e) {

var scriptProperties = PropertiesService.getScriptProperties();
var myKey = scriptProperties.getProperty('SECRET_KEY');
.....
const siteresponse = e.parameter['cf-turnstile-response'];
.....
var verifyurl = 'https://challenges.cloudflare.com/turnstile/v0/siteverify';
var formData = {
'secret': myKey,
'response': siteresponse
};
var options = {
'method' : 'post',
'payload' : formData
};

var responsetositeverify = UrlFetchApp.fetch(verifyurl, options);
var verifydata = JSON.parse(responsetositeverify.getContentText());


if (!verifydata.success) {
// do the rest of the processing only if verification returns success.
return ContentService.createTextOutput().append('Failed captcha.');
}
 
 

 


Monday, June 17, 2024

problem and workaround for Youtube api calls from Google Apps script

When trying to implement the earlier solution to one of our channels, the script would fail, complaining that the user was not authorized for live streams. Interestingly, when using google api explorer, it asks whether to use the google account or the youtube brand name. If we choose the latter, it works.

The issue and its solution are discussed at  

Accordingly, started work on a script of our own, based on this blog post, but paused development since manual creation of broadcasts was preferred due to the complicated setup which depends on GDrive service which would fail at least once a month as my previous experience with Drive service shows.

The one take-away from this exercise seemed to be that the 'consent screen' needs to be set to 'Production' for this workaround to work, otherwise the Oauth doesn't proceed.

Sunday, June 16, 2024

Missing Site UUID or Hub Secret error in Moodle

One of our Moodle sites was presenting users with this error, "Missing Site UUID or Hub Secret. Please check your Hub registration".

Apparently the fix is to change a setting, as mentioned at
https://h5p.org/node/1472461

"uncheck the option "Use H5P-hub. mod_hvp | hub_is_enabled" in the H5P settings in Moodle (.../admin/settings.php?section=modsettinghvp"

But that setting says, "It's strongly encouraged to keep this option enabled. The H5P Hub provides an easy interface for getting new content types and keeping existing content types up to date. In the future, it will also make it easier to share and reuse content. If this option is disabled you'll have to install and update content types through file upload forms."

There is also an option to "Register an account with H5P hub" just below that.

I have now tried entering some data into the "register an account" part, for one of our Moodle sites.

Hopefully this resolves the issue.

Sunday, June 02, 2024

closed Airtable and SendinBlue (now Brevo) accounts

Since I'm no longer using their services, closed Airtable and Brevo (formerly Sendinblue) accounts. For Airtable, I copy-pasted a table I had made into a Google Sheet, deleted collaborators from it, and then deleted my account. 

Saturday, June 01, 2024

VP9 codec for 4K video on Raspberry Pi4 - stutters

Tested a video encoded with VP9 - very good quality 4K video - only 2.5 GB file size for a 24 minute 4K video - but playback on Kodi running on Raspberry Pi 4 stutters for high complexity scenes. x265 is the way to go, for now.