Skip to content

Instantly share code, notes, and snippets.

View Seven0492's full-sized avatar
💭
I may be slow to respond.

Seth Martin Seven0492

💭
I may be slow to respond.
View GitHub Profile
@Seven0492
Seven0492 / main.rs
Created November 23, 2022 06:13
func
if response.to_lowercase() == String::from("e") {
let editor = var("EDITOR");
Command::new({
if cfg!(windows) {
"cmd"
} else {
"/usr/bin/bash"
}
})
@Seven0492
Seven0492 / main.rs
Created November 23, 2022 06:12
func
} else if response.to_lowercase() == "s" {
make_dir(&PathBuf::from(flag_path.parent().unwrap()), false);
println!("\nFlag to set:");
let mut flag = String::new();
capture_input(&mut flag);
match write(CONFIG.dir_root.join(&flag_path), flag) {
Err(E) => {
@Seven0492
Seven0492 / main.rs
Created November 22, 2022 02:37
draft
use confy::{get_configuration_file_path, ConfyError};
use dirs::home_dir;
use serde::{Deserialize, Serialize};
use std::io::Read;
use std::path::{Path, PathBuf};
use std::process::exit;
use once_cell::sync::Lazy;
#[derive(Debug, Deserialize, Serialize)]
struct MyConfig {
@Seven0492
Seven0492 / main.sh
Created November 22, 2022 01:17
ex
#!/usr/bin/env bash
key_dir="";
# config_dir=; # I'll hold off on implementing that for now
if [ "$(command ls ~/.cache/overthewire/config)" == "$(echo ~/.cache/overthewire/config)" ]; then
key_dir=$(cat /home/${USER}/.cache/overthewire/config);
fi
if [ "${key_dir}" == "" ]; then
@Seven0492
Seven0492 / main.rs
Created November 22, 2022 00:32
Draft
use confy::{get_configuration_file_path, ConfyError};
use dirs::home_dir;
use serde::{Deserialize, Serialize};
use std::io::Read;
use std::path::{Path, PathBuf};
#[derive(Debug, Deserialize, Serialize)]
struct MyConfig {
max_level: usize,
dir_root: PathBuf,
@Seven0492
Seven0492 / Cargo.toml
Created November 21, 2022 22:58
Draft
[package]
name = "rust-rewrite"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
confy = "0.5.1"
dirs = "4.0.0"
@Seven0492
Seven0492 / main.rs
Created November 21, 2022 22:55
Draft
use confy::{get_configuration_file_path, ConfyError};
use dirs::home_dir;
use serde::{Deserialize, Serialize};
use std::io::Read;
use std::path::{Path, PathBuf};
#[derive(Debug, Deserialize, Serialize)]
struct MyConfig {
max_level: usize,
dir_root: PathBuf,
@Seven0492
Seven0492 / main.rs
Created November 21, 2022 22:01
Draft
use std::io::Read;
use std::path::{Path, PathBuf};
use dirs::home_dir;
use serde_derive::{Serialize, Deserialize};
use confy::get_configuration_file_path;
#[derive(Debug, Serialize, Deserialize)]
struct MyConfig {
max_level: usize,
dir_root: PathBuf