As a work-in-progress programmer, I have produced some really stupid mistakes that has taken way too long to rectify. This time, it’s file manipulation.
Messing around with some mined data, I decided to neatly modify and place it (the data) in descriptive files for more managability and control. My specification was to include in the filename, the title, source and date of extraction. Pretty easy right? Actually, yes it is. Using python, you can use the io library to open and read/write to a file in just 2 lines of code.
Error after error, the same message propped up.
File cannot be found
What?! I’m trying to create the file, it obviously won’t be found yet! Maybe it was a problem with my environment? Maybe folder permissions? Maybe I need to find an alternative way.
I eventually found some examples where someone queried the current path of the process and used os.system to touch a file of the required filename. This was looking pretty promising!
Alas… It didn’t work. 3 hours into this perculiar problem, and now I am getting bored of it. Literally, Google could help no more. Perhaps the string built name needs to escape the spaces. Went through the line of code, until I reached the date:
I then proceeded to escape the formatting:
I tried again to only receive the same error. What is going on? Removed the escape slashes and that’s when it clicked.
Fundamental Linux 101
- Do not use ” / ” characters in Linux filenames.
What a complete noob… 4 hours of screaming, trying and crying later… it was working! Perfectly generated filenames. I won’t live this one down anytime soon!
I have provided a page for projects featured in this blog (here)
Hopefully, as I get more comfortable with python and other languages, the page will fill up quite nicely! It’s mainly to allow important things to flow a bit better here, especially as it would be difficult to dredge up some of these potentially interesting posts from the darkest corner of the database, in a nicely, effeciant way!
The little RPI home server has atlast given up the ghost. It seems SD card burn has destroyed the data and will boot no more. Ideally now, I would like to look around for a more robust solution to this ongoing problem. I have mentioned previously that I have a spare i5 pc waiting only for a storage drive. Ideally an SSD would be great to run a small web host but considering the secondary use of the computer ( network backup storage ) , an SSD is still impractical at this point.
I’ve been mulling over the problem of continuous uptime and again too have been snagged up at power usage. Now considering the time involved for bringing up the host and (its’) VM containers, might it be too enduring to boot it up and shut it down when not needed?
I may just resort to a VM on each device to serve a web host and use an external drive as storage for now.
Want to upgrade to something? Think before you buy. Sure the immediately new tech is nice to have, but what about in the future?
Mobile (cell) phone companies love this. They harass you into buying the next (mediocre) tech just released. Alot of the time now, I find the tech isn’t much more of an upgrade to the previous model, but with a noticeably larger price tag.
I currently have an S6 (Android)… the S7 was not a big jump but the S8 is pretty impressive. Regardless however of the S8’size presidence, it might be missing 5G.
My point here is give it a few more years, USB-C will be widespread on computer and portable tech. 5G might be on its way too… so with that in mind, I can wait.
There might be a sweetspot for upgrading gadgets but they’re not always timely. Secondly, I’ve seen too many bleeding-edge tech fail to know it might pay to wait just that little bit longer.
Hi! Recently I’ve been submersed in all sorts of different C code. I’ve been taking the #CS50 computer sciences course online from Harvard through edx.org.
I had originally started the course last year (2016) but I really couldn’t find the time. It can take a while to complete the different sections of the course; I like to watch the lecture and create code of the “shorts” to better understand what the shorts are trying to explain. (this has become a really useful method of learning, but not required)
There are 12 weeks of lectures, packed with shorts and documentation and afterwards a couple of assignments to undertake and submit for scoring. Sometimes there are questions to complete (sometimes about something not yet touched on) and alot of the time you have to research to answer them. It can be time consuming, especially as it is a bit harder to converse with people online also taking the classes.
There is a subreddit dedicated for questions about specifics of the course, managed by some of the Harvard staff and more experienced or better progressed students can also help you with a query.
Overall, I’m really enjoying this experience, but I have to keep dedicating alot of time to get through the weeks, especially as the weeks go on. Hopefully this year will allow me to finish the course (unlike last year)
I’m currently working through week4!