kionite231

joined 2 years ago
MODERATOR OF
[–] kionite231@lemmy.ca 1 points 2 months ago (1 children)

It's supposed to be used to create throwaway accounts. Or to give a number for random sites which you don't care about.

[–] kionite231@lemmy.ca 3 points 2 months ago

Sorry I have chosen duckdns as a domain provider... It gives some errors sometimes

You can try to reload it a few times, it will load eventually.

[–] kionite231@lemmy.ca 4 points 2 months ago

Fuck you google

[–] kionite231@lemmy.ca 2 points 2 months ago (1 children)

There is already IRC protocol for that use case.

[–] kionite231@lemmy.ca -1 points 2 months ago

Could you elaborate please, I mean yeah there is some risk but what part made you think it's a "terrible" idea?

[–] kionite231@lemmy.ca 1 points 2 months ago (2 children)

Yeah I was afraid of doing that because of the reasons you said here.

It doesn't matter in what part of the world you are in

TBH I am from a third world, fascist country where laws are jokes. If anything I can just say "ohh someone hacked my number somehow". The police and authorities are literally illiterate.

If 5 in 10 people would use it for good cause I am happy.

[–] kionite231@lemmy.ca 6 points 2 months ago (1 children)

Sadly qwant isn't available in my country :(

[–] kionite231@lemmy.ca 1 points 2 months ago (1 children)

Not related to the OP's post,

But are you using FUTO's keyboard? I thought that because everytime someone tries to add ASCII smiley emoji FUTO removes space between colon and the last word.

[–] kionite231@lemmy.ca 2 points 3 months ago (9 children)

Can't we just scrape Google maps and add things to OSM? 🤔

[–] kionite231@lemmy.ca 2 points 3 months ago

people with schizophrenia are violent which is not true. imo this is the biggest misconception about schizophrenia.

[–] kionite231@lemmy.ca 4 points 3 months ago (1 children)

You’ll have to look at why the upstream isn’t accepting them then. I’m not familiar with azuracast.

yes you are right, I asked it in Azuracast discord server and they said I have to manually enable "reverse proxy" option.

Thank you so much for helping me <3

[–] kionite231@lemmy.ca 1 points 3 months ago (3 children)

ok I tried to add those two in my Caddyfile:

ac.ghodawalaaman.duckdns.org {
	reverse_proxy http://localhost:4000/ {
		header_up X-Forwarded-Host {host}
		header_up X-Forwarded-For {host}
		header_up X-Real-IP {host}
	}
}

here is the output of a request.

2025/04/16 15:52:17.005	WARN	http.handlers.reverse_proxy	aborting with incomplete response	{"upstream": "localhost:4000", "duration": 0.000995717, "request": {"remote_ip": "103.250.137.61", "remote_port": "19389", "client_ip": "103.250.137.61", "proto": "HTTP/3.0", "method": "GET", "host": "ac.ghodawalaaman.duckdns.org", "uri": "/static/vite_dist/assets/Roboto-Light-DHTugVNA.woff2", "headers": {"User-Agent": ["Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"], "Sec-Fetch-Dest": ["font"], "Accept-Encoding": ["identity"], "Cookie": ["REDACTED"], "Sec-Fetch-Mode": ["cors"], "Accept": ["application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8"], "Accept-Language": ["en-US,en;q=0.5"], "X-Forwarded-For": ["ac.ghodawalaaman.duckdns.org"], "X-Real-Ip": ["ac.ghodawalaaman.duckdns.org"], "Sec-Fetch-Site": ["same-origin"], "Alt-Used": ["ac.ghodawalaaman.duckdns.org"], "X-Forwarded-Host": ["ac.ghodawalaaman.duckdns.org"], "X-Forwarded-Proto": ["https"], "Referer": ["https://ac.ghodawalaaman.duckdns.org/static/vite_dist/assets/Layout-Cv860oWs.css"]}, "tls": {"resumed": false, "version": 772, "cipher_suite": 4865, "proto": "h3", "server_name": "ac.ghodawalaaman.duckdns.org"}}, "error": "writing: H3_REQUEST_CANCELLED"}

I also tried this but it didn't work either:

ac.ghodawalaaman.duckdns.org {
    	log {
    	    output file ./azuracast.log
    	    format json
    	}
	reverse_proxy http://localhost:4000/ {
		header_up X-Forwarded-For {request.remote}
		header_up X-Real-IP {request.remote}
	}
}

here is the azuracast.log: https://0x0.st/8fd7.bin

I am still very confused why it's not working...

 

Hello,

It's been some time since I changed my phychiatrist, ( I wrote the reason in a previous post). the new phychiatrist think that I don't have phychotic symptoms instead he think that I just have social anxiety since I only think that people are talking about me and want to harm me, I am not actually believe that. he says I don't have schizophrenia because I don't have any phychotic symptoms anymore. he is decreasing the dose of antiphychotic and increasing the dose of anti-depressant.

I am no longer sure if I even had schizophrenia or my previous phychiatrist misdiagnosed me.

 

Hello,

I try out new distro every week since I have a lot of free time and want to learn more about Linux. I was thinking that it would be interesting to make a Lemmy post every week talking about my experience with the distro and what I did with it. right now I have alpine linux installed and thinking about using it till next sunday.

feel free to suggest next distro that I should try out. (I have tried out a lot of distros but never wrote anything about the experience but now on I will be making post about it here on Lemmy :) )

 

This is a test

 

Thank you peertube.wtf !!

 

Greetings,

sometimes I want to read new comments on a particular post but I don't want to check it every hour to see new comments. It would be nice if I can just say "!remind 5h" so that I get a reminder to checkout a specific post which would have new comments after 5 hour.

I am thinking about making it myself in Rust, but if there is already a bot here and I don't know, please tell me.

 

What I learned about Rust while making pastebin in Rust

First iteration

Hello, I have recently started to make a pastebin to learn more about Rust and understand the underlying concept of Rust so I first made a very naive pastebin where I used axum to serve the files and used a TCPListener to handle file upload. I didn't use axum to handle file upload because I didn't know how to do it, so basically my program was listening to two different port 8080 and 3000 where on port 3000 I served the files and on 8080 I handle file upload using simple TCP connection. I also used a static variable to name the uploaded file, but in Rust mutable static variable considered unsafe since it could lead to race condition, but at that time I didn't know much about Atomic variables so I wraped the code with unsafe.

Second iteration

I uploaded my code of First iteration to Lemmy, and people on Lemmy gave me a lot of suggestions, like using Atomic variable to eliminate the need of unsafe block and using axum to handle file upload. so I implemented that.

Third iteration

there are still some security issue like anyone can scrape entire pastebin since I was using an incremental file name. also if I rerun the pastebin It will reset the file name variable and it would overwrite previously uploaded files, to overcome this issue a person on Lemmy suggested that I should use uuid, that way it would solve those security issue.

Final thoughts

so yeah, that was it, I learned a lot about Rust and programming in general, thank you all on the Lemmy to teach me these cool stuff :D

 

Hello, last time I shared my dirty code of pastebin and people suggested me a lot of things so I have implemented those. now the code is reduced to only 42 lines of code :D

last post: https://lemmy.ca/post/36410861

here is the code:

use axum::{extract::Path, routing::get, routing::post, Router};
use std::fs::{read_to_string, File};
use std::io::prelude::*;
use std::sync::atomic::{AtomicUsize, Ordering};

const MAX_FILE_SIZE: usize = 1024 * 1024 * 10;
static mut FILE_COUNT: AtomicUsize = AtomicUsize::new(0);

async fn handle(Path(id): Path<String>) -> String {
    if let Ok(content) = read_to_string(id) {
        return content;
    }
    return String::from("ERROR: File not found");
}

async fn submit_handle(bytes: String) -> String {
    dbg!(&bytes);
    if bytes.len() > MAX_FILE_SIZE {
        // Don't store the file if it exceeds max size
        return String::from("ERROR: max size exceeded");
    }
    unsafe {
        let path = FILE_COUNT.load(Ordering::Relaxed);
        FILE_COUNT.store(path+1, Ordering::Relaxed);
        let mut output = File::create(path.to_string()).unwrap();
        write!(output, "{}", bytes).unwrap();
        let mut url = String::from("http://localhost:3000/");
        url.push_str(&path.to_string());
        return url;
    }
}

#[tokio::main]
async fn main() {
    let app = Router::new()
        .route("/", get(|| async { "Paste something in pastebin! use curl -X POST http://localhost:3000/submit -d 'this is some data'" }))
        .route("/{id}", get(handle))
        .route("/submit", post(submit_handle));

    let listener = tokio::net::TcpListener::bind("127.0.0.1:3000").await.unwrap();
    axum::serve(listener, app).await.unwrap();
}

 

Hello,

I was making a pastebin in Rust which I shared to the Rust community but there was one person who asked "why didn't you use upload functionality of axum" (I implemented the upload functionality using by simply using TCP connection). now I think that it might be a good idea to have file upload using axum but I couldn't find how to do it in their documentation. could someone point me to the right direction please? :)

 

the code I have written isn't very idiomatic or efficient. I am still new to Rust so I am learning things. I am amazed that I can write a pastebin in just 60 lines of Rust code. It's awesome. I am thinking about deploying it on my server.

any suggestions would be appreciated :)

code:

use axum::{extract::Path, routing::get, Router};
use std::fs::{read_to_string, File};
use std::io::prelude::*;
use std::net::{TcpListener, TcpStream};
use std::str;

const MAX_FILE_SIZE: usize = 1024 * 1024 * 10;
static mut FILE_COUNT: usize = 0;

fn handle_client(stream: &mut TcpStream) -> std::io::Result<()> {
    let mut buf = vec![0; 1024];
    unsafe {
        let file_name = FILE_COUNT.to_string();
        FILE_COUNT += 1;
        let mut file = File::create(file_name)?;
        let mut size: usize = 0;
        loop {
            let read_data = stream.read(&mut buf).unwrap();
            size += read_data;
            if size >= MAX_FILE_SIZE {
                return Ok(())
            }
            if read_data == 0 {
                return Ok(());
            }
            stream.write_all(&buf[..read_data]).unwrap();
            write!(file, "{}", str::from_utf8(&buf[..read_data]).unwrap())?;
        }
    }
}

async fn upload_handle() -> std::io::Result<()> {
    let listener = TcpListener::bind("127.0.0.1:8080")?;

    // accept connections and process them serially
    for stream in listener.incoming() {
        handle_client(&mut stream?)?;
    }

    Ok(())
}

async fn handle(Path(id): Path<String>) -> String {
    if let Ok(content) = read_to_string(id) {
        return content;
    }
    return String::from("ERROR: File not found");
}

#[tokio::main]
async fn main() {
    tokio::spawn(upload_handle());

    let app = Router::new()
        .route("/", get(|| async { "Paste something in pastebin!" }))
        .route("/{id}", get(handle));

    let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
    axum::serve(listener, app).await.unwrap();
}

 

Hello,

I am trying to solve the day 7 using Rust and this is what I came up with so far:

use std::fs;

fn calculate(answer: &i32, numbers: &mut Vec<i32>) -> bool {
    if numbers.len() >= 2 {
	let tmp1 = numbers[0];
	let tmp2 = numbers[1];
	numbers.remove(0);
	numbers.remove(0);

	numbers.insert(0, tmp1 * tmp2);

	if calculate(answer, numbers) == true {
	    return true;
	} else {
	    numbers.remove(0);
	    numbers.insert(0, tmp1 + tmp2);
	    if calculate(answer, numbers) == true {
		return true;
	    } else {
		return false;
	    }
	}
    } else {
	if *answer == numbers[0] {
	    println!("> {} true", numbers[0]);
	    return true;
	} else {
	    println!("> {} false", numbers[0]);
	    return false;
	}
    }
}

fn main() {
    let contents = fs::read_to_string("sample.txt")
        .expect("Should have been able to read the file");

    for line in contents.lines() {
	let tmp = line.split(":").collect::<Vec<&str>>();
	let answer = tmp[0].to_string().parse::<i32>().unwrap();
	println!("{:?}", answer);
	let numbers_str = tmp[1].split(" ");
	let mut numbers: Vec<i32> = Vec::new();
	for num in numbers_str {
	    if num.len() == 0 {
		continue;
	    }
	    numbers.push(num.parse::<i32>().unwrap());
	}
	println!("{:?}", numbers);
	if calculate(&answer, &mut numbers) == true {
	    println!("it's true");
	}
    }
}

I don't know why the recursion is not working. any help would be appreciated.

view more: ‹ prev next ›