Skip to content

Instantly share code, notes, and snippets.

View abiiranathan's full-sized avatar
🎯
Focusing

Dr. Abiira Nathan abiiranathan

🎯
Focusing
View GitHub Profile
//#include "stdafx.h"
#include <sodium.h>
#include <iostream>
using namespace std;
#define MESSAGE (const unsigned char *) "test"
#define MESSAGE_LEN 4
#define CIPHERTEXT_LEN (crypto_box_SEALBYTES + MESSAGE_LEN)
@abiiranathan
abiiranathan / pushtags
Created May 17, 2023 12:36
Automatically create and push tag to remote with git.
[alias]
pushtags = "!sh -c 'if [ -z \"$1\" ]; then echo \"No tag name provided\"; exit 1; fi; tag_name=\"$1\"; git tag -a \"$tag_name\" -m \"Tag: $tag_name\" && git push origin \"$tag_name\"' \"\""
@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"