Skip to content

Instantly share code, notes, and snippets.

View sheepla's full-sized avatar
🐑
メェ〜

sheepla sheepla

🐑
メェ〜
View GitHub Profile
@sheepla
sheepla / dotnet-uninstall.sh
Last active April 6, 2025 07:25
.NET SDKs/Runtimes uninstall script for Linux, installed with dotnet-install.sh (Because the uninstall script does not yet support Linux)
#!/usr/bin/env bash
set -e
INSTALL_DIR="$HOME/.dotnet"
VERSION_PREFIX=""
RUNTIMES=()
DRY_RUN=false
AUTO_YES=false
LIST_MODE=false
@sheepla
sheepla / Cargo.toml
Last active March 24, 2025 12:12
Fetch and parse RSS/Atom feed in Rust
[package]
name = "rustyfeed"
version = "0.1.0"
edition = "2024"
[dependencies]
clap = { version = "4.5.32", features = ["derive"] }
reqwest = "0.12.15"
serde = { version = "1.0.219", features = ["derive"] }
syndication = "0.5.0"
@sheepla
sheepla / Dockerfile
Last active March 19, 2025 03:27
Dockerfile for SML#
# About:
# Dockerfile for SML# a Standard ML family programming language
# See:
# https://github.com/smlsharp/smlsharp
# Usage:
# docker build -t smlsharp .
# docker run --rm -it smlsharp:latest rlwrap smlsharp
#
FROM --platform=linux/x86-64 debian:buster
@sheepla
sheepla / confirm.rs
Created March 18, 2025 12:07
Confim prompt in Rust
mod cli {
use std::io::Write;
#[derive(Debug, thiserror::Error)]
pub enum CliError {
#[error("failed to flush stdout: {0}")]
Flush(std::io::Error),
#[error("failed read line: {0}")]
ReadLine(std::io::Error),
@sheepla
sheepla / event_stream.rs
Last active March 10, 2025 12:03
Asynchronous event stream with tokio_stream for ratatui crossterm backend, replacement for event.rs on ratatui-org/templates simple-async template
/// A module for emitting [`Event`] defined in this module by internally looping events and handling crossterm events
use crossterm::event::{Event as CrosstermEvent, EventStream as CrosstermEventStream};
use pin_project::pin_project;
use std::time::Duration;
use tokio::sync::mpsc;
use tokio_stream::{Stream, StreamExt};
#[derive(Debug, Clone, Copy)]
pub enum Event {
Tick,
@sheepla
sheepla / README.md
Last active February 9, 2025 11:09
Cheat Sheet for windows-rs (WIP)

Cheat sheet for windows-rs 🚀

🦀 Basic string types in Rust

  • String:
    A growable, heap-allocated string type. It's the most common string type used in Rust and is often used when you need to modify the string's contents.

  • &str:
    A string slice, which is a reference to a portion of a string, usually a part of a String or a string literal. It is an immutable reference to a sequence of UTF-8 encoded bytes.

@sheepla
sheepla / main.rs
Last active February 9, 2025 06:52
Iterate files with optional globbing
use clap::{Parser, ValueEnum};
use glob::{glob, GlobError, PatternError};
use std::path::PathBuf;
use thiserror::Error;
#[derive(Debug, clap::Parser)]
struct Args {
#[arg(help = "Target files path")]
files: Vec<String>,
@sheepla
sheepla / main.go
Last active January 26, 2025 22:30
Progress bar implementation in Go with github.com/cheggaaa/pb/v3
package main
import (
"progressbar_example/progress"
"time"
)
func main() {
count := 10000
@sheepla
sheepla / run_command.rs
Created December 30, 2024 09:19
Run command asynchronously in Rust
use eyre::{Result, WrapErr};
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufWriter};
use tokio::process::Command; // Use eyre for error handling
pub async fn run_command<W: tokio::io::AsyncWrite + Send + 'static + Unpin>(
cmd: &str,
args: &[&str],
stdout_writer: W,
stderr_writer: W,
) -> Result<()> {
@sheepla
sheepla / fetch_aur_diffinfo.rs
Created December 14, 2024 14:05
Fetch AUR page and extract PKGBILD and other filees diff info in Rust (reqwest + select-rs)
use eyre::OptionExt;
use reqwest::Url;
use select::{
document::Document,
predicate::{Class, Name, Predicate},
};
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct DiffInfo {