Category: Software Development

  • Display git branch on your cli prompt

    Display git branch on your cli prompt

    Want to display the current git branch on your cli prompt and go from ~/mywork$ to something like this ~/mywork [main]$ ?

    Useful when working with multiple branches or projects. It makes it less confusing when switching between environments/tabs.

    This is for bash and I haven’t tried on other cli. To include the current branch your in to your prompt :

    Edit your .bashrc file (or equivalent config file for your cli). nano ~/.bashrc

    Then add this at the end of your file

    parse_git_branch() {
       git branch 2>/dev/null | grep '^*' | colrm 1 2
    }
    export PS1="\[\e[32m\]\w\[\e[91m\] [\$(parse_git_branch)]\[\e[00m\]\$ "

    This includes color and formatting for the prompt and then resets the text color to the default.

    Restart your terminal program or do a source ~/.bashrc to see the changes.

    Enjoy!

  • Godot button not working on mobile?

    Godot button not working on mobile?

    I’ve been working on a simple Godot game for a few days now and was about to start testing on an actual phone. To my suprise all buttons doesn’t seem to be working on my phone. But they are working when testing them on my computer.

    For reference I’m using Godot 4.3.

    After looking online for any similar cases, the common response was to enable “Emulate Mouse From Touch” option in the project settings or check if I’ve connected the signal for the “pressed()” event.

    I’ve done all of those things and on mobile the buttons are showing indications of being pressed (color changes and outlines showing). One helpful idea I got was something might be erroring out in my project and I’m just not seeing it.

    I had to turn on the “Deploy with Remote Debug” option under “Debug” menu to display the errors when I’m running the game on my phone remotely.

    Image

    After that one of my scene that was being loaded at the start has an error that’s not showing up when I ran it in my computer. After I fixed that error all buttons are working on my phone.

    The game is still in beta as of this moment, you’re free to join the internal tester list: https://play.google.com/apps/internaltest/4701666419675268448

    It’s live now on google playstore: https://play.google.com/store/apps/details?id=com.palawenos.eliminateblocks

    Thanks : )

  • Installing Docker in Ubuntu

    Installing Docker in Ubuntu

    Just sharing my experience while re installing docker to a new ubuntu installation for future reference for myself. Well hopefully it can help some devs as well, might help wasting a few hours of reading or testing.

    I am using Ubuntu 24.04.1 at the moment but this might be applicable to future versions too. I installed a package and it seemed to cause ubuntu to perform a system check but it stops in fsck check. After doing an fsck check via bootable usb drive it still gave me the same error so I decided to re install Ubuntu, which brings me to re installing all the programs I’m using for dev. One of which is docker.

    Since it’s been some time since I last installed docker, I went to https://docs.docker.com/engine/install/ubuntu/ and decided to follow one of the instructions. I can’t remember which method I used though, but it installed docker with rootless access and without any error. Then I tried running my dev containers and they were running fine except for some of the codes are failing due to permission issues.

    After a few hours of reading I just found out docker is being run as root from the host machine if it’s being run in rootless mode and therefore everything created at the moment of running the container would be owned by that user, including volumes I’m automatically mounting via docker-compose, which includes the source code for my project. I didn’t know this before. The way I understood it is that since the container is being run without root access (from host) the container will be using a default user which is user with ID=0 which is the root (of the container’s system, not root of the host/my machine). Basically the user in the container doesn’t match the user in my machine (host machine).

    I tried a couple of solutions I found online and since I am lazy and didn’t want to spend too much time bringing back my previously working setup I decided to just remove docker (https://docs.docker.com/engine/install/ubuntu/#uninstall-docker-engine) and re install it with root access (which is by default if you follow the other installation method). This time i chose Install by package : https://docs.docker.com/engine/install/ubuntu/#install-from-a-package. Package url is here : https://docs.docker.com/engine/install/ubuntu/#install-from-a-package

    After a succcesful installation I won’t be able to use docker without root access (via sudo) so their instruction is to add my user to a docker group (you should create one if none exist yet). And probably restart (for assurance) afterwards. You can copy this command to add your user to the docker group

    sudo usermod -aG docker your-user-name

    I also had an issue with docker daemon not running turns out /etc/docker/daemon.json was misconfigured from my previous installation. I just removed everything from the file and it ran properly.

    So that’s it! In summary, next time I have to reinstall docker follow these steps :

    1. Install docker via packages method
    2. add docker group
    3. add my user to docker group
    4. restart computer
    5. check docker’s log if it keeps failing to launch

  • All barangays in Palawan (PHP Array)

    All barangays in Palawan (PHP Array)

    $municipality = [
                'Aborlan' => [
                    'Apo-Aporawan',
                    'Apoc-apoc',
                    'Aporawan',
                    'Barake',
                    'Cabigaan',
                    'Culandanum',
                    'Gogognan',
                    'Iraan',
                    'Isaub',
                    'Jose Rizal',
                    'Mabini',
                    'Magbabadil',
                    'Plaridel',
                    'Poblacion',
                    'Ramon Magsaysay',
                    'Sagpangan',
                    'San Juan',
                    'Tagpait',
                    'Tigman',
                ],
    
                'Agutaya' => [
                    'Abagat',
                    'Algeciras',
                    'Bangcal',
                    'Cambian',
                    'Concepcion',
                    'Diit',
                    'Maracanao',
                    'Matarawis',
                    'Villafria',
                    'Villasol',
                ],
                'Araceli' => [
                    'Balogo',
                    'Dagman',
                    'Dalayawon',
                    'Lumacad',
                    'Madoldolon',
                    'Mauringuen',
                    'Osmeña',
                    'Poblacion',
                    'San Jose de Oro',
                    'Santo Niño',
                    'Taloto',
                    'Tinintinan',
                    'Tudela',
                ],
    
                'Balabac' => [
                    'Agutayan',
                    'Bancalaan',
                    'Bugsuk',
                    'Catagupan',
                    'Indalawan',
                    'Malaking Ilog',
                    'Mangsee',
                    'Melville',
                    'Pandanan',
                    'Pasig',
                    'Poblacion I',
                    'Poblacion II',
                    'Poblacion III',
                    'Poblacion IV',
                    'Poblacion V',
                    'Poblacion VI',
                    'Rabor',
                    'Ramos',
                    'Salang',
                    'Sebaring',
                ],
                'Bataraza' => [
                    'Bono - bono',
                    'Bulalacao',
                    'Buliluyan',
                    'Culandanum',
                    'Igang - igang',
                    'Inogbong',
                    'Iwahig',
                    'Malihud',
                    'Malitub',
                    'Marangas',
                    'Ocayan',
                    'Puring',
                    'Rio Tuba',
                    'Sandoval',
                    'Sapa',
                    'Sarong',
                    'Sumbiling',
                    'Tabud',
                    'Tagnato',
                    'Tagolango',
                    'Taratak',
                    'Tarusan',
                ],
                "Brooke's Point" => [
                    'Amas',
                    'Aribungos',
                    'Barong - barong',
                    'Calasaguen',
                    'Imulnod',
                    'Ipilan',
                    'Maasin',
                    'Mainit',
                    'Malis',
                    'Mambalot',
                    'Oring - oring',
                    'Pangobilian',
                    'Poblacion I',
                    'Poblacion II',
                    'Salogon',
                    'Samareñana',
                    'Saraza',
                    'Tubtub',
                ],
                'Busuanga' => [
                    'Bogtong',
                    'Buluang',
                    'Cheey',
                    'Concepcion',
                    'Maglalambay',
                    'New Busuanga',
                    'Old Busuanga',
                    'Panlaitan',
                    'Quezon',
                    'Sagrada',
                    'Salvacion',
                    'San Isidro',
                    'San Rafael',
                    'Santo Niño',
                ],
                'Cagayancillo' => [
                    'Bantayan',
                    'Calsada',
                    'Convento',
                    'Lipot North',
                    'Lipot South',
                    'Magsaysay',
                    'Mampio',
                    'Nusa',
                    'Santa Cruz',
                    'Tacas',
                    'Talaga',
                    'Wahig',
                ],
                'Coron' => [
                    'Banuang Daan',
                    'Barangay I',
                    'Barangay II',
                    'Barangay III',
                    'Barangay IV',
                    'Barangay V',
                    'Barangay VI',
                    'Bintuan',
                    'Borac',
                    'Buenavista',
                    'Bulalacao',
                    'Cabugao',
                    'Decabobo',
                    'Decalachao',
                    'Guadalupe',
                    'Lajala',
                    'Malawig',
                    'Marcilla',
                    'San Jose',
                    'San Nicolas',
                    'Tagumpay',
                    'Tara',
                    'Turda',
                ],
                'Culion' => [
                    'Balala',
                    'Baldat',
                    'Binudac',
                    'Burabod',
                    'Culango',
                    'De Carabao',
                    'Galoc',
                    'Halsey',
                    'Jardin',
                    'Libis',
                    'Luac',
                    'Malaking Patag',
                    'Osmeña',
                    'Tiza',
                ],
                'Cuyo' => [
                    'Balading',
                    'Bangcal',
                    'Cabigsing',
                    'Caburian',
                    'Caponayan',
                    'Catadman',
                    'Funda',
                    'Lagaoriao',
                    'Lubid',
                    'Lungsod',
                    'Manamoc',
                    'Maringian',
                    'Pawa',
                    'San Carlos',
                    'Suba',
                    'Tenga - tenga',
                    'Tocadan',
                ],
                'Dumaran' => [
                    'Bacao',
                    'Bohol',
                    'Calasag',
                    'Capayas',
                    'Catep',
                    'Culasian',
                    'Danleg',
                    'Dumaran',
                    'Ilian',
                    'Itangil',
                    'Magsaysay',
                    'San Juan',
                    'Santa Maria',
                    'Santa Teresita',
                    'Santo Tomas',
                    'Tanatanaon',
                ],
                'El Nido' => [
                    'Aberawan',
                    'Bagong Bayan',
                    'Barotuan',
                    'Bebeladan',
                    'Bucana',
                    'Buena Suerte Poblacion',
                    'Corong - corong Poblacion',
                    'Mabini',
                    'Maligaya Poblacion',
                    'Manlag',
                    'Masagana Poblacion',
                    'New Ibajay',
                    'Pasadeña',
                    'San Fernando',
                    'Sibaltan',
                    'Teneguiban',
                    'Villa Libertad',
                    'Villa Paz',
                ],
                'Linapacan' => [
                    'Barangonan',
                    'Cabunlawan',
                    'Calibangbangan',
                    'Decabaitot',
                    'Maroyogroyog',
                    'Nangalao',
                    'New Culaylayan',
                    'Pical',
                    'San Miguel',
                    'San Nicolas',
                ],
                'Magsaysay' => [
                    'Alcoba',
                    'Balaguen',
                    'Canipo',
                    'Cocoro',
                    'Danawan',
                    'Emilod',
                    'Igabas',
                    'Lacaren',
                    'Los Angeles',
                    'Lucbuan',
                    'Rizal',
                ],
                'Narra' => [
                    'Antipuluan',
                    'Aramaywan',
                    'Bagong Sikat',
                    'Batang - batang',
                    'Bato - bato',
                    'Burirao',
                    'Caguisan',
                    'Calategas',
                    'Dumagueña',
                    'Elvita',
                    'Estrella Village',
                    'Ipilan',
                    'Malatgao',
                    'Malinao',
                    'Narra',
                    'Panacan',
                    'Panacan 2',
                    'Princess Urduja',
                    'Sandoval',
                    'Tacras',
                    'Taritien',
                    'Teresa',
                    'Tinagong Dagat',
                ],
                'Quezon' => [
                    'Alfonso XIII',
                    'Aramaywan',
                    'Berong',
                    'Calatagbak',
                    'Calumpang',
                    'Isugod',
                    'Maasin',
                    'Malatgao',
                    'Panitian',
                    'Pinaglabanan',
                    'Quinlogan',
                    'Sowangan',
                    'Tabon',
                    'Tagusao',
                ],
                'Rizal' => [
                    'Bunog',
                    'Campong Ulay',
                    'Candawaga',
                    'Canipaan',
                    'Culasian',
                    'Iraan',
                    'Latud',
                    'Panalingaan',
                    'Punta Baja',
                    'Ransang',
                    'Taburi',
                ],
                'Roxas' => [
                    'Abaroan',
                    'Antonino',
                    'Bagong Bayan',
                    'Barangay 1',
                    'Barangay II',
                    'Barangay III',
                    'Barangay IV',
                    'Barangay V Poblacion',
                    'Barangay VI Poblacion',
                    'Caramay',
                    'Dumarao',
                    'Iraan',
                    'Jolo',
                    'Magara',
                    'Malcampo',
                    'Mendoza',
                    'Narra',
                    'New Barbacan',
                    'New Cuyo',
                    'Nicanor Zabala',
                    'Rizal',
                    'Salvacion',
                    'San Isidro',
                    'San Jose',
                    'San Miguel',
                    'San Nicolas',
                    'Sandoval',
                    'Tagumpay',
                    'Taradungan',
                    'Tinitian',
                    'Tumarbong',
                ],
                'San Vicente' => [
                    'Alimanguan',
                    'Binga',
                    'Caruray',
                    'Kemdeng',
                    'New Agutaya',
                    'New Canipo',
                    'Poblacion',
                    'Port Barton',
                    'San Isidro',
                    'Santo Niño',
                ],
                'Sofronio Española' => [
                    'Abo - abo',
                    'Iraray',
                    'Isumbo',
                    'Labog',
                    'Panitian',
                    'Pulot Center',
                    'Pulot Interior',
                    'Pulot Shore',
                    'Punang',
                ],
                'Taytay' => [
                    'Abongan',
                    'Alacalian',
                    'Banbanan',
                    'Bantulan',
                    'Baras',
                    'Batas',
                    'Bato',
                    'Beton',
                    'Busy Bees',
                    'Calawag',
                    'Casian',
                    'Cataban',
                    'Debangan',
                    'Depla',
                    'Libertad',
                    'Liminangcong',
                    'Meytegued',
                    'Minapla',
                    'New Guinlo',
                    'Old Guinlo',
                    'Paglaum',
                    'Paly',
                    'Pamantolon',
                    'Pancol',
                    'Poblacion',
                    'Pularaquen',
                    'San Jose',
                    'Sandoval',
                    'Silanga',
                    'Talog',
                    'Tumbod',
                ]
            ];