Skip to main content

Posts

Showing posts from May, 2026

Recursion example with SQL

I asked my friend Chatty, can you use recursion in SQL? For example I have a table (ID, value) ordered by increasing ID. Can you guide me through using recursion to select all the rows of consecutive repeated values using and creating an SQLite database. Provide the small sample data. Is there a better way to do this? A More Modern Alternative (Window Functions) In real-world SQL, this problem is usually solved more efficiently using window functions like: LAG() ROW_NUMBER() SUM() OVER But recursion is excellent for learning traversal logic and hierarchical thinking. Recursion example using sqlite on termux DROP TABLE IF EXISTS sample; CREATE TABLE sample (     id INTEGER PRIMARY KEY,     value TEXT ); INSERT INTO sample (id, value) VALUES (1, 'A'), (2, 'A'), (3, 'A'), (4, 'B'), (5, 'B'), (6, 'C'), (7, 'A'), (8, 'A'), (9, 'D'), (10, 'D'), (11, 'D'), (12, 'D'); WITH RECURSIVE grouped AS (    ...

23 by 2

At 239am, on my 46th birthday, I decided to write. I got up early and washed the wares, and now I am in my bed enjoying the silence of the night. The room echoes with the fan breeze. Birthdays are special because they mark our entrance into this world, a reminder that our mothers carried us for nine months and laboured to bring us here. In Islam we are taught not to make birthdays into celebrations, but reflection and gratitude are different. I think we can pause and be thankful. When I look back on my life, I see ups and downs, ease and struggle, calm and chaos. It may sound cliche, but the older I get, the more I value peace and quiet. I no longer have the energy for drama, negativity, endless news, or politics. I simply want to be surrounded by goodness and positivity. More than anything, I want to hold on to God for whatever time I have left here, because in the end, all the fighting and chasing make little sense. One day, every one of us will leave everything behind. This has been...

Stuck running sftp server on termux alpine for multi-user setup

The below is my journey trying to get multi-user sftp working using alpine on termux pkg update && pkg upgrade pkg install proot-distro openssh proot-distro install alpine proot-distro login alpine apk update apk upgrade apk add openssh shadow sudo apk add vim vim /etc/ssh/sshd_config Port 8022 PermitRootLogin no PasswordAuthentication yes Subsystem sftp internal-sftp Match Group sftpusers     ChrootDirectory /sftp/%u     ForceCommand internal-sftp     X11Forwarding no     AllowTcpForwarding no addgroup sftpusers adduser user1 adduser user1 sftpusers mkdir -p /sftp/user1/upload chown root:root /sftp/user1 chmod 755 /sftp/user1 chown user1:sftpusers /sftp/user1/upload How I run my server each time pkill sshd rm -f /etc/ssh/ssh_host_* ssh-keygen -A /usr/sbin/sshd -D -d -d -d From another termux session sftp -P 8022 user1@127.0.0.1 Connection reset by 127.0.0.1 port 8022 Connection closed Some troubleshooting steps mkdir -p /run/sshd chmod 75...

Wordpress on termux

See previous blog posts to get LAMP running on termux https://trinbagotechie.blogspot.com/2026/05/installing-mysql-and-phpmyadmin-on.html https://trinbagotechie.blogspot.com/2026/05/running-php-and-apache-on-termux.html This is the official wordpress guide - https://developer.wordpress.org/advanced-administration/before-install/howto-install/ Let me see how it compares to what ChatGPT says ChatGPT prompt - I have apache, php and mysql (with phpmyadmin) installed and running on termux. Guide me through installing the latest wordpress locally. Start my servers php-fpm -y $PREFIX/etc/php-fpm.conf -d opcache.enable=0 -d opcache.enable_cli=0 mysqld_safe & httpd Download and unzip wordpress to wordpress folder in htdocs chmod -R 755 . CREATE DATABASE wordpress; CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'strongpassword'; GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost'; FLUSH PRIVILEGES; EXIT; cp wp-config-sample.php wp-config.php ...

Installing mysql and phpmyadmin on termux

ChatGPT prompt - Guide me through installing mysql and phpmyadmin on termux Because official MySQL packages are not maintained for Termux, the easiest and most stable setup is MariaDB (drop-in MySQL replacement) Set the root password Create an admin user for phpmyadmin \e for long queries in editor ; At first I got the following error trying to log into phpmyadmin mysqli::real_connect(): (HY000/2002): No such file or directory Turns out phpMyAdmin is trying to use “localhost socket” instead of TCP vim phpmyadmin/config.inc.php change $cfg['Servers'][$i]['host'] = 'localhost'; to $cfg['Servers'][$i]['host'] = '127.0.0.1'; Restart everything. This forces TCP instead of socket. Now that I have a beautiful LAMP stack setup I could try to install wordpress locally on termux.

Running php and apache on termux

This was my experience getting php and apache to run on termux apt update && apt upgrade -y apt install php-apache I was following an old blog post that used php 7 and got these errors Can't locate API module structure `php7_module' in file /data/data/com.termux/files/usr/libexec/apache2/libphp.so: undefined symbol: php7_module Cannot load /data/data/com.termux/files/usr/libexec/apache2/libphp7.so Corrected in apache config file vim $PREFIX/etc/apache2/httpd.conf LoadModule php_module /data/data/com.termux/files/usr/libexec/apache2/libphp.so Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe.  You need to recompile PHP. Comment out mpm_worker and use mpm_prefork #LoadModule mpm_worker_module libexec/apache2/mod_mpm_worker.so LoadModule mpm_prefork_module libexec/apache2/mod_mpm_prefork.so This still does not work as apache (httpd) was failing silently. According to Chatty LoadModule php_module ...libphp.so often fails in Termux becau...

Custom youtube search

I had this idea to create my own custom youtube search page. On youtube you cannot block a channel or have it removed from future search results. I find this useful for example when I search "Tobago vlog" I get the politics spam videos also showing up from one channel in particular. Sometimes others. I want to filter those out. ChatGPT prompt I want to build a youtube search page that shows each result with a "add to watch later" button and a "remove channel from search results" button that removes that channel from current results and future results. Removed channels are added to filter.dat. Search results shows videos from the last week. Folder structure youtube-filter-app/ │ ├── public/ │   ├── index.html │   ├── app.js │   └── styles.css │ ├── data/ │   ├── filter.dat │   └── watchlater.dat │ ├── server.js ├── package.json └── .env I created an MVP and it works beautifully. I had to log into Google Developer Console and create an API...

Why is the Caribbean not a tech hub?

Why is the Caribbean not a tech hub? I saw this question online and it got me thinking. Who should be asking this question? Who should be answering this question? Do we have the data to answer this question? Besides data, what else do we need to answer this question? And when we have answers, who is going to do the work to change things? This is what my friend Chatty had to say: The question "Why is the Caribbean not a tech hub?" is really a question about history, capital, education, governance, culture, and coordination, not just technology. The Caribbean is often unfairly compared to places like Silicon Valley or Shenzhen without acknowledging that those regions benefited from massive investment, large markets, and long-term industrial planning, while Caribbean nations were shaped by colonial extraction, small fragmented markets, debt, and brain drain. We have some useful data, but not enough to fully understand the region’s digital potential, and data alone cannot answer ...

Termux big digital ASCII clock script

I had this idea to create a big digital clock display using shell script in termux just for the fun of it. This is what I came up with with the help of Chatty.

Getting started with nanoc

I love static site generators. Ease of use and simplicity and speed. I remember trying 11ty and Middleman before. Today I am trying nanoc. Nanoc is written in Ruby. https://nanoc.app/doc/installation/ I am also using the siimple css framework Where the documentation could not help me, I turned to ChatGPT, for example: I am trying out nanoc static site generator. Can I have a list of images and captions and generate a page for each photo with caption and have a list of these pages on the homepage? I asked my friend Chatty about some of the considerations when choosing static site generators. When choosing a static website generator, consider ease of use, performance, customization options, and compatibility with your workflow. Evaluate factors such as the programming language and templating system it uses, support for plugins and themes, build speed, SEO features, documentation quality, community support, and how well it integrates with hosting platforms and version control systems. The...

Hobby project - play whe payout calculator

These were the ChatGPT prompts I used. It is amazing how quickly simple apps can be coded with the right prompting and proper testing and sometimes troubleshooting and debugging. I want to create a play whe payout calculator html/javascript page User enters under their wager Base1 Wager Mega Wager Base2 Wager MU Wager Base3 Wager MX Wager Then multi selects what balls have called Mega, MU, MX, MBonus, MUBonus, MXBonus Bonus pays 36 to 1 Base pays 26 to 1 Mega pays 80 to 1 MU pays 100 to 1 MX pays 125 to 1 Show calculations Base always pays out and user can only select mega or mbonus, mu or mubonus, mx or mxbonus Tax is 10% on winnings 1000 and over I tested it myself and this was the results

Hobby project - Next experiments

This is ChatGPTs suggestions on what could be some next experiments. 1. Add a queue system for async job processing and retries 2. Automate scheduled scraping with cron-based GitHub Actions 3. Create notification rules/alerts for exchange rate thresholds 4. Add authentication with Supabase Auth or OAuth 5. Build an admin dashboard with logs and controls 6. Version your API endpoints (/v1, /v2) 7. Implement webhooks for outbound event notifications 8. Add rate limiting and API security protections 9. Experiment with serverless/edge functions 10. Add real-time updates using websockets or Supabase realtime 11. Build a small ETL pipeline for transforming scraped data 12. Add monitoring, logging, and failure alerts 13. Intentionally test failures and recovery handling 14. Compare JSON storage vs databases like SQLite/Postgres 15. Add analytics and metrics collection 16. Store historical exchange rate snapshots and graph trends 17. Add caching layers and cache invalidation strategies 18. Cre...

Hobby project - Store and view exchange rates

The next step in my project was to test out being able store and display the rates in a database. I decided to use nodejs and supabase for this. Everything worked beautifully. Only hickup was the following error due to my package.json not being correct. SyntaxError: Cannot use import statement outside a module Added this to package.json   "type": "module" This works beautifully. Right now I am just testing fragments of what could be part of a bigger system to see what is possible and what works and how easy to code on a mobile. There is no fully functioning integrated end to end system just yet. This is also what I tested. A serverless append-only database using GitHub + Actions + Pages. That’s basically a lightweight backend system. This was the ChatGPT prompt I used. Guide me through each step. This is what I want. A manually run github actions that adds to docs/data.json with the current date and time. docs/index.html displays all the entries in data.json. Make s...

Hobby project - Sending exchange rates via SMS

Continuing from last blog post , I was able to send an SMS to myself using twilio and nodejs. So now I have the capability to send email or sms with data scraped from a website and schedule this to happen daily for example. And I coded all this from my android phone using termux and vim. Pretty cool. Next up I want to be able to store the exchange rates in a database and display it on a webpage to show historical values. See results below This is my code require("dotenv").config(); const axios = require("axios"); const twilio = require("twilio"); const client = twilio(   process.env.TWILIO_ACCOUNT_SID,   process.env.TWILIO_AUTH_TOKEN ); async function sendUsdRate() {   try {     const response = await axios.get(       process.env.MY_API     );     // Get USD row     const usdRow = response.data.data.find(       row => row[0] === "United States Dollar"     );     const buyingRate =...

Hobby coding project - exchange rate api

I used ChatGPT to provide the guidance. Basically I created a serverless api endpoint (using Vercel) to share the exchange rate data from the front page of the central bank website. I will contact the Central Bank to ask if they plan to provide public APIs for their data in the future. The project uses Axios + Cheerio, the Requests + BeautifulSoup of the Node.js world. Axios handles HTTP requests with a clean promise-based API. Cheerio provides jQuery-style HTML parsing without a browser. So my api endpoint serves up json exchange rate data. Next, what I did was create a Github actions to read data from the api endpoint and send it to my email address. I used resend for this and nodejs. Now I could easily send the exchange rates data to my email address on a daily basis by scheduling the action in Github. Next I am going to test out sending the data via sms if I can find a good free sms sending api. See results below.

Hobby coding project - Queries for play whe data

I have an interest in open data and being able to query that data and gain beautiful insights. One data set that would be interesting is the play whe results data. Our open data is lacking in Trinidad and I will try to contact NLCB to see if they can provide and maintain the data online. But in the meanwhile I will use randomised data to create the website and do my testing. First thing I did was install sqlite on termux pkg update && pkg upgrade pkg install sqlite sqlite3 --version Create my database in my project folder sqlite3 results.db Useful commands .exit .quit Exit from multiline prompt ; SQL to create my table (create_tbl_results.sql) CREATE TABLE DrawResults (     DrawNo INTEGER PRIMARY KEY,                           DrawDate DATE,     ResultNo INTEGER CHECK (ResultNo BETWEEN 1 AND 36),     DrawTime INTEGER CHECK (DrawTime BETWEEN 1 AND 4) ); SQL to create the random dat...

Leaders versus dealers

It is 3:55am and I have decided to write. We all should be the leaders of our own lives. Good leaders allow us to develop ourselves to the point where we can become our own leaders. Too often, what we see instead are die-hard followers and fans of leaders who are not allowed to question anything, but are expected to blindly support. If I rearrange the letters of "leader" I can get "dealer". We need leaders, not dealers. Dealers trade in influence, emotions, loyalty, and power for personal gain, while leaders elevate people beyond dependence. There is a difference between leadership that empowers and leadership that creates dependency. This made me think about God as the grand example of good leadership. I think the same principle applies. God gave us free will, and we are told that God helps those who help themselves. If God gave human beings minds, curiosity, conscience, and moral awareness, then perhaps faith was never meant to replace them, but to guide them. I t...

What is important

Every now and again, I get reminded of the why. Why I have handed my life over to God. It is 3:08 p.m. and I have decided to write. Honestly, I feel like I could end this blog post right here. What more is there to say? God above all else. God is our compass on this journey called life. Everything else can become a distraction. Maybe not everything, but certainly many things. You get the point. What is important? What do we prioritise? What do we make time for? The answers look different for everyone. Our lives are different. We are tested differently. We are all products of our circumstances, and those circumstances vary from person to person. Yet God is the common thread across humanity and throughout time. God always was and always will be. One day, we will answer to God. We will give account to God. We cannot live without food, water, and oxygen, but all of those things come from God. So how can we live without God? How timely. I just received a notification from the Quranly app: S...