Friday, March 13, 2026

Programming in 2026 with Artificial Intelligence tools

Some context:

I work on mostly legacy applications. Some are gigantic mono-repos, some are running  on Python 2 and some are a mash of half-solutions and ideas (like some of the UI is in JavaScript and the other half is TypeScript; made to work with a kludgy, brittle build script).

I've been using mostly Cursor. It was provided by my employer and I'm familiar with it's VScode editor. I also installed their CLI for Windows Terminal. I've tried other stuff like Co-pilot (not a fan, it was too intrusive for me) and Gemini.

Here's a couple of things that I've learn so far:

1. The Cursor agent for coding will get you almost there, I'd say 90% of the way. They will often misinterpret some nuance but I think that's probably more of the prompt used rather than the agent. You can "chat" with the agent to get what you want but be aware that has limitations - ie. context. 

2. Speaking of prompts, the Cursor agent works better if you can provide more detailed instructions rather than letting it guess. Too often, if you provide a vague enough prompt, it will use the latest or most "popular" approach. For example, it picked Set collection to use on a JS codebase prior to 2015. Sets are only supported by ECMAScript 6 which was released on 2015. But then again, the project code base was a mess of shims and Babel scripts. 

3. Setting up a project especially long-term ones, need some time and thought. For example, Cursor supports things like Rules to provide project to system-level instructions. You can add hooks to do stuff like run formatters or scan for bad practices like hard-coding secrets or API keys. The small downside for this is that senior developers have to make conscious decisions for these things because you can include these rules and hooks in the codebase. 

4. I don't like the feeling of giving the Cursor agent "full-control" of my PC outside of the VScode editor like issuing Git commands or doing az or gcloud calls. I didn't auto-allow those types of commands. If the agent wants to execute those, I have to manually allow. 

Personally, I still don't fully trust AI in doing my job. Don't get it twisted though, my job is to solve business problems and NOT writing code. Writing code is just a side effect. But not fully trusting AI tools doesn't mean not using them. It just means using or viewing them differently from what social media or the "tech bros" are saying.



Wednesday, March 19, 2025

Working with server and browser time


Consider the image:

  • A is showing 8 hours ago because the server time is in a different time zone (TZ) to the TZ of the browser
  • B is what we want because that's the browser or local time which is computed with the TZ offset.

In the "olden" times, getting the browser or local datetime in reference to a server's datetime was to use a library like moment.js. But browsers have come a long way.

Actually code:


const offsetLocalTime = new Date(dateStringFromServer);

offsetLocalTime.setHours(
  offsetLocalTime.getHours() - offsetLocalTime.getTimezoneOffset() / 60,
);

The trick is the getTimezoneoffset() function. But it's not a silver bullet because:

  • It only works with UTC or ISO dates. Remember, that UTC and ISO dates are "time keeping" standards NOT A FORMAT. Although, UTC and ISO are slightly different ways to track time, usually that's not a problem since the different between the two is a fraction of a second - which is only really significant if you're working in an ultra precise environment.
  • It "guesses" the time zone of the OS so if the user configured his TZ incorrectly, then the computation is also off.


Tuesday, January 21, 2025

Fix Losing your HD mounts on RaspberryPI with a Orico 9558u3

If you're anything like me, having a lot of old, mismatched 3.5" drives, you'd probably decide on getting a n USB enclosure like the Orico 9558u3, plug it into your RaspberryPI, edit your FSTAB to automount, then setup Samba to file share. 

Well, that works until the Orico 9558u3 decides to sleep to save power when there's no drive activity. It can't help itself BECAUSE it's a feature. Now you lose access to your mount drives. Now what?

Lucky, we're in linux and we can simply fake drive activity and set it on a schedule.

We simply run a cronjob every 5 minutes to "touch" the disk. Hehehe.

Open your CronTab:

$ sudo crontab -e

With your text editor (nano or vi), add the following line:

$ */5 * * * * /bin/touch /your/hdd/mnt/here &>/dev/null

Add more lines for each drive you want to keep awake.

Lastly, restart your crontab.

$ sudo systemctl restart cron
$ sudo systemctl status cron



Friday, November 29, 2024

Doing a git clone within a LAN without Internet

On the laptop where the repo to be clone is hosted, we run the command git daemon from the terminal.

Sample command on the HOST:

 $ git daemon --base-path=<path_to_folder_containing_project_folder> --export-all --verbose  

<path_to_folder_containing_project> is the folder containing your projects folders, it will provide all projects under that folder. You're basically looking for the project folder containing the .git folder.

The client:

 $ git clone git://<local ip>/<project name>  

It's that easy but do note that the cloned repo's origin will be pointing to the HOST IP, so you need to use git remote set-url origin to point it to a different IP or origin. 

We might want to run git daemon with the --verbose option to get more details in case we run into problems.

If we are getting connection problems, you might have to check Firewall settings to allow the connection.


Reference

* https://stackoverflow.com/questions/5200181/how-to-git-clone-a-repo-in-windows-from-other-pc-within-the-lan


Saturday, September 7, 2024

Figuring out if that USB drive is legit

So you just bought USB drives off Temu or some other e-commerce site because it was cheap. You like what you see, 32GB for 99 bucks + shipping, I guess I'll buy five.

But are you really getting a deal?

Mayhaps. But unlike the common folk I don't take such things on face value and  see if we are really getting the real deal. Thankfully, Linux - in this case, PopOS - has the command line tools to check.

So get 1 USB drive to test and we install, F3

$ sudo apt install f3

F3 comes with a command line utility named f3probe, which is used to test USB flash drives for capacity.

But before we run f3probe, we need to figure what block device name the USB drive was given.

$ lsblk

 

As you can see, mine is sdb/sdb1

so

$ sudo f3probe --destructive --time-ops /dev/sdb

Wait for it. BTW, back up if you files in the USB before you do this.

And then be disappointed because your 99 bucks 32GB USB drive is "counterfeit". It's only an 8GB.

Oh well. I hope you didn't buy five. 

 

Ref

  • https://www.linuxbabe.com/command-line/f3-usb-capacity-fake-usb-test-linux