Restructure repository: organize tools by purpose, create what search tool

- Move single-file tools to tools/ organized by category (security, forensics, data, etc.)
- Move multi-file projects to projects/ (go-tools, puzzlebox, timesketch, rust-tools)
- Move system scripts to scripts/ (proxy, display, setup, windows)
- Organize config files in config/ (shell, visidata, applications)
- Move experimental tools to archive/experimental
- Create 'what' fuzzy search tool with progressive enhancement (ollama->fzf->grep)
- Add initial metadata database for intelligent tool discovery
- Preserve git history using 'git mv' commands
This commit is contained in:
tobias
2025-08-24 19:50:00 +02:00
parent 9518290544
commit 619b0bc432
124 changed files with 1063 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
use std::env;
use std::fs::File;
use std::io::{self, BufRead, BufReader};
fn main() -> io::Result<()> {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
eprintln!("Usage: {} start-end [count] [file...]", args[0]);
std::process::exit(1);
}
let range = &args[1];
let (start, mut end) = if let Some(dash_pos) = range.find('-') {
(range[..dash_pos].parse().unwrap(), range[dash_pos + 1..].parse().unwrap())
} else {
(range.parse().unwrap(), 0)
};
let mut count = 1;
let mut files_start = 2;
if end == 0 {
if args.len() > 2 {
if let Ok(c) = args[2].parse::<usize>() {
count = c;
files_start = 3;
}
}
end = start + count - 1;
}
if args.len() > files_start {
for filename in &args[files_start..] {
let file = File::open(filename)?;
let reader = BufReader::new(file);
process_lines(reader, start, end)?;
}
} else {
// No files provided, read from stdin
let stdin = io::stdin();
let reader = stdin.lock();
process_lines(reader, start, end)?;
}
Ok(())
}
fn process_lines<R: BufRead>(reader: R, start: usize, end: usize) -> io::Result<()> {
reader.lines()
.enumerate()
.filter_map(|(i, line)| if i + 1 >= start && i + 1 <= end { line.ok() } else { None })
.for_each(|line| println!("{}", line));
Ok(())
}

BIN
projects/rust-tools/uniq Executable file

Binary file not shown.

View File

@@ -0,0 +1,41 @@
use std::env;
use std::fs::File;
use std::io::{self, BufRead, BufReader};
use std::collections::HashSet;
use std::hash::{Hash, Hasher};
use std::collections::hash_map::DefaultHasher;
fn main() -> io::Result<()> {
let args: Vec<String> = env::args().collect();
if args.len() > 1 {
for filename in &args[1..] {
let file = File::open(filename)?;
let reader = BufReader::new(file);
remove_duplicates(reader)?;
}
} else {
// No files provided, read from stdin
let stdin = io::stdin();
let reader = stdin.lock();
remove_duplicates(reader)?;
}
Ok(())
}
fn remove_duplicates<R: BufRead>(reader: R) -> io::Result<()> {
let mut seen_hashes = HashSet::new();
for line in reader.lines() {
let line = line?;
let mut hasher = DefaultHasher::new();
line.hash(&mut hasher);
let hash = hasher.finish();
if seen_hashes.insert(hash) {
println!("{}", line);
}
}
Ok(())
}

BIN
projects/rust-tools/uniq2 Executable file

Binary file not shown.

View File

@@ -0,0 +1,36 @@
use std::collections::HashSet;
use std::hash::{Hash, Hasher};
use std::collections::hash_map::DefaultHasher;
struct HashOnlySet {
set: HashSet<u64>,
}
impl HashOnlySet {
fn new() -> HashOnlySet {
HashOnlySet { set: HashSet::new() }
}
fn insert<T: Hash>(&mut self, item: &T) -> bool {
let hash = Self::hash_item(item);
self.set.insert(hash)
}
fn contains<T: Hash>(&self, item: &T) -> bool {
let hash = Self::hash_item(item);
self.set.contains(&hash)
}
fn hash_item<T: Hash>(item: &T) -> u64 {
let mut hasher = DefaultHasher::new();
item.hash(&mut hasher);
hasher.finish()
}
}
fn main() {
let mut set = HashOnlySet::new();
set.insert(&"Hello, world!");
println!("Contains 'Hello, world!': {}", set.contains(&"Hello, world!"));
println!("Contains 'Goodbye, world!': {}", set.contains(&"Goodbye, world!"));
}