Thursday, December 28, 2023

Wordpress users unable to log in

Troubleshooting request - admin users got logged out of Wordpress, unable to log in, "reset password also not working".

Rebooting the server has not resolved the issue.

The users shared this page,

https://blog.hubspot.com/website/locked-out-of-wordpress

Reset the password by connecting to the database and editing the users table, getting the MD5 hash of the password using

echo -n testpasswrdreplacewithcorrectone | md5sum

which works fine, tested with

 
Still could not log in, so renamed the password security plugin directories as mentioned in the post above, located in public_html/wordpress/wp-content/plugins
password-protect-page
and
password-policy-manager 
in this case, renamed to the directoryname_deactivate or whatever.

Then login works.
 

Friday, December 22, 2023

frame repeat / drop bug

Found frames being repeated (or dropped?) with a ~20 minute video processed with OCVvid2fulldome - found duration had reduced from 24 minutes to 22, and also some jerkiness in motion. The github issue is here.  

Possibly this is due to using ffmpeg in the backend, and this issue?
https://superuser.com/questions/1255380/ffmpeg-duplicating-frames

ffmpeg seems to assume 25fps input as default for frame sequences, and adds duplicate frames if output is 30 fps. https://gist.github.com/hn-88/95dbd59767dcdff23eab2f2be5880c2f

-fps_mode passthrough

seems to be a workaround when using ffmpeg from the commandline, but when ffmpeg is used via OpenCV, how do we manage this? 

generate a video with frame numbers

 Using ffmpeg, can use the following

Generate a video of frame numbers. (github.com)

This can be used to test for bugs like this one, 

frames being repeated or dropped · Issue #10 · hn-88/OCVvid2fulldome

Tuesday, December 12, 2023

update to Moodle minor update post - stop git from complaining about file permissions changes

Found a couple of issues while upgrading using the steps given in my previous post regarding Moodle minor update using git -

  1. If we uninstall the h5pactivity built-in plugin before the upgrade, the upgrade does not proceed - it complains about corrupted plugin. So, basically, we can't uninstall the default plugins without causing issues with upgrades.

  2. If we change the file permissions, we need to add a command
    git config core.filemode false
    to prevent git from complaining about overwriting local files, listing all the files, and aborting the git pull. Via this post.

So, the updated list of commands:

cd /var/www/theLMSgit
sudo -u www-data /usr/bin/php admin/cli/maintenance.php --enable
git config core.filemode false
git pull
sudo chown -R azureuser:www-data .
sudo chmod -R 775 .
sudo -u www-data /usr/bin/php admin/cli/upgrade.php
(type y when prompted)

 

workflow and supported codecs

Workflow for creating files playable at our theatre using only cross-platform tools.

  1. ffmpeg to create mp4 file if input is frame sequence - as in this post,
    ffmpeg -r 30 -f image2 -i "Our-frame_%06d.png" -vcodec libx264 -crf 15  -pix_fmt yuv420p Our-movie-4k-frames.mp4

  2. OCVWarp to create warped file. Fourcc of avc1 results in x264 video, good quality.

  3. Avidemux to edit the warped file, move the credits to the beginning and speed up credits. Also overlay Hindi / Telugu title text as graphics using the logo filter.
     
  4. To note: Firestick 4K needs FAT32 formatted disk, which has a 4 GB file size limitation. So, re-encoding files with x265 (HEVC) using the options in the Configure button to choose file-size based codec quality. This takes around 8 hours to encode a half-hour 4K 30 fps video on an i5 laptop!

  5. Similarly, the older BluRay player needs to have 1080p encoded with XVID fourcc. x263, I guess. 

Upcoming - perhaps try AV1 codec?

https://trac.ffmpeg.org/wiki/Encode/AV1

 

Sunday, December 10, 2023

Moodle server down - restart db server fixed it

Uptimerobot alerted me that one of our Moodle servers was down.

The database server is not responding, that was the reason.

Initiated a restart, hoping this may solve the problem. 10 minutes later, systems were up.

Copy-pasting from an email exchange about the reasons:
 
It could have any of the following causes:
1. automated bot attack
2. some services not restarted properly after an automated system update
3. some other issue triggered by some user action

Right now I'm not digging into the logs for troubleshooting, in case the issue happens again, will do more digging.

We anyway would need a server upgrade some time in the first half of 2024 for operating system upgrades - at that time, I could tighten some of the parameters for better security (like the open ports with default services present currently).

Friday, December 08, 2023

Wordpress permalink issue

One of our servers' site admins reported a problem, with "remove the index.php from the URL" - the standard method of 
WordPress dashboard --> Settings --> Permalinks --> "Post Name" Permalink, Save Changes
did not work for them. "File not found" error.

Checked the .htaccess file, it seemed to be OK.

But looking at how Apache handles .htaccess files, found that AllowOverride would be needed for the .htaccess files to work.

Following

https://ubuntu.com/tutorials/install-and-configure-wordpress#4-configure-apache-for-wordpress

added the lines

<Directory /oursrv/path/to/www/wordpress>
        Options FollowSymLinks
        AllowOverride Limit Options FileInfo
        DirectoryIndex index.php
        Require all granted
    </Directory>

to the relevant files in /etc/apache2/sites-available and then did

sudo service apache2 reload

The admins report that this solved the issue.

Saturday, December 02, 2023

Update your trusted root store for Azure Storage services

We got an email from Azure, asking us to update our trusted root store for Azure Storage services - "If you have client applications that still use certificate pinning, they'll be affected by this change and you'll need to take action by 29 February 2024 to avoid potential connection interruptions."

I don't think any of our apps or services use certificate pinning, so did not take any action.

Wednesday, November 29, 2023

converting flat video to fulldome

Leaving aside paid products like Adobe After Effects, for multiple videos on a fulldome frame, a good option would be OCVvid2fulldome

If we want to project a high resolution, say 4K flat-screen video onto the dome, OCVvid2fulldome v1.6 or above, with the following parameters works relatively well, except for some slight distortion at the bottom and top edges - 
#Outputw_pixels__=height
4096
#Output_fps
30
#Output_fourcc
XVID
#Number_of_input_videos_max_is_99
1
#Filename0
D:/Input/Filenm.avi
#vidlongi0
180
#vidlati0
76
#vidw0
270

Example images - 
Flat, 16x9

Using OCVvid2fulldome with 270 degrees coverage as above:


Another option is Natron, which has a G'MIC Distort filter for "Square to Circle" as referenced in this video. But Natron is prone to crashing for video to video conversions, image sequences seem to work OK. Also, Natron renders at something like 2 seconds per frame for 4K output, at least 4x slower than OCVvid2fulldome.

Square input - 


to Circle output - 

Natron troubleshooting notes:

im seq crashes were probably due to wrong way of entering filename?

im_%05d.jpg works well. Also need to check if the pre-multiplied value is correct, Opaque is fine for RGB video. Natron Tutorial | How to Render / Export / Write - YouTube

In the video link above, he has to re-render missing frames! and creating a proxy mov file at around the 13:00 minute mark.

troubleshooting premiere import - source settings, set the R, G, B.

Some frames randomly lo res!

Use precomp for large script if rendering fails!

saving script can overwrite a jpg!

To make a 16x9 video into a square video, padding with 1080 black border on top - does not look good - too small on the dome. Need to crop to square, so the sides are lost. 




Wednesday, November 22, 2023

saga of backing up and restoring a course with H5P content on moodle

My initial understanding was that backing up and restoring a course with H5P content on moodle would not work, based on the discussion at https://moodle.org/mod/forum/discuss.php?d=427198

A test course backup and restore did not work. But then, it turned out that the issue was that the H5P plugin mod_hvp had some missing files (since this moodle instance had its database copied over from another test instance) which were causing H5P content to not display at all. Diagnosed via php errors in /var/log/apache2/error.log.

The relevant course had 90+ H5P activities, it took 2.5 hours to backup via the CLI, and the restore also is likely to have taken a similar amount of time. 
screen
date && sudo -u www-data /usr/bin/php admin/cli/backup.php --courseid=511 && date
Mon Nov 20 14:38:34 UTC 2023
== Performing backup... ==
Backup completed, the new file is listed in the backup area of the given course
Mon Nov 20 17:09:05 UTC 2023

Detailed notes and dead ends listed below.

Looking at the discussion here,
It seems there are two ways in which H5P files can be used in a course - as a "link" and as a "downloadable file".
The "downloadable file" method is such that the course instructors cannot edit the content from the server, they need to download it to their computer and use some other software to edit it - so I guess what you have used is the "link" method.

In that case, there seems to be no easy way to backup and restore, the easiest way may be to re-create the course on the new server, if my understanding of the discussion here is correct - 

(
Another option would be to copy the entire database of the learning server onto the student server - and then you would need to
delete all unnecessary users
delete all unnecessary courses
re-upload files for all necessary courses
re-upload all files for appearance, logo, etc.
but this seems to be more difficult that re-creating the course. 
)

(
According to the last-but-one comment in the bug tracker
course backup and restore would work, but only tested on the same server. 

I tried out the command-line backup option for that course,
but that also did not finish even after an hour - stopping it manually gave the error message
Potential coding error - existing temptables found when disposing database. Must be dropped!
This looks like some sort of bug in the moodle backups code, I guess.

Or maybe just some temp tables which need to be dropped.

Apparently temp tables are automatically dropped when the connection to the database is closed.

)

(
Checking
moodledata/temp/backup/ directory
and
and

Even after clearing the moodledata/temp/backup directory, even a small course is taking a long time to backup.
So, there may be some temp data tables which need to be dropped. Need to check - 
Potential coding error - existing temptables found when disposing database. Must be dropped!

SELECT * FROM information_schema.INNODB_TEMP_TABLE_INFO;
(no results)
)

mentions backup can hang if non-standard course format

delete a file
go to course, choose the file / activity / resource, choose delete

delete a course

h5p backup speedup by disabling backing up libraries

Backup settings page, choose not to include the libraries
But not available in
Site Administration - Courses - General backup defaults

Will enable async backup with
https://devel2.server.of.ours.org/admin/settings.php?section=asyncgeneralsettings
and try.

Tried creating a course on devel2 with
My Courses -> Create new course.

Backup option is inside the course, under More -> Course Reuse -> Backup

Restoring similarly,
can go to any course, More -> Course Reuse -> Restore
and then choose to restore to a new course.
(NOT Import)

Just as in the learning portal, on the student portal also, the H5P hub option is turned on,
https://our.server/admin/search.php?query=hub

I have turned off and turned on this setting as suggested in one of the replies in the thread

In case that does not help, it may be required for you to fill in the H5P Hub account settings,
Register an account on the H5P Hub here

If not,

Another possible cause for confusion may be the two different ways of using H5P, using a plugin and using H5P core.
This discussion above uses Moodle 3.9, but our case with Moodle 4.1 might be different, too, and we might have to investigate further.

mod_h5p and mod_h5pactivity are already installed by default in Moodle 4.
https://server/admin/plugins.php

I tried creating a simple h5p activity in a test course by uploading a file arithmetic-quiz-22-57860.h5p, but the activity is not visible on the student site

To display H5P content in Moodle activities, the Display H5P filter must be enabled, and the URL (e.g., h5p.com) should be listed as an allowed source in Site admin / Plugins / Filters / Display H5P.


https://docs.moodle.org/401/en/Display_H5P_filter

Found a google drive listed there,

https://drive.google.com/file/d/1Mviw-REDACTEDZ3F/view?usp=sharing

After removing, still no. 

I see two possibilities.

1. In the page which talks about setting up h5p on moodle, there is mention of a filters page, where the url of the h5p server should be entered - 
There was a google drive link in that filters section which I have now removed. But then, we may need to add the correct filters. Or perhaps the "show h5p content"  may be sufficient, which is done at this page,
https://server/admin/filters.php 
If you have some url with a working h5p content from the hub, we can put the appropriate url in
https://server/admin/settings.php?section=filtersettingdisplayh5p

2. Another possibility is this thread - 


1. files missing as seen in apache2 errors.log


2. Compatibility issue with PHP 8,

But we're using PHP 7.x, so not this issue.

Trying uninstalling both
mod hvpactivity and mod hvp
installed only mod hvp, working
While installing mod_hvp, it mentioned "automatically registering your site with h5p" - so that is also done.

Even the web-based backup worked, for the test course! Just took an hour. and included 4 MB.

For without user data,
first change backup default setting at
(take backup and then change the default back)

CLI backup completed in around 2.5 hours, it is available to download from the course's restore area
in "User private backup area" of admin user

Tuesday, November 14, 2023

moodle app build for v4.3.0

Some small changes were needed in the github workflow in order to build the latest version, 4.3.0, of the moodle android app. My earlier posts about building the moodle app can be found here

Trying the old workflow led to some errors like

Failed to restore plugin "cordova-plugin-screen-orientation". You might need to try adding it again. Error: Error: Command failed with EACCES

Checking the testing.yml in the 4.3.0 tag found some extra lines like 

npm ci --no-audit --prefix cordova-plugin-moodleapp

Adding that led to a different error,

 cordova-plugin-moodleapp@0.0.0 prod /home/runner/work/LMSapp/LMSapp/cordova-plugin-moodleapp

> NODE_ENV=production scripts/build.js

sh: 1: scripts/build.js: Permission denied

Trying the simplistic solution of giving run permissions for everything,

chmod -R +x ./*

This worked, except for needing resources/android/icon-background.png to be added manually as in earlier releases. 

Tweaked the build script to directly pull the codebase of the release from github instead of manually adding it, with all customizations from our private repo which has the following file structure:



 

 

 

Monday, November 13, 2023

moodle app ui for multiple logins

Once logged in to one site, if someone has a login in another site also, they can log in to the other site by tapping on their profile icon on the top right corner of the screen and choosing the "Switch account" option, even without logging out completely.

using mv to move hidden files from a script or command line on Linux

mv subfolder/{.,}* /path/

But this can cause scripts in github actions to fail, so using cp -r instead.

show hidden files in Linux Mint File Open Dialog

 

 Ctrl+H to toggle show/hide hidden files!

Saturday, November 11, 2023

mirror ipad screen on Windows PC

 https://www.howtogeek.com/247573/how-to-mirror-your-iphone-or-ipads-screen-on-your-windows-pc/

Install AirPlay Screen Mirroring Receiver (free) from the Microsoft Store, open it.

Open the Control Center in ipad/iphone by swiping up from the bottom, or down from the top right edge, depending on which version of iOS you have. Then tap "Screen Mirroring." The PC should appear on a list of available devices.

But some apps like Disney + Hotstar don't work if mirroring is enabled, "Please try again after disabling screen recording".


Friday, November 10, 2023

the beginning of the end of Google

Whatever goes up has to come down. Ever since it went public, Google seems to have slowly but surely gone down the road that leads to its ultimate decline. People were discussing this in 2006, but now even their flagship Google Search seems to have gone downhill with their policies put in place (probably to avoid abuse). 

Case in point - a personal blog, created on blogspot.com (owned by Google!) was not being indexed. Even after submitting the sitemap created by blogspot itself, Google Search console shows that blog as being crawled, but not indexed. Whereas bing.com and duckduckgo.com at least show the pages on the site if the keyword site:actual.url.of.the.site is used. After filling up the "submit feedback" form on Google Search Console, of course, there was no response whatsoever.

Cory Doctorow, of course, has written about it eloquently on medium -
https://doctorow.medium.com/googles-enshittification-memos-2d6d57306072

and the ad-free, login-free version on

https://pluralistic.net/2023/10/03/not-feeling-lucky/#fundamental-laws-of-economics

Edit: Here is a Google insider's take on Google's cultural erosion - via slashdot, 

Hixie's Natural Log: Reflecting on 18 years at Google

Wednesday, November 08, 2023

turning off some notification types in a default Moodle install

It is probably prudent to turn off "forum" and "new login" notifications in a new moodle instance to avoid users' email providers marking the emails from the server as spam, and to avoid exceeding quota limits if using GMail / Google Workspace / other provider with daily quotas.

Tuesday, November 07, 2023

zoom effect in blender without moving camera

 By animating the focal length property of the camera, we can get the equivalent of a zoom lens effect in blender, without moving the camera.

https://blender.stackexchange.com/questions/23783/zoom-with-camera-in-an-animation

getting started with google search console

Google webmaster tools have been moved to google search console. Got an email after signing up, "Now that you've verified your site in Search Console (or created a site in Blogger or Google Sites, which verified your site for you) we have some tips to help you use Search Console more effectively."


Sent a report via google search console. The above page gives detailed about search indexing problems like "crawled, not indexed."
 
Edit - more about "crawled, not indexed" in this post, https://hnsws.blogspot.com/2023/11/the-beginning-of-end-of-google.html

Probable reason for crawling and not indexing could be that most of the posts are back-dated to the 1990s and some in the mid 2000s.

Bing does index it though. And so duckduckgo does too, since it uses Bing for the back-end.

Friday, November 03, 2023

adding a file to an appimage

To test out the script in the interesting discussion
https://github.com/Stellarium/stellarium/discussions/3424

I tried to add the script in the discussion to an appimage of stellarium 19.3. It turns out it's not that easy, but some things can be done.

https://superuser.com/questions/1301583/how-can-i-extract-files-from-an-appimage

suggests the --appimage-extract command-line option, but is not very explicit on whether the option should be run on appimagetool or on the appimage itself.

https://unix.stackexchange.com/questions/517881/how-can-i-change-the-files-of-an-appimage

clarifies that the option is to be run on the appimage itself, and not on appimagetool.

So, that extracted the files into ./squashfs-root, and I could add the new script into the scripts directory. But when I tried to create an appimage from the modified squashfs-root using appimagetool, it failed with an error,

org.stellarium.Stellarium:~: metainfo-filename-cid-mismatch

Googling led me to https://kb.vmware.com/s/article/1007969
which says that we should manually correct the cid for similar errors with VM images. But that advice doesn't seem to be relevant here. 

In any case, the bin directory inside ./squashfs-root had a stellarium executable which could run, and the extra added script also showed up.

Saturday, October 28, 2023

moodle site registration issue and fix

There was a problem with site registration, saying "your site is already registered". This is probably because we had copy-pasted the database from an existing site. 
 
This discussion 
suggests deleting the entry in the registration_hubs table in the database to allow us to register.

I have done that now, and that allowed the site to be registered.

request for new font in Moodle instance

Following a request to install a new font in a Moodle instance, I did a local install with

sudo mkdir -p /user/share/fonts/googlefonts 
cd /usr/share/fonts/googlefonts
sudo unzip -d . ~/Tangerine.zip
sudo fc-cache -fv
Links - Using web fonts -
Using local installation -

 
But then it was reported that this font is not seen as one of the options when editing an element in the custom certificate plugin.
 
Certificate builder needs fonts in a separate format?
 
Tried purging cache, purging cloudflare cache etc, but still not seen. 
 
Not the manual method, but this plugin method in the up-to-date docs.


Finally, trying the TCPDF fonts plugin
As screenshot shows,
Dashboard - Site Administration - Server - TCPDF Fonts
 
After initialization and adding the font that way, works fine - did not have to purge caches etc.
 
 

Wednesday, October 25, 2023

Amazon firestick not recognizing a USB drive - issue was with partitioning

There was one drive which was being recognized, and another drive which was not. The drive which was being recognized had the original 16 GB FAT32 partition, while the one which was not being recognized had been used as a Linux Mint installation disk, and had been later reformatted as FAT32 using the "Disks" utility on Linux Mint.

Both show in "Disks" on Linux Mint the following info:
 
 

Suspecting that block size might be the issue, to show the block size,

 
stat -f shows  8192 for the non-working drive and 16384 for the working drive. Tried to see if reformatting would work -

(trying 32k size instead of 16k)
 sudo mkfs.fat /dev/(device name from above) -s 64 -F 16
 

Changed label using
Disks --> Edit Filesystem --> it prompts for the label.
 
But that didn't seem to work - copying a test file seemed to take ages. 

Then, tried GParted. GParted showed the partition to be of type iso9660! 

Unmounted, Deleted the partition, recreated partition table with device -> create partition table (msdos), formatted as msdos, then the Firestick recognizes it OK even though the block size is 8K as shown in 

 stat -f /media/mac/LM
  File: "/media/mac/LM"
    ID: 83100000000 Namelen: 1530    Type: msdos
Block size: 8192       Fundamental block size: 8192
Blocks: Total: 1951116    Free: 1318805    Available: 1318805
Inodes: Total: 0          Free: 0


 

Sunday, October 22, 2023

Saturday, October 21, 2023

optimizing github actions build using cache

When I was poking around the github actions tab, saw the cache side-bar link, and thought I'd check it out. 

When added to this msbuild action, the OpenCV caching brought down the total build time from 5-8 minutes to just 1.5 minutes - the download and untar from cache happens in 25 seconds instead of the download and unzip from github releases which would take 6 minutes or so.

More references:

Need to order the named jobs so that the cache comes first - https://github.com/actions/cache#skipping-steps-based-on-cache-hit

Wednesday, October 18, 2023

Travis deploy to Github releases - requires classic personal access token

OCVWarp deployment from Travis-CI to Github Releases failed because the token had expired. When creating a new token, I tried a fine-grained token with write permissions to releases on that repo alone. But that did not seem to work. A "classic" personal token with "repo" scope worked fine. 

https://github.com/settings/tokens

Sunday, October 15, 2023

migrating from Android to iPhone


How to migrate your WhatsApp data from Android to iPhone | WhatsApp Help Center

 Though this method was followed, only the photos and media were transferred from whatsapp, not the chat history. Probably that was because whatsapp had been earlier installed on the iphone, though it was then removed with "delete all data"?

https://faq.whatsapp.com/1195710084347483?helpref=faq_content

then, to transfer music, move content manually from your Android device to your iPhone,

https://support.apple.com/en-gb/HT205063

Friday, October 13, 2023

playing local video from firestick without internet

While setting up the Firestick, we wanted to create a new dedicated account for it, but it asked for a unique phone number - so we just used my account.

We found VLC player was stuttering with our 4K videos on USB, but MXPlayer works with hardware acceleration, and plays them perfectly. To access MXPlayer without internet, via Quora,

Settings --> “Applications” --> “Manage installed applications” --> "MXPlayer" --> "Launch"

And it looks like there is no "shutdown" option - we just press "home" to come out of MXPlayer, and then turn off power to the device.


Maybe this will? Long press centrebutton + play for 10 sec

Our Firestick runs FireOS 6.4, but we did not have to do any ADB commands to use FAT32 formatted USB memory. The ADB commands in this pdf may be useful for increasing system usable memory, installing apps and so on, but not needed for us.

As recommended in this troubleshooting video, when connecting for the first time, doing so from the "home" screen might be beneficial.

How to play our own content from USB on Amazon Firestick

We can't just connect the firestick to a computer and transfer files to its internal memory - MTP does not work with Firestick 4k

Can probably use adb pull


But far simpler to just use a removable USB drive.


Thursday, October 12, 2023

error updating snapd

Investigating unresponsive server behaviour on one of our servers,

grep -i error /var/log/syslog

showed some lines with WALinuxAgent - this is Azure's agent, I guess, as well as snapd.

 snapd[63805]: stateengine.go:149: state ensure error: cannot query the store for updates

 To check if we can remove snapd


snap list
 
shows lxd, which might be needed - 

How to remove LXD from my system - LXD - Linux Containers Forum

So I left it alone, and tried a manual update with

 sudo snap refresh

which indicated all packages were up to date. So maybe the error was a temporary error.

issue with one of our Linux servers

One of our Linux servers was becoming unresponsive around 2-5 pm daily over 2-3 days. Checked the logs as in my earlier post but did not find anything except the usual SSH brute-forcing attacks. Changed the port from 22 to something else by
sudo nano /etc/ssh/sshd_config
sudo service sshd restart

And opened the new port on Azure portal Networking screen. 

This seems to have worked.

Wednesday, October 11, 2023

redesigning python code to fade out smart lamps

 The smart lamp controls with a python flask app as in a previous post had some issues. 

  1. There was no feedback to the user in case the mobile browser lost connection or the python app lost connection to the smart lamps.

  2. The raspberry pi was showing slightly excessive cpu usage, with the lightning bolt icon on the top right corner appearing sometimes.

  3. There was no way to stop the python loop in case it was taking too long to complete.

  4. The way I'd written it, if the /fadein url was the last used one before mobile browser disconnect, the next time I opened the mobile browser, the lights would come on! due to the mobile browser retrying that page.

So, thought of redesigning the code. 

Found that RaspController has a section for running user-defined custom commands. Since both KR and I use RaspController on our phones, the simplest solution seemed to be to just use a python script to do the fadeout of the lights, and show the output of the script on the terminal using RaspController. 

And that seems to be working fine. 

Since the code on github has the device ids and local keys, instead of taking the time to modify the code to put the private info in separate files etc, I'll just copy-paste the current state of the code here.

import tinytuya, sys
from time import sleep

def moveup(lines):
        for _ in range(lines):
            sys.stdout.write("\x1b[A")

nowait = bool(1);

# Connect to Device
d = tinytuya.BulbDevice(
    dev_id='changeme',
    address='our.ip.2',      # Or set to 'Auto' to auto-discover IP address
    local_key="changeme12",
    version=3.5)
print("Connected to d")
b = tinytuya.BulbDevice(
    dev_id='deviceidchange',
    address='our.ip.1',      # Or set to 'Auto' to auto-discover IP address, but that takes 10 sec
    local_key="changeme34",
    version=3.4)
print("Connected to b")

def fadeout():
    d.set_brightness_percentage(100, nowait)
    sleep(1)
    b.set_brightness_percentage(100, nowait)
    sleep(1)
    d.turn_on()
    print("d turn on")
    sleep(1)
    b.turn_on()
    print("b turn on")
    sleep(1)
    i = 100
    while i > 10:
      d.set_brightness_percentage(i, nowait)
      print("d brightness {0:3d}".format(i))
      b.set_brightness_percentage(i, nowait)
      print("b brightness {0:3d}".format(i), end='\r')
      moveup(1)
      sleep(1)
      i -= 10
    i = 10
    while i > 11:
      d.set_brightness_percentage(i, nowait)
      print("d brightness {0:3d}".format(i))
      b.set_brightness_percentage(i, nowait)
      print("b brightness {0:3d}".format(i), end='\r')
      moveup(1)
      i -= 1
    d.turn_off()
    print("d turned off.          ")
    b.turn_off()
    print("b turned off.          ")

fadeout() 

finding duplicates to fix SQL query - ad hoc query in Moodle

There was an issue once again with the feedback ad-hoc Moodle report - checking the query in DBeaver, the database returns an error "Subquery returns more than one row" for some dates. Eg Oct 1.

Via https://stackoverflow.com/questions/2594829/finding-duplicate-values-in-a-sql-table

Found the duplicate timestamps with

select timemodified, count(*) from ourprefix_feedback_completed
GROUP BY timemodified
HAVING COUNT(*) > 1

1690263769    2
1696119639    5


Have changed the timestamps to increment the duplicates by one, so that the query works without issues.

 

Tuesday, October 10, 2023

blender rendering notes

I tried out some rendering of scenes using the Cycles Panorama camera 180 degree Fisheye Equidistant option. A large number of links to howtos for accomplishing specific tasks in blender - link dump below.

1. Render optimizations - 4K render of one frame takes 6:45 - nearly 7 minutes a frame is not enough - need to check out GPU rendering. GPU needs min compute capability 3 Nvidia or AMD GPU -
https://www.youtube.com/watch?v=1io1yPj0Sk0.
https://docs.blender.org/manual/en/latest/render/cycles/gpu_rendering.html
For reference, the old Macbook Pro with 4 GB RAM and i7 processor has a compute capability of 1.2 -
From System Info
NVIDIA Corporation GT216M [GeForce GT 330M]
GeForce GT 330M compute capability is 1.2
But for tests, can do with some optimizations - render time tweaks -
5 Tips for FASTER Renders in Blender Cycles - YouTube

Noise threshold of 0.5 and enabling noise threshold reduced render times nearly 50%.

2. Animate rocket launch tutorials -
Involved version - https://youtu.be/NFtXTruJ-_c
Simpler version - Rocket Launch Smoke Simulation in Blender 3.0 [Easy!] - YouTube - this is the one I tried out, removing the grass in the foreground and adding water instead.

 
4. Blenderkit - For current versions of blender, need to install blenderkit addon from blenderkit.com
BIG CHANGE! You won't find BlenderKit in Blender 3.0 by default anymore || Blender Tutorial - YouTube

5. The reason the smoke was not working for my rocket was the Bake settings, and the paths to the bake were also set wrongly.  Need to set the paths correctly, Free all, then bake all.
In Physics tab, which is the one which is below the particles tab, with a sphere in orbit around another sphere, 
choosing SmokeDomain object,
under Cache,
changed the directory of the cache to within the project directory,
"Free all"
Then 
"Bake all" - this took approx 3 sec per frame in the beginning, becoming 10 sec per frame near the end.
 
and if only Sky is needed, Nishita sky seems to be a good option - 
 
7. Make all paths relative - so that the project directory can be copied and used on another machine - 
https://blender.stackexchange.com/questions/230328/how-to-package-all-assets-image-textures-mainly-into-a-folder-not-into-blend
File --> External Data --> Make all Paths relative
 
8. Importing a model - like FBX - with textures -
Imported 3D model missing textures - Simple Fix - YouTube - which says just re-apply the textures - Material properties --> Surface --> Emission --> Color--> Image Texture --> open file.
Blender 2.8 - OBJ materials are not imported properly - [ SOLVED ] - YouTube - this one renames the mtl file, if that was the issue.
How to PROPERLY Import Models With Textures in Blender - YouTube - this also uses Node Wrangler, which has a detailed tutorial below - 
What I needed was Node Wrangler:
How to use node wrangler for setting texture roughness, colour etc in one step.
 
9. Moving all keyframes to make a 150 frame video 1500 frames instead -  with the current version of blender's smoke simulator, just doing the time remapping as 10 to 100
https://blender.stackexchange.com/questions/3242/can-i-increase-the-frame-rate-of-an-animation-while-keeping-it-the-same-length
http://www.ffnn.nl/pages/articles/media/blender-tips-and-tricks.php
- is not sufficient. The smoke gets updated only once in 10 frames if the time remapping is 10 to 100. Trying 100 to 1000 - the maximum value for the latter value is 999 - so 100 to 999, but the resulting animation still has the smoke particle system jumping from one state to the next every 9-10 frames. So the only way is to add more frames to the project, and drag the keyframes further along the timeline. A separate post about it coming up.





Monday, October 09, 2023

remove loggly

I'd installed loggly free trial on one of our servers, and had forgotten about it. Installation documentation
https://documentation.solarwinds.com/en/success_center/loggly/content/admin/sending-apache-logs.htm

 When it came to uninstalling it, Solarwinds support said just remove the API token. But then the server would continue to send the data to solarwinds' server, only we can't see it, right? Not very customer-friendly. Anyway, their own documentation says

Stop Sending Data to Loggly (solarwinds.com) 

sudo bash ./configure-linux.sh -a our.domain.org -r
 

for removing the service. So I did that also, and removed the token also.