Monday, May 24, 2021

Opening a pdf as a Google Document using google apps script

This link has the steps to make Google apps script do OCR on the PDF - 

const blob = DriveApp.getFileById(fileID).getBlob();
  const resource = {
    title: blob.getName(),
    mimeType: blob.getContentType()
  };
  const options = {
    ocr: true,
    ocrLanguage: "en"
  };
  // Convert the pdf to a Google Doc with ocr.
  const file = Drive.Files.insert(resource, blob, options);

But this generally gave pretty terrible results for me, and the formatting was completely lost.  

For my use case, found that the PDF was being created from HTML, so direct conversion from HTML to GDoc gave good results - 

assethtml += contentdata;
var ablob = Utilities.newBlob(assethtml, MimeType.HTML, "asset.html");
var AssetGDocId = Drive.Files.insert(
      { title: 'The name of the document', 
      mimeType: MimeType.GOOGLE_DOCS, parents: [{"id": destFolderID}] },
      ablob ).id;


Wednesday, May 19, 2021

appending Google docs and adding header and footer

In the current implementation, the adding of header and footer is done by making a copy of an existing template doc which has the required header and footer, and then appending the required contents inside it. 

Unfortunately, with the (slow) template method, Google Apps script seems to have difficulty with importing more than 2-3 chapters at a time, where each chapter consists of around 10-15 Google Docs which need to be concatenated. Each chapter takes 5 to 10 minutes, and we reach the limits of processing time + parsecsv's max char limit. 



Saturday, May 08, 2021

glitch.com for building web apps quickly

An interesting service to build Node.js web apps by "remixing" available code - 

https://blog.glitch.com/post/google-docs-markdown-glitch

https://help.glitch.com/kb/article/17-what-are-the-technical-restrictions-for-glitch-projects/ - 1000 free project hours per month, 200 MB disk space, 4000 requests per hour.

https://flaviocopes.com/glitch/ has some interesting use cases - teaching, timed webhook and so on.

Tuesday, May 04, 2021

calling a web app using curl in php

Just the syntax to use in php for using curl and making a GET or POST request to a google apps script - a slight modification from the answer given here, as curl_close was not needed for us - 

$url = 'https://script.google.com/macros/s/ID_GOES_HERE/exec?optionname=OptionValue';
$schName = 'Some test';
$url = $url . urlencode($schName);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl,CURLOPT_FOLLOWLOCATION, true);
$response = curl_exec($curl);
echo $response;

Monday, May 03, 2021

enabling desktop app notifications on linux

I had mistakenly clicked on "Don't show this message again" or something like that, and wanted to re-enable the notification shown when a VPN connection is made (or fails). The way to do it was mentioned at https://forums.linuxmint.com/viewtopic.php?t=89627

sudo gsettings set org.gnome.nm-applet disable-connected-notifications false sudo gsettings set org.gnome.nm-applet disable-disconnected-notifications false sudo gsettings set org.gnome.nm-applet disable-vpn-notifications false

file written to google drive by service account

When using a service account to create a new file and add it to Google drive, the file owner is the service account.

Can transfer ownership using Google Apps Script also.

https://stackoverflow.com/questions/46680352/how-can-i-change-the-owner-of-a-google-sheets-spreadsheet

https://stackoverflow.com/questions/65256980/google-drive-api-v3-php-client-transfer-file-ownership


restarting remote desktop via ssh or azure portal

Bs series burstable Azure VMs seem to have an endemic problem of the remote desktop service dying or refusing connections after the VM sees some heavy loads. Initially I had no idea why RDesktop was not connecting ... anyway, a couple of workarounds - 

  1. install ssh server and leave the ssh service running
    ssh into the machine when RDP has issues,
    ssh  adminuser@server.tld -p port
    powershell
    get-service termservice
    get-service termservice -dependentservices

    stop-service UmRdpService
    restart-service termservice
    start-service UmRdpService


  2. install Windows Admin Center on the VM and connect via the Azure portal, restarting the same services as above. We need to use the "Connect with Public IP address" method on the Azure portal. 




Sunday, May 02, 2021

limits for google apps scripts execution

A six-minute script execution time is mentioned at
https://developers.google.com/apps-script/guides/services/quotas (also many more limits)
but if we run the script from the Script Editor, the limit is 30 minutes. Probably since our Google Workspace is a non-profit one, so the "paid" limit applies. And a programmatic workaround (which I've not used till now.)

Saturday, May 01, 2021

handling duplicates in an sql query

There was a database in which we needed to join three tables, asset id -> subtheme id -> subtheme and the subtheme ids had duplicates as well as multiple subthemes mapped to an asset id. Getting a go-ahead from the content lead, the solution chosen was to just take a single subtheme, using select distinct - something like the first method at https://www.sisense.com/blog/4-ways-to-join-only-the-first-row-in-sql/  

left join (select distinct on (asset_id) * 
         from asset_subtheme_xref
     order by asset_id asc
) as asx on asx.asset_id = tma.asset_id
        left join subtheme_master lsm on lsm.subtheme_id = asx.subtheme_id

Edit: Later on, multiple subthemes were desired. Then, instead of using select distinct in this way, we would need some sort of subquery similar to the one used below for another field, using concat to add all the different subthemes together with CHR(10) - linefeed - between them - all enclosed in parentheses - 

(select string_agg(concat(btwo.name,',',stwo.name,',',sutwo.NAME,',',ctwo.name), CHR(10))
as "Asset tagged to Board Standard Chapter"
from asset_bssc_xref tabxr 
left join chapters ctwo on ctwo.chapter_id = tabxr.chapter_id
left join board_master btwo on btwo.board_id = ctwo.board_id 
left join standard_master stwo on stwo.standard_id = ctwo.standard_id
left join subject_master sutwo on sutwo.subject_id = ctwo.subject_id 
where 
tabxr.asset_id = tma.asset_id) as "Asset Tagged to"


installing ssh client and server on Windows Server 2016

https://hostadvice.com/how-to/how-to-install-an-openssh-server-client-on-a-windows-2016-server/

Or maybe needs this,

https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH

or other solutions listed at

https://docs.microsoft.com/en-us/answers/questions/79182/sshd-and-sshd-agent-service-not-appearing-after-in.html

or maybe the powershell method listed at

https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse

Friday, April 23, 2021

demo of displaying content from google drive using a service account

Following
https://www.labnol.org/code/20375-service-accounts-google-apps-script

creating a service account and delegating authority domain-wide via the method at
https://developers.google.com/admin-sdk/directory/v1/guides/delegation

The google apps script's Code.gs has the following, and will work even when the doc is not shared with anyone except theuser@ourdomain.tld:

var JSON = {
    "private_key": "-----BEGIN PRIVATE KEY-----\nMI -- snip -- pJKdnI=\n-----END PRIVATE KEY-----\n",
    "client_email": "what-name-we-give@proj-name.iam.gserviceaccount.com",
    "client_id": "1020123456872",
    "user_email": "theuser@ourdomain.tld"
};

function getOAuthService() {
    return OAuth2.createService("Service Account")
        .setTokenUrl('https://accounts.google.com/o/oauth2/token')
        .setPrivateKey(JSON.private_key)
        .setIssuer(JSON.client_email)
        .setSubject(JSON.user_email)
        .setPropertyStore(PropertiesService.getScriptProperties())
        .setParam('access_type', 'offline')
        .setScope('https://www.googleapis.com/auth/drive');
}


function getUserFiles() {
    var service = getOAuthService();
    service.reset();
    //Logger.log("Getting the Access Token:");
    var atoken = service.getAccessToken()
    //Logger.log(atoken);
    if (service.hasAccess()) {      
        var url = 'https://drive.google.com/open?id=1qM_DOC_ID_5QiIJ0Ls';
        var response = UrlFetchApp.fetch(url, {
            headers: {
                Authorization: 'Bearer ' + atoken
            }
        });
        return response.getContentText()        
    }
}

function reset() {
    var service = getOAuthService();
    service.reset();
}


function doGet(e) {    
  var htmlout = HtmlService.createHtmlOutput(getUserFiles());
  return htmlout
      .setTitle('Our Team')
      .setSandboxMode(HtmlService.SandboxMode.IFRAME);
}

Thursday, April 22, 2021

Google sign in on Moodle

The user experience for google sign-in on Moodle is shown at 
https://www.youtube.com/watch?v=1_HDZoir3eQ
and how to set up, for admins, is shown at 
https://www.youtube.com/watch?v=cwUWvTiGSAk
- accurate as of Nov 2020, as google's api and set up screens keeps changing.

Tuesday, April 20, 2021

No matching client found - error for android app

As mentioned on this page - 
https://stackoverflow.com/questions/34990479/no-matching-client-found-for-package-name-google-analytics-multiple-productf

the reason was that the package name in the google-services json and the local package name of the app had a discrepancy. 

monitoring ram usage over time on windows server

One of our servers running a .NET app was undergoing a stress test to check whether it could scale to the required number of users. RAM was the biggest question-mark. Looking for ways to monitor RAM usage, found this page which talks about creating a counter log in perfmon. And how to create a counter log is explained here

Basically - 
  1. Start - Run - perfmon.exe
  2. User defined folder -> New -> Data Collector Set and give it a name.
  3. Choose Create Manually, and Next.
  4. Create Data Logs -> Performance Counter and then click Next.
  5. Choose the desired object(s) to log
  6. (Every 5 seconds may be a good option for short collection runs)
  7. Choose location to save in.
  8. "Start this data collector set now" if desired.
  9. To stop data logging, right-click User Defined -> Data Collector Set -> our set and click Stop.
And later to view the data, choose the View Log Data button, Data Source as Log Files, and add the relevant log file.

And caveat when viewing and using Processor usage, the Scale factor has to be taken into account. 

Sunday, April 18, 2021

search for a string or a number in an entire database

With just sql queries, this would need some amount of scripting as mentioned on stackoverflow. But with visual database tools like DBeaver, it's just a simple operation of doing a full-text search, with the option of including numeric fields or not - "Search in numbers" and the option to search Large Objects or not - "Search in LOBs".

show an image from binary data using php

This SO link gives two techniques - using data URIs and using a helper function to fetch the image from some storage location. 

Edit: My initial implementation was using the simpler data URI method. Later, also implemented using the other method. 

Intially,

    // to prevent images from being dropped due to timeouts, we'll encode them inline
    // https://ads-developers.googleblog.com/2013/11/how-to-send-pdf-reports-with-adwords.html

    // to parse the img src, we'll use regex, since the html is of limited scope
    // https://stackoverflow.com/questions/14939296/extract-image-src-from-a-string/15013465
    // https://support.google.com/a/answer/1346938

    var m;
    imageurls = [];
    regexstring = '(http\\S*' + currentTicket +')'; // the \ is escaped, so it becomes doubled.
    //Logger.log(regexstring);
    //myregex = new RegExp(/(http\S*0d0a226a47229313863)/,"gi");    // the ticket is the string after S*
    myregex = new RegExp(regexstring, "gi");
    
    var imageindex=1;

    while ( m = myregex.exec( contentdata ) ) {
      imageurls.push( m[1] );
      //Logger.log(m[1])
      var imagemimetypeandenc = 'data:image/png;base64,'; // default
      if ( m[1].includes('.jpg?ticket') || m[1].includes('.jpeg?ticket') ) {
        imagemimetypeandenc = 'data:image/jpeg;base64,';
      }
      else if ( m[1].includes('.gif?ticket') || m[1].includes('.GIF?ticket') ) {
        imagemimetypeandenc = 'data:image/gif;base64,';
      }
      else if ( m[1].includes('.tif?ticket') || m[1].includes('.tiff?ticket') ) {
        imagemimetypeandenc = 'data:image/tiff;base64,';
      }

      Logger.log('%s of assetid %s',imageindex.toString(),data_array[i][0].toString());
      imageindex = imageindex + 1;
      var imageBlob = UrlFetchApp.fetch(m[1]).getBlob();
      var base64EncodedBytes = Utilities.base64Encode(imageBlob.getBytes());
      var imageencoded = imagemimetypeandenc + base64EncodedBytes;
      contentdata = contentdata.replace(m[1], imageencoded);

    }

and later, when images were available on Google Drive,

  var placeholder = 'data:image/png;base64,iVBORs_a_few_kb_of_chars_QAAAABJRU5ErkJggg==';
  // made with https://www.w3docs.com/tools/image-base64

.....
var m;
    imageurls = [];
    regexstring = 'img\\s*src\\s*=\\s*"(http\\S*)"'; // the \ is escaped, so it becomes doubled.
    // Only the http part is captured, within parenthesis
    // currently it matches only if the img src is within double quotes. "https://whatever"
    //Logger.log(regexstring);
    
    myregex = new RegExp(regexstring, "gi");
    var imageindex=1;

    while ( m = myregex.exec( contentdata ) ) {
      imageurls.push( m[1] );
      
      Logger.log('%s of assetid %s',imageindex.toString(),data_array[i][0].toString());
      imageindex = imageindex + 1;
      
      // here we use a helper if the url contains the alfresco url
      var response;
      if (m[1].includes('ticket=') ) {
        //use the helper function after extracting the filename
        Logger.log('Downloading %s using Alfresco helper', m[1])
        var fname = m[1].split('/')[9]; // from the url similar to 
        // https://www.ourdomain.tld/alfresco/d/direct/workspace/NameOfStore/f8b56b7c-long-id-a35c30be756a/filename-15092020100930PM?ticket=
        fname = fname.split('?')[0];
        // handle cases where fname does not have extension
        var urlFromHelper = UrlFetchApp.fetch(returnUrl+encodeURIComponent(fname));
        response = UrlFetchApp.fetch(urlFromHelper, { muteHttpExceptions: true });
      } 
      
      
      if (response.getResponseCode()==200) {
        var imageBlob = response.getBlob();
        var base64EncodedBytes = Utilities.base64Encode(imageBlob.getBytes());
        //var ctype = response.getHeaders().Content-Type
        var headermap = new Map(Object.entries(response.getHeaders()));
        var mimetypeofim = headermap.get('Content-Type');
        var imagemimetypeandenc = 'data:'+mimetypeofim+';base64,';

        var imageencoded = imagemimetypeandenc + base64EncodedBytes;
        contentdata = contentdata.replace(m[1], placeholder);
      }
      

And in cases where we did not want the images to be base64 encoded - for example in the case of large images, which would cause the function to run out of memory - the whole code-block above would be not needed, since the img src link in the original html would work OK.

Saturday, April 17, 2021

embedding a pdf in a web page

Several ways to embed a pdf in an html page - 
  1. Using the object or embed tag (deprecated)
  2. Using a tags with href links (not actually embedding, linking)
  3. Using iframe tags where the toolbar can be made hidden with src="/path/my.pdf#toolbar=0"
  4. Using Adobe's SDK - somewhat complicated initial setup
  5. If hosted on Google Drive, using an iframe with src="https://drive.google.com/file/d/FILE_ID/preview">

Friday, April 16, 2021

showing memory usage by process and user

Using ps on the linux terminal, we can check out memory usage - 
https://www.networkworld.com/article/3516319/showing-memory-usage-in-linux-by-process-and-user.html

"sort is being used with the -r (reverse), the -n (numeric) and the -k (key) options which are telling the command to sort the output in reverse numeric order based on the fourth column (memory usage) in the output from ps. If we first display the heading for the ps output, this is a little easier to see."

ps aux | head -1; ps aux | sort -rnk 4 | head -5

resubscribing to letsencrypt emails

According to this thread,
https://community.letsencrypt.org/t/accidentally-unsubscribed/14682/14
the way to resubscribe after accidentally unsubscribing would be to change the registration to email+1@mydomain.com with

certbot update_account --email yourname+1@example.com

Wednesday, April 14, 2021

azcopy with sas tokens and more

I struggled a bit with using azcopy to copy from one Azure storage container to another. The issue finally turned out to be that when a new SAS token was created, the default permissions were not sufficient for what I wanted to do - needed to set the expiry time and read / write permissions correctly. After doing that, the command was:

azcopy cp "https://ourstorage.blob.core.windows.net/ourname/*" "https://ourdestination.blob.core.windows.net/destname?sp=racw&st=-snip-&se=-snip-&spr=https&sv=-snip-&sr=c&sig=-snip-%3D" --recursive

51.3 %, 4919 Done, 0 Failed, 5647 Pending, 0 Skipped, 10566 Total, 2-sec Throughput (Mb/s): 3685.9743
 
- finished in around 5 min.

updating an app on Google's Android Play App store

Updating an already existing app with an already existing developer account - the process was fairly intuitive. Older tutorials point to https://market.android.com/publish/Home - that url now redirects to https://play.google.com/console

Basically we need to click on the relevant app, choose View Releases Overview - Release Dashboard - Create new Release.

To edit the play store listing - the text shown on the play store - we need to scroll all the way down on the left-hand side, Grow - Store presence - Main store listing.

For creating the release, we need to sign with the same keystore and signature used to sign the earlier version, etc. as in this post.

Monday, April 12, 2021

comparing Azure pricing in different locations

An interesting site - https://azureprice.net/ Makes it easy to find the region with lowest pricing for a particular type of VM. 

As the site says, pricing is also different in different currencies. 

Sunday, April 11, 2021

customizing and building the moodle app

After learning how to use an older node version, the moodle app could finally be customized and built - a follow-up to my failed trials here

The customization steps and the relevant modified files are in this location, with the changes being mentioned in the readme as follows:

1. Changes as per the moodle doc on compiling with AOT
Edit Oct 2022 - the link content seems to have changed, so here is the archived version.

2. Change to the build.gradle to force minSdkversion 22

ext.cdvMinSdkVersion = 22

to build with android studio. This can also be done in config.xml

3. Changing all ~ and ^ package dependencies in package.json (except cordova-android itself) to the exact package. Done by replacing

"~ with "

and

"^ with "

in package.json

Or else, all sorts of dependency issues while building the 2019 release in 2021. (The nvm use 11 may also suffice for solving the dependency issues.)

The build directory takes up more than 1 GB, lots of dependencies are downloaded. 

4. Customization - Changes as per the Configuration heading at this post,

config.xml

reduced SplashScreenDelay

and SplashShowOnlyFirstTime true

also, very important,

content src="https://sssvidyavahini.org" would make the app like a simple webview.

We don't want that, so leave the content src as it is, 

but change the siteurl in src/config.json

and onlyallowlistedsites true.

We also set android-minSdkVersion" value="22" in config.xml

google-services.json - changed the package name

and changed the version in src/config.json , ensured it is different, but same number of digits.

5. Changing logo and splash screen as per above url and also resources/android/icon-background.png and icon-foreground.png

and in src dir assets/img

Build steps

Set up environment variables as per

https://cordova.apache.org/docs/en/10.x/guide/platforms/android/


JDK tar.gz needed oracle login, created as my official email

Set JAVA_HOME

https://docs.oracle.com/cd/E19182-01/821-0917/inst_jdk_javahome_t/index.html


in .bashrc, added the following.

export JAVA_HOME=/home/mac/Downloads/jdk1.8.0_281
export PATH=$JAVA_HOME/bin:$PATH
export ANDROID_SDK_ROOT=/home/mac/Android/Sdk
export PATH=$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/tools/bin:$ANDROID_SDK_ROOT/platform-tools:$PATH

As mentioned in the cordova documentation, we can open a cordova project inside android studio for the final build - choose the import gradle project option, and choose the platforms/android directory.

But we need to edit www folder outside android studio, then copy over changes by doing cordova build - in our case, npx etc as below.

The build process is detailed in the following steps to build document:

# https://docs.moodle.org/dev/Setting_up_your_development_environment_for_Moodle_Mobile_2

nvm install node 11.15.0

# https://www.sitepoint.com/quick-tip-multiple-versions-node-nvm/

nvm use 11

# this is very important - if starting again in another terminal window, must do nvm use 11

# or else all sorts of hard to diagnose errors occur during the build.


sudo apt-get install libsecret-1-dev


npm install 

# cordova.plugins.diagnostic: Diagnostic plugin - ERROR: ENOENT: no such file or directory, open '/home/mac/StudioProjects/LMSappBuildTrial/config.xml'

# added 1829 packages from 1022 contributors and audited 1958 packages in 98.592s


npx cordova prepare 

# Current working directory is not a Cordova-based project.

# https://stackoverflow.com/questions/21276294/cordova-current-working-directory-is-not-a-cordova-based-project

#mkdir www

npm install cordova

# this is also important. Without this, the www directory is not populated for the final prod build.


npm i -g cordova-res

# This is also important - without this, the image resources won't get processed

# config.xml was missing, so copied over with git

# No platforms added to this project. Please use `cordova platform add <platform>`.

npx ionic cordova platform add android --verbose

#Source path does not exist: resources/android/icon/drawable-hdpi-smallicon.png

#Error: Source path does not exist: resources/android/icon/drawable-hdpi-smallicon.png

# editing gitignore file to add the resources

npx cordova prepare

# ignoring the warning about conflict


npx gulp


npm start

# This is an optional step to check in a browser and verify.

# waiting till transpile started etc. then Ctrl+C

# If we wait till the end - nearly an hour on a 4 GB system? it opens in the default browser.


# https://docs.moodle.org/dev/Setting_up_your_development_environment_for_Moodle_Mobile_2#Compiling_using_AOT

cp -v "changes made to moodleapp files/inside node_modules dir/@angular/platform-browser-dynamic/esm5/platform-browser-dynamic.js" "node_modules/@angular/platform-browser-dynamic/esm5"

cp -v "changes made to moodleapp files/inside node_modules dir/@ionic/app-scripts/dist/util/config.js" "node_modules/@ionic/app-scripts/dist/util/config.js"

# edited gitignore to not ignore this config.js, did git add -f.


npm run ionic:build -- --prod

# this takes a lot of RAM and a lot of time. 

# if possible, avoid swapping by closing all apps and clearning memory before doing this.

# REMEMBER to use nvm use 11 if doing this in a fresh terminal

#PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND 

# 3682 mac       20   0 3142252 2.215g  28948 R 131.5 59.6   6:34.48 node

#   build prod finished in 3128.04 s - this was on a 4GB machine

# on a 16 GB GCP instance, it took up around 1/3rd of memory - 5 GB+ - 

# and finished in just 5 or 6 minutes instead of 50 minutes.


# npx cordova run android

# Could not find an installed version of Gradle either in Android Studio,

#or on your system to install the gradle wrapper. Please include gradle 

#in your path, or install Android Studio

# So, I just imported the platforms/android directory using the Import Gradle project option in Android Studio 4.1.3, and built from there.


/dev/kvm permission denied fix for Android AVD unable to open in Android studio

I did not go through this, since my machine had only 4 GB RAM and was probably too RAM constrained to run the virtual device, but

https://16shuklarahul.medium.com/how-to-fix-kvm-permission-denied-error-on-ubuntu-18-04-16-04-14-04-f04a6e23c0cd

- install qemu-kvm and then give appropriate permission to the current user.

$ sudo apt install qemu-kvm

% add your user to the kvm group.

$ sudo adduser <username> kvm

% And then 

$ sudo chown <username> /dev/kvm

Saturday, April 10, 2021

uninstall apk before installing with different signature

While developing android apps, we find that sometimes the apks we build don't get installed - the package manager just says Not Installed. The reason is apparently that if the same app is currently installed with a different signature, it will not get overwritten. 

Uninstalling via long press on the home screen on my LG Q6 was not sufficient.

To uninstall cleanly, the way was as listed at this page:

Settings - Apps - Select the app to uninstall - Choose Force Stop
Then choose Storage - Clear Cache - Clear Data
Return to the app screen - choose Uninstall

After doing this, the apk will install. If it doesn't there may be something wrong with the signing etc. which will be the subject of another post of mine


Wednesday, April 07, 2021

signing release build apk files in android studio

The procedure to sign apk files - if you just click on Generate Signed Bundle / APK, the wizard prompts you to create a keystore (or use an existing one) and create the signed build. We have to save that keystore safely, since we will need it for signing any updates to the app on Google's Android Play store (app store). 

But that is not enough - the apk would not install. We've also got to set the signing configuration in the Project Structure, check both v1 and v2 signature versions, and also look for any of the issues which are listed at this page. Mainly, as in this link
Project Structure - Modules - Signing tab - add a configuration, and under Build types tab, release build, under signing config, choose the one which we have added. 

loading software on a few hundred tablets

There was some discussion about loading software on some Android devices which were to be shipped to schools. 

Initial thought was to create ids like
OurPrefix.TAB.2021.01@gmail.com
to log on to the play store for the tablet which has asset id OurPrefix-TAB-01 etc.

We could then print out the password and put it in the box for the teachers to change if necessary.

This is required, since this is not a factory install, and factory install process is very different from manual install :) For a manual install, we have to log on to the play store with a particular account, etc etc. 

If we are to not create such ids, installing and then logging out of the account used to install can work for our free apps, but with the drawback that the apps will not update. For updates, the users would have to uninstall and reinstall. 

The next idea was to install all these apps using pre-downloaded APK files, so that the internet connection would not be a bottleneck in the prep process which was planned to be done on a single day for several hundred devices - taking the help of a score or more of volunteers. This too had the drawback of the apps not updating automatically from the Play store. 

Finally the idea of links to the Play store was mooted. 

  • Connect via USB cable to the computer, Choose the "File transfer' USB usage preference, copy the tabletslinks.txt file to the Download directory on the tablet. 
  • Navigate to the txt file using Google Files on the tablet, click on it and choose to open with Chrome. 
  • Copy each line (each link), open a new tab in Chrome, paste in Chrome, hit Enter (while offline)
  • Click the three vertical dots on the right hand side of the Chrome address bar, choose "Add to Home Screen"
  • Write an appropriate short link title like Pdf for the adobe pdf reader link, Office for the office link, Teams/Meet/Zoom for the respective links.
  • Drag and drop the link to the home screen.
The whole process was timed at less than 5 minutes from the time the tablet was booted up. And this was the final solution chosen.


Saturday, April 03, 2021

Android studio Git checkout

For checking out at a specific commit - 
https://stackoverflow.com/questions/36517118/how-do-i-checkout-an-old-git-commit-in-android-studio

right-click relevant commit on the Git tab's history, choose 'Checkout revision <hash>'

keeping Windows and Linux dual-boot times correct

This 2011 post has the Kubuntu 10 way, and for current machines running systemd, the way to do it is, if choosing to make Linux use the hardware clock as local time, 
timedatectl set-local-rtc 1

Thursday, April 01, 2021

fixing Filezilla error about LC_CTYPE environment variable

As described on this page, the solution was

sudo nano /usr/share/applications/filezilla.desktop

Find  the line
Exec=filezilla
and replace it with
Exec=env LC_ALL=en_US.UTF-8 filezilla


Tuesday, March 30, 2021

how to identify if a DLL is a debug or release build

Needed to check if one of our servers was gobbling up RAM due to a debug DLL, so checked and found this SO conversation about identifying debug / release builds DLLs. One of the replies mentions '.NET Assembly Information' by Rotem Bloom - https://github.com/jozefizso/AssemblyInformation and a more recent fork at https://github.com/tebjan/AssemblyInformation

Also a quick and dirty solution, "One way that could work for most people is to simply open the DLL/EXE file with Notepad, and look for a path, for example search for "C:\" and you might find a path such as "C:\Source\myapp\obj\x64\Release\myapp.pdb", the "Release" shows that the build was done with Release configuration."

Monday, March 29, 2021

repairing boot after installing windows

For Ubuntu and Ubuntu-based distros like Linux Mint, running the graphical boot-repair tool from a live CD / USB is a good option. In my case, I had to choose to boot with advanced startup and restart in Windows 10, or else the BIOS screen was not visible for me to boot from USB.

creating Windows installer USB drive from ISO - on Linux with woeusb

The usual route using unetbootin would need the USB drive to be partitioned as FAT32 (using gparted, the Disks utility on Linux Mint doesn't do it - and have to mount with Disks utility after gparted does the reformatting). But then the Windows 10 installation ISO contains a file installer.wim which is 5 GB, so it can't be written to the FAT32 volume. So we have to use ntfs - 
https://askubuntu.com/questions/162174/how-do-i-use-unetbootin-to-make-a-bootable-windows-usb-installer
or use woeusb.

(Detailed steps:

woeusb ppa gives error on install,
The following packages have unmet dependencies:
 woeusb : Depends: libwxgtk3.0-0v5 (>= 3.0.4+dfsg) but it is not installable
E: Unable to correct problems, you have held broken packages.

woeusb 
needs https://wimlib.net/

sudo apt install build-essential
./configure

gave
No package 'libxml-2.0' found

sudo apt install libxml2-dev

Cannot find libntfs-3g

sudo apt install ntfs-3g-dev

error: Cannot find libfuse

sudo apt install libfuse-dev

sudo ./woeusb-5.1.0.bash --device /home/path/Win10_20H2_v2_EnglishInternational_x64.iso /dev/sdb

wimlib-imagex: error while loading shared libraries: libwim.so.15: cannot open shared object file: No such file or directory

Solution was to run ldconfig, as found in
https://wimlib.net/forums/viewtopic.php?t=240

sudo ldconfig -v

)


Visual Studio publish and deploy ASP .NET Core app to IIS

This link has the basics on how to do the setup, and also some do's and don'ts for ASP .NET apps on IIS - https://docs.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-3.0&tabs=visual-studio

Sunday, March 28, 2021

run explorer as Administrator

On Windows server, there is no "Run As Administrator" directly available for File Explorer. So, we can go to C:\Windows with File Explorer, and then right-click on explorer.exe and Run As Administrator. 

sql query to replace a substring

We needed to replace some Windows paths in a MySQL database. Following 
https://www.mysqltutorial.org/mysql-string-replace-function.aspx/

update tablename set tablename.MediaSource = REPLACE(tablename.MediaSource,
        m4a,
        mp3)
WHERE
    tablename.MediaSource like '%Dashboard%1%1%2%1%2.m4a';

and if we wanted to be more specific, the '\' in the Windows paths need to be escaped as four backslashes - following https://stackoverflow.com/questions/14926386/how-to-search-for-slash-in-mysql-and-why-escaping-not-required-for-wher - 

select * from tablename where tablename.MediaSource like '%Dashboard%1%1%2\\\\1\\\\2.m4a';

And the syntax for a count statement was like

select count(*) from (select * from tablename where tablename.MediaSource like '%Dashboard%m4a') myqueryname;

finding mysql data size

According to 

https://support.microfocus.com/kb/doc.php?id=7019203#

we can find the data directory from my.ini which would be in server directory in program files - the datadir line in my.ini

But on our install, it was in c:\programdata\mysql

and data was also there.

Notes on locally mounting Windows NTFS drive on dual boot Linux

In order to make the partition visible as a separate entry on the side bar, move mount point to /media/windows1 or something like that - 
https://forums.linuxmint.com/viewtopic.php?t=300597

https://www.google.com/search?q=umask+needed+to+make+vfat+drive+writable+by+all+users+on+linux

umask=0 for writable by all.

visual studio offline installer

Wanted a way to create an offline Visual Studio installer - found it is possible, but have to run Windows to go through the process at this link.

Adding google search to Firefox on Linux Mint

Linux Mint has removed Google from the search engines available by default, and we have to follow a "Microsoft-esque" convoluted procedure to make Google search available from the address bar or the search box - following https://www.techbrown.com/add-google-default-search-engine-firefox-linux-mint/

  • Go to https://linuxmint.com/searchengines.php
  • Scroll down to the bottom of the page and click on the Google logo
  • The page which loads up then has instructions to right-click on the address bar and add Google search from the context menu. 
  • Then we can choose to make Google the default search from the search box from the "Change search settings" gear icon under the search box also. 

Restoring Linux after Windows install

Following the instructions from https://forums.linuxmint.com/viewtopic.php?t=92409

"Boot from a LIVE DVD (in my case Linux Mint booting from USB key drive)

If you don't know the location of the linux partition, you can determine the partition that Mint is installed on by:
Open terminal and run
sudo gparted
Look for the large EXT4 partition and make a note of what it says on the far left such as sda6
Close gparted

In terminal enter:
sudo mount /dev/sda6 /mnt (replace sda6 with whatever is appropriate for your system)
sudo grub-install --root-directory=/mnt /dev/sda (note there is a space between mnt and /dev and do not put a number after sda)

Restart the computer and you should have your grub menu available again."

But in order to boot from a different medium when Windows 10 is installed, we may need to go through some hoops, as mentioned in this post.

Friday, March 26, 2021

customizing Moodle theme per course

Replying to a request of adding blocks to some courses on one of our Moodle servers - 

https://moodle.org/mod/forum/discuss.php?d=256667

Site administration>Appearance>Themes>Theme settings - can set it to allow course themes. 

Then I went to an example test course I created,

  • Turned editing on,
  • clicked on the gear icon,
  • clicked on Edit settings,
  • Scrolled down to Appearance, opened up the Appearance section,
  • and in the appearance section, chose
  • Force Theme : Boost.
  • After doing that, I'm able to add blocks as per this video,
    https://www.youtube.com/watch?v=uByp1qqcWt8

But please note, not all types of blocks are supported on mobile - please see the list of supported blocks below.

https://docs.moodle.org/310/en/Moodle_App_Block_support

In this way, you can set your own look and feel for only some courses as per the method above, without disturbing the look and feel of the rest of the site.

finding and listing files without extensions in Linux

This post - 
https://askubuntu.com/questions/337964/list-all-files-that-do-not-have-extensions
uses ls to list all files without extensions.

Then there is the technique using find,
https://unix.stackexchange.com/questions/47151/how-do-i-list-every-file-in-a-directory-except-those-with-specified-extensions
to list those files other than those with specific extensions, which I used like

find nameofdirectory ! '(' -name '*.mp3' -o -name '*.docx' -o -name '*.zip' ')'

find nameofdirectory ! '(' -name '*.*'  ')'
lists directories also.

find nameofdirectory -type f ! '(' -name '*.*' ')' | wc -l 
for counting the total.

Thursday, March 25, 2021

file transfer using remote desktop - RDP

Transferring a single zip file is much much faster than transferring a large number of small files. Another issue with transferring a large number of files this way is that some extra files are created - "which indicate that the file originated from the network". Zone Identifier files as explained in this post - https://apple.stackexchange.com/questions/378438/what-are-these-extra-zone-identifier-files-created-during-windows-remote-deskto

To enable file transfer from the Remmina RDP client, check the shared folder and enable a folder to share, in the Basic tab, and Sound Local in Advanced tab



Macbook not charging

Resetting the SMC - System Management Controller - is supposed to cure many issues related to battery etc. In my case it did not help - maybe because the Applecare person has removed the bulged battery?

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

"with non-removable battery" - 

Hold down Shift + Ctrl + Opt , then hold down power button also, for 10 sec.

Release all, then press power button to turn on.

creating webview android apps, and angular to apk

Some links, tutorials etc for easily creating webview-based Android apps - 

Edit: 25 Dec 2021 - For another version of webview with upload support, 
https://github.com/delight-im/Android-AdvancedWebView

Wednesday, March 24, 2021

changing the name of an Android app

1. From https://stackoverflow.com/questions/5443304/how-to-change-an-android-apps-name

By changing the android:label field in your application node in AndroidManifest.xml - Please make sure that you change label:

android:label="@string/title_activity_splash_screen"

in your Splash Screen activity in your strings.xml file. It can be found in Res -> Values -> strings.xml

2. change the package name - from

https://stackoverflow.com/questions/16804093/rename-package-in-android-studio

  • In your Project pane, click on the little gear icon
  • Uncheck the Compact Empty Middle Packages option
  • Your package directory will now be broken up into individual directories
  • Individually select each directory you want to rename, and:
  • Right-click it, Select Refactor, Click on Rename
  • In the pop-up dialog, click on Rename Package instead of Rename Directory
  • Enter the new name and hit Refactor
  • Click Do Refactor in the bottom
  • Allow a minute to let Android Studio update all changes
  • Note: When renaming com in Android Studio, it might give a warning. In such case, select Rename All

To change the build package name, change
File > Project Structure > Modules > Default config > Application ID

A commit with the name change is here.

Tuesday, March 23, 2021

ASP .NET memory usage

An ASP .NET web app under development was using a lot of memory. Googling, found this resource from Microsoft to check - https://docs.microsoft.com/en-us/troubleshoot/aspnet/high-memory-level

Monday, March 22, 2021

send a post request with curl

https://github.com/thephpleague/oauth2-server/tree/master/examples

https://gist.github.com/subfuzion/08c5d85437d5d4f00e58

Since the default is application/x-www-form-urlencoded, the shortest would be
curl -d "param1=value1&param2=value2" -X POST http://localhost:3000/data

or with a data file,
curl -d "@data.txt" -X POST http://localhost:3000/data

Saturday, March 20, 2021

some post install changes needed for moodle

I had made a test moodle server by copying over the database, moodledata and /var/www/html/moodleinstalldirectory to a different server. Additionally, the following changes needed to be made.

  • Had to set up the cron job. The instructions given at MoodleDocs were to create it as the www-data user, crontab -u www-data -e 

    First ran it on the command-line to test that it works, running it as the www-data user with
    sudo -u www-data /usr/bin/php   /var/www/sssvv/admin/cli/cron.php
    - that took 2 minutes to run the first time, but later runs finished in a second or so.

    But on this Ubuntu 20.04 machine, a cron set for www-data did not work - probably as a security feature - though it did have a file in /var/spool/cron/crontabs as a comment on this page mentions. So, made a cron job as root, but running as www-data as per this post.
    * * * * * su www-data -s /bin/bash -c "/usr/bin/php /var/www/sssvv/admin/cli/cron.php"

  • Had to increase the php file upload limit
    sudo nano /etc/php/7.4/apache2/php.ini
    ( Ctrl+w to find and change post_max_size
    Ctrl+w to find and change upload_max_filesize
    Ctrl+w to find and change max_execution_time  - set to 600 for now.)
    sudo apachectl restart

  • Make the disk mount permanent by editing /etc/fstab - had to find the UUID of the partition using
    lsblk -f
    sudo blkid

    and then in /etc/fstab, added the line at the end,
    UUID=<uuid found using blkid>   /datadrive/mount/path   ext4   defaults,nofail   1   2
    Doing a umount and then a mount -a would mount it from fstab, so that we can correct errors if any. 

Linux Mint Workspace size

In order to disable extra workspaces on Linux Mint,
https://forums.linuxmint.com/viewtopic.php?t=280563

Ctrl+Alt+Up Arrow to enter the workspaces mode, select each unwanted workspace and choose to close.

Then my recurrent issue on Linux Mint installs on a Macbook - the workspace size seems to be much bigger than the screen size. Menu - Preferences - Display - found that two screens were enabled - disabled one to solve the issue.




delete a service on Windows server

One of our servers had an issue with RAM being used up. Found that it was due to a second instance of Mysqld being created as a service as seen in the screenshot. 



The two instances of Mysql were conflicting with each other, and causing mysqld to continuously use up RAM and CPU. I deleted the 2nd instance of mysqld, following this procedure.

  • Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services key with regedit
  • Select the key of the service you want to delete and choose Edit menu - Delete

Thursday, March 18, 2021

Moodle layout - removing the footer

This page has a discussion about hiding the footer in Moodle where Boost theme is used - 
https://moodle.org/mod/forum/discuss.php?d=349625

The idea of hiding a section with something like
footer#page-footer {display: none;}
in the custom scss box is useful. 

In the Moove theme, there is the option to not display the footer, as noted elsewhere in the thread. 

Wednesday, March 17, 2021

removing android app splash screen

Quite an involved process to remove the splash screen, and many places where things can go wrong - 
https://stackoverflow.com/questions/48239602/how-to-remove-splash-activity-from-an-existing-project/482396

Probably just easier to customize the splash screen with our graphics, and reduce its time interval. For example,
val SPLASH_TIME_OUT = 5000
in  PYF-SmartWebView-3.5

Tuesday, March 16, 2021

install parse failed no certificates error for Android apk

It turns out that this is some sort of catch-all error, and various things which can cause this
Installation error: INSTALL_PARSE_FAILED_NO_CERTIFICATES
for Android apk files are discussed at
https://stackoverflow.com/questions/2914105/what-is-install-parse-failed-no-certificates-error

My issue turned out to be an incorrect signing configuration as in the top answer. 

Saturday, March 13, 2021

warning in firefox for mixed content

Copy-pasting from a long explanation I had sent to someone:

The reason why Firefox shows the warnings and Chrome doesn't is because Chrome automatically checks for https links for mixed content, and automatically serves the https link instead of the http link in case it works.

You can find out which particular links are serving the mixed content (http links on a https page) by choosing inspect element when you right-click on the page, and seeing the console output.

Looks like Firefox will display the warning even if the http link is redirected to an https link - 

https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content

"To fix this type of error, all requests to HTTP content should be removed and replaced with content served over HTTPS. Some common examples of mixed content include JavaScript files, stylesheets, images, videos, and other media.

Note: The console will display a message indicating if mixed-display content is being successfully upgraded from HTTP to HTTPS  (instead of a warning about "Loading mixed (insecure) display content")."

So even with cloudflare proxying set to strict https, Firefox would show this warning (as of March 2021).

Then, if you want this to be fixed, ask whoever has access to the web server to change all http requests to https - 

https://themify.me/blog/mass-replace-urls-https-wordpress-database


Friday, March 12, 2021

Tuesday, March 09, 2021

sending emails as a particular Google Workspace user from Moodle

My reply to a query about a Moodle instance sending emails with a professor's email id instead of a generic address, and how to change it - 

1. Please try logging on to the-desired-email@ourdomain.tld on your browser, see if there is some issue with the username and password.

2. As you know, on moodle, you have to set up the outgoing email configuration with that username and pw at
Site administration > Server > Email > Outgoing mail configuration.

3. The sending of emails has to be authenticated and set up

4. Why the professor's account works and not the-desired-email account - probably because the professor's account has SMTP enabled from earlier. 

You could please do the setup for (3.) using the recommended option, using smtp-relay.gmail.com 

Monday, March 08, 2021

ssh keep alive

ssh kept timing out on one of our servers - when the terminal window inactive for 10 minutes or something like that. Came across this article to fix it - did it using the client side, adding the line: ServerAliveInterval 60
to the file /etc/ssh/ssh_config


Sunday, March 07, 2021

failed attempts to build the moodle app apk

 Documenting my failed attempts to build the Moodle Android app.

Edit: The successful attempt is documented in this post.

For customizing
We may need to follow
http://blog.vinodsingh.com/2020/05/how-to-customize-moodle-mobile-app.html

But even the basic moodleapp fails to build - as below.
Android Studio version etc as of March 4th to 7th 2021.


Steps for build
---------------

Following https://docs.moodle.org/dev/Setting_up_your_development_environment_for_Moodle_Mobile_2
except for some exceptions, and ignoring errors.

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash




nvm install node
# don't do nvm use 11 - current version is 15, that works. 11 has bugs.

sudo apt-get install libsecret-1-dev

git clone https://github.com/moodlehq/moodleapp.git moodleapp
cd moodleapp
git checkout integration

# dont't run npm run setup - run each individually, since errors can be ignored.
npm install 
#(
#npm ERR! npm ERR! network aborted
#npm ERR! npm ERR! network This is a problem related to network connectivity.
#Re-ran ...
#)
#Took ~ 10 minutes on lenovoPC, 2 minutes on GCP.

npx cordova prepare 
# ignore the errors.
#Failed to restore plugin "phonegap-plugin-push". You might need to try adding it again. 
# Error: CordovaError: Failed #to fetch plugin 
# git+https://github.com/moodlemobile/phonegap-plugin-push.git#moodle-v3 via registry.
#Probably this is either a connection problem, or plugin spec is incorrect.
#Check your connection and plugin name/version/URL.
# (Ran again, due to internet breakage)


npx gulp

npm start
# Did not show any errors, showed waiting for connection

npx ionic cordova platform remove android
npx ionic cordova platform remove ios
npx ionic cordova platform add android
# did not do npx ionic cordova platform add ios
# ignored the error, 
# Failed to fetch platform cordova-android@^9.0.0
#Probably this is either a connection problem, or platform spec is incorrect.
# in verbose mode, 
#npm ERR! errno ENOTFOUND
#npm ERR! network request to https://registry.npmjs.org/coffeescript failed, 
#reason: getaddrinfo ENOTFOUND #registry.npmjs.org
#npm ERR! network This is a problem related to network connectivity.
# Ran again, 
# npx ionic cordova platform add android --verbose
# Platform android already exists.
# did remove and add again, then looks like it is not a connection problem, but platform spec is incorrect

# https://stackoverflow.com/questions/55965450/failed-to-fetch-platform-cordova-android8-0-0
# ignoring,

npm run dev:android
# gave error, but wrote
#cordova-android-support-gradle-release: Android platform: V7+
#cordova-android-support-gradle-release: Wrote custom version '27.1.0' to 
#/home/user/moodleapp/platforms/android/app/#build.gradle
#cordova-android-support-gradle-release: Wrote custom version '27.1.0' to 
#/home/user/moodleapp/platforms/android/
#cordova-android-support-gradle-release/moodlemobile-cordova-android-support-gradle-release.gradle
#[ERROR] An error occurred while running subprocess cordova.

# on GCP, error was No valid Android SDK root found.
# did again on a fresh terminal so that .bashrc is processed again,
# then it worked.

sudo apt-get install gradle
sudo apt-get install libgradle-android-plugin-java

Edits as per
https://docs.moodle.org/dev/Setting_up_your_development_environment_for_Moodle_Mobile_2#Compiling_using_AOT

npm run ionic:build -- --prod
# LenovoPC bogged down since it uses too much memory and goes into swap, trying on cloud dev machine.
# GCP finished in 6 minutes - used nearly all of 16 GB RAM. 200% cpu of 4 core machine.
npx cordova run android

# on GCP, gave response as below
# npx cordova run android
Conflict found, edit-config changes from config.xml will overwrite plugin.xml changes
9.0.0
cordova-android-support-gradle-release: Android platform: V7+
cordova-android-support-gradle-release: Wrote custom version '27.1.0' to 
/home/user/moodleapp/platforms/android/app/build.gradle
#cordova-android-support-gradle-release: 
#Wrote custom version '27.1.0' to 
#/home/user/moodleapp/platforms/android/cordova-android-support-gradle-release/moodlemobile-cordova-android-support-gradle-release.gradle
Cannot find module 'xcode'
Require stack:
- /home/user/moodleapp/plugins/cordova-plugin-add-swift-support/src/add-swift-support.js
- /home/user/moodleapp/node_modules/cordova-lib/src/hooks/HooksRunner.js
- /home/user/moodleapp/node_modules/cordova-lib/src/plugman/install.js
- /home/user/moodleapp/node_modules/cordova-lib/src/plugman/plugman.js
- /home/user/moodleapp/node_modules/cordova-lib/cordova-lib.js
- /home/user/moodleapp/node_modules/cordova/src/help.js
- /home/user/moodleapp/node_modules/cordova/src/cli.js
- /home/user/moodleapp/node_modules/cordova/bin/cordova

###########

# so tried importing into android studio
# https://cordova.apache.org/docs/en/10.x/guide/platforms/android/index.html#debugging
# 

#android studio gave error as follows:
# ~/androidstudioerr.txt
#Manifest merger failed : uses-sdk:minSdkVersion 19 cannot be smaller than version 22 declared in library [:CordovaLib] 
#/home/user/moodleapp/platforms/android/CordovaLib/build/intermediates/library_manifest/debug/AndroidManifest.xml 
#as the library might be using APIs not available in 19
#	Suggestion: use a compatible library with a minSdk of at most 19,
#		or increase this project's minSdk version to at least 22,
#		or use tools:overrideLibrary="org.apache.cordova" to force usage (may lead to runtime failures
#
# https://github.com/apache/cordova-android/issues/1070
# so edited config.xml with the info as given in the above, but that gave unbound prefix error.
# 
# Then, tried changing minSdkVersion=22 (from 19) on line 212 of config.xml
# still
# so, https://www.learningsomethingnew.com/how-and-why-to-change-your-android-cordova-apps-min-sdk-version
# but cordova platform rm android
# cordova: command not found.
# so tried
npx ionic cordova platform remove android
npx ionic cordova platform add android
# but the same error inside android studio.

Edit: The successful attempt is documented in this post.

Thursday, March 04, 2021

German letters without diacritics

Sometimes we have to post descriptions on our schedule page of German programs, which may contain diacritics. But our schedule software currently doesn't support unicode, so I've to convert those to characters without diacritics. This page has a handy conversion guide - mostly adding e for umlauts.



Tuesday, March 02, 2021

REISUB - for restarting linux machines which are unresponsive

From http://blog.kember.net/articles/reisub-the-gentle-linux-restart/

https://en.wikipedia.org/wiki/Magic_SysRq_key
says that on linux mint, it is Ctrl Alt PrtScr, and then - slowly - 

Alt + REISUO to shut down, REISUB to reboot.

  • Switch from RAW to XLATE
  • Send Sigterm
  • Send Sigkill
  • Sync all mounted filesystems
  • remount in read-only
  • Shutdown.

Running Linux Mint 20 on a Lenovo B460 laptop, on hitting Ctrl Alt F2 and seeing the 2nd terminal, 
R
E
I
show "This SysReq is disabled."

has details on the bitmask etc. 

cat /proc/sys/kernel/sysrq

"0 - disable every SysRq function.
1 - enable every SysRq function.
2 - enable control of console logging level
4 - enable control of keyboard (SAK, unraw)
8 - enable debugging dumps of processes etc.
16 - enable sync command
32 - enable remount read-only
64 - enable signalling of processes (term, kill, oom-kill)
128 - allow reboot/poweroff
256 - allow nicing of all RT tasks
438 = 2 + 4 + 16 + 32 + 128 + 256, so only the functions associated with those numbers are allowed. Read all about it in the documentation."

deploy from github to server with php

https://docs.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account

https://medium.com/riow/deploy-to-production-server-with-git-using-php-ab69b13f78ad

But then didn't use because of this,

https://medium.com/@skoskie/oh-no-c1068ed30c6b