Skip to content

Instantly share code, notes, and snippets.

View abiiranathan's full-sized avatar
🎯
Focusing

Dr. Abiira Nathan abiiranathan

🎯
Focusing
  • Yo Medical Files(U) Ltd
  • Uganda
  • 06:49 (UTC +03:00)
  • X @abiiranathan
View GitHub Profile
@abiiranathan
abiiranathan / dotfile.sh
Created April 26, 2023 12:14
Backup dotfiles, ssh keys, gnupg keys, zsh config, Vscode Settings. Restore with a single command.
#!/bin/bash
# Define the backup directory
BACKUP_DIR="$HOME/dotfile-backup"
get_vscode_settings_path() {
case "$OSTYPE" in
linux-gnu*)
# Linux
if [ -n "$WSL_DISTRO_NAME" ]; then
@abiiranathan
abiiranathan / install-go.sh
Last active May 5, 2023 13:35
Bash script to install the latest version of go or update Go to the latest version. Caches downloads so you won't do work twice.
#!/bin/bash
# This script installs the latest version of Go on your system.
# _________ _ _______ _________ _______ _ _ _______ _______
# \__ __/( ( /|( ____ \\__ __/( ___ )( \ ( \ ( ____ \( ___ )
# ) ( | \ ( || ( \/ ) ( | ( ) || ( | ( | ( \/| ( ) |
# | | | \ | || (_____ | | | (___) || | | | | | | | | |
# | | | (\ \) |(_____ ) | | | ___ || | | | | | ____ | | | |
# | | | | \ | ) | | | | ( ) || | | | | | \_ )| | | |
# ___) (___| ) \ |/\____) | | | | ) ( || (____/\| (____/\ | (___) || (___) |
# \_______/|/ )_)\_______) )_( |/ \|(_______/(_______/ (_______)(_______)
@abiiranathan
abiiranathan / Makefile
Created April 4, 2023 15:59
Same make file to simply compile and run C projects.
CC = gcc
CFLAGS = -Wall -Wextra -std=c11 -O2
LDFLAGS = -lcurl -ljansson -ldotenv
SRCDIR = src
OBJDIR = obj
BINDIR = bin
DATADIR = data
SRC = $(wildcard $(SRCDIR)/*.c)
@abiiranathan
abiiranathan / install-docker.sh
Last active March 23, 2023 07:49
Install docker on Ubuntu
#!/bin/bash
sudo apt update -y
sudo apt-get install ca-certificates curl gnupg lsb-release
# Add Docker’s official GPG key
sudo mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
@abiiranathan
abiiranathan / ast_parsing.go
Created March 16, 2023 08:10
Parsing AST in go
package schemagen
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"strings"
)
@abiiranathan
abiiranathan / gh-gpg-keygen.sh
Last active March 9, 2023 18:03
Generate GPG Keys for Github to securely sign your commits.
#!/bin/bash
gpg --full-generate-key
key_id=$(gpg --list-secret-keys --keyid-format=long | grep sec | awk '{print $2}' | awk -F '/' '{print $2}')
echo "Key ID: $key_id"
gpgKey=$(gpg --armor --export $key_id)
echo $gpgKey
@abiiranathan
abiiranathan / password_auth.sql
Created January 26, 2023 06:48
Hashing and Verifying passwords with postgresql extension pgcrypto
```sql
-- Create the extension if it doesn't exist
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
-- Create table
CREATE TABLE IF NOT EXISTS users(
id serial not null primary key,
username text not null unique,
password text not null,
@abiiranathan
abiiranathan / goupdate.sh
Created November 22, 2022 10:42
go installation script
#!/bin/bash
ARCH="amd64"
LATEST_VERSION="go1.19.3"
# "$(curl -sL https://golang.org/VERSION?m=text)"
ZIP_FILE="${LATEST_VERSION}.linux-${ARCH}.tar.gz"
if [ -f "$ZIP_FILE" ]; then
echo "go version $LATEST_VERSION already downloaded"
@abiiranathan
abiiranathan / qtssl.cpp
Created August 12, 2022 07:11
Loading TLS certificates in Qt5
#include <qcoreapplication.h>
#include <qfile.h>
#include <qnetworkaccessmanager.h>
#include <qnetworkconfiguration.h>
#include <qnetworkproxy.h>
#include <qnetworkreply.h>
#include <qnetworkrequest.h>
#include <qsslcertificate.h>
#include <qsslconfiguration.h>
#include <qsslkey.h>
@abiiranathan
abiiranathan / poly.c
Created May 6, 2022 10:32
C program to solve polynomials using Horner's algorithm
// Polynomial evaluation with Horner's method
#include <stdio.h>
#include <stdlib.h>
// poly is an array of coefficients
// n is the degree of the polynomial + 1
// x is the value at which to evaluate the polynomial
//
// Returns value of poly[0]x(n-1) + poly[1]x(n-2) + .. + poly[n-1]