Saturday, September 30, 2023

simple efficient code to push multiple rows of data into a google sheet

As mentioned in
https://spreadsheet.dev/write-multiple-rows-to-google-sheets-using-apps-script
it is much more efficient to use Google Apps Script Spreadsheetapp function
Range -> setValues()
rather than
Sheet -> appendRow()

Concise code snippet, similar to what is used in a function in one of my private repos "Search results to sheet":

var data = [];
// add as many times as needed in a loop
data.push([value1, "value2", value3]);
//
var lastRow = SpreadsheetApp.getActiveSheet().getLastRow();
SpreadsheetApp.getActiveSheet().getRange(lastRow + 1,1,data.length, 
data[0].length).setValues(data); 

Thursday, September 28, 2023

correct way to check GPG signature - Stellarium AppImage

I thought the Stellarium AppImage was corrupted or changed, and submitted an issue - https://github.com/Stellarium/stellarium/issues/3432

It turns out the correct way to check files in stellarium releases is mentioned on https://github.com/Stellarium/stellarium/releases/

It's not the AppImage signing method as mentioned at
https://docs.appimage.org/packaging-guide/optional/signatures.html#validating-the-signature

So, not

./Stellarium-0.19.3-x86_64.AppImage --appimage-signature

but

gpgv --keyring ./stellarium.gpg 
Stellarium-0.19.3-x86_64.AppImage.asc
Stellarium-0.19.3-x86_64.AppImage

Wednesday, September 27, 2023

Stellarium scripting discussion

Copy-pasting one of my private replies sparked by the interesting discussion at
https://github.com/Stellarium/stellarium/discussions/3424

The internals of stellarium are such that you can't use Spacebar to control a script - you can use keys like

=, -, ] or [ or L or J

That is, those keys which are mapped to some functions already in

More information about this limitation is at
and

So, if using another key is acceptable to you, we can go ahead with that.

Request for diurnal motion and annual motion specifically for Stellarium v0.19.3 - 

As far as I know, there is not much difference between 0.19.3 and the latest version, as far as this particular script goes.


Diurnal motion - just hitting (lower case L) "speeds up time" , so you can see the stars/planets/sun/moon go around faster.

Annual motion - I suppose you would want the night sky as seen at Bristol at 12 midnight over the course of one year to be shown in 36.5 seconds?
This can be done using something like this script

Stellarium has a remote control plugin, which allows you to run scripts using a different computer / tablet / phone.
If that is useful for you, you can enable it using
(F2) Configuration Window -> Plugins tab -> Remote control -
choose enable at startup
Then close and open stellarium
Then go back to
(F2) Configuration Window -> Plugins tab -> Remote control
choose the configure button, and check the "Server enabled" box.
(Also check the "Enable automatically on startup" if you want it permanently enabled every time.)

 

playing out 4K videos from network share on Firestick 4K - buffering

According to this video, the app to use is Network Browser, for playing out files on a Firestick from a Windows (SMB) share over the network instead of streaming or from a USB drive. 

 But unfortunately, a share from a Raspberry Pi 2, even connected via Ethernet to the Router and the Router connected via Wifi 5g to the firestick, could not send the file fast enough - Network Browser was buffering for the high bandwidth parts. Maybe I'll revisit this with a faster network share, maybe from Windows laptop? Or perhaps connect the Firestick via Ethernet using something like this?

Tuesday, September 26, 2023

EMI or grounding issues

My replies to a query about some sensitive instruments showing noise on-screen at a particular installation:

This tektronix page gives some ideas on how we can search for EMI, and the frequency bands we need to look at.

Here is a link to a low cost device using an arduino for a SDR (software defined radio) which can be tuned from 100 khz to 50 Mhz - 

Ready-made SDRs are also available, for eg. SoftRock,

Even simpler might be, if you have a portable radio which can tune from AM to SW bands, you could take that to test for EMI (which would be heard as a KRRRR noise in some band, if you tune over all bands) and then change volume as you move closer / farther from the EMI source. 

To see if earthing is the culprit and not EMI, one possibility is:

Use some thick short 15 amp electric wire and connect together the working and non-working (noisy) equipments using their grounding lugs if any, or some sort of screw mounts on the metal part of their body.

Excerpts from S's reply:

the article is extremely informative and helpful.
i do not think grounding is a an issue. Engineers from  ...
have come and  checked the ...
installation which is
right below ....
They found that the Gradient Pipe  which is
right below the ceiling is not shielded.
... if the power cable is passing through ...
there is noise Hence i think if we use a EMF shielded  power
cable there might be  noise reduction....
i have asked ...
to come with a Spectrum Analyzer and also EMF
shielded power cables...

printing from Gmail without the header

It looks like the only way is to select part of the message, right-click and choose "Print selection". But then, the From email address, date, To email address etc are still not displayed. So my workaround was to copy-paste into a new Google Doc the from, to etc from the "Show Original" menu item, copy-paste the body, then print from the Google Doc.

all issues were due to a router reset

Multiple things went wrong -

  1. we could not ssh into the Raspberry Pi doing loop playout in the lobby in order to reboot it - for which we generally use the RaspController app.
  2. we could not control our theatre lights - controlled using a python script as per this post.
  3. The playout Amazon Firestick could not connect to the internet, so it was displaying "Home Unavailable" - the workaround was to long-press home, and choose MxPlayer from the installed apps from the shortcut menu.  

It turned out that all the issues were due to the Wifi router getting reset. Why? No idea. Anyway, filled in all the static ip addresses mapped to MAC addresses, as well as the gateway information, restarted the router and the devices, and all was well. 

Monday, September 25, 2023

network inventory or discovery - finding IP addresses of all hosts using nmap

I had written earlier about the arp command to check all the hosts on the network, but sometimes that does not work. It turns out nmap does a good job. Referencing https://www.redhat.com/sysadmin/quick-nmap-inventory

nmap 192.168.0.0/24

does a full scan of all hosts, 

(4 hosts up) scanned in 24.17 seconds

nmap -sn 192.168.0.0/24

does a quick scan, which only shows which hosts are up - in around 4 seconds.

The link above even shows how to do a packet trace using nmap, 

# nmap -vv -n -sn -PE -T4 --packet-trace 192.168.2.3

use NTFS USB drive with Android - possible workaround

 Maybe this will work with Amazon firestick also? This forum thread -
https://xdaforums.com/t/how-to-get-usbs-to-work-on-android.3952656/

mentions the app “Microsoft exFAT/NTFS for usb by Paragon software” - and the comments there point to total commander.

Sunday, September 24, 2023

getting rid of "unverified publisher" warnings in Windows builds

 It looks like it would cost a minimum of $100 a year to get a trusted certificate to get rid of the "unverified publisher" warnings - we could create an openssl certificate with our name, but it would still be "unverified".

Get rid of "Publisher Unverified" warnings in Windows for executables - Stack Overflow

Saturday, September 23, 2023

manually renewing letsencrypt certificates for a migrated server

One of our wordpress web servers running on Ubuntu 22 showed certificate errors - apparently the letsencrypt certificates had not been auto-renewed.

Following

sudo apt install certbot python3-certbot-apache
#(was already installed)
sudo apache2ctl configtest
#(Syntax OK)
sudo certbot --apache
#(chose to Expand and replace current certificates for all domains, done.)

Then, I put in a reminder in my google calendar to check if auto-renewal has any problems, one week before expiry 3 months later.

flask app takes a long time to load on Linux Mint

 In addition to all the issues with a python flask app for controlling smart bulbs as mentioned in this other post, when I tried to run the flask app for troubleshooting on Linux Mint, it would take nearly 3 minutes to start up. Probably due to python installation issues? Python2 vs Python3 issues? Did not go too deep into it at this time.

Thursday, September 21, 2023

hard coding subtitles with avidemux

For our planetarium show subtitles in Hindi and Telugu, the avidemux subtitle settings were as below:



Sunday, September 17, 2023

Friday, September 15, 2023

Stellarium flybys in high resolution

1. vncserver -geometry 7680x4320

Tightvnc viewer, choose 25% zoom in options

Flybys are possible now!

Board a spacecraft and flyby planets, moons and a comet yourself · Stellarium/stellarium · Discussion #2178 (github.com)

2. Xubuntu with high-res screen : r/xubuntu (reddit.com)
Settings -> Appearance -> Fonts and set to roughly 180.

3. Now stellarium can save screenshots in desired resolution directly, so no need of vnc etc.

Thursday, September 14, 2023

delete an EFI partition with Windows Diskpart

Following the advice at
https://www.easeus.com/partition-master/delete-efi-system-partition.html

Run cmd.exe

diskpart
list disk
sel disk 2
list partition
sel partition 1
SET ID=ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
delete partition override


Thursday, September 07, 2023

dot net app (on Linux) broke - "Forbidden" error - needs roll-forward

The issue turned out to be -

  1. some dot net commands like
    dotnet --version
    would not work due to mismatch between Ubuntu and Microsoft tracks for dotnet. Fixed with help from this blog post,

    # first remove everything
    sudo apt remove dotnet*
     sudo apt remove aspnetcore*
     sudo apt remove netstandard*
    sudo rm /etc/apt/sources.list.d/microsoft-prod.list
     sudo apt update
    sudo apt upgrade


    Then as in the original install link
    https://www.syncfusion.com/blogs/post/hosting-multiple-asp-net-core-apps-in-ubuntu-linux-server-using-apache.aspx

    wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
    sudo dpkg -i packages-microsoft-prod.deb
    sudo apt-get update; sudo apt-get install -y apt-transport-https && sudo apt-get update && sudo apt-get install -y aspnetcore-runtime-7.0

    dotnet --list-runtimes
    # pinned as per the troubleshooting blog post
    sudo nano /etc/apt/preferences
    Package: dotnet-* aspnetcore-* netstandard-*
    Pin: origin "packages.microsoft.com"
    Pin-Priority: 999

    #set /etc/dotnet/install_location to /usr/share/dotnet.

    #Then fix the missing DOTNET_ROOT environment variable and add (re-add?) that path #to the PATH environment variable in ~/.bashrc
    sudo apt update
    sudo apt install dotnet-sdk-7.0


  2. Next, the particular dot net app was targeting 7.0.0 - and that framework was not being found, since it had been updated to 7.0.400 or 7.0.10 (depending on whether it was the runtime or the sdk. Running from the commandline gave this error,

    dotnet ourdll.dll

    Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)
    .NET location: /usr/share/dotnet/

    No frameworks were found.

    and
    /usr/bin/dotnet --info

    Host:
      Version:      7.0.10
      Architecture: x64
      Commit:       a6dbb800a4
     
    Informed the developers,

    it is targeting dot net 7.0.0 and yesterday an update was rolled out to dot net, and the dot net is currently at 7.0.10

    You would need to target using roll-forward - so that updates to dot net do not break the app -
    Select which .NET version to use - .NET | Roll forward
     
    Instead of targeting 7.0.0 alone, you need to retarget the app using 7.0.* as mentioned in the above link.
    They seem to have fixed it by adding the "rollForward": "LatestMinor" in the runtimeconfig.json file.

  3. As suggested by the developers, disabled automatic updates, so that this issue won't happen for the next major upgrade of dotnet. Set up apticron to inform me of pending updates. Set up the "mail" command using ssmtp as in this earlier post

    apt - How to make my server email me when there are security updates? - Ask Ubuntu 

    sudo nano /etc/apt/apt.conf.d/20auto-upgrades
    # set both to 0
    sudo apt install apticron
    cd /etc/apticron
    more README
    sudo cp '/usr/lib/apticron/apticron.conf' . -v
    sudo nano apticron.conf
    # set it with
    NOTIFY_NO_UPDATES="1"
    # so that I'll know if it's working, by emailing every day
    .

Tuesday, September 05, 2023

limitations of github pages, and how to use it

Copy-pasting from an email I sent - the full documentation is, of course, at https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-github-pages-site

To log in to github, please go to github.com and sign in with
username
password 

Once your email is confirmed, you can change the password also, and also set 2 factor authentication with your phone number if you wish.

To add files, after logging in, you need to go to

https://github.com/theusername/thereponame

and choose the "Add file" on the top right.

Limitations of this free Github pages account -
1. individual files are limited to either 100 MB (or 20 MB with the web interface) or something like that.
2. total space used by all files combined must be less than 1 GB.
3. even if you delete files, they can still be seen by someone who knows where to look, ie via github.com/theusername/thereponame
(for permanent deletion, you will need my help.)

increasing wordpress max upload size by changing php.ini

Via 

https://docs.moodle.org/402/en/File_upload_size

and

https://www.w3docs.com/snippets/php/where-is-php-ini-on-ubuntu.html

Edited the php.ini file to increase file upload size for a Wordpress site hosted on Ubuntu 22.04.

sudo find / -name php.ini
/etc/php/8.1/apache2/php.ini
/etc/php/8.1/cli/php.ini 

sudo nano /etc/php/8.1/apache2/php.ini
sudo nano /etc/php/8.1/cli/php.ini 
and Ctrl-w post_max_size, upload_max_filesize to 50 M

max_execution_time to 600.

Saturday, September 02, 2023

how to remove azure cloud shell

Saw some cloud shell charges in Azure invoice, so tried to remove cloud shell via

https://blog.ibrahimambodji.com/2020/04/09/remove-or-re-configure-azure-cloud-shell/

dismount cloud drive via the powershell command

dismount-clouddrive  

size of all storage accounts on a Microsoft Azure subscription


For seeing all storage accounts in a subscription - 
Log in to Azure Portal, Home --> (search for)  Monitor -> (LHS) under Insights, Storage account

There are two tabs, overview and capacity. The capacity tab is what we are interested in.





Friday, September 01, 2023

modifying activity completion report on Moodle?

Copy-pasting from an email exchange:

Need help. In the activity completion report, we do not get cohort id /name. Could you please modify this system report to include cohort id?

Within my current limited understanding of moodle, I don't think this is possible. 

We can write some sort of ad-hoc report to have the contents of the activity completion report with cohort being one of the fields, but that would end up being
very complicated, because of the different numbers and names of activities over different courses.

A simpler option might be to filter inside google sheets or Excel based on users in the cohort you desire, after importing the csv of activities as one sheet, 
and the list of users + cohort in another sheet. An example is shown here.
(attached file removed)
 
In the Method1 sheet, the last field EZ has been filtered to include only Cohort_2_2023

There is one complication. Each user can appear in more than one cohort. I've used the LOOKUP function to map user to cohort,
=LOOKUP(B27,Cohortusers!D27:Cohortusers!D3199,Cohortusers!A27:Cohortusers!A3199)
but I think the LOOKUP function returns only the last cohort to which the user belongs. 
A better option might be, if you know which cohort you want, to use a function like
=IF(COUNTIF(OnlyCohortusers!$D$2:OnlyCohortusers!$D$87, B2)>0,"Yes","No")

This has been implemented in the Method2 sheet of the same spreadsheet file.

For some reason, both these methods seem to return 137 rows, even though the OnlyCohort sheet has only 85 rows of data.
I'm not sure why.

I have obtained the cohort users using a "custom report",
User id by cohort (link removed)

Hope this helps.
 

Blender - export with transparency

via How to render transparent PNG images in Blender? - YouTube

First, of course, we have to choose Choose PNG and RGBA as the export file format.

Then, we have to enable "Transparent" in "Film" section of Render properties.


 


import a 3ds file into blender

Apparently the process involves the 2.79 version, since the newer versions have the functionality removed. 

First use 2.79b version. Import the 3ds file.

Export as fbx.
Then import the fbx into the current version of blender.

For texture, follow the procedure at
 
Materials tab --> Base color --> Image texture --> choose the image texture file
 
For bump map, open Shader Editor, drag in the normals file for the relevant material, attach the color node of the normals file to the normal node of the material texture.
 

 
 

wordpress - multisite or multiple wp installs - pros and cons

The pros and cons of multisite wordpress installations are mentioned at

https://multilingualpress.org/docs/wordpress-multisite-pros-cons/

Apparently the pros are installing themes and plugins globally in a single dashboard, and making plugin install available only to Super Admin and not to Admins. And cons include some plugins not working in multisite installs, and users being logged in to all sites if logged in to one site.