Thursday, March 30, 2023

new schedule page based on json data instead of database back-end - ChatGPT for Javascript to PHP translation

Initially created a Google apps script / Google Sheet version to replicate the schedule page and audio search page - 

https://github.com/hn-88/mktxt/tree/main/GAS

Then created a php-based version to run on our local server, since remote server audio search functionality was being dropped in favour of SSSMC search page - 

https://github.com/hn-88/mktxt

Tried using ChatGPT to convert code snippets from Javascript to PHP. It was surprisingly good. Saves a lot of time.




Sunday, March 26, 2023

parsing a csv with pipe symbol as separator in PHP

Following this discussion, where it was noted that "PHP's array_map() supports a third parameter which is an array representing the parameters to pass to the callback function" the method I used was:

$file = "../path/to/".$playlistDatenodash.".csv";
$filearray = file($file);
$data = array_map('str_getcsv', $filearray, array_fill(0,count($filearray),'|'));


unable to ssh into old server after client upgrade to Linux Mint 21

After upgrading my client machine to Linux Mint 21, I was unable to ssh into an old internal server of ours. Interestingly, Filezilla on the client machine was able to sftp into the old server. At first, I thought the keys in .ssh might have changed, but it was an upgrade and not a reinstall, so the old keys were still there. Then found this - https://stackoverflow.com/questions/73795935/sign-and-send-pubkey-no-mutual-signature-supported - and ssh worked when I added the parameter

ssh -o PubkeyAcceptedKeyTypes=ssh-rsa

So, probably the new client has RSA disabled, while the old internal server still uses RSA.

possible google play developer console bug - testing for wearos even when we do not target it

When a new app was uploaded to Google Play console for internal testing, the pre-launch report showed

Errors found. Fix before releasing to production.

Error

Issue 1 of 1Detected on 1 device during testing
Stack trace etc etc.
Detected on 1 device during testing
Google Wear (virtual) 454x454 Android 11 (SDK 30) - x86 en_I
 
This happened even though we had de-selected Google Wear in the targeted devices list.
 
This seems to be a google bug - testing on WearOS even when we have not targeted WearOS -

So I think we can safely ignore the Google Wear crash report, at least in this case. (And the app was released later into production with no problems - I deselected pre-launch reports just in case.)

Thursday, March 23, 2023

making a network directory writable for an internal webserver

In order to automate some of our processes, wanted a PHP page to trigger some file copy commands to a shared directory. Initially the network share was not writable by the web server.

I have made it writableby mounting it with file_mode=0777,dir_mode=0777

sudo mount -t cifs //Internal-IP/SHARENAME sharenamelocal -o uid=ourusername,username=username,password=xxxxx,file_mode=0777,dir_mode=0777

as suggested by ChatGPT :)


print jobs making notification sounds after Linux Mint upgrade to 21

After upgrading my machine from Linux Mint 20.3 to 21, print job notifications were making "ping" sounds. 

Opened the "Sound" configuration applet, Sounds tab - turned off the sound for "Showing notifications" after scrolling down. This seems to be a newly added sound, since earlier I had turned off all sounds. (At first glance, I didn't see it, but it was visible after scrolling down.)

Sunday, March 19, 2023

VNC error - startxfce4: X server already running on display :1

Saw this error in the logs when trying to start VNC on a machine where VNC was earlier working, but was now displaying a blank screen.

https://superuser.com/questions/1607082/tightvnc-in-ubuntu

advises to 

Change the ~/.vnc/xstartup file to:

#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &

This worked - the session commands were not present before.

Saturday, March 18, 2023

Moodle Moove theme footer and support popup

The Moove theme on Moodle has a very prominent copyright notice, and the latest version of Moodle (4.1.1) seems to have added a "footer popup" button with a "?" sign, pointing to Moodle support - which might be confusing for our users. Hiding these using the Raw SCSS option in 
oursite.tld/admin/settings.php?section=themesettingmoove#theme_moove_advanced

footer::after {content: "© 2010 - 2023 (Our copyright notice). "} 

.card-body {
min-height: 100%;
}

footer#page-footer .row  {display:none;}

footer#page-footer .copyright  {display:none;}

footer#page-footer .footer-content-popover  {display:none;}

footer#page-footer   button{display:none;}

.stores {display:none;} 

a[href*='apple.com'] {display:none;}

nav.navbar .navbar-brand .logo img{

max-width:100%;

height:auto;

}

nav.navbar .navbar-brand .logo{

display:inline!important;}


setting up cloudflare origin certificates on Windows server

There seemed to be something wrong with win-acme which was preventing automatic renewals of the LetsEncrypt certificate on one of our servers. Possible reason could be that the server is switched off during the nights as it is a test / development server. Anyway, wanted to try Cloudflare's Origin server certificate instead, like we'd done for a Linux bitnami server earlier.

This post
https://bytefreaks.net/applications/cloudflare-origin-server-certificate-for-iis-10-server-on-windows-server-2016-to-allow-full-strict-mode-ssl-tls-encryption-mode
gives a good step-by-step guide. (Archived link)

Cloudflare's doc

points to

which is perhaps less clear.

When I try to select the cloudflare cert, the following error message is displayed:


I suppose that is because the certificate is from Cloudflare and not from one of the recognized certificate providers. Works with Cloudflare proxying in Full/ Strict mode. As the documentation says, "Site visitors may see untrusted certificate errors if you pause or disable Cloudflare on subdomains that use Origin CA certificates. These certificates only encrypt traffic between Cloudflare and your origin server, not traffic from client browsers to your origin."

Thursday, March 16, 2023

Cloudflare configurations for a new domain of ours

 
1. Made ourdomain.tld and www.ourdomain.tld proxied through cloudflare, from cloudflare dashboard - this is required for the next two points,

2. Added a page rule to redirect all requests to the bare domain ourdomain.tld to www.ourdomain.tld (which points to the google sites website).

3. Verified that "Always use HTTPS" is turned on in cloudflare Zone settings --> SSL/TLS --> Edge Certificates page. This will ensure that any http requests will be redirected to https.

Tuesday, March 14, 2023

printing a poster on multiple A4 sheets with a home office printer

Googling brought up PosteRazor - a nifty tool - which has an online webassembly-based version also. Worked perfectly in Firefox even on my underpowered machine with only 4 GB RAM running Linux Mint. Embedding their how-to video below - 



Saturday, March 11, 2023

pop-up Window - Modal box - in javascript

This is useful when you want to load a list of files or something like that when the user click on a link, using Ajax - How To Make a Modal Box With CSS and JavaScript

Friday, March 10, 2023

Listing / Getting Keys Values etc from javascript objects

https://www.educative.io/answers/how-to-get-keys-values-and-entries-in-javascript-object

If we don't know what a javascript object contains, we can use these to learn more about the object - 

    Object.keys(obj) – returns all the keys of object as array
    Object.values(obj) – returns all the values of the object as array
    Object.entries(obj) – returns an array of [key, value]

and we can check the length of the object using Object.keys(obj).length

using which we can loop through the object, or we can use foreach or for var in array and so on.

messages.forEach(function(message) {
   console.log(message);
}

for(let message of messages){
   console.log(message);
}

for(let key in messages){
       console.log(messages[key]);
 }

data.messages.forEach((obj, i) => {
     console.log("msgFrom", obj.msgFrom);
     console.log("msgBody", obj.msgBody);
 });

data.messages.map((obj, i) => {
     console.log("msgFrom", obj.msgFrom);
     console.log("msgBody", obj.msgBody);
 });

We can also implement lookup tables using objects,

https://www.educative.io/answers/how-to-use-objects-for-lookup-in-javascript




Thursday, March 09, 2023

one more link to remove files from github repo

To add to my earlier post about removing files from a github repository, and from git history, github's documentation is at

https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository#using-git-filter-repo

 

python3 -m pip install --user git-filter-repo

Requirement already satisfied: git-filter-repo in ./.local/lib/python3.8/site-packages (2.34.0)

 

Tuesday, March 07, 2023

HFS+ on Linux - or exFAT for Linux/Windows/Mac compatibility

HFS plus formatted Mac removable SSD (USB external hard disk) was not recognized on Windows and not writable on Linux. 

perhaps can be force mounted?
https://forums.linuxmint.com/viewtopic.php?t=283956

Or perhaps would need journaling turned off?
https://help.ubuntu.com/community/hfsplus

Anyway, with journaling turned off, exFAT is more compatible.

Trying to format it to exFAT on Linux -
https://unix.stackexchange.com/questions/61209/create-and-format-exfat-partition-from-linux

on my system,
sudo apt-get install exfat-utils exfat-fuse
(all installed already)
and then gparted

But greyed out in gparted - apparently a newer version of gparted is needed - my gparted version was 1.0 - so used Disks instead, OK.

But did not read on Windows. Reformatted in Windows, then OK. Some blocks issue, I guess. Or maybe needs to be GPT? I've not yet tried on Mac.

ffmpeg syntax to create movie from sequentially numbered frames

https://stackoverflow.com/questions/47670918/create-video-from-images-sorted-in-numerical-order-using-ffmpeg

ffmpeg -framerate $FRAMERATE -i "image%05d.jpg" output.mp4

and if we want XVID,

https://trac.ffmpeg.org/wiki/Encode/MPEG-4

ffmpeg -framerate $FRAMERATE -i "image%05d.jpg" -c:v mpeg4 -vtag xvid output.avi

(not yet tested for compatibility with our Blu Ray player.)

What I've used for 4K frames, 

ffmpeg -r 30 -f image2 -i "paranal_timelapse_vst_%05d.jpg" -vcodec libx264 -crf 15  -pix_fmt yuv420p paranal_timelapse_vst-4k-frames.mp4

Edit: 

# for starting at arbitrary frame number

ffmpeg -r 30 -start_number 405 -f image2 -i "paranal_timelapse_vst_%05d.jpg" -vcodec libx264 -crf 15  -pix_fmt yuv420p partial.mp4


Sunday, March 05, 2023

removing hyperlinks from PDF

Apparently in Adobe Acrobat, it is by Edit PDF -> Link -> Remove web links 

https://community.adobe.com/t5/digital-editions-discussions/how-to-remove-hyperlink-from-pdf/m-p/2236139

But then if the PDF is viewed inside Moodle, Moodle puts the web links back by parsing the text? Maybe. Works OK for a normal webserver.