Tuesday, November 30, 2021

download a file using powershell

One of the first things we try to do on a fresh Windows server install would be to download and install Chrome or Firefox, due to the extreme tiresomeness of "locked down Internet Explorer" which doesn't allow any downloads by default. A quick way to do that is via powershell, courtesy this page

powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://example.com/file.zip', 'c:\somefile.zip') }"

Wednesday, November 24, 2021

finding files modified in the last 10 days using Linux find -mtime

I needed to find all files modified in the last 10 days in a directory using the Linux bash shell. One of the ways listed was using find -mtime,

find /var/the/relevant/dir -mtime -10

Monday, November 22, 2021

AJAX code snippet using Google Apps Script as backend

A drop-down list called Chapter gets updated by the following code - 

window.addEventListener('load', getChapterData); document.getElementById("board").addEventListener('change', updateChpDropdown); document.getElementById("standard").addEventListener('change', updateChpDropdown); document.getElementById("subject").addEventListener('change', updateChpDropdown); function updateChpDropdown() { if (document.getElementById("dataready").innerHTML == "Yes") { // clear the dropdown document.getElementById("chapter").innerHTML = '<option value="Choose">Chapter</option>'; var ddl = document.getElementById("chapter"); var chosenboard = document.getElementById("board").value; var chosensubject = document.getElementById("subject").value; var chosenstandard = document.getElementById("standard").value; for (var j=0; j < chapObj.length; j++ ) { if (chapObj[j]["boardname"]==chosenboard && chapObj[j]["subjectname"]==chosensubject && chapObj[j]["standardname"]==chosenstandard) { var option = document.createElement("OPTION"); option.innerHTML = chapObj[j]["chaptername"] ; option.value = chapObj[j]["chaptername"] ; ddl.appendChild(option); } } } } function getChapterData() { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { chapObj = JSON.parse(this.responseText); document.getElementById("dataready").innerHTML = "Yes"; } }; xmlhttp.open("GET", "https://script.google.com/macros/s/ID_OF_GAS_SCRIPTyL/exec",true); xmlhttp.send(); } </script>

Saturday, November 20, 2021

find a deleted file in a git repository

https://stackoverflow.com/questions/7203515/how-to-find-a-deleted-file-in-the-project-commit-history

git log --all --full-history -- "**/thefile.*"

This outputs a list of commits which reference the deleted file.

commit d1c --snip hash -- 51ae
Author: Name <email>
Date:   Sat Mar 6 13:05:11 2021 +0000

    validate password

commit 161--snip hash --1cf04
Author: Name <email>
Date:   Wed Mar 3 03:22:55 2021 +0000

    Changes for postgresql DB

and so on. 


Tuesday, November 16, 2021

recording Google Meet sessions

Google Meet offered recording to drive, and later restricted the recording to these editions of Google Workspace. So, I get lots of queries on how those without those editions can record. 

One option was to stream the Google Meet on youtube live via services like streamyard. The youtube live stream is automatically recorded, and there is no hassle of saving locally and then uploading. The streamyard free plan has a limit of 20 hours a month.

If you wish to record more than that, it may be advisable to record locally either using software or a hardware screen-grabber.

One of the ways to do that would be using the free software called OBS - https://obsproject.com/

Record google meet call with OBS, https://www.youtube.com/watch?v=2ipPdxOZ27U

Some changes in settings from the above video in my notes on recording with Linux Mint on a 2010 model Macbook Pro - 30 fps was fine.

Had to "Lock X server when capturing" in the Window capture (Xcomposite) settings for the Meet video to be not black. Else, after clicking join, video becomes black. 




Around 60% cpu for 720p output rescaled from screen resolution.

Saturday, November 13, 2021

Moodle MySQL collation warning

While upgrading Moodle on one of our sites, There was a warning, with a link to https://docs.moodle.org/311/en/MySQL_full_unicode_support

The admin of the site reported, 

Received an error message, "Error writing to database" on trying to add an emoji. 

Though emojis were not so important, Indian language support was required.

On checking the collations, found that the db used
Default Charset = utf8 and 
Default Collation = utf8_general_ci
just like another test site of ours, and that copy-pasting Indian language text was working - 

நமது தளத்தில் தமிழைச் சோதிக்கவே இந்த உரை.
यह पाठ हमारी साइट में हिंदी का परीक्षण करने के लिए है।
ഈ വാചകം ഞങ്ങളുടെ സൈറ്റിൽ മലയാളം പരീക്ഷിക്കുന്നതിനുള്ളതാണ്.
ಈ ಪಠ್ಯವು ನಮ್ಮ ಸೈಟ್‌ನಲ್ಲಿ ಕನ್ನಡವನ್ನು ಪರೀಕ್ಷಿಸಲು.
ఈ వచనం మన సైట్‌లో తెలుగును పరీక్షించడానికి.

(Made with translate.google.com )

So I did not change the collation to utf8mb4_unicode_ci as suggested in the Moodle documentation in the link at the beginning of this post, since this is a potentially dangerous operation, and can take a long time and can break things, so I would need to take precautions like making a backup, a rollback plan and so on. 

Monday, November 08, 2021

postgresql read-only user

There seem to be different ways of creating a read-only user in postgresql, depending on the version, and depending on whether you want the user to have access to future tables and so on. 

And when creating a user like that, we have to connect to the database first, using
\connect dbname
to prevent errors

Monday, November 01, 2021

adding the UserWay accessibility widget to Moodle

The way to add the accessibility widget for all users, as against only one user, seems to be :
https://docs.moodle.org/311/en/Header_and_footer

I added to the HEAD section at
https://our.server.org/admin/settings.php?section=additionalhtml

and now on the widget appears fine.

Need to check it out and see if it gives something better than the default "accessibility settings" at the bottom left corner built in to Moove theme on Moodle.