From d2f297862e2d72c6618426b2515660a3c2f3ad8e Mon Sep 17 00:00:00 2001 From: Josh Ashton Date: Mon, 12 Feb 2024 10:17:44 -0700 Subject: [PATCH] cleanup --- cast | 2 - mkmp3 | 16 ----- paint | 3 - src/goto.c | 73 ------------------- src/mark.c | 86 ---------------------- src/newproject.c | 183 ----------------------------------------------- 6 files changed, 363 deletions(-) delete mode 100755 cast delete mode 100755 mkmp3 delete mode 100755 paint delete mode 100644 src/goto.c delete mode 100644 src/mark.c delete mode 100644 src/newproject.c diff --git a/cast b/cast deleted file mode 100755 index b8817b5..0000000 --- a/cast +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/zsh -xrandr --auto --output DP1 --mode 2560x1440 diff --git a/mkmp3 b/mkmp3 deleted file mode 100755 index ed54aad..0000000 --- a/mkmp3 +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/zsh - -TARGET=$1 - -if [[ -e $TARGET.mkv ]]; then - ffmpeg -i $TARGET.mkv -n $TARGET.mp3 - rm $TARGET.mkv -elif [[ -e $TARGET.webm ]]; then - ffmpeg -i $TARGET.webm -n $TARGET.mp3 - rm $TARGET.webm -elif [[ -e $TARGET.mp4 ]]; then - ffmpeg -i $TARGET.mp4 -n $TARGET.mp3 - rm $TARGET.mp4 -else - echo "file not found" -fi diff --git a/paint b/paint deleted file mode 100755 index eb5b940..0000000 --- a/paint +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/zsh - -python ~/dev/research/python.playground/gui/canvas.py diff --git a/src/goto.c b/src/goto.c deleted file mode 100644 index cd679b6..0000000 --- a/src/goto.c +++ /dev/null @@ -1,73 +0,0 @@ -#include -#include -#include -#include -#include - -/* -void error() { - printf("\nImproper usage: goto[ keyword ]\n" - " Usage:\n" - " goto downloads\n" - " goto school\n" - " goto portfolio\n" - " goto -h\n" - " goto --help" - ); -} - -void help() { - printf("\nQuickly navigate to saved bookmarks in the terminal.\n" - " Usage:\n" - " goto downloads\n" - " goto school\n" - " goto portfolio\n" - " goto -h\n" - " goto --help" - ); -} -*/ -void validateDir(char input[]) { - //char * bookmarksFile = strcat(getenv("HOME"), "/.bookmarks"); - char * bookmarksFile = "/home/jashton/.bookmarks"; - FILE * f = fopen(bookmarksFile, "r"); - - // Unable to access file. - if(f == NULL) { - printf("Error accessing file located at %s.\n", bookmarksFile); - return; - } - else { - char cwd[PATH_MAX]; - if(getcwd(cwd, sizeof(cwd)) != NULL) { - printf("cwd: %s\n", cwd); - } - - char *line = NULL; - size_t len = 0; - ssize_t read; - - while((read = getline(&line, &len, f)) != -1) { - printf("%s", line); - if(strstr(line, input) != NULL) { - printf("%s", line); - chdir(line); - return; - } - } - } -} - -int main(int argc, char *argv[]) { - - // Invalid number of arguments. - if(argc != 2) { - //error(); - printf("error"); - return 1; - } - - // Display help. - else if(strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) printf("help"); - else validateDir(argv[1]); -} diff --git a/src/mark.c b/src/mark.c deleted file mode 100644 index e75e4dc..0000000 --- a/src/mark.c +++ /dev/null @@ -1,86 +0,0 @@ -#include -#include -#include -#include -#include - -// Displays error message upon improper usage. -void error() { - printf("\nImproper usage: mark { -ls | -rm [ keyword(s) ] }\n" - " Usage:\n" - " mark\n" - " mark -ls\n" - " mark -rm [ keyword ]\n" - " mark -h\n" - " mark --help" - ); -} - -// Displays help message. -void help() { - printf("\nCreate and manage persistent bookmarks in the terminal.\n" - "Usage:\n" - " mark\n" - " mark -ls\n" - " mark -rm [ keyword ]\n" - " mark -h\n" - " mark --help" - ); -} - -// Lists all bookmarks in file. -void list(FILE * f) { - int c; - printf("Bookmarks:\n"); - while(1) { - c = fgetc(f); - if(feof(f)) break; - printf("%c", c); - } -} - -// Removes a bookmark from the file. -void removeMark(FILE * f, char *argv[]) { - printf("remove mark function not implemented. received input to remove: %s.", argv[2]); // TODO: Need to implement. -} - -int main(int argc, char *argv[]) { - char * bookmarksFile = strcat(getenv("HOME"), "/.bookmarks"); - FILE * f = fopen(bookmarksFile, "a+"); - - // Unable to access file. - if(f == NULL) { - printf("Error accessing file located at %s.", bookmarksFile); - return 1; - } - - // Invalid number of arguments. - else if(argc > 2 && strcmp(argv[1], "-rm") != 0) { - error(); - return 1; - } - - // Append the current directory to the bookmarks file. - else if(argc == 1) { - char cwd[PATH_MAX]; - fprintf(f, "\n%s", getcwd(cwd, sizeof(cwd))); - printf("Successfully bookmarked %s.", cwd); - } - - // Display help. - else if(strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) help(); - - // List bookmarks. - else if(strcmp(argv[1], "-ls") == 0) list(f); - - else if(strcmp(argv[1], "-rm") == 0) removeMark(f, argv); - - // Invalid argument. - else { - error(); - return 1; - } - - fclose(f); - return 0; -} diff --git a/src/newproject.c b/src/newproject.c deleted file mode 100644 index ddec09e..0000000 --- a/src/newproject.c +++ /dev/null @@ -1,183 +0,0 @@ -#include -#include -#include -#include -#include - -const int numTypes = 8; -int type; -char name[25]; - -const char *types[8]; - -int error() { - printf("Improper usage. Try:"); - - printf("\n\nnewproject { language }"); - printf("\n newproject"); - printf("\n newproject c"); - printf("\n newproject -h"); - printf("\n newproject --help"); - - printf("\n\nSupported languages/stacks:"); - for(int i = 0; i < numTypes; i++) { - printf("%s, ", types[i]); - } - - return 1; -} - -int help() { - printf("Abstracting away command line tools to create projects in various languages."); - printf("\nUser can use with or without arguments. Without arguments, 'newproject' will"); - printf("\nprompt for a supported language, project name, and if a git repository should"); - printf("\nbe created.\n\nBookmarks the new project directory using the 'mark' script."); - printf("\nDetects required tools to use based upon language selected.\n"); - printf("\n\nUsage:\nnewproject { language }"); - printf("\n newproject"); - printf("\n newproject c"); - printf("\n newproject -h"); - printf("\n newproject --help"); - - printf("\n\nSupported languages/stacks:"); - for(int i = 0; i < numTypes; i++) { - printf("%s, ", types[i]); - } - - return 0; -} - -void getName() { - printf("Project name: "); - fgets(name, 25, stdin); -} - -int initC() { - getName(); - mkdir(name, S_IRWXU); - chdir(name); - system("cp -r ~/templates/c/main.c"); - system("mark"); - return 0; -} - -void initRust() { - getName(); - char arduino[1]; - printf("Is this an Arduino project? (y/N): "); - scanf("%s", arduino); - - if(strcmp("y", arduino)) system("cargo generate --git https://github.com/Rahix/avr-hal-template.git"); - else if(strcmp("N", arduino) || strcmp("n", arduino)) { - char cmd[15]; - strcpy(cmd, "cargo new "); - strcat(cmd, name); - - system(cmd); - } else { - printf("\nThe choice is y, N, or n. Please try again."); - initRust(); - } -} - -void initCSharp() { - getName(); - mkdir(name, S_IRWXU); - chdir(name); - system("mark"); - system("dotnet new console"); -} - -void initJava() { - getName(); - mkdir(name, S_IRWXU); - chdir(name); - system("mark"); - system("gradle init"); -} - -void initHtml() { - getName(); - mkdir(name, S_IRWXU); - chdir(name); - - system("cp -r ~/templates/web/public_html"); - chdir("public_html"); - system("mark"); -} - -void initJs() { - getName(); - mkdir(name, S_IRWXU); - chdir(name); - system("mark"); - system("touch main.js"); -} - -void initPython() { - getName(); - mkdir(name, S_IRWXU); - chdir(name); - system("touch main.py"); - system("mark"); -} - -void initFlutter() { - getName(); - char cmd[25]; - strcpy(cmd, "flutter create "); - strcat(cmd, name); - system(cmd); - - chdir(name); - system("mark"); -} - -void initT3() { - system("npm create t3-app@latest"); -} - -void determineLang(char *argv[]) { - printf("determining lang"); - if(strcmp(argv[1], types[0]) == 0) initC(); - else if(strcmp(argv[1], types[1]) == 0) initRust(); - else if(strcmp(argv[1], types[2]) == 0) initCSharp(); - else if(strcmp(argv[1], types[3]) == 0) initJava(); - else if(strcmp(argv[1], types[4]) == 0) initJs(); - else if(strcmp(argv[1], types[5]) == 0) initT3(); - else if(strcmp(argv[1], types[6]) == 0) initPython(); - else if(strcmp(argv[1], types[7]) == 0) initFlutter(); -} - -int main(int argc, char *argv[]) { - types[0] = "c"; - types[1] = "rust"; - types[2] = "c-sharp"; - types[3] = "java"; - types[4] = "js"; - types[5] = "t3"; - types[6] = "python"; - types[7] = "flutter"; - - switch (argc) { - case 1: - printf("Language: "); - char *cmd[25]; - scanf("%s", *cmd); - - determineLang(cmd); - - break; - - case 2: - if(strcmp(argv[1], "-h") == 0) return help(); - else if(strcmp(argv[1], "--help") == 0) return help(); - else determineLang(argv[1]); - - break; - - default: - return error(); - } - return 0; -}