Go using AF_UNIX

You can use Unix Domain Socket aka AF_UNIX for your interprocess communication. Previously, It was only available in a Linux/Unix operating system until Microsoft added it in Microsoft Windows in the beginning of Insider build 17063. It offers better throughput and improved security package main import ( "log" "net" "net/http" "os" "os/signal" "syscall" ) func main() { socketPath := "uds.sock" socket, err := net.Listen("unix", socketPath) if err != nil { log....

February 14, 2024
Check JPA Query Type

Check JPA Query Type

I am developing a repository as a service application. An application that let users create their endpoints with queries via a web interface. This application uses either Hibernate or Eclipselink as a JPA provider. The challenge is to check if the supplied user string (query) is a native SQL or a JPQL and that Eclipselink and Hibernate handles this differently, so I decided to wrap it behind this simple checker....

January 28, 2024 · John Pili
using-vue-without-a-build-step.webp

Using Vue without a build step

Background I would like to share my experience using Vue 2 without a build step in my project and factors using this approach. I started experimenting with Vue.js (Vue 2) back in 2020. One of the nice feature of Vue is the ability to use the framework directly into HTML page without a build tool (compilation). This particular feature is the deciding factor why I selected this framework in migrating a jQuery based web application....

October 25, 2023 · John Pili
set-http-request-body-size-in-go.webp

Set HTTP Request Body Size in Go

Use http.MaxBytesReader to limit and control the size HTTP request body. This is a good practice to prevent abuse and save bandwidth. In the example below, I set a 20 bytes HTTP request body size limit. package main import ( "github.com/julienschmidt/httprouter" "io" "log" "net/http" "time" ) func main() { router := httprouter.New() router.HandlerFunc(http.MethodPost, "/", func(w http.ResponseWriter, r *http.Request) { buffer, err := io.ReadAll(http.MaxBytesReader(w, r.Body, 20)) defer r.Body.Close() if err != nil { w....

October 23, 2023 · John Pili
boot-linux-without-a-splash-screen.webp

Boot Linux without a splash screen

If you prefer to boot up your Linux machine with the boot messages rather than the distro splash screen. You can enable that by editing the file /etc/default/grub and set the value of GRUB_CMDLINE_LINUX_DEFAULT to an empty string. Example: GRUB_DEFAULT=0 GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="" GRUB_CMDLINE_LINUX="" After editing the file, execute update-grub to load your configuration into the bootloader. sudo /usr/sbin/update-grub Output of update-grub Generating grub configuration file ....

August 5, 2023 · John Pili
start-a-react-project-without-using-cra.webp

Start a React project without using CRA

Let’s start a React project without using create-react-app (CRA). CRA is a good project starter but for those who wants a complete control over the building process, we will have to use bundler tools like webpack or yarn. Prerequisites React.js knowledge Installed and configures NodeJS Installed node package manager (npm) Steps Using the command-line, let us follow the following steps: Create directories and files mkdir webapp cd webapp Let us continue with our src folder and placeholder files...

May 30, 2023 · John Pili
pragmatic-programmer-its-your-life.webp

The Pragmatic Programmer - It's your life

A sound bite from The Pragmatic Programmer: Your Journey To Mastery, 20th Anniversary Edition (2nd Edition) Interested? You can grab a copy of this book from Amazon. https://www.amazon.com/Pragmatic-Programmer-journey-mastery-Anniversary/dp/0135957052

January 17, 2023 · John Pili
change-your-ssh-server-port-to-reduce-brute-force-attacks.webp

Change your SSH server port to reduce brute force attacks

Reduce SSH brute force attacks by changing your default SSH server (sshd) port from port 22 to a different one. Below is a sshd log example of a brute force attacks. Changing the port You can change the default port by editing the sshd configuration file. sudo nano /etc/ssh/sshd_config Find the line that say #Port. Remove the # symbol and set the port number you prefer. Refer to the image below as reference....

December 27, 2022 · John Pili
rsync-with-different-ssh-port.webp

Rsync with different SSH port

Some Linux servers were security hardened by changing the default SSH port from port 22 to a different port number. To use rsync with a different SSH port, add ‘ssh -p 12345’ in the rsync parameters. Push rsync -azvP -e 'ssh -p 12345' SOURCE USER@HOST:DEST Pull rsync -azvP -e 'ssh -p 12345' USER@HOST:SOURCE DEST

December 26, 2022 · John Pili
golang-with-recaptcha.webp

Golang with reCAPTCHA

Google’s reCAPTCHA is one of the tool we can use to stop malicious internet bots from abusing our web applications. It comes in two versions, reCAPTCHA v2 and v3. Version 3 uses a score-based method with no user interaction. Version 2 uses a checkbox that will require users to answer a question. In this tutorial we will focus on reCAPTCHA v2. Prerequisite This tutorial requires the following: Registered Google webmaster account Domain registered property in Google webmaster Created Google reCAPTCHA account – https://www....

December 18, 2022 · John Pili