Skip to content

Instantly share code, notes, and snippets.

View abiiranathan's full-sized avatar
🎯
Focusing

Dr. Abiira Nathan abiiranathan

🎯
Focusing
View GitHub Profile
@abiiranathan
abiiranathan / fileserver.go
Created April 12, 2022 09:48
A file server written in go
package main
import (
"flag"
"log"
"net/http"
"path/filepath"
)
var (
@abiiranathan
abiiranathan / age.c
Last active May 6, 2022 10:28
A C program to calculate age from birth date.
// prints age given date of birth in form dd/mm/yyyy
// compile with: gcc age.c -o age
// Author: Dr. Abiira Nathan
// Date: May, 2022
// Version: 1.0
// License: MIT License
// Copyright (c) 2020 Dr. Abiira Nathan
#include <stdio.h>
#include <time.h>
@abiiranathan
abiiranathan / fracadder.c
Created May 6, 2022 10:30
fraction adder is a C program that add 2 fractions and prints the result in a reduced form or mixed fraction form.
// program to add two fractions and print results
// compile with gcc -o fracadder fracadder.c
// run with ./fracadder
// Author: Dr. Abiira Nathan J.K
// Date: May, 2022
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[])
@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]
@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 / 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 / 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 / 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 / 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 / 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