Friday, August 26, 2022

Python and MySQL query using Prepared Statement

so i just found out that mysql-connector for python from Oracle have a prepared-statement subclass just like their JAVA counterpart.

and here i am using PyMySQL for years like an idiot

Tuesday, August 9, 2022

animated progress on terminal

i always interested with how some shell script is capable to animate their console output, but never put any effort to learn until lately. this is a simple one

Thursday, August 4, 2022

Secure your god damn web...

open this link:

https://ssl-config.mozilla.org/ 

copy the given example to your web server.. make some adjustment to your configuration.

use this link to test your new configuration.

https://observatory.mozilla.org

Wednesday, August 3, 2022

PYTHON: slice a string by Indices

RASPBERRY PI: Compiling kernel for long BLE advertising timings

just follow this for the compiling process :

https://www.raspberrypi.com/documentation/computers/linux_kernel.html

before compiling the kernel open include/net/bluetooth/hci.h with any text editor and find this line

then replace it with

Saturday, July 30, 2022

NGINX: reverse proxy for python websockets

the websockets can be accessed using ws://{ip-address}:11000.

or maybe using subdirectory on SSL enabled domain

the url now is wss://{domain-name}/ws

Friday, July 29, 2022

Sunday, July 17, 2022

INDONESIA'S VERY OWN CHAT APP (AN IDEA)

There is news in Indonesia about the plan to block WhatsApp and some other services for six days. The plan is to force the company behind them to register their services to KOMINFO during the ban or risk their services being banned permanently.


With the digitalization of the Indonesian citizen registry for the last decade, they should've been able to make their own chat app using NIK as an id number. The users can register the account using their registered SIM card or simply use NFC to scan the id card to automatically log in to the app.

 

This way the government can proactively protect their citizen from scams that getting more rampant over the last few years, especially during the pandemic. The government can verify the people behind an id and protect businesses and consumers so they can do their business online with peace of mind. And they can also create more jobs and business opportunities as a government-based public company.

Friday, July 15, 2022

MIKROTIK : reset usb modem

create the script to cut power to USB port for 5s

/system script add name=reset_usb owner=admin dont-require-permissions=yes policy=read,write source="/system routerboard usb power-reset bus=0 duration=5s"

create a netwatch to ping 8.8.8.8 or any public ip, that will run in 5min interval, with 5s timeout and add the down-script for when the test failed

/tool netwatch add host=8.8.8.8 interval=300s timeout=5s down-script=reset_usb

Thursday, July 14, 2022

converting NMEA coordinate to standard decimal

for every GPS module I've been using till now I usually use RMC to get everything. the standard GPRMC/GNRMC looks like this.
$GPRMC,220516,A,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*70
this is the breakdown of segments after the header.
      1   220516     Time Stamp
      2   A          validity - A-ok, V-invalid
      3   5133.82    current Latitude
      4   N          North/South
      5   00042.24   current Longitude
      6   W          East/West
      7   173.8      Speed in knots
      8   231.8      True course
      9   130694     Date Stamp
      10  004.2      Variation
      11  W          East/West
      12  *70        checksum
other than the coordinates data, everything is pretty straightforward. But now I need to convert the coordinate into standard format that's being used by google maps or any other GIS provider. refer to this

and this is how to do it

Wednesday, July 13, 2022

shared memory in python multithreading

pretty basic just call the variable as a global for each thread

shared memory in python multiprocessing

when running a multiprocessing sometimes there is a need to share some variable across processes

the simplest way is by using multiprocessing.Value or multiprocessing.Array

use multiprocessing.Value if the variable a simple numeric (int/double) variable, just replace 'i' (integer) into 'd' (double) as you need.

use 'c' in multiprocessing.Array if the the data is a string or a byte, for other types refer to ctypes or array module

Tuesday, July 12, 2022

is HTML & CSS a programming language??

NO IT IS NOT.. MOVE ON... GET OVER IT.. DO SOME REAL PROGRAMMING.. 

🤪🤪🤪🤪🤪

pyenv installation for raspberry pi (Bullseye)

Let start by installing all the necessary libraries.
sudo apt install -y git openssl libssl-dev \
    libbz2-dev libreadline-dev libsqlite3-dev \
    libffi-dev liblzma-dev
use pyenv-installer script to make our live a lil' bit easier.
curl https://pyenv.run | bash
edit your ~/.bashrc, add this 3 lines at the end of the file. what it does? this 3 lines is going to add pyenv executable to the environment PATH of the shell session and to enable autocomplete function

restart the shell session by reopening the terminal session or reload the session using this command
source ~/.bashrc

install any python version you wanted, use this command to list all available python versions

pyenv install -l
 i.e. installing python version 3.10.
pyenv install 3.10.5
it's always a good idea to create individual venv for each of your projects, i.e. making a venv named project1 based of python 3.10.5
pyenv virtualenv 3.10.5 project1
activate the venv for this shell session
pyenv shell project1
to confirm which version of the venv currently active
pyenv version
you can make the shell automagically enabled for when changing directory to specific projects folder.
cd ~/project_folder
pyenv local project1
or just enable it globally
pyenv global project1

Monday, July 11, 2022

BLOGGING IN 2022

well i am back blogging in 2022... it's been 12 years since my old blog domain expires which i am not gonna tell you the name.. LOL. 

does people still blogging anyway.. most people i know who still writing are switching to medium nowadays, which i didn't particularly like. they seems..... lack personality..

anyway here i am now.. today.. STILL ALIVE !!!.. this last 2.5 years of pandemic hitting me hard last year. i didn't know if i am going to survive it, but thanks god (ALHAMDULILLAH)..

so what am i gonna do with this blog?? probably doing some documentation for anything from job related or just anything i am interested at the moment.

i think that is all i have to say for now.. so yeah... see you tomorrow for my first post.. feeling sleepy.. gonna hit the bed now.. 

〜( ̄▽ ̄〜)(〜 ̄▽ ̄)〜