Skip to content

Instantly share code, notes, and snippets.

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

sheepla sheepla

🐑
メェ〜
View GitHub Profile
@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 {
@sheepla
sheepla / main.rs
Last active March 3, 2025 01:44
CSV内のデータから自動的に型を識別してCREATE文を組み立てる
use clap::{Parser, ValueHint};
use eyre::WrapErr;
use polars::datatypes::DataType;
use polars::prelude::*;
use sea_query::{Alias, ColumnDef, Iden, SchemaStatementBuilder, Table, TableCreateStatement};
use std::path::{Path, PathBuf};
use tokio;
#[derive(clap::Parser, Debug)]
#[command(about = "A command line tool for flexible registration for CSV data to DB tables")]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Find Text from JSON</title>
</head>
<body>
<h1>Find Text from JSON</h1>
@sheepla
sheepla / App.tsx
Last active December 15, 2024 11:23
React + MUIによるダークモードに切り換え可能なUIの実装
import React from "react";
import "./App.css";
import LoginBox from "./components/LoginBox";
import {
createTheme,
CssBaseline,
ThemeProvider,
useMediaQuery,
} from "@mui/material";
import { deepPurple, indigo } from "@mui/material/colors";
@sheepla
sheepla / main.rs
Last active August 14, 2024 11:30
Nadenade Shikoshiko in Rust
fn main() {
println!(
"{}",
(["なで", "しこ"])
.iter()
.flat_map(|&s| std::iter::repeat(s).take(2))
.collect::<String>(),
);
}
@sheepla
sheepla / main.go
Last active August 13, 2024 12:07
Print raw SQL for debugging with uptrace/bun
package main
import (
"context"
"database/sql"
"fmt"
"log"
"github.com/uptrace/bun"
"github.com/uptrace/bun/dialect/sqlitedialect"