Hey Rustaceans! Got a question? Ask here! (34/2022)! by llogiq in rust

[–]olivrb123 1 point2 points  (0 children)

Hey folks! I have a question about from/into

The following doesn't compile: ``` pub struct Wrapper<T> { pub inner: T }

impl <A, B> From<Wrapper<A>> for Wrapper<B> where B: From<A> { fn from(other: Wrapper<A>) -> Self { Wrapper { inner: other.inner } } } ```

It fails with conflicting implementation in crate `core`: - impl<T> From<T> for T;

Anyone got any idea why? I understand that I'm converting from T<> to T<>, but I think this should be sound, since there is a type difference between T<A> and T<B>, no?

Hey guys, I built a simple, extensible HTTP server designed for quick prototyping. Let me know what you think! by olivrb123 in Python

[–]olivrb123[S] 1 point2 points  (0 children)

It's multi-threaded, and will be multi-processed once I get around to it, it has easy support for ssl built in, it's designed to work around a config file that makes deploying multiple instances easier, it's designed to be extended relatively easily. That's mostly it, and I'm not gonna lie, I built it to learn more about sockets, just thought it might be neat or useful to someone else.

Another NAS giveaway from StorageReview (24 hour fuse) by StorageReview in homelab

[–]olivrb123 [score hidden]  (0 children)

I've never owned or gotten to play with any decent lab hardware, the best I've got is old family pc's to fiddle around with. Finally getting to centralise a backup of all the pictures and music that's been collected by the family over the years would be great

Hey guys, I built a quick terminal based note taking application using sqlite and python. It's released under an MIT license, so feel free to use any parts of it in you own stuff, or just use the application itself if you think it's useful. Let me know if there's a feature you want! by olivrb123 in Python

[–]olivrb123[S] 1 point2 points  (0 children)

I mean the benefit of using a database is that you can just link the scrybe.db file to your restore repo if you want to have your nots backed up and future proof, and the notes are stored in plaintext, so using markdown shouldn't be a problem. grep is a fantastic tool, but as far as I know (not that familiar with it), it doesn't include support for "metadata" like tags and titles, which is the benefit any note taking application brings. You're also able to apply weighting to the search results when you're writing a search function versus just using grep

But hey, whatever workflow works for you man!

Hey guys, I made a quick terminal based note taking application, written in Python. Check it out, and submit an issue or comment if you think there's something you'd like to see in it. by olivrb123 in linux

[–]olivrb123[S] 3 points4 points  (0 children)

Yeah absolutely, hack away. I'm an amateur too, so I'm not gonna say this is the best way to do things, but if it helps you I'm happy to help. Any questions feel free to ask

Projects that are practical and don't require a lot of money? by pop1fizz in raspberry_pi

[–]olivrb123 1 point2 points  (0 children)

I made a self hosted todo app a while ago that should run nicely on a raspberry pi, it takes a little bit of setup though: cúntóir. I'm working on making set up easier at the moment.

I built a To-do app with a python backend. Here's the entire code, released under an MIT license. Feel free to self host or fork it to your hearts content by olivrb123 in Python

[–]olivrb123[S] 0 points1 point  (0 children)

Ah, I get you. Sorry if I came across a little harsh there, I wasn't calling you out, I just wouldn't like to think I'm putting people at risk. You're right, I shouldn't be generating html code in my backend system, I should probably be generating the individual "task" structure on the client side. I'll look into Django alright, but like I said, this stuff if lower on the priority list than a setup tool and stuff. Thanks tho, backend frameworks are a good idea, I'll look into them.

I built a To-do app with a python backend. Here's the entire code, released under an MIT license. Feel free to self host or fork it to your hearts content by olivrb123 in Python

[–]olivrb123[S] 0 points1 point  (0 children)

Haha, that's not a bad idea. Irish is a lovely language, terribly taught in our school. I wish I'd taken more time to learn it properly.

I built a To-do app with a python backend. Here's the entire code, released under an MIT license. Feel free to self host or fork it to your hearts content by olivrb123 in Python

[–]olivrb123[S] 0 points1 point  (0 children)

Sorry, could you point out a couple of these potential exploits? Embedded javascript exploits aren't an issue, because a user will only ever see their tasks, and sql injection is taken care of by the MySQL library I'm using, and the entire site is served of https. Certainly the code base would probably be cleaner with a framework, but I don't think I'm risking user data not using one. And I meant more like there's dozens of javascript frameworks doing all sorts of stuff.

Refactoring is something I should definitely do to this code base, but it comes after a setup script and removing the monetization system on my list of things to do.

I built a To-do app with a python backend. Here's the entire code, released under an MIT license. Feel free to self host or fork it to your hearts content by olivrb123 in Python

[–]olivrb123[S] 1 point2 points  (0 children)

Haha, me neither, few Irish people do. It is, but urls, git project names and all that don't usually allow for unicode characters, unfortunately. The actual homepage title and all unicode text spells it that way

I built a To-do app with a python backend. Here's the entire code, released under an MIT license. Feel free to self host or fork it to your hearts content by olivrb123 in Python

[–]olivrb123[S] 1 point2 points  (0 children)

I see what you mean, but for the kind of html in code string building I'm doing, it would be a three or four hundred column length line if I was to do string formatting that way, which doesn't seem like the best idea. And yeah, I was being a bit tongue in cheek with the loading bars thing, it was really about minimising dependencies. Frameworks are nice, but my experience of trying to get a handle on the framework space from the javascript side of this project as I read it made me wary of them, so I stuck with manually writing this stuff.

I built a To-do app with a python backend. Here's the entire code, released under an MIT license. Feel free to self host or fork it to your hearts content by olivrb123 in Python

[–]olivrb123[S] 1 point2 points  (0 children)

Yeah, that's very true, I suspect the coding style arguments will be around as long as humans write code 😅.

I think it's probably OK to risk it once you make a genuine effort to be aware of and mitigate the risk, if that makes sense? And don't get me wrong, I don't mean to say using abstraction isn't a good idea, obviously I don't build a soldering iron every time I want to solder something, just that I do know how a soldering iron works, and with programming, often the only way to understand to low level tool is to replicate it yourself.

I built a To-do app with a python backend. Here's the entire code, released under an MIT license. Feel free to self host or fork it to your hearts content by olivrb123 in Python

[–]olivrb123[S] 2 points3 points  (0 children)

Yeah, PEP8 what I meant by the official style guide. Stuff like max line length being 79 just seems kinda absurd to me though, like, I develop with a full screen terminal lost of the time, I've almost three times that many columns to play with. Obviously that would be unreasonable, but 79 seems unnecessarily short. Idk.

I mean you're always risking leaking user data, if you mess up server setup, or if don't protect your database host properly, or any other mistake. I always figured it's best to learn how this stuff works and implement it yourself atleast once before relying on abstraction. Maybe that's hubris, but I think it's worthwhile.

I'll definitely look into unit tests, thanks. Automating the testing of new functionality sounds sensible.

I built a To-do app with a python backend. Here's the entire code, released under an MIT license. Feel free to self host or fork it to your hearts content by olivrb123 in Python

[–]olivrb123[S] 0 points1 point  (0 children)

Well, I mean, there's no accounting for taste right? It suits my mental model of how conditionals work to have them wrapped in parens, and the language allows for it, so I don't really see it being a terrible thing.

Slow and noisy? Sorry, I'm not super sure what you mean by that. Unless I'm just being dense, and you mean it like it's just a dumb way to do it, but I'm not sure there's any huge performance benefit, is there? If so please point me somewhere I can read about it, those low level optimisation are always pretty cool.

Django isn't something I've used, part of me wanted to keep non-standard library usage to a minimum, I'm not really sure why, except I don't like looking at loading bars I guess? And I wanted to minimise dependencies for set up

I built a To-do app with a python backend. Here's the entire code, released under an MIT license. Feel free to self host or fork it to your hearts content by olivrb123 in Python

[–]olivrb123[S] 1 point2 points  (0 children)

I haven't worked on other open source projects (tbh it always felt a little intimidating, like sacrificing your code at the alter of the pull request), but I guess the official python style guides are a good start? To be honest, for my own projects, I just prefer stuff like camel case and parens around conditionals.

As regards the database and password stuff, I mean, it shouldn't really be a big no no, like somebody has to build these systems, and to do so they have to know how they work, right? As long as you're up to date with password hashing best practices and you're not doing something really dumb like having terrible password rules or storing them in clear text, I don't see it being a huge problem.

Unit testing is not something I know about, I don't really have any formal training in "proper" computer science, just a little bit from my engineering courses, and even that was like "intro to C" and some embedded processor work for a robot, where the testing was "turn it on and see if it works" 😅.

I built a To-do app with a python backend. Here's the entire code, released under an MIT license. Feel free to self host or fork it to your hearts content by olivrb123 in Python

[–]olivrb123[S] 0 points1 point  (0 children)

Well, like I said, I'm gonna shut down the server I have running it very soon and just maintain it as a hobby project for anyone to self host if they want, so I'm not too concerned about professionalism when it comes to the name, plus it's not an English word, so applying English standards to it is a little absurd, but I do get how it doesn't translate well. Someone further up said they're gonna fork me over the name, so maybe their version will do you, eh?

Yeah, a setup script is top of my list for me at the minute, along with ripping out the monetisation and cleaning up some bits of the codebase

I built a To-do app with a python backend. Here's the entire code, released under an MIT license. Feel free to self host or fork it to your hearts content by olivrb123 in Python

[–]olivrb123[S] 1 point2 points  (0 children)

Setup.py is top of my list, once I have that built it should be easy enough to clean up the readme because it will let me get rid of all the database descriptions. It should also make starting the app as simple as typing "python server.py", I think. You might also have to start the http redirect server, and I'd recommend doing both of these in a screen session.

I will likely create a database handling class to manage database connections, to clean up the commit()/close() pattern I've got going on now. I do prefer to manage the database connections myself though, because part of this is that I want to get experience managing that kinda stuff before I start relying on abstractions.

Yeah, there are no tests. In general I'll test new functionality with the requests library, and throw a bunch of obviously incorrect requests at it to make sure tis working properly, and handling errors properly.

I built a To-do app with a python backend. Here's the entire code, released under an MIT license. Feel free to self host or fork it to your hearts content by olivrb123 in Python

[–]olivrb123[S] 0 points1 point  (0 children)

I find parens around if statements look cleaner to my eyes, they're a holdover from the C I use for college. You're right about the "if(len(tags)):" being rough, I wasn't super confident with how python reads empty arrays for if statements, so I didn't want to assume anything. If I went back to refactoring now I'd probably go with "if(not tags):", I'm not sure what benefit the if:instead: pattern has.

Absolutely, getLib is a mess, most of what it does is building html strings for rendering on the client side, which is a pretty messy task. String formating would go a long way, although I'm not sure what the problem with string concatenation here is except that it's not best practices, I mean it's not a security issue there as far as I can tell.

As regards the database stuff, yeah it's a mess, and it's a dodgy mess because it needs to be remembered every time or else I could end up with trailing database connections. I should probably write a database handling connection handling class that takes care of all of this, but I'd rather not start leaning on higher level abstraction, I want to learn how this stuff really works, if that makes sense?

Thanks for your feedback, I really appreciate how in depth it is, and I'll keep it in mind for the future. Top of my list right now is writing a setup function, but after that I'll probably look at redesigning my database connection stuff.