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. 

Tuesday, May 28, 2024

Zoom in from Milky Way to Puttaparthi

The scripts and settings used to generate this 4k fisheye fulldome video are shared at https://github.com/hn-88/openspace-scripts 


The following script was used,
https://github.com/hn-88/openspace-scripts/blob/main/user/recordings/zoom-out-psn-to-galaxy4.osrectxt

where the motion is actually backwards, zooming out, in order to give a more controlled zoom travel. 

ffmpeg and blender were used to render the screenshot image sequences into video, forward and backwards. Blender could be used to fine-tune the video by speeding up parts of the video without much action and so on. 

ffmpeg to reverse a frame sequence - https://stackoverflow.com/questions/40475480/ffmpeg-convert-image-sequence-to-video-with-reversed-order

The zoom-in (reversed frames) have been uploaded and made available at archive.org using the x265-lossless codec under a Public Domain licence.

https://archive.org/details/zoom-in-to-psn-lossless

react app in docker vs native

Relative performance etc - via
which is hosted on vercel, https://gitachapsummwtel.vercel.app/

Hosting next.js on our own server -

Performance of docker -

Apparently nearly as good as native.

Monday, May 27, 2024

ffmpeg lossless for archive.org and reverse order of frames

Archive.org did not accept zip files containing frames for uploading 4K content, but lossless codecs were accepted.

ffmpeg - Best Lossless Video Codec for 8 bpc RGB image sequences? - Super User

seems to indicate that the best seems to be x265,

and commandline
 
ffmpeg -i input.mp4 -c:v libx265 -x265-params lossless=1 output.mp4 

And for reversing the frame order (backwards video),

 
- first bulk rename to - (minus) for the numbers prefix.

Saturday, May 25, 2024

github importer, for making a copy of a repository from the web interface

For testing a reported opencv bug

 
I wanted to make a copy of one of my repositories. Instead of cloning to a local directory etc, I wanted to do it from github's web interface. The solution seemed to be to use github importer. 
 
At the upper-right corner of any page, click the plus sign, and then click Import repository
 

making google great again

A follow-up to my post about the beginning of the end of Google -

https://askleo.com/why-ive-stopped-using-google-search/

and a temporary band-aid fix to get better search results from google,

https://tedium.co/2024/05/17/google-web-search-make-default/

- just add &udm=14 to the end of the search query url. 

Tuesday, May 21, 2024

Fly through Mars valley and Grand Canyon - generated with OpenSpace

The scripts and settings used to generate these 4k fisheye fulldome videos are shared at https://github.com/hn-88/openspace-scripts


 

https://github.com/hn-88/openspace-scripts/blob/main/user/recordings/setupgrandcanyon.osrectxt

https://github.com/hn-88/openspace-scripts/blob/main/user/recordings/grandcanyonflyin5.osrectxt

(default profile, Window options fisheye 4k as at
https://github.com/hn-88/openspace-scripts/blob/main/config/single_fisheye-4k.json )

Link to 4096x4096 video at archive.org -  https://archive.org/details/grand-canyon5

Flying 5 km (3 miles) above a valley on Mars, near Valles Marineris


https://github.com/hn-88/openspace-scripts/blob/main/user/recordings/marsvalley2setup2.osrectxt

https://github.com/hn-88/openspace-scripts/blob/main/user/recordings/marsvalley2upfrombeginning3.osrectxt

(this recording is played in reverse at the beginning of the video.)

https://github.com/hn-88/openspace-scripts/blob/main/user/recordings/marsvalley2.osrectxt

Link to 4096x4096 video at archive.org - https://archive.org/details/mars-fly-into-valley0001-6940

The 4k frames are available with me, and can be made available. I'll also see if I can upload them to archive.org - Edit - apparently zip files with jpg frames can't be uploaded to archive.org, so I have added links to the 4K movie files uploaded to archive.org above.

Monday, May 20, 2024

Microsoft's answer to brute force mitigation - $$$

 How to avoid successful SSH Brute Force Attack - Microsoft Q&A

mentions Just-in-time access usage. But that

https://learn.microsoft.com/en-us/azure/defender-for-cloud/just-in-time-access-usage

requires Defender for Cloud Plan 2

https://learn.microsoft.com/en-us/azure/defender-for-cloud/plan-defender-for-servers-select-plan#plan-features

which costs nearly $15 per month per server!

https://azure.microsoft.com/en-us/pricing/details/defender-for-cloud/

Indian income tax e-filing - validation failed

When filling up the ITR2 income tax return, one of the "validation failed" messages said:

In Schedule CG, Sl. No. B4a LTCG u/s 112A is not equal to total of Col. 14 of Schedule 112A

This is probably because of rounding errors, I think. The numbers in the quarter-wise table in Schedule CG (Capital Gains) must add up to the numbers in Schedule 112A. So we should manually add and check, and make small one rupee adjustments to make the quarterly numbers add up to the total in Schedule 112A.

Another couple of points to note when there are "brought-forward losses" -
(1) in that case, the maximum amount of the BFL has to be applied - we can't apply a lower amount of the total losses to cover only part of the profits of this financial year
(2) and the numbers in the quarterly numbers should then add up to zero (if the losses completely cover the profits.)

Monday, May 13, 2024

making a copy of a wordpress blog and setting it up on another domain

What I should have done:

Probably I should have used wp-cli to deactivate all plugins before the migration. And apparently, the whole thing could have been done far easily with wp-cli - https://rocketgeek.com/basics/using-wp-cli-to-migrate-copy-your-site/
https://guides.wp-bullet.com/migrate-wordpress-site-new-server-wp-cli/

Steps taken:

0. Ran all commands inside screen.

1. https://wordpress.stackexchange.com/questions/75135/how-to-export-import-wordpress-mysql-database-properly-via-command-line
says a normal mysqldump should suffice.

2. Mysqldump complained about permissions -
Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespacesldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces

So, https://dba.stackexchange.com/questions/271981/access-denied-you-need-at-least-one-of-the-process-privileges-for-this-ope

SHOW GRANTS for someuser@localhost;.

To add the global privilege use the SQL command
GRANT PROCESS ON *.* TO someuser@localhost;

That solved the issue. In our case, I was running the SQL commands from the SQL console of dbeaver.

3. Created a new db as root, granted permissions for the relevant user as per https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql

4. mysql -u theuser -p thenewdb < wpdevelbackup.sql to populate the new db.

5. Copied over the directory with cp -a to retain permissions as well as do a recursive copy - https://unix.stackexchange.com/questions/44967/difference-between-cp-r-and-cp-a
sudo cp -a olddirectory newdirectory

6. After that, need to update the wp_options table in the new database. option_value like '%public_html%' showed all the required changes to be made after siteurl -
siteurl
home
astra_sites_recent_import_log_file
recently_edited
astra_sites_recent_import_log_file
fs_active_plugins
duplicator_package_active
uagb_downloaded_font_files
_transient_dirsize_cache

(Had to copy paste to text editor and find and replace for the multiple instances of the old path in some of these fields.

the _transient field was very big. Since anyway it would be recreated, deleted its value instead of changing the path to the new path for that value.)

7. Have to edit wp-config file also, since the site was redirecting back to the old url. https://www.sitepoint.com/how-to-migrate-a-wordpress-site-to-a-new-domain-and-hosting/
Had to add the
define('WP_HOME','https://oursite.com');
define('WP_SITEURL','https://oursite.com');

at the end of wp-config file also, since I had not de-activated the plugins before doing the migration. Or maybe just a caching problem with firefox which I used for testing. Site was working at this point, when tested with another browser. (I had done the editing of /etc/apache2/sites-available etc beforehand.)

Wednesday, May 08, 2024

Schedule Page date listing much in advance

 PB wanted to verify that the schedule created for a few days in advance loads OK on the schedule page. But only a few days were visible. This was because

the code checks if the schedule data txt file is available, and then updates the dropdown, but only up to 5 days in advance -


while (dtimems < dateplus5ms) {
addifscheduledataavailable(dtimems);
dtimems += 24 * 60 * 60 * 1000;
}

It may be possible to see the schedule of other dates by changing your system date to the future.

And indeed, PB confirmed that he could check the published playlists for future dates by changing the system date.

Monday, May 06, 2024

run simple python code online

There is google's colab for executing python workbooks online, in the browser. But for simple code, trinket.io - "no need to log in, download plugins, or install software. "
via
https://www.youtube.com/watch?v=v7svyPnIeGA
via
https://www.wired.com/story/why-the-solar-system-is-flat/

Thursday, May 02, 2024

interesting problem with S3 buckets - anyone can do a $ DDoS now

Copy-pasting from Slashdot - 

How an Empty S3 Bucket Can Make Your AWS Bill Explode (medium.com) 55

Posted by msmash on Tuesday April 30, 2024 @03:10PM from the oops dept.
Maciej Pocwierz, a senior software engineer Semantive, writing on Medium: A few weeks ago, I began working on the PoC of a document indexing system for my client. I created a single S3 bucket in the eu-west-1 region and uploaded some files there for testing. Two days later, I checked my AWS billing page, primarily to make sure that what I was doing was well within the free-tier limits. Apparently, it wasn't. My bill was over $1,300, with the billing console showing nearly 100,000,000 S3 PUT requests executed within just one day! By default, AWS doesn't log requests executed against your S3 buckets. However, such logs can be enabled using AWS CloudTrail or S3 Server Access Logging. After enabling CloudTrail logs, I immediately observed thousands of write requests originating from multiple accounts or entirely outside of AWS.

Was it some kind of DDoS-like attack against my account? Against AWS? As it turns out, one of the popular open-source tools had a default configuration to store their backups in S3. And, as a placeholder for a bucket name, they used... the same name that I used for my bucket. This meant that every deployment of this tool with default configuration values attempted to store its backups in my S3 bucket! So, a horde of misconfigured systems is attempting to store their data in my private S3 bucket. But why should I be the one paying for this mistake? Here's why: S3 charges you for unauthorized incoming requests. This was confirmed in my exchange with AWS support. As they wrote: "Yes, S3 charges for unauthorized requests (4xx) as well[1]. That's expected behavior." So, if I were to open my terminal now and type: aws s3 cp ./file.txt s3://your-bucket-name/random_key. I would receive an AccessDenied error, but you would be the one to pay for that request. And I don't even need an AWS account to do so.

Wednesday, May 01, 2024

OCVWarp on Google Cloud Shell

Checked and found that OCVWarp works (though slowly - 5 fps for XVID encoded 1080p output) even on Google Cloud Shell, after installing the dependencies.

wget https://github.com/hn-88/OCVWarp/archive/refs/tags/v4.01.zip
unzip v*.zip
cd OCVWarp*/build
wget https://github.com/hn-88/OCVWarp/releases/download/v4.01/OCVWarp-4.01-x86_64.AppImage
chmod +x OCV*mage
mv OCV*mage ocvwarp
sudo apt install libopencv-dev


(after uploading the input file)


./ocvwarp OCVWarp.ini 30fps.mp4 output.mp4

Friday, April 26, 2024

Moodle upgrade path - 4.1 to 4.5

An evaluation of requirements and timelines for upgrading Moodle 4.1 to 4.3 or 4.5.

Moodle 4.1 -> 4.3

Min PHP 7.4 -> 8
PHP extension sodium is required
(seems to be built in to 8
)
PHP setting max_input_vars must be >= 5000.
PHP variants: Only 64-bit versions of PHP are supported.

MySQL 8.0 (increased since Moodle 4.1)

Moodle 4.4 release date is 22 April 2024
so probably should upgrade to that - OR -

Next LTS is 4.5. 7 October 2024.

Moodle 4.1 -> 4.4

Min PHP 8.1

Ubuntu 22.04
PHP 8.1.2
Mysql 8.0.28

PHP 8.3

How to upgrade from Ubuntu 20.04 to 24.04 - Probably will need to do it as a two step process -
https://linuxconfig.org/ubuntu-upgrade-to-24-04-noble-numbat-a-step-by-step-howto-guide
 
20.04 is supported till Apr 2025. So in Oct 2024, we should be able to upgrade the OS and Moodle together. 







Friday, April 19, 2024

Filezilla TLS errors

When using Filezilla on Linux Mint at work, connecting to an FTP server, after logging in, I get some errors like the following:


Command: LIST
Response: 150 Opening BINARY mode data connection.
Error: GnuTLS error -110: The TLS connection was non-properly terminated.

Some file transfers go through, while some get 550 errors - when I close Filezilla and open it again, the transfer succeeds.
 
Later, when using Windows and downloading using a domestic BSNL fiber line, there were no errors.
 
According to this set of posts on serverfault, it may have been due to either the firewall gateway blocking passive mode FTP or it may have been something to do with implicit/explicit TLS.

Wednesday, April 17, 2024

methods to download from Amazon S3 bucket (if we own/manage the bucket)

Some ways are mentioned at 

 
Cyberduck can provide a UI for Windows or Mac - "Cyberduck is a libre server and cloud storage browser for Mac and Windows with support for FTP, SFTP, WebDAV, Amazon S3, OpenStack Swift, Backblaze B2, Microsoft Azure & OneDrive, Google Drive and Dropbox."

Saturday, April 13, 2024

workflow_dispatch only from default branch

I like to set Github Actions to only run when manually triggered, that is, using workflow_dispatch

As that page says,  "To trigger the workflow_dispatch event, your workflow must be in the default branch."

But we can change the default branch - like we may want to do for forks etc - Repository --> Settings --> Default branch (choose by clicking the "choose another branch" button which has two opposing arrows as an icon)

comparing the contents of two directories on Windows

 How to Compare Two Folders on Windows 11 and 10 (howtogeek.com)

robocopy "C:\first" "C:\second" /L /NJH /NJS /NP /NS

Thursday, April 11, 2024

reminder to take a break - using cron

Wanted to create a pop-up message or reminder (and was later requested an audio reminder) for N to take periodic breaks from the computer. Since his usage was mostly passive, workrave did not work for this purpose - workrave's timer only progresses when the keyboard or mouse are active.

 Looking for solutions, reminder apps on Mint/Ubuntu seemed to have only flatpak versions which I did not want to install.

Finally thought it would be simpler to use cron.

But, to pop up messages on the screen with cron, we need some special handling.
https://unix.stackexchange.com/questions/307772/pop-up-a-message-on-the-gui-from-cron
https://unix.stackexchange.com/questions/111188/using-notify-send-with-cron

And for audio, we would need another line to be added to the script. Working script - 

#!/bin/bash
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
export DISPLAY=:0
export XDG_RUNTIME_DIR=/run/user/1000
# this last line above is for sound to work
notify-send -u critical "this is the reminder to take a walk"
# the -u critical is supposed to show over full screen apps, but doesn't always work
/usr/bin/mpg123 /home/username/Downloads/Walk.mp3 > /dev/null 2>&1

For help with setting up cron, cron.help is useful. Eg.

*/30 * * * * /home/username/walkremind.sh

for every half an hour.

For getting the environment variables' values, used

printenv

And for installing notify-send

sudo apt install libnotify-bin






using a laptop as a secondary monitor using Miracast

Apparently Windows now has built-in support for Miracast, so we can use a Windows laptop as a secondary display for a Windows desktop, for example.

https://www.tomshardware.com/how-to/use-laptop-as-monitor-for-another-pc
that is if both run Windows.

Miracast client for Linux - miraclecast - to use as sink,
https://askubuntu.com/questions/1254998/how-do-i-launch-miraclecast-after-installation

https://alternativeto.net/software/miraclecast/
https://letsview.com/screen-mirroring
(but not on linux)

https://github.com/albfan/miraclecast

 

Wednesday, April 10, 2024

RAM usage - Edge and Firefox browsers on Linux Mint

I've installed 'Graphical Hardware monitor' to show RAM, Disk read and Disk write on the panel of the old Macbook Pro running Linux, which has only 4 GB of RAM including VRAM. Curious to see RAM usage, tried opening Gmail + GDrive + a spreadsheet on Firefox and Edge browsers separately. With Firefox, total RAM used was 1.92 GB. With Edge, it was 1.63 GB. So, Firefox was using around 300 MB more than Edge in this (not too rigourous) test.

image sequence support for OCVWarp

Prompted by this feature-request for command-line support, OCVWarp version 4.00 now has basic support for image sequences, too. The documentation in the wiki has been updated with caveats. And here is a link to all posts about OCVWarp.

PS. And in December, a test build with MacOS X succeeded on github actions using homebrew to install OpenCV.

Sunday, April 07, 2024

using blender online

As noted at https://digitalarthub.net/3d/how-to-use-blender-online-without-downloading/

"Do note that most of these apps run outdated versions of Blender and they’re pretty laggy",

Since Blender doesn't run any more on the old Macbook running Linux - https://www.blender.org/download/requirements/ - I can use the online versions for quick screenshots and so on.

 

Friday, April 05, 2024

Windows defender finding a Trojan in build from Github actions - false positive

Artifacts from some builds of OCVWarp were being flagged by Windows Defender as having a trojan, Wacatac. As mentioned in this page, https://github.com/RPCS3/rpcs3/issues/15309 this is probably a false alarm, as some other builds with minimal changes were not flagged. So, tried Add an exclusion to Windows Security - Microsoft Support - that worked well. 

Start --> Settings --> Privacy & security --> Virus & threat protection -->  Manage settings --> Exclusions --> Add or remove exclusions.

shifting a blogger blog to Google Analytics 4

There was an email from Google, "All Universal Analytics services cease to function starting July 1, 2024"

Googling "use analytics with blogger", found this support article - and found that this blog was not automatically transferred from the earlier Universal Analytics to Google Analytics 4. Copy-pasted the "Measurement ID" as mentioned in that support article, finding the "Measurement ID" via this article. Now let's wait for a couple of days and see if it works.

Thursday, April 04, 2024

CPU-based stable diffusion

In my previous post about Stable Diffusion and how I could not generate 4k fulldome images with it, I had mentioned running out of RAM as the reason it failed. I thought perhaps if there is a way to run it on CPU instead of GPU, I could use a more recent faster machine - and perhaps use virtual memory and run for a longer time - to generate 4096 x 4096 fulldome images. But trying out rupeshs/fastsdcpu: Fast stable diffusion on CPU - found that even if I do an img2img using a 4K fulldome image as the input, the output was only 1024 x 1024. 

There may be ways to run google colab or something like that, and generate 4K fulldome images - but that is something to be tested later. At first glance, it seems that even Dall-E is limited to 1024x1024, and people have to stitch generated images together to make bigger canvases, as mentioned in this reddit thread. And this thread gives a Stable Diffusion guide which uses upscaling - which has issues as mentioned in my previous post.

super-resolution experiments

I thought of doing some super-resolution experiments directly with ffmpeg or something similar for virtualdub or avisynth or avidemux, but this detailed post makes me pause - mostly not so much better than Lanczos, as they say - scale - How do the super resolution filters in FFmpeg work? - Video Production Stack Exchange

Tuesday, April 02, 2024

stable diffusion experiments

Now that I have access to a GPU, I tried out some AI-based image resizing, video upscaling and image generation, using stable diffusion as noted in a previous post. This post notes some of the pros and cons of the technology as it stands now, in April 2024.

1. There doesn't seem to be a way to incrementally correct images as with ChatGPT-generated code. We need to fine-tune our prompts if we need better results, and run the generation once again.

2. On this machine - 1050TX GPU, quite slow - stable diffusion with the webui takes around a minute to generate a 512x512 default image with an img2img promt and the default 20 steps.

3. Following this guide on fddb, my results with generation were not so great. Changing "little girl" to "businessman with briefcase" did not result in a briefcase in the 4-5 iterations I tried out. Additionally, scaling up the image showed that the skyscrapers were not realistic at all. Perhaps this can be fixed by generating in the higher quality instead of first generating in 512x512 and then scaling up - but I can't do that, since I run into 'CUDA out of memory' errors.. Edit - further experiments in this post seem to indicate 1024x1024 seems to be the upper limit for most models.

Example - part of the fddb example image, upscaled to 4k using Lanczos resizing,

 and using R-ESRGAN-4x+, we see the cartoonish quality,



4. Trying to upscale a video which had a series of stills - something like a slideshow - resulted in lots of image flicker in the upscaled video. The reason for the flicker is some horrendous hallucination, close-ups from a couple of frames shown below.
Original - 

Upscaled - 


and the next frame has the shading which causes the flicker,


Decided to use Lanczos instead of AI in that case. But single image upscaling can give good results, especially if the image is a generic image and not an exact likeness of someone. In case of an exact likeness, some hallucination of features is seen. Example close up, something like spectacles is seen on the bridge of the nose, not present in the original.





 

Monday, April 01, 2024

supported browser for old versions of Windows and MacOS

Copy-pasting from an email I sent:

There is a Chromium-based browser called Thorium which has support for Win7 and above.


(So it may allow use of Google Drive, Google Meet etc which nowadays say "not supported" on older versions of Chrome.)

(Via

A list of browsers for older Macs -