Home Weekly 15: Simple Automation Script, Volunteering and Bomberman
Post
Cancel

Weekly 15: Simple Automation Script, Volunteering and Bomberman

This weekly post technically should’ve released on the 22st January 2024, so it is therefore late by about 5 days.

I do have some valid reasons for it and will be writing in this post about the various things that have kept me busy on my second and third week of my last academic trimester of classes at SIT.

Even this early on, I have made a ton of work and progress both related to university and outside if it.

The headings will detail each project I have been working on. Most are WIPs. I also am going to write about some school related stuff because I don’t see a reason why not… the work at school did occupy a lot of my time, so I might as well write about what that work actually was.

This post is a bit more of a stream of consciousness style writing, like an informal report of what I have been up to during January… or reflection writing in Primary School after a school trip… or book report… that kind of thing.

I think for the Weekly blog posts, I should be comfortable just writing even if it is rambling, to keep the editing and planning time lower while just getting everything out of the way.

I could instead reserve the more conscious editing and structured writing for articles and project posts.

Blog Writing Scripting Tool

The first of this is relatively simple and in some ways underwhelming, but practical. A major bottleneck of uploading blog posts isn’t just the writing and editing of posts, but also the actual upload process.

I will create a new blog post going through this tool in more detail and will retroactively edit this post to include a link to it, but for now this is the short version.

The Problem

I always draft and edit my blog posts using Obsidian, but Obsidian saves its markdown files in a slightly different format for image attachments that were pasted in.

/assets/Weekly/Weekly15/0.png

The screenshot above shows the long, painful attachment folder… where the images I have used in a blog post have to be retrieved by hand, copied and renamed. It is tedious.

These images have to be uploaded onto my GitHub Page’s repository in order to be served by the blog, and the blog post draft had to be edited by hand in order to match the markdown format that Chirpy expects for images.

/assets/Weekly/Weekly15/1.png /assets/Weekly/Weekly15/2.png

The screenshots above show examples of how in the past, I would have to manually copy these images into my virtual machine and name them accordingly. I will explain in the follow up post why I use a VirtualBox machine to host an Xubuntu instance to make changes for my Jekyll website. I think it had something to do with a broken Ruby install on my Windows, but I am unsure.

Some of you reading this might be asking why I am not using a Content Delivery Network, like Cloudflare or Amazon CloudFront to host my blog’s media assets. The answer to that is anticlimactic in that its a simple matter of just not getting around to doing it. Not only that, but also I have a naive assumption that for a small personal static blog with low web traffic that hosting the assets in the GitHub repo is fine, at least for the time being. Regardless, even when if I do switch to a CDN, this issue of converting and uploading the imags will still be present.

This process of editing the images by hand, renaming them, and uploading them onto my virtual machine so that it can be pushed onto the GitHub is relatively time-consuming, about 15 minutes. I know this because I would record the time taken, like in the screenshot below.

/assets/Weekly/Weekly15/3.png

The Solution

So, what should I do? Well, why not create a simple Python script to automate this conversion process? That way, once I am done writing a blog post locally I only need to hit a script to get a generated markdown format that compiles with the site, and a folder with the images to upload.

So that was what I did yesterday evening (26th January 2024). I measured the time it took to write it, and it took me about four hours to do so including unit testing. I will go into the details in a different post.

/assets/Weekly/Weekly15/4.png A screenshot showing my messy Visual Studio Code window making it… a dramatization, of course.

I wrote the script to parse previous markdown files, get the image tags and image directory, duplicate images from an attachment folder into a new location, and edit the new markdown file to contain the corrected image tags and names.

It sounds simple, and it is, but nevertheless there are actually enough interesting details and notes that I could go in depth on… but that would be for the dedicated post as it’d a fairly long report and there is still other data I would want to obtain for it, like benchmarking and profiling.

Conclusion

Since this tool took about four hours to script, which is 240 minutes, this means that I would get an effective ‘return on investment’ in the time spent to create the tool compared to doing it by hand in only around fifteen blog posts or so! That’s a pretty good deal if you ask me.

Not only does such a tool decrease the time (and effort) spent per blog post, but it should also ‘improve morale’. An ‘improvement of morale’ would mean that I would be more likely and eager to write more blog posts, with a lot more details and uses of relevant images (which are a very useful aid for my style), knowing that it won’t be a painful process to actually upload it onto my GitHub pages.

OpenLibrary and Volunteer Commitments

Time Commitments

I told the mentors and community leaders at OpenLibrary that I’d be taking a short break to focus on my studies. I have not made any new significant contributions since Weekly 13’s post. They were supportive of my requests to focus more on my education during this semester, especially with my internship job hunt.

Still, I am hoping to continue to find some small packets of time later in the middle of February to do some minor bug fixes and catch up on the issues I was assigned to.

I was wise enough to choose non-blocking and non critical tasks, knowing my own commitment levels for OpenLibrary would be lower priority to other pursuits, so this has allowed my working relationship with the contributors to remain positive.

This is, after all, a volunteering commitment. I see it as similar how I also do volunteering for the National Library Board for only a few hours every week, although with OpenLibrary it is digital rather than physical. As long as the communication is made clear, both the organizations and the volunteers can meet a healthy consensus for the expected time commitment.

With National Library Board, this is done in a very structured way using a volunteer portal, where we can book slots. With OpenLibrary, and other open source projects on GitHub, this is done through the ‘assignment’ system for GitHub Issues.

What have I learned volunteering?

One of the biggest things I got to practice from both OpenLibrary and National Library Board volunteering positions was how to handle feedback and criticism professionally, as well as taking initiative to ask questions and clarify instructions early.

Usually in an academic environment during group projects, I am often thrusted into leadership positions or are quite close to it. As such, I have less opportunities to practice my professional self in the context of more subordinate positions.

National Library Board - Owning up to mistakes

While volunteering for library@chinatown, which is a volunteer run library, I was in charge of sorting books as a librarian helper. Early on during my first few sessions, I had made a major mistake while sorting the books, where I had ordered them based on their full Dewey Decimal Classification (DDC) number. This was caused by a misunderstanding when I was being given the instructions.

For library@chinatown, the correct way to sort the books was up to the first five numbers in the DDC, and then after that the initials of the author is taken priority.

The mistake I made was sorting the books according to all numbers in the DDC, rather than up to only five. This meant that I was unnecessary reshuffling and sorting the books wrongly.

Responding Well to Criticism

I was told off harshly for the mistake later on and the staff member was upset as he had to take extra time off his shift to correct my mistake. Even though he was stern, I am proud of my ability to take his harsh criticism in stride without letting it personally affect me.

Admittedly, I was internally upset at first and embarrassed for making such a mistake. There was an urge inside of me to protect my ego, to be defensive, or try to argue that the mistake I made was a reasonable one or deflect blame by stating that the instructions were unclear. But, in practice, I did not give into that petty and unprofessional desire and I am glad that I did not. I simply thanked the staff for informing me of my errors, apologized sincerely, and I did so with a friendly and calm tone.

Being able to handle criticism in a professional and amicable manner is an important aspect of a workplace, and I was glad I had that skill to take it.

Taking Initiative to Double Check

Another lesson I learned from that exchange is to always seek feedback early when doing work in a new environment or task. This is especially true if there happened to be a lot more work and ‘productivity’ then expected, like how there were a lot of books that were ‘shelved wrongly’ when I had my misconception.

Instead of assuming that I was smarter than the system, I should have questioned that I could have had a misconception. If I had shelved only a small section of the shelf first and get extra verification that it was correct, that mistake would’ve been pointed out to be sooner. It is better to be correct if unsure at the start, than to do things ‘fast’ and ‘get a lot of work done’ but making a lot of mistakes due to honest misunderstandings.

As a result for being professional and mature, I still have good relations with the staff at library@chinatown and am still welcomed as a volunteer there, and I no longer make the same shelfing mistake.

OpenLibrary - Mentorships

Volunteering, however, allowed me to get that outlet. It can come from simple things, such as taking initiative to seek out mentors to ask questions or report progress early. These help me remain on the right track and avoid assumptions and miscommunications.

Being able to ask intelligent questions after attempting the problem myself is also important, as I need to still be independent despite the humility of knowing that I don’t know much.

With OpenLibrary, this came in the form of talking to Scott Barnes with clarifying questions often when blocked. I would catalog what I have done or attempted first, so that I would be able to get clarifications in a way that is easy for him to help.

/assets/Weekly/Weekly15/5.png

An example of this in a slack conversation that I could find in a single message. The discussion is on this open source issue and not confidential, but I only wanted to share what I had written for privacy. The loan status button was actually from my first issue.

Soft Skills

Volunteering have been a great opportunity to practice many professional soft skills, especially when it comes to conflict management or understanding instructions.

These soft skills are harder to practice in an academic environment, due to inherently different expectations of authority and hierarchy, and so I am very glad I discovered an outlet to practice them in a way to prepare for my internship.

Soft skills, such as the ability to understand instructions, ask for help, and own up to mistakes, are easy to take for granted in the working world. Despite this, I have seen how the neglect of them causes many unnecessary conflicts and ‘drama’ from the stories that relatives have shared about their working life. Even in academic settings I have observed them cause a lot of unnecessary hostility, such as during group projects.

As such, I take them very seriously, and I am glad that I volunteer work has been a productive outlet to improve and hone these skills.

Regex

Deviating away from professional etiquette, this section discusses a technical skill I have learned from coding contributions. Regarding the actual code contributions for OpenLibrary, I did actually finish the Allow ‘xxxx’ in date field when adding new edition issue.

This was interesting as it got me to practice and improve my understanding of regex, which I was able to also apply in the markdown automation tool mentioned at the start of this post.

/assets/Weekly/Weekly15/6.png As detailed in that draft pull request, I had created a very simple test with regex101 to verify if the regex was working. While no replacement for a proper unit test, it was a decent starting point.

Regex is interesting. While I am still a novice at it, even just being more aware of its potential allowed me to see more ways I can use it to solve simple problems in scripting that I might have otherwise over complicate. I remembered in my freshman year in undergrad, parsing through c-style string arrays and backtracking to and from characters. Still, it was good practice to have that foundation of what strings even were by starting from C++ and C, as it allows me to be aware of potential issues with Regex’s time complexity concerns when working in Python. I could write more about that some other time though, this is the Weekly post.

School Stuff

I had originally intended to write more for the School Projects section, going into detail over what we are covering and learning this trimester. There is a strange sense of nostalgia knowing that this will be my last time taking lectures at this campus.

However, I realize that since the projects for my classes are still in the pre-production, planning and early stages, I will reserve writing about them for a later date.

This is simply because I prefer to write about what I have completed, rather than what I have planned. While there is still a lot of stuff I could write about here, I feel speculative plans are less meaningful to discuss publicly than post-mortems and reflections. So I will preserve and my energy and time to doing the actual work now than writing about them here.

Instead, this section is dedicated to showing gratitude for the existence of school itself. I am taking this trimester very seriously and being able to pay more attention and focus in classes now than before. This is due to a mixture of my recovering health and improved productivity systems. I really appreciate school now that I have experienced the circuit breaker period and while I will miss aspects of it once I graduate, I am also eager to begin my adventure into the professional world.

My health did not handle the circuit breaker period as well, which was where my first few years of education at the university took place in. Despite the fact that it was a struggle, I am glad that I was able to survive it and making to the end.

The contrast between, however, and the circuit breaker period is striking. There have been vast improvements of my performance as I am now able to be fully immersed at campus, and have the benefits of getting treatments for my health issues. These improvements have really enabled me to take full advantage of my education now, whereas prior I felt that I was struggling to keep my head over water. It is ironic in a way, as earlier course material was actually easier than stuff later in the year.

I think this shows that environmental factors are just as important for one’s ability to perform and thrive, rather than just the raw difficulty of the tasks expected. It also highlights that prioritizing one’s health is one of the most important aspects of having a productive and meaningful life. We do things with our bodies, after all. I no longer take my health for granted after surviving the Circuit Breaker period.

Personal Projects

Pygame Stuff

I have been playing around with Pygame again, because I have fallen in love with Python. It’s just nice how easy virtual environments (venv)s with pip packages are to setup, especially compared to CMake which I still struggle with. Makes it easy to just prototype stuff when you get an idea. Even if I do encounter bottlenecks, having that prototype code in Python can make planning the architecture to make the improvements in another codebase easier.

I do find npm to be also relatively painless too. Not as painless as pip but better than my past nightmares with CMake. Sometimes npm error messages can be cryptic when dealing deprecation or older codebases though, like in this (now fixed) issue I commented on for a Phaser template.

Still, I like that with Python it feels like I spend more time coding and writing tests instead of fighting against build systems, which is what I want out of my hobbyist outlet for programming.

Bomberman Clone

As a last minute entry to Week Sauce Game Jam for the month, I decided to make something that would be simple for me: a clone of Bomberman.. It is not finished yet, so when it is done I would write a post elaborating on it.

/assets/Weekly/Weekly15/7.gif

The main difference from my clone and the original to fit the theme of ‘One Tool, Many Uses’ is to have it so that players can place remotely detonated ‘TNT blocks’ instead of regular bombs. This would mean that bombs act as both bombs and walls. It is an underwhelming interpretation of the theme, but I think it fits.

As I developed the project, I realized that I could also add another deviation in the form of implementing turn-based mechanics rather than real-time gameplay. This was because during prototyping, I noticed that the remote detonation of the bombs provided some tactical orientated thinking.

The next steps I have to work on is creating an ‘asset pack’ type logic for allowing an easy way to swap out graphics, an improved UI for feedback, and also maybe computer opponents.

I quite like my progression for this simple game jam prototype because I got to implement all gameplay code myself, without any reference or tutorial or whatever.

Pygame is just a wrapper for SDL, so it provides the stuff involving windowing, rendering, playing audio, getting inputs and some useful helper functions like a Rectangle class. This means that for everything else, such as how I want to store levels or define the abstraction for an ‘entity’, it was all up to me. I see this as a form of freedom.

I used csv files to create simple tests levels. This reminded me of my article I had written last year, about using Blender and mspaint as a level editor.

Additionally, I want profile and benchmark this project so I can get a proper analysis over the performance costs of my choices. This can be a useful study and report, especially if I were to compare the performance of different implementations of the same features.

Conclusion

So this is the end of the post. My writing style is a bit messy this week, and there was probably a ton of paragraphs that could be edited out and condensed, but I don’t want to spend too much time on this post when I could be actually working on things. Weekly posts being a bit of a ramble is fine, as the tradeoff of just posting it and moving on is worth it compared to the additional editing time.

In many ways these weekly posts also act as a public journal and a way to reflect on lessons I have learned as I better myself as a person.

For any potential employers reading this, I am not shy to confess that some of the content is, in a way, preparation for some questions that might be asked in interviews, especially regarding professional development.

Despite that motivation that these journals are acting as a sort of preparation for job interviews, I think since the content and stories are genuine, authentic and honest reflections, that we don’t have to view these posts in a cynical light. This habit I am developing of sharing stories publicly will be one I will continue even after I am very secured in my career, as I think they are very useful tools for personal reflection, and maybe even possible learning avenues for other people in my life if I were to share them.

Thanks for reading this far. Do let me know if you have thoughts you’d like to share, or if you too have similar blogs. I will write more next week.

This post is licensed under CC BY 4.0 by the author.

Weekly 14: Lots of content for next week...

Weekly 16: Working Part-Time

Comments powered by Disqus.