Skip to content

Instantly share code, notes, and snippets.

View pahosler's full-sized avatar

pahosler pahosler

View GitHub Profile
@pahosler
pahosler / advent.sh
Created December 21, 2023 07:15
advent of code rust template
#!/bin/sh
# get $TOKEN from .env
if [ -f .env ]
then
export "$(grep -v '^#' .env | xargs)"
fi
if [ -z "$1" ]
then
#!/bin/sh
# update discord after downloading new version
CWD='.'
PREV_DISCORD=$(find "$HOME"/Downloads/discord*)
get_newest_discord () {
LOCATION=$(curl -SsI "https://discord.com/api/download?platform=linux&format=tar.gz" | grep location)
@pahosler
pahosler / main.odin
Created September 28, 2023 16:35
a simple game written with odin-lang
package main
import "core:fmt"
import "core:math/rand"
import "core:os"
import "core:strconv"
main :: proc() {
win := false
num := rand.int_max(99) + 1
@pahosler
pahosler / Super_Friends_Tech_Stack.md
Created September 28, 2023 02:39
The Super Friends choose a tech stact

Superman: "Fellow Super Friends, we need to choose a tech stack for our new website. I suggest JavaScript. It's widely supported and great for front-end interactivity."

Batman: "I agree with Superman. JavaScript is a solid choice for client-side scripting. We can use it to create dynamic web pages and interactive features."

Wonder Woman: "But what about server-side? I propose using Rust or Go. They're both known for their speed and security."

The Flash: "Yeah, Rust and Go are lightning fast! But don't forget Python. It's versatile and has a large ecosystem of libraries."

Aquaman: "Hold on a sec, folks. PHP has been around for a long time and is reliable for server-side scripting. It could be a good choice too."

@pahosler
pahosler / 12baddaysofrust.txt
Created February 21, 2023 18:35
12 Bad Days of Rust Code
On the first day of Rust, my codebase gave to me,
A learning curve that's much too steep.
On the second day of Rust, my codebase gave to me,
Two lifetimes to worry,
And a learning curve that's much too steep.
On the third day of Rust, my codebase gave to me,
Three borrow checkers,
Two lifetimes to worry,
@pahosler
pahosler / 12daysofRust.txt
Last active February 21, 2023 18:17
12 Days of Rust Code
On the first day of Rust code, my compiler gave to me
A module full of traits for free.
On the second day of Rust code, my compiler gave to me
Two macros for parsing, and a module full of traits for free.
On the third day of Rust code, my compiler gave to me
Three match arms, two macros for parsing, and a module full
of traits for free.
@pahosler
pahosler / Cargo.toml
Last active January 13, 2023 17:10
get gif images from a web page and save locally
[package]
name = "basic"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
error-chain = "0.12.4"
reqwest = "0.11.13"
@pahosler
pahosler / main.rs
Created January 7, 2023 05:20
speedtest
use serde::{Deserialize, Serialize};
use serde_json::Result;
use tokio::process::Command;
#[derive(Serialize, Deserialize, Debug)]
struct Metrics {
bytes: i64,
elapsed: i64
}
@pahosler
pahosler / main.rs
Last active January 7, 2023 02:55
tokio interval
use tokio::time;
#[tokio::main]
async fn main() {
let mut interval = time::interval(time::Duration::from_secs(1));
let mut c = 10;
loop {
interval.tick().await;
println!("{c}");
c = c - 1;
@pahosler
pahosler / main.rs
Last active January 7, 2023 02:56
get a horoscope w/tokio&serde
use regex::Regex;
use reqwest::header::USER_AGENT;
use tokio;
use serde_json::Result;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
struct Data {
description: String,
date: String,