Jan 28, 2025

Windows: Run exe as a background service even if it is not a windows service

Auto start service
Came across a scenario where I needed to setup Console Application on a windows machine, All they provided was a simple binary exe which needed to be executed and it started a web server on port 3000

Now the issue was next time when I restart the server, I need to re-execute the binary exe.

NSSM comes to the rescue. Literally meaning `the Non-Sucking Service Manager`.
NSSM allows to manage windows services.

To install any exe as a windows service we simply execute the command


set path="D:\PathToNSSM\nssm.exe"
nssm install MyService


This will display the GUI for NSSM service installer.


Select the path to your exe file & other paramers and click on "Install Service"
Now your app is installed as a windows service and it is visible under "Administrative Tools/Services" under control panel.
You can set the startup type to "Automatic" and next time when you restart the server, the exe will auto start (even if it is a windows app, even though it is not a good idea).
Finally to uninstall the service

set path="D:\PathToNSSM\nssm.exe"
nssm remove MyService

Oct 24, 2024

'illegal instruction' on raspberry pi 0w while installing cloudflared

Adding `raspberry pi zero w` as tunnel to cloudflared zero trust
Whenever two people talk there are six opinions

Considering the fact that you have installed Debian on `raspberry pi 0w`,
While setting up cloudflared tunnel on `raspberry pi 0w` we get following error

illegal instruction

workaround for fixing this issue:

Groundwork before execution

1. First we make sources.list modifyable
  
chmod 777 /etc/apt/sources.list

2. Add following entry in sources.list
deb [arch=arm signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared buster main

3. Add arm architecture to the system
dpkg --add-architecture arm

The execution

4. Install ARM version of cloudflared on your `raspberry pi 0w` as shown in above screenshot
curl -L --output cloudflared.deb https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm.deb
sudo dpkg -i cloudflared.deb
sudo cloudflared service install <connector-token>

Oct 11, 2024

Whenever two people talk, there are seven opinions

Whenever two people talk there are six opinions

When two people talk, there are seven opinions

- P1's opinion about P2
- P2's opinion about P1
- T's opinion about P1
- T's opinion about P2
- P1's own opinion about himself
- P2's own opinion about himself
- T's opinion about both P1 & P2

PS: P1 & P2 are the two people and T is third person

Oct 1, 2024

Busyness contributes to happiness

Meme,Programmer, Programming, Babuji, Dad, Ultimate gift

Researchers found that those who'd spent 15 minutes walking ended up significantly happier than those who’d spent 15 minutes waiting.
Busyness contributes to happiness even when you think you’d prefer to be idle.
A recent study has suggested that there really is such a thing as too much free time
– and that our subjective well being actually begins to drop if we have more than five hours of it in a day.
As a dev if you feel I dont know what to do, you don't even realize that idleness is killing your mental state & making you unhappy

Conclusion

To recap, the universe has been fundamentally altered by this revelation.
So dont stay idle for longer time,
Dont stay longer in dark places for longer time
Avoid procrastination
Otherwise your happiness will drop to 0


Linux is the underdog that's gonna steal the show


Nowdays Linux can be easily installed on
1. Windows -> WSL
2. Android Mobile -> Termux, proot-distro
3. Cloud -> Google cloud shell
4. VM -> virtualbox

Too much procrastination because idleness?? dont want to choose either options??
Go investigate the mysterious device lurking in the corner,
hint: it has blinking lights, and check if it supports OpenWrt and install it.

Most devs will go to random OTT/YT or keep on scrolling those shorts/reels
that is also killing your mental state & you dont even realize it is continuously disturbing you.
Technology is saving you from profound levels of boredom and its a problem
devs should keep themselves idle for sometime but no longer than 5 hours,
software development is 80% thinking and 20% summoning those digital spirits with your keyboard prowess

Don't keep yourself busy watching that ott or listening to that music
Just do nothing for sometime, just breathe, live in present,
understand your surrounding in detailed manner,
After sometime your mind will be filled with void
Let it happen, dont label it as boredom.


after random interval your mind will wakeup from deep sleep state and you will feel productive
and when you are at that state you can do the impossible. go do that impossible thing now!


PS: The author is not a software engineer, he is computer scientist

Sep 30, 2024

Sep 28, 2024

Own micro home-lab on-premise cloud using Android

Aim

At the end of this article you will be running your own small scale on-premise cloud on Android device and hosting a web page

Requirements

  1. Android device
  2. Cloudflare account
  3. Domain name
  4. Knowledge of Linux (optional)

The Method

1. Visit F-Droid open source app store and install Termux on your Android device
Download APK
2. After installation is complete, open termux, you will be presented with Android terminal, execute following commands:

pkg update
pkg upgrade
termux-setup-storage
the above commands updates termux packages if there is any update and permits Termux to access files in your device's internal storage. 3. Sign up for cloudflare zero trust 4. Register a .com domain name or get a free domain from afraid.org 5. Install proot-distro
pkg install proot
pkg install proot-distro
proot-distro allows to install linux which runs along with android os. This is not a vm so we get native performance.

proot-distro commands:
    proot-distro list - show the supported distributions and their status.
    proot-distro install - install a distribution.
    proot-distro login - start a root shell for the distribution.
    proot-distro remove - uninstall the distribution.
    proot-distro reset - reinstall the distribution.

Following linux flavours are supported:
  1. Alpine Linux (edge)
  2. Arch Linux / Arch Linux 32 / Arch Linux ARM
  3. Debian (stable)
  4. Fedora 35
  5. Manjaro AArch64
  6. OpenSUSE (Tumbleweed)
  7. Ubuntu (22.04)
  8. Void Linux

Following are the steps for Ubuntu
proot-distro install ubuntu
proot-distro login ubuntu  --termux-home 
su
apt install wget -y
apt install ssh -y
apt-get install -y net-tools

Conclusion

Unlimited possibilities when you run linux on your mobile phone and point cloud to your linux running on mobile

Recommended Hardware

--TODO--

References

--TODO--

TLDR;

  1. Install termux on your Android device
  2. Create Cloudflare account & Setup cloudflare zero trust
  3. Get your domain name and point nameservers to Cloudflare
  4. Install any proot-distro on Android using Termux
  5. Point domain to your Linux using Cloudflare zero trust

May 16, 2023

Mobile first css media queries

Mobile first css media queries to adjust UI controls for various resolutions:
@media (min-width:320px) { /* smartphones, portrait iPhone, portrait 480x320 phones (Android) */ }
@media (min-width:480px) { /* smartphones, Android phones, landscape iPhone */ }
@media (min-width:600px) { /* portrait tablets, portrait iPad, e-readers (Nook/Kindle), landscape 800x480 phones (Android) */ }
@media (min-width:801px) { /* tablet, landscape iPad, lo-res laptops ands desktops */ }
@media (min-width:1025px) { /* big landscape tablets, laptops, and desktops */ }
@media (min-width:1281px) { /* hi-res laptops and desktops */ }

May 2, 2023

Installing .NET on Android


This runs .NET natively
not in a vm
not in a container
no need to have root access or jailbreaking your android
.NET runs natively on android in user space

Install Termux apk on android
pkg install proot
pkg install proot-distro
proot-distro allows to install linux which runs along with android os. This is not a vm so we get native performance.

proot-distro commands:
    proot-distro list - show the supported distributions and their status.
    proot-distro install - install a distribution.
    proot-distro login - start a root shell for the distribution.
    proot-distro remove - uninstall the distribution.
    proot-distro reset - reinstall the distribution.

Following linux flavours are supported:
  1. Alpine Linux (edge)
  2. Arch Linux / Arch Linux 32 / Arch Linux ARM
  3. Debian (stable)
  4. Fedora 35
  5. Manjaro AArch64
  6. OpenSUSE (Tumbleweed)
  7. Ubuntu (22.04)
  8. Void Linux

Following are the steps for Ubuntu
proot-distro install ubuntu
proot-distro login ubuntu  --termux-home 
su
apt install wget -y
apt install ssh -y
apt-get install -y net-tools

Manual installation of .NET: https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
cd ~/.dotnet
echo 'export DOTNET_ROOT=$HOME/.dotnet' >> ~/.bashrc
echo 'export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools' >> ~/.bashrc
source ~/.bashrc
Now the dotnet CLI can be used, more on this: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet

--REMOTE TERMUX--
https://gist.github.com/mjnaderi/b933fe940cd47b09d5cfc14875e77d67
https://glow.li/posts/run-an-ssh-server-on-your-android-with-termux/
Detailed video coming soon

Applications:
1. You can install cloudflared (Cloudflare zero trust) and then can host asp.net site on your android device
2. Run FTP server
3. Share the files without uploading anywhere