My Projects

Here is some sample code, along with links to my projects posted on GitHub


Profiler

A program profiler written in C++ as the last project of my abstract data structures class. I cannot take credit for all the code included as some of the basic stuff was written by my professor, Dr. Jonathan I. Maletic, but I did write the algorithms for searching and inserting the necessary lines of code to profile a C++ program.

                                    
/////////////////////////////////////////////////////////////////////
// Searches an AST and returns a vector of list iterators pointing
// to the AST children that have a tag matching that specified
// REQUIRES: A vector of list iterators
//
std::vector::iterator>& AST::deepScan(std::string searchTag, std::vector::iterator>& vecToPopulate) {
    std::list::iterator ptr = child.begin();
    if (isStopTag(tag)){
        return vecToPopulate;
    }
    while (ptr != child.end()) {
        (*ptr)->deepScan(searchTag, vecToPopulate);
        if ((*ptr)->tag == searchTag) {
            vecToPopulate.push_back(ptr);
        }
        ++ptr;
    }
    return vecToPopulate;
}

/////////////////////////////////////////////////////////////////////
//  Adds in the includes and profile variables in a main file.
//
void AST::mainHeader(const std::vector& profileName) {

    std::list::iterator ptr = child.begin();
    while (ptr != child.end()) {
        if ((*ptr)->tag == "function") {
            break;
        }
        ++ptr;
    }

    /////////////////////////////////////////////////////////////////////
    // Create include directive
    AST* cpp_include = new AST(token, "\n\n// Include header for profiling\n#include \"profile.hpp\"\n");
    child.insert(ptr, cpp_include);
    /////////////////////////////////////////////////////////////////////
    // Create profile declaration for each in profileName
    for (unsigned long i = 0; i < profileName.size(); ++i) {
        std::string profName = profileName[i];
        std::string profileDec = "profile " + profName + "(\"";
        unsigned int lastUnderscoreIndex = 0;
        for (unsigned int j = 0; j < profName.size(); ++j) {
            if (profName[j] == '_') lastUnderscoreIndex = j;
        }
        profName[lastUnderscoreIndex] = '.';
        profileDec += profName + "\");\n";
        if (i == profileName.size() - 1) profileDec += "\n";
        AST* profNode = new AST(token, profileDec);

        child.insert(ptr, profNode);
    }

}

/////////////////////////////////////////////////////////////////////
//  Adds in the includes and profile variables for non-main files
//
void AST::fileHeader(const std::string& profileName) {

    std::list::iterator ptr = child.begin();
    while (ptr != child.end()) {
        if ((*ptr)->tag == "function") {
            break;
        }
        ++ptr;
    }

    /////////////////////////////////////////////////////////////////////
    // Create include directive
    AST* cpp_include = new AST(token, "\n\n// Include header for profiling\n#include \"profile.hpp\"\n");
    child.insert(ptr, cpp_include);
    /////////////////////////////////////////////////////////////////////
    // Create profile declaration for each in profileName
    std::string profName = profileName;
    std::string profileDec = "extern profile " + profName + ";\n\n";
    AST* profNode = new AST(token, profileDec);

    child.insert(ptr, profNode);

}
                                    
                                

GitHub Link

Document Editor

The first true JavaScript app I ever wrote. Needs some work, and I intend to perfect it, but for now serves as a basic document editor that utilizes Node.js, React.js, and Quill to work.

                                    
import React from "react"
import { useCallback } from "react"
import Quill from "quill"
import "quill/dist/quill.snow.css"
const TOOLBAR_OPTIONS = [
    [{ header: [1, 2, 3, 4, 5, 6, false]}],
    [{ font: [] }],
    [{ list: "ordered"}, { list: "bullet" }],
    ["bold", "italic", "underline"],
    [{ color: [] }, { background: [] }],
    [{ script: "sub" }, { script: "super" }],
    [{ align: [] }],
    ["image", "blockquote", "code-block"],
    ["clean"],
]
export default function TextEditor() {
    const wrapperRef = useCallback((wrapper) => {
        if (wrapper == null) return
        wrapper.innerHTML = "";
        const editor = document.createElement('div');
        wrapper.append(editor);
        new Quill(editor, {theme: "snow", modules: {
            toolbar: TOOLBAR_OPTIONS
        }})
    }, [])
    return 
} 
                                    
                                

GitHub Link

While it won't function if you simply want to edit and print a document the way it is embedded here, you can also simply demo the app down below or view it on its own page here.

Space Game

As you can probably tell, I'm not great at coming up with titles, but this is a simple space-themed game made using the Pygame library in Python.

                                
# The game
def main():
    # Begin the music!
    pygame.mixer.music.load(os.path.join("assets", "space_game_music.wav"))
    pygame.mixer.music.play(-1)
    run = True
    FPS = 60
    level = 0
    lives = 5
    # Create fonts
    main_font = pygame.font.SysFont("comicsans", 50)
    powerup_font = pygame.font.SysFont("comicsans", 40)
    lost_font = pygame.font.SysFont("comicsans", 60)
    # List of enemies
    enemies = []
    wave_length = 0
    # Relevant velocities
    enemy_vel = 1
    player_vel = 5
    laser_vel = 5
    # List of powerups
    powerups = []
    num_powerups = 0
    fast_timer = 0
    rapid_timer = 0
    clock = pygame.time.Clock()
    # Create player
    player = Player(300, 630)
    lost = False
    lost_count = 0
    
    paused = False
    pause_delay = 0
    nuke_deployed = False
    nuke_deployed_notification = 0
    nuke_enemies = False
    def redraw_window():
        # Draw BG
        WIN.blit(BG, (0,0))
        # Draw text
        lives_label = main_font.render(f"Lives: {lives}", 1, (255, 255, 255))
        level_label = main_font.render(f"Level: {level}", 1, (255, 255, 255))
        WIN.blit(lives_label, (10, 10))
        WIN.blit(level_label, (WIDTH - level_label.get_width() - 10, 10))
        # Draw powerups
        for powerup in powerups:
            powerup.draw(WIN)
        # Draw player
        player.draw(WIN)
        # If the player lost put a 
        if lost == True:
            lost_label = lost_font.render("You Lost!", 1, (255, 255, 255))
            WIN.blit(lost_label, (WIDTH/2 - lost_label.get_width()/2, 350))
            pygame.mixer.music.pause()
        # If paused post a pause screen
        if paused == True:
            pause_label = lost_font.render("Paused. Press enter to continue...", 1, (255, 255, 255))
            WIN.blit(pause_label, (WIDTH/2 - pause_label.get_width()/2, 350))
        # Notfiy player if they have nuke ready
        if player.nuke == True:
            nuke_label = main_font.render("NUKE READY", 1, (255,255,255))
            WIN.blit(nuke_label, (WIDTH/2 - nuke_label.get_width()/2, 10))
        # Notify of deployed nuke
        if nuke_deployed == True:
            nuke_deployed_label = main_font.render("NUKE DEPLOYED!", 1, (255,255,255))
            WIN.blit(nuke_deployed_label, (WIDTH/2 - nuke_deployed_label.get_width()/2, 10))
        # Powerup sidebar
        if player.shield:
            shield_label = powerup_font.render("Shield", 1, (255, 255, 255))
        else:
            shield_label = powerup_font.render("Shield", 1, (100, 100, 100))
            
        if player.rapid:
            rapid_label = powerup_font.render("Rapid Fire", 1, (255, 255, 255))
        else:
            rapid_label = powerup_font.render("Rapid Fire", 1, (100, 100, 100))
            
        if player.fast:
            fast_label = powerup_font.render("Fast Movement", 1, (255, 255, 255))
        else:
            fast_label = powerup_font.render("Fast Movement", 1, (100, 100, 100))
        WIN.blit(shield_label, (10, 50))
        WIN.blit(rapid_label, (10, 75))
        WIN.blit(fast_label, (10, 100))
        # Draw enemies
        for enemy in enemies:
            enemy.draw(WIN)
        pygame.display.update()
                                
                            

GitHub Link

Command-Line Poker

A personal project of mine to test my understanding of C++, specifically with objects, inheritance, and data types, this is a mostly-finished program that displays your cards and allows you to bet against a bot in a game of poker.

                                
void player::evaluate() {
    bool twoPair = false;
    bool onePair = false;
    bool ofAKind3 = false;
    bool ofAKind4 = false;
    bool straight = false;
    bool flush = false;
    bool royal = false;
    // Sort from lowest to highest
    std::vector sortedValues;
    for (int i = 0; i < HAND_SIZE; i++) sortedValues.push_back(hand[i].value);
    std::sort(sortedValues.begin(), sortedValues.begin() + 5);
    // Check for a straight
    int straightCount = 0;
    for (int i = 0; i < HAND_SIZE - 1; i++) {
        if (sortedValues[i] == sortedValues[i + 1] - 1) {
            straightCount++;
        }
    }
    if (straightCount == 4) straight = true;
    // Check for a royal
    if (sortedValues[0] == 10 && straight) royal = true;
    // Check for flush
    int suitCount = 0;
    for (int i = 0; i < HAND_SIZE - 1; i++) {
        if (hand[i].suit == hand[i + 1].suit) suitCount += 1;
    }
    if (suitCount == 4) flush = true;
    // Check for "-of-a-kind" hand
    int faceMatches[HAND_SIZE];
    for (int i = 0; i < HAND_SIZE; i++) faceMatches[i] = 0;
    for (int i = 0; i < HAND_SIZE; i++) {
        for (int j = i; j < HAND_SIZE; j++) {
            if (hand[i].face == hand[j].face) {
                faceMatches[i] = faceMatches[i] + 1;
            }
        }
    }
    // Check for full house
    for (int i = 0; i < HAND_SIZE; i++) {
        if (faceMatches[i] == 3) ofAKind3 = true;
    }
    // Count the number of pairs
    int pairCount = 0;
    for (int i = 0; i < HAND_SIZE; i++) {
        if (faceMatches[i] == 2) pairCount++;
    }
    maxInfo maxInfo = max(faceMatches, HAND_SIZE);
    assignHighest();
    if (pairCount == 2) twoPair = true;
    else if (maxInfo.maxVal == 2) onePair = true;
    else if (maxInfo.maxVal == 3) ofAKind3 = true;
    else if (maxInfo.maxVal == 4) ofAKind4 = true;
    if (straight && flush && royal) { score = (36608398 * highVal); handRank = "Royal Flush"; }
    else if (straight && flush) { score = (5229771 * highVal); handRank = "Straight Flush"; }
    else if (ofAKind4) { score = (747111 * hand[maxInfo.maxIndex].value); handRank = "4 of a Kind"; }
    else if (twoPair && ofAKind3) { score = (106730 * highVal); handRank = "Full House"; }
    else if (flush) { score = (15247 * highVal); handRank = "Flush"; }
    else if (straight) { score = (2178 * highVal); handRank = "Straight"; }
    else if (ofAKind3) { score = (311 * hand[maxInfo.maxIndex].value); handRank = "3 of a Kind"; }
    else if (twoPair) {
        int temp = 0;
        for (int i = 0; i < HAND_SIZE; i++) {
            if (faceMatches[i] == 2) temp += hand[i].value;
        }
        score = (23 * temp); 
        handRank = "Two Pair";
    }
    else if (onePair) { score = (8 * hand[maxInfo.maxIndex].value); handRank = "One Pair"; }
    else {
        score = highVal;
        handRank = "High Card";
    }
} 
                                
                            

GitHub Link

Apache Log Parser

A class project where we create and utilize a custom string class in order to parse apache logs and format the data as well as extract data such as a list of all hosts and total bytes transferred.

                                
if (vec.size() == 10)
{
    bool noEmpties = true;
    for (size_t i = 0; i < vec.size(); i++)
    {
        if (vec[i] == '\0' || vec[i] == ' ') noEmpties = false;
    }
    if (noEmpties) {
        valid = true;
        host = vec[0];
        //Extract day
        day = vec[3].substr(1, vec[3].findch(0, '/') - 1);
        //Extract month
        int offset = vec[3].findch(0, '/');
        month = vec[3].substr(offset + 1, vec[3].findch(offset + 1, '/') - 1);
        //Extract year
        offset = vec[3].findch(offset + 1, '/');
        yearStr = vec[3].substr(offset + 1, vec[3].findch(0, ':') - 1);
        //Convert year to int
        year = string_to_int(yearStr);
        //Extract hour
        offset = vec[3].findch(0, ':');
        hourStr = vec[3].substr(offset + 1, vec[3].findch(offset + 1, ':') - 1);
        //Convert hour to int
        hour = string_to_int(hourStr);
        //Extract minute
        offset = vec[3].findch(offset + 1, ':');
        minuteStr = vec[3].substr(offset + 1, vec[3].findch(offset + 1, ':') - 1);
        //Convert minute to int
        minute = string_to_int(minuteStr);
        //Extract second
        offset = vec[3].findch(offset + 1, ':');
        secondStr = vec[3].substr(offset + 1, vec[3].length());
        //Convert second to int
        second = string_to_int(secondStr);
        //Extract request
        request = vec[5].substr(vec[5].findch(0, '"'), vec[5].length()) + ' ' + vec[6] + ' ' + vec[7].substr(0, vec[7].findch(0, '"'));
        //Extract status
        status = vec[8];
        //Extract number_of_bytes
        numBytesStr = vec[9];
        if (numBytesStr == '-') numBytesStr = '0';
        //Convert number_of_bytes to int
        number_of_bytes = string_to_int(numBytesStr);
        //Make assignments to date
        date = Date(day, month, year);
        //Make assignments to time
        time = Time(hour, minute, second);
    }
}
else if (vec.size() < 10) valid = false;
} 
                                
                            

GitHub Link

Links To The Rest

Since this webpage would quickly become a bit unwieldy if I were to include samples from each of my projects here are the links to the ones I didn't include here

Carbon Map

A python script that uses data files downloaded from online to create an interactive map of the top 500 cities in terms of carbon emissions and provide information and links about each city such as their population, total carbon footprint, and carbon footprint per capita.

GitHub Link

Command-Line-Dictionary

My first project attempted in Python. It's a basic dictionary utilizing a json file containing words and their definitions in key-value pairs which displays neatly formatted defintions and has the ability to recommend closest-matching words in case of a misspelling.

GitHub Link

This Website

This website has its own GitHub repository as it is hosted by GitHub Pages.

GitHub Link