Mostly work related stuff which I would've entered into my "Log book". Instead of hosting it on an intranet site, outsourcing the hosting to blogger!
Tuesday, March 30, 2021
how to identify if a DLL is a debug or release build
Monday, March 29, 2021
repairing boot after installing windows
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
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
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
- https://www.tutorialspoint.com/how-to-create-a-webview-in-android-app
- https://developer.chrome.com/docs/multidevice/webview/gettingstarted/ - the official doc
- https://developer.android.com/codelabs/basic-android-kotlin-training-change-app-icon#0
- https://developer.android.com/guide/webapps/webview.html#kotlin - Java and Kotlin code
- https://github.com/mgks/Kotlin-SmartWebView - used this to create a demo app (but doesn't have microphone 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
Tuesday, March 23, 2021
ASP .NET memory usage
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¶m2=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
- 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
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
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
SCORM creation from Microsoft Word documents and other tools
Some discussion about SCORM - sharable content object reference model - packages, importing from Word etc -
https://moodle.org/mod/forum/discuss.php?d=57059
Tuesday, March 09, 2021
sending emails as a particular Google Workspace user from Moodle
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.
deploy from github to server with php
https://medium.com/riow/deploy-to-production-server-with-git-using-php-ab69b13f78ad
But then didn't use because of this,