Table of Contents
My Mini-Blog
MY1 C Compiler
Guess what I have been doing for the last month? I call it my1cc (duh!)… and I have published my initial work at codeberg.org. Obviously it is wayyyyy from being usable, but the parser seems to work… somewhat. In the end, I was hoping to develop a usable C compiler for 8051/8085 platforms, so that I can use it in my microcontroller/microprocessor classes. I do have to pause a bit… hopefully I can resume A.S.A.P.
But, DO NOT hold your breath for that
That is all I have to say about that.
SPM-Level Computer Science
It turns out, Computer Science (CS) for SPM (Malaysia Certificate of Education @MCE) deals mainly with database and web interface. I have developed database-related systems before, but I was doing it without having formal class on it. Basically, I simply wing-it based on what I know on how computers store data (i.e. C data types).
I need to help my son with some questions, so I looked up 'database normalization' and found some things. The good thing is the way I implemented my database is mainly the 'correct' way. The not-so-good thing is that I am NOT able to help my son much with the practice questions - simply too many terms that I am not familiar with. Just shows that implementations need not be theoretically developed - experience (and good fundamentals) can also help to produce relatively sufficient results.
Anyways, the main reason I am writing this here is to 'store' the following 'note' (for my personal future reference).
- db_normalization.txt
Database Normalization Five 'rules' to make data normal: 1NF,2NF,...,5NF (NF=normal form) - each rule builds on another, starting from 1NF - 1NF/2NF/3NF -> Core Basics (normalization usually means 3NF!) - 4NF/5NF -> Exceptions *Note: Normalization is about grouping & connecting data the right way! 1NF is about - atomic values - unique identifiers *Term: Imagine a spreadsheet -> [table] or [entity] 1NF rules - a cell cannot contain more than 1 value = if it does, that column needs to be split into multiple columns - each row (@record) must be unique = look for potential primary key = usually, we use system-generated (integers are better!) - each column name must be unique - there must be no repeating groups (or cells?) = it there are, remove and create new table (1NF!) 2NF rule - all data/column(s) must depend on the primary key = if it does not, must be split into it own table (1NF!) = use primary key in new table as column value -> foreign key 3NF rule - primary key must define all non-key column(s) = non-key column(s) must not depend on any other key = if this is not met, must create new table and use foreign key to link
Why engineering students should not use Arduino
I am one of those tertiary educators in engineering (E&E) who is against the idea of Electronics Engineering students using Arduino for their bachelor degree project. This is a great example why that is the case. I know that is about software, but still the same principle.
When your system depends on other people's work (i.e. you use library/libraries most of the time in Arduino), there is always a possibility it cannot be maintained in the future. And, for engineering students, the most important thing for you is to be competent at creating that 'building block' (@fundamental code/design) on your own… so that even if you do not need to write/develop any, your can still fix it when something no longer works.
That is all I have got to say about that… for now
Broadcom-sta on Slackware 15 for old laptop
I need to use my old laptop that requires broadcom-sta driver for its WiFi module.
Updated20240301: Updated script
- getbuild_broadcom-sta
#!/bin/bash TOOL="wget" TCHK=$(which $TOOL 2>/dev/null) [ ! -x "$TCHK" ] && echo "** Cannot find $TOOL!" && exit 1 OPTS="--recursive --no-parent --no-host-directories" OPTS="$OPTS --reject index.html*" OPTS="$OPTS --cut-dirs=3" OPTS="$OPTS --execute robots=off" FROM="https://www.slackware.com/~alien/slackbuilds/broadcom-sta/build/" $TOOL $OPTS $FROM echo "[DONE] $TOOL $OPTS $FROM" # https://github.com/winterheart/broadcom-bt-firmware
That is all I have to say about that.
Valgrind
Just a self reminder - I actually only just found out how useful valgrind can be
Simple run
$ valgrind --tool=memcheck --leak-check=full --track-origins=yes -s <command>
Or, with logger
valgrind --leak-check=full --track-origins=yes --log-file=valgrind.rpt <command>
Maybe I will elaborate on this some other time.
Using UniMAP Thesis Latex template with TexLive
On Slackware
- texlive is now default! (used to be tetex)
- get
texlive-extrafrom https://slackbuilds.org
On Devuan
- install
$ apt install texlive texlive-latex-extra texlive-science
- install
$ apt install texlive-lang-other texlive-fonts-extra texlive-font-utils
- need to check this
$ apt install texlive-bibtex-extra biber
biber package info text says it breaks texlive-bibtex-extra
Edited20230922 Fixed wrong package name
Getting word count for Latex-generated document
We need texcount binary for this. For a Latex source saved as paper.tex, simply run
$ texcount -inc -v -sum paper.tex
to get various statistics for each *.tex (files specified using \include will also be in the analysis). To get the information in an HTML formatted file, run
$ texcount -inc -v -html -sum paper.tex >info.html
Edit the written HTML document to filter out any information if necessary.
That is all I have to say about that
Running C program on Android
I come across this page today which was written in 2020! How could I have missed this??? Anyway, I have actually been thinking of exploring this opportunity for years (always got stucked thinking how cumbersome Android NDK is!) - well, I guess this can be a good starting point! The repo to look into is this. Unfortunately, I am working on something else at the moment… let's see how far I can get with this.
That is all I have to say about that.
Using DWM on Slackware
I have used DWM before on a laptop - it was nice and minimal… perfect for that old laptop. I just got myself a refurbished i5-based desktop PC and I decided to install Slackware and use DWM on it. For networking, I have network-manager icon running in system tray (using systray patch). For volume control, I have a simple script (wrapper for amixer) to help me with that. But, I also need to test some headphones for my kids. So, I just found out that ALSA actually have a binary speaker-test to help with that!
A simple test on simple stereo speaker (2-channel) can be done by running:
$ speaker-test -c 2 -t wav -l 4
That is all I have to say about that.
CPU scaling on Linux
Just a short one… I cannot find any info regarding this in my wiki.
Using cpufrequtils, to get info
$ cpufreq-info
To set new governor
$ cpufreq-set -c {core-idx} -g {powersave,ondemand,etc}
Devuan apt update error
Running apt update on my Devuan machine today results in these:
# apt update Get:1 http://deb.devuan.org/merged chimaera InRelease [33.9 kB] Err:1 http://deb.devuan.org/merged chimaera InRelease The following signatures were invalid: EXPKEYSIG BB23C00C61FC752C Devuan Repository (Amprolla3 on Nemesis) <repository@devuan.org> Get:2 http://deb.devuan.org/merged chimaera-security InRelease [26.5 kB] Err:2 http://deb.devuan.org/merged chimaera-security InRelease The following signatures were invalid: EXPKEYSIG BB23C00C61FC752C Devuan Repository (Amprolla3 on Nemesis) <repository@devuan.org> Get:3 http://deb.devuan.org/merged chimaera-updates InRelease [26.5 kB] Err:3 http://deb.devuan.org/merged chimaera-updates InRelease The following signatures were invalid: EXPKEYSIG BB23C00C61FC752C Devuan Repository (Amprolla3 on Nemesis) <repository@devuan.org> Fetched 86.9 kB in 1s (88.4 kB/s) Reading package lists... Done Building dependency tree... Done Reading state information... Done All packages are up to date. W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://deb.devuan.org/merged chimaera InRelease: The following signatures were invalid: EXPKEYSIG BB23C00C61FC752C Devuan Repository (Amprolla3 on Nemesis) <repository@devuan.org> W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://deb.devuan.org/merged chimaera-security InRelease: The following signatures were invalid: EXPKEYSIG BB23C00C61FC752C Devuan Repository (Amprolla3 on Nemesis) <repository@devuan.org> W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://deb.devuan.org/merged chimaera-updates InRelease: The following signatures were invalid: EXPKEYSIG BB23C00C61FC752C Devuan Repository (Amprolla3 on Nemesis) <repository@devuan.org> W: Failed to fetch http://deb.devuan.org/merged/dists/chimaera/InRelease The following signatures were invalid: EXPKEYSIG BB23C00C61FC752C Devuan Repository (Amprolla3 on Nemesis) <repository@devuan.org> W: Failed to fetch http://deb.devuan.org/merged/dists/chimaera-security/InRelease The following signatures were invalid: EXPKEYSIG BB23C00C61FC752C Devuan Repository (Amprolla3 on Nemesis) <repository@devuan.org> W: Failed to fetch http://deb.devuan.org/merged/dists/chimaera-updates/InRelease The following signatures were invalid: EXPKEYSIG BB23C00C61FC752C Devuan Repository (Amprolla3 on Nemesis) <repository@devuan.org> W: Some index files failed to download. They have been ignored, or old ones used instead.
It turns out that the keyring has been rebuilt (read post #7). More than one way to fix it - I choose this one:
rm -rf /var/lib/apt/lists/* apt update --allow-insecure-repositories apt install devuan-keyring --allow-unauthenticated
note: removing all in list may be overkill - maybe try removing just deb.devuan.org_merged_dists_chimaera_InRelease instead? keep in mind that some pc may still use pkgmaster.devuan.org
All is well now… and that is all I have to say about that.
Revisiting MinGW (for sdcc build)
I want to build sdcc for NMK322 so that my students can use EXACTLY what I have. So, here we go again:
Installing MinGW:
- Get the 'package manager' from here
- version 0.6.3 (beta) at the moment
- I prefer the standalone binary (no setup)
- Pick a location and extract the zip file
- I choose
C:\Users\Public\Tool - change the folder name so that we have
C:\Users\Public\Tool\mingw\bin\mingw-get.exe
- Prepare to use mingw-get binary
cd C:\Users\Public\Tool\mingw\var\lib\mingw-get\data\copy defaults.xml profile.xml
- Open a command prompt and update catalogue
cd C:\Users\Public\Tool\mingw\bin\mingw-get.exe update
- Get stuffs (compiler with Unix-like environment) without using GUI
mingw-get.exe install gcc g++ gmp mpfr mpc msys msys-wget-bin
- To get GUI interface install mingw-get (apparently, we are NOT running mingw-get!
)
mingw-get.exe install mingw-get- now, a window will come up when you run
mingw-get
Note20220808 Current software versions {gcc:9.2.0,binutils:2.32}
Some useful things to do:
- To have git in MinGW shell, install Git-for-Windows at
C:\Users\Public\Tool\Git- edit
C:\Users\Public\Tool\mingw\msys\1.0\etc\profileand insertMY1GITPATH="/c/users/public/tool/git/bin" [ -d "$MY1GITPATH" ] && PATH="$MY1GITPATH:$PATH"
before the block containing an
export PATHline(s)
- Get helper script(s) - I wrote that for personal use
- copy everything (except LICENSE, README.md and msys2.vbs) to
C:\Users\Public\Tool\mingw - allows environment to be used on shared computer (no need for admin account)
- Running
msys.vbs(*Hint*: double-click) will install (or remove if already installed) a pop-up context menu entry (MinGW Shell) whenever you right-click on a folder in Windows Explorer- edit
C:\Users\Public\Tool\mingw\msys\1.0\etc\profileand comment (place '#' at the beginning of) the last line withcd $HOMEcommand
- If you want to use normal Windows command prompt to run stuff, these two scripts are you friend (you may ignore them otherwise)
- Running
mingw-setup.batsets up normal command prompt for command-line compilation- place
mingw-term.batscript (form tools folder) in any folder - when executed, it will open a command prompt (with MinGW path properly configured) in that folder
- Running
mingw-clear.batcleans up settings created bymingw-setup.bat
RGB 80x160 OLED ST7735S
I bought this display module a while back, but never got the chance to test it out. I have multiple platforms to test it with: (1) Pi Zero (2) 8051:stc12 (3) Maker Uno (4) ESP32 (5) Pi Pico. While I figure out what I am going with, I just want to put some basic info so I can refer to it later.
Interface Pins (info from the link above):
- GND (Power ground)
- VCC (Power +3.3 or 5V)
- SCL (SPI clock line)
- SDA (SPI data line)
- RES (LCD reset, LCD needs to be reset once after power-on)
- DC (SPI data/command selection pin)
- BLK (LCD backlight control, the default can be left floating, low level to turn off the backlight)
Although the pin labels suggests I2C interface, it is actually recommended to use SPI (as stated on the board itself). So, for 8051 I may try I2C - but since this is said to be a fast display (timing specs at ns range), I want to try it on Pi Zero/Pico. We shall see…
Useful desktop entry for my personal use
Place this in $HOME/.local/share/application
- gedit-standalone.desktop
[Desktop Entry] Version=1.0 Type=Application Name=gEdit (Standalone) Comment=Edit text files Exec=gedit -s %U Icon=org.gnome.gedit Terminal=false Categories=GNOME;GTK;Utility;TextEditor; MimeType=text/plain;text/x-chdr;text/x-csrc;text/x-c++hdr;text/x-c++src;text/x-java;text/x-dsrc;text/x-pascal;text/x-perl;text/x-python;application/x-php;application/x-httpd-php3;application/x-httpd-php4;application/x-httpd-php5;application/xml;text/html;text/css;text/x-sql;text/x-diff; StartupNotify=true Keywords=Text;Editor;
- geany-workspace.desktop
[Desktop Entry] Version=1.0 Type=Application Name=Geany (WorkSpace) Comment=A fast and lightweight IDE using GTK+ Exec=geany_space %F Icon=geany Terminal=false Categories=GTK;Development;IDE;TextEditor; MimeType=text/plain;text/x-chdr;text/x-csrc;text/x-c++hdr;text/x-c++src;text/x-java;text/x-dsrc;text/x-pascal;text/x-perl;text/x-python;application/x-php;application/x-httpd-php3;application/x-httpd-php4;application/x-httpd-php5;application/xml;text/html;text/css;text/x-sql;text/x-diff; StartupNotify=true Keywords=Text;Editor; Name[en_US]=Geany (WorkSpace)
- android-studio.desktop
[Desktop Entry] Version=1.0 Type=Application Name=Android Studio Comment= Exec=/home/share/appx/android-studio/bin/studio.sh Icon=/home/share/appx/android-studio/bin/studio.png Path=/home/share/appx/android-studio/bin Categories=Development;IDE; Terminal=false StartupWMClass=jetbrains-studio StartupNotify=true
- arduino.desktop
[Desktop Entry] Name=Arduino Comment=Arduino IDE Exec=/home/share/appx/arduino/arduino Path=/home/share/appx/arduino Icon=/home/share/appx/arduino/lib/arduino_icon.ico Terminal=false Type=Application Categories=Utility;Application;Development;
- arduino-appimage.desktop
[Desktop Entry] Type=Application Version=1.0 Name=Arduino IDE (App-Image) Comment=Arduino IDE (App-Image) Exec=/home/share/appx/appimage/arduino-ide %F Terminal=false Categories=Utility;Application;Development;
- scangearmp2.desktop
[Desktop Entry] Comment=Scanner Terminal=false Name=Canon e3370 Scanner Exec=scangearmp2 Type=Application Icon=scanner-symbolic Name[en_US]=ScanGear-E3370
- librewolf.desktop
[Desktop Entry] Type=Application Version=1.0 Name=LibreWolf (App-Image) Comment=Access to Internet Exec=/home/share/appx/appimage/librewolf %F Icon=librewolf Terminal=false Categories=Network;WebBrowser;
Re-Post: Cron
Note: This is taken from my previous blog - Published on: Jul 11, 2011 @ 10:35
Sounds very computer-ish isn't it? Well, it is… it's actually a scheduling table, something that computer system admins are very familiar with. It's nothing fancy, I could have written this in my wiki, which is what I usually would have done. But, since it's been quite a while since I last write something in this blog, I just feel like putting the info here. I know I'm going to regret this and spend more time transferring this to my wiki later… but I'll do it anyways :-p
A task/job is made of 1 line with 6 items - 5 items/numbers represent time, and the last one is the job/task to be executed. Check it out…
* * * * * job/task_to_be_executed ┬ ┬ ┬ ┬ ┬ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─── weekday (0 - 7) 0/7 => Sunday │ │ │ └──────── month (1 - 12) │ │ └───────────── day (1 - 31) │ └────────────────── hour (0 - 23) └─────────────────────── minute (0 - 59)
I got the above 'figure' from wikipedia (with minor personal adjustments). To view your current cron jobs, type
crontab -l
So, how do we 'install' a new job? Type
crontab -e
which will open your default terminal editor (e.g. vi) and enter a task in the given format, then save. Voila!
Update20220307 So, after more than 10 years, I finally manged to transfer this to my wiki's mini-blog. Yay! Here are some additional info..
Some examples:
- To run binary
toolevery hour:0 * * * * /path/to/tool <args>...
Special cases:
- To run binary
toolevery 5 minutes:*/5 * * * * /path/to/tool <args>...
- To run binary
toolon reboot/startup:@reboot /path/to/tool <args>...
Latest HC06 AT firmware
I am trying to create an 8051 code library for HC06 bluetooth module. I have done one for my my1barepi library, so I thought that would be easy. Boy! Was I wrong! It turned out that the AT firmware on the latest HC06 module have been upgraded. The old ones do not need any CR/LF pair (the new ones do) and the AT command for changing name requires a ':' i.e. AT+NAME:<name> instead of just AT+NAME<name>. I am using AT firmware version 3.0-20170609 - not sure when this was changed. Maybe I need to update my my1barepi code? Since I no longer handle that paper, that is not in my priority list at the moment.
That is all I have to say about that.
Working on a repository with 3-branches
I have a repository with 3 branches:
- master - main project
- upstream - upstream project
- work - working copy of project with current semester data
In order to update (merge) upstream into master, I need to
# git checkout upstream # git pull /path/to/upstream/repo # git checkout master # git merge upstream # git checkout work # git merge master
I would prefer to do this without doing those multiple checkouts. SO, I found a way to do just that…
# git fetch /path/to/upstream/repo master:upstream # git fetch . upstream:master # git merge master
However, this only work IF updating master involves purely fast-forward merge.
That is all I have to say about that.
Moved to a new server
Due to a problem on the older server provided by my Uni's ICT department, I decided to move this wiki to the newer server. However, now I am having problems updating (some of?) my wiki pages. Need some time to check this out, but at the moment I think I am affected by this. Anyway, if this is NOT fixable, I may have to revert the old server… if they still keep that one running. Hopefully we can make it work on this new server.
A New Hope
Starting to use this as my little notebook - putting in notes that I want to refer to and have a timestamp on it I hope this one sticks… who knows? Maybe this will grow in to a full blog and replace my currently dormant blog
Now on my1matrix.cc
