13
votes
What programming/technical projects have you been working on?
This is a recurring post to discuss programming or other technical projects that we've been working on. Tell us about one of your recent projects, either at work or personal projects. What's interesting about it? Are you having trouble with anything?
I got a new M1 MacBook Air for work, and our dev environment for the new chips is set up via VS Code since apparently VirtualBox might not work with the new chips. I’m way more used to Sublime, but the learning curve isn’t too bad. I spent today setting up my old snippets and customizing the interface with a pretty theme and font. The actual work I’m doing isn’t that exciting, but I have gotten really comfortable with CSS grid, which is fantastic.
Reformatted my computer and installed Fedora on it. Usually I'd install Arch and tweak it, but lately I've been wanting something that "just works", and decided on Fedora because I never really used it and wanted to know how it was.
For the day or so I've been using it, it's really pleasant so far. I did have to install some extensions to GNOME shell, and I had to add some userChrome.css magic to Firefox so the top bar takes up less screen space. I don't know if it counts as "just works" anymore, but hey, it was easier than caring about "ricing" and whatnot.
I do miss some stuff like my screenshot uploading script, but I found an extension that uploads screenshots to Imgur, so I hope that would be enough, though I'd prefer uploading them to my own server instead.
I am also thinking of shutting down my Gitea, Drone, and a few other selfhosted things, just to clean stuff up further, but I am not entirely sure on that just yet.
FYI, flameshot is really good IMO and worth checking out if you haven't already. It can do imgur uploads, and also has a feature that lets you open the screencap in another app, so you could probably use that to upload to your own server if you "appify" your script. Edit: Looks like someone has done something like that before
I'll try it, thanks for the recommendation!
Edit: It seems to work pretty well, thanks again!
I'm so lucky that I found flameshot before doing my OSCP, the annotation features and copy-pasting were a game changer for reporting.
Now that I'm done with school for the summer, there are a couple of technical projects I'm excited for.
First, I've been working on installing Calyx OS on my Pixel 5, since it seems to strike a good balance between usability and privacy. It also seems to have a good backup system, SeedVault, that will let me back up my data to Nextcloud. The only hangup I've encountered so far is that my current carrier doesn't support anything other than stock Android (No Beta, no Lineage, no Calyx), so I'm working on switching over to Mint Mobile.
Second, I'm gonna start self hosting some services, like nextcloud, splunk, synapse, gitea, and shadowsocks. I have a small, cheap VPS in the cloud, but it doesn't have the specs to do everything I want to do, so I'm planning on putting some old laptops on an isolated network in my house and using Wireguard to bridge them to my VPS. Then, I'll be able to use a nginx proxy to expose the services I need to access publicly.
And I'm gonna reinstall Arch, when I feel like it.
It's slightly ambitious, but I have the whole summer, so we'll see.
~Archwizard
Just finished writing a program that stores the songs, artists and albums played (and number of plays) in a SQLite database.
Here it is: https://github.com/crdpa/cmusicbox
I made it to use with cmus, but it can work with any player that outputs song title, artist name and album title.
cmusicbox-print prints a top 10 artists and a top 10 songs tables.
It is like a poor man's personal last.fm.
I'm planning to output the results weekly to a html page and upload to my website. Since it is a static page hosted on github, i will probably do it by hand.
Any criticisms are welcome. I just learned how to create databases so it's probably messy.
You could definitely run into some issues with your database setup.
The largest one is that you're using things as the primary key that aren't truly unique identifiers. For example, you're using a track's title as the primary key in the
tracks
table, but this means that you can only ever keep a record of one track with the same name. To find a random example from my own music library, both Way Out West and Tesseract have a song named "Survival". Listens to both of those songs would get counted as playing the same song (whichever one was inserted first).The simplest way to solve this without having to re-work a lot of your program is probably to change the tables so they have "compound primary keys", which means the key (which has to be a unique identifier for a row) is made up of a combination of multiple columns instead of just one.
So for the albums table, you could change the definition to be like:
You'll need to modify the
INSERT
statements to change theON CONFLICT
clauses as well, albums would beON CONFLICT(artist_name, title)
.It would also be more typical database design to only store the play count in the tracks table, and you could then get total play counts for artists/albums by just aggregating the rows. For example, getting a total count for an artist would be something like:
Doing it that way isn't essential, but it can simplify a lot to not have the same data spread across multiple places. For example, imagine if you notice that you accidentally left a track on repeat while you were away, and you come back to see that now there are 100 more plays of that track than is really "correct". If you want to fix it, you'd have to subtract 100 from the right row in 3 different tables, instead of only on the track itself.
If you want to try moving towards that, the simple way would probably be to just remove the
plays
column from the albums and artist tables, and changing the inserts into those tables to sayON CONFLICT DO NOTHING
.Thanks a lot! That is really helpful.
I'll change right now.
I think i'm going to do an udemy or another similar course on databases. I noticed i don't know a single thing about it. I messed with PostgreSQL in one course and the syntax is really similar, but it was a little superficial. It didn´t teach anything about how databases work, just insert, replace, etc.
How would i go to print the top 10 most played artists in this setup since plays are only on tracks?
This is not working. An artist has 9 plays with 3 different albums, but the result shows just 6 from the most played album.
Update: using SUM(plays) worked. Is this correct?
Yes, that's right. When you use a
GROUP BY
in your query, you're saying "combine all of the rows together where the value of this column (or columns) is the same". It also allows you to use aggregate functions to specify how you want to combine some columns from the rows together.In general, every column you're selecting in a query with
GROUP BY
either has to be included in theGROUP BY
, or have an aggregate function called on it. This is because otherwise there's not really any way to know what to put in that column of the results. For example, say you have an artist with 3 albums and try to do this query:The 3 rows from that artist are told to all get grouped into 1 row, but what would be in the
title
column? None of the individual album titles is the "right" choice, so you have to specify how you want them combined. For text, you'd usually do something like this:That will make it so that the column has all of the album titles separated by commas, like
Album One, Album Two, Album Three
. For numbers, you can get the sum, minimum value, maximum value, average, etc.