embed-resources-in-go.webp

Embed Resources in Go

The go:embed feature was introduce in Go 1.16. It lets you embed resources into the compiled application. Prior to version 1.16, developers uses external tooling to do this. With go:embed you can embed images, webpages, email templates, predefined SQL statements or an entire directory. That’s neat! Usage Examples Embedding a text file in a string //go:embed version.txt var version string Embedding a binary file //go:embed product-catalog.pdf var catalog []byte Embedding a directory filesystem //go:embed template/* var templateFS fs....

December 18, 2022
active-directory-useraccountcontrol-flags_2.webp

Active Directory userAccountControl flags

I was creating an Active Directory (AD) security auditing tool in Go and Python when I stumbled upon the UserAccountControl flags. This attribute can hold multiple statuses like ACCOUNTDISABLE, NORMAL_ACCOUNT, or DONT_EXPIRE_PASSWORD. It uses a bit-field; a bit-field is a group of bits with each bit representing a value. It is an efficient way of handling multiple statues of a record. A tool that helps identify the property flags. Since a bit-field can hold a range of values, I need a tool that can help me look up the value it represents....

December 2, 2022 · John Pili
Python batch file MD5 checksum generator and checker

Python batch file MD5 checksum generator and checker

I am backing-up a large number of files to another computer when this idea came to me to write a Python script that generate and validate batch MD5 checksum. Feel free to customize the script according to your needs.

March 2, 2022 · John Pili
python-rename-files-that-begins-with-matching-string.webp

Python rename files that begins with matching string

Do you want to rename a number of files that begins with a specific name or string? I wrote this small Python script that does that. Of course, you can also do this with Bash or Powershell. I hope somebody might find it useful. import os import sys from os import path parameters = sys.argv[1:] if len(parameters) == 0: print(f"usage: {sys.argv[0]} <startswith-string>") sys.exit(0) if len(parameters) > 0: for file in os....

February 27, 2022 · John Pili
fix-raspberry-pi-ssh-freezing-issue.webp

Fix Raspberry Pi SSH freezing issue

If your SSH connection to your Raspberry Pi is freezing or unstable it could be because of OpenSSH TOS (Type of Service). To fix this, add IPQoS cs0 cs0 in the sshd configuration file. Open your /etc/ssh/sshd_config and add IPQoS cs0 cs0 at the bottom of the file. Please refer to the example configuration file below. # $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $ # This is the sshd server system-wide configuration file....

November 9, 2021 · John Pili
setup-static-ip-address-in-debian-linux.webp

Setup Static IP Address in Debian Linux

Setting up static IP address in Debian Linux is easy. In this simple guide, I will be configuring the IP address using the old way (ifconfig) and requires that you have system administration rights to do the following steps: Open the network interface file with the following command: sudo vi /etc/network/interfaces Once opened you might see something similar like this Your interface label might be different from the example but in this case we are interested in making interface ens33 to have a static IP....

June 12, 2021 · John Pili
Allow user or group to run sudo on specific applications in Linux

Allow user or group to run sudo on specific applications in Linux

In some situation, we may want to delegate a sudo capability to Linux users or groups without completely giving them full access to the operating system. We can achieve this by using User_Alias inside the /etc/sudoers configuration file. I will share the simple settings that I used in my RHEL server. ## Sudoers allows particular users to run various commands as ## the root user, without needing the root password. ## ## Examples are provided at the bottom of the file for collections ## of related commands, which can then be delegated out to particular ## users or groups....

May 2, 2021 · John Pili
Remove Source Path From Go's Panic Stack Trace

Remove Source Path From Go's Panic Stack Trace

I would like to share the Golang’s build flag to remove the source path (GOPATH) from panic stack trace output. In production environments or commercial projects it is sometimes not ideal to display the source path because of privacy, security or other reasons. Below is an example of a stack trace output that reveals the GOPATH location which is located inside the developer’s home directory. In this case /home/johnpili/go/ panic: Aw, snap goroutine 1 [running]: main....

February 19, 2021 · John Pili
Generate text to image in Go

Generate text to image in Go

In this blog post, I’ll share how to generate text to image in Go programming language (Golang). I have a previous and similar blog post using Python. You can check that post here I created this application to generate images of my Linux configuration files or source code snippets and share it via WhatsApp or other messaging platforms. Another reason is to generate featured images for my social media posts in Twitter, Facebook or LinkedIn....

February 12, 2021 · John Pili
create-a-linux-systemd-entry-for-your-application.webp

Create a Linux systemd entry for your application

Systemd is a Linux software suite that handles system services (daemon) and timers; it enables you to start, stop and restart your application using systemctl command. It can also start your application during operating systems boot-up sequence. Note that you will need to have root or sudo privileges for this operation. To create a systemd unit file, create a service file inside the directory /etc/systemd/system/. The filename must end with ....

January 4, 2021 · John Pili