What are you coding?

Well, it wasn’t so much devops as my incompetence in python that stopped me last week. But now it is done and working. Much prettier and more maintainable despite my lack of python skills!

And it is ready to be acquiring more features. I’ve already made plans. Once the basics are there adding additional MVCs is kind of trivial :slight_smile:

3 Likes

After spending way more time than I planned on it, I have finished the python project that was intended for my partner to relearn how to code with chatGPTs help. Apparently, just because I can code a bunch of stuff now that I previously couldn’t, doesn’t mean anyone else that doesn’t know how to code can do the same. Duh.

He can now process a bunch of badly formatted PDFs that he is downloading from one of his wine merchants into a nicely formatted excel with tracking of vintages, pricing over multiple documents, markers for new wines and new vintages… so he can keep track of his wishlist. There are way more new vintages of wines every year than there are boardgames. Just saying…

Luckily for me there are some really nice python libraries for excel writing and for pdf reading. Or else this project would have waited for chatGPT to analyze the pdfs for him (we tried with copy and pasting some text from the pdfs and it did really well, it is just not configured currently to process those amounts of data for the users–I am sure it does for the devs :stuck_out_tongue: ).

2 Likes

On about my third or fourth attempt, I seem to have finally discovered how1 to write a web browser userscript that does post-processing of the lazy-loaded video thumbnails on the youtube home page. It… mostly works… I assume there are race conditions to figure out for the cases where it fails. It’s a pretty brute-force approach at present, so I should look for optimisations later, but right now I’m happy.

It was mostly this one grinning idiot face that youtube insisted on showing me over and over and over which prompted me to try to figure this out. I’ve never watched any of their videos, but even the thumbnail pictures irritated me enough to want to figure out a way to make them go away.

1 MutationObserver - Web APIs | MDN

2 Likes

I don’t even understand the use-case. But it could be that I just don’t use youtube on my browser very much. I only watch a few channels on TV…

1 Like

It’s a block list for certain youtube users. I’d looked previously, but couldn’t find a working example of such a thing for the current youtube UI.

If I visit https://www.youtube.com/ in my web browser, I am presented with a big grid of video thumbnails and titles. Some of these pictures and titles are immediately irritating to me on sight, and the videos posted by certain users are guaranteed to fall into that irritating category, and some of those irritating users are evidentially very, very popular and so seemingly every video they make appears on the grid, which only makes them even more irritating.

Out of sight, out of mind is my goal.


I did a similar thing recently for StackExchange sites, in an effort to prevent myself from seeing questions posted by certain people. That script only partially works too, because the markup generated by StackExchange isn’t guaranteed to identify the author of a question (often it only tells you who last edited or answered); however it works much of the time, and something is better than nothing!

In the absence of more helpful markup, my idea for a more robust solution is to query their API for the list of question IDs for the users in question, and then remove questions on that basis rather than looking for usernames in the markup (and maybe store data so that I can query only newer questions); but I’ve no idea when I’ll get around to that. When the end user is me, a low-effort implementation which doesn’t entirely work can be an acceptable trade-off :‍)

3 Likes

I’ve been writing HTML for over 15 years and I’ve only just realised the purpose of a non-breaking space :upside_down_face:

3 Likes

I have spent a lot of my spare time on this instead of boardgames in the last couple of weeks. (The rest is Zelda)

This is 2 things:

  1. email address management tool for our personal complicated mail setup which I reimplemented with python/flask recently.

  2. I have now extended it with my other personal use-case of a delicio.us reimplementation (the ancient long-dead web2.0 social bookmarking tool which proved that not every use-case is a business-case)

At this very moment I am struggling with sqalchemy to figure out an elegant way to select tags along with their link-count in one big statement via the query interface. I hate joins and many2many relationships. Worst invention ever.

If I had considered before implementing this I might have also considered doing it in a more modular way so that I could publish the link/bookmark thing as OSS somewhere just in case anyone would be interested.

But the mail tool is just too specific for us and cannot currently see a way to take the two apart. This may also be a function of my general lack of python / flask skills…

edit: Found it
count = column_property( select(func.count()).where(and_(link_tags.c.tag_id == id,link_tags.c.link_id==Link.id)).scalar_subquery())

2 Likes

I’m perfectly happy with joins, it’s abstraction layers which annoy me…

Or the one I mostly work with, anyhow. The first problem is that it isn’t an abstraction layer in the sense that you don’t need to know SQL to work with it; it just forces you to learn its custom syntax for those particular SQL statements in addition to having to know how you’d do it in SQL. It’s an abstraction layer in the sense that it lets you write code which is agnostic to the RDBMS you’re connecting to, and so the second problem is that it uses the lowest common denominator behaviour in all cases, which leads to joy such as “you literally cannot obtain an integer from a query on an integer column, because everything comes back as strings, because there is some scenario with some supported database in which not doing that causes a problem”.

1 Like

Ah yes and no.
I like querying stuff quickly in the sql console to find test data or see how the model is structured.

In code I really like the abstraction layers because they help me get away from having to modify tons of sql when I refactor the code. They help me make fewer mistakes. And they often allow me to produce more readable code.

We recently spent a lot of time refactoring our DAO objects to use the jpa criteria query API (moving on from hibernate at last) and I must say that while I struggled with it initially… I am happy we moved to a consistent thing and that api can do anything we have discovered, even things that we ended up deciding to stick with native queries because just because the API can do it…

With python here, I like that sqlchemy provides me with a lot of easy to grok query options because my model is really simple—there is just that one many2many relationship. But most of the time that relationship isn‘t relevant. And the queries are shorter and more readable than writing the sql in many cases even though python at least has a nice syntax for writing string templates.

I agree btw the int thing is … awful. I struggle with that still.

2 Likes

A personal quirk: I use case and indentation to help make my SQL readable (at least to me!) years later.

So I might have something like:

SELECT sa.id,sb.id
FROM oldroute AS o
 JOIN stars AS sa on a=sa.id
 JOIN stars AS sb on b=sb.id
WHERE a>b
 AND NOT EXISTS (SELECT a,b FROM route AS r WHERE r.a=o.a AND r.b=o.b)
 AND sa.id IN (SELECT star FROM soldist)
 AND sb.id NOT IN (SELECT star FROM soldist)
ORDER BY (sa.SpNum-sb.SpNum)*(sa.SpNum-sb.SpNum)*(sa.X-sb.X)*(sa.X-sb.X)*(sa.Y-sb.Y)*(sa.Y-sb.Y)*(sa.Z-sb.Z)*(sa.Z-sb.Z)
3 Likes

That indentation is really nice. I have something similar at work but it doesn’t indent the joins. It’s amazing how much more readable that is.

2 Likes

We have style guides for all the languages we use., enforced by diff time linters. It’s very hard to commmit code that violates them. (I don’t agree with their opinions on everything, but consistency is more important than details.)

4 Likes

consistent styles are important. ours have some abominations in it but I am just a freelancer so …

My brain was spiraling out of control today, so I put metaphorical pen to metaphorical paper (in reality: it was vi to file) a stupid idea that occurred to me as a way to distract my brain.

I made a new program: randsort

It takes a filename argument or alternately reads from stdin and then checks if the file is sorted using sort -c; if it is, great, it spits it out and that’s the end of it.

If it’s not, it runs the file through shuf(1), and then checks it with sort -c again.

It will do this continually until sort -c passes.

I think this is O(n!)


EDIT:

$ echo -e "aaa\nccc\nbbb\nhhh\nddd" | time randsort
aaa
bbb
ccc
ddd
hhh
randsort  0.55s user 0.17s system 107% cpu 0.672 total
3 Likes

Today, randsort; tomorrow, the complete works of Shakespeare!

2 Likes

Needs more monkeys.

3 Likes

I had an assignment in college to write a sorting program that wasn’t one of the ones we’d already done. I provided two. One was ‘quantum sort’, which tested if input was sorted. If so, it printed out. If not, it slept a little bit, and checked again.
The other was your rand sort, which required some actual code…,

4 Likes

There’s always sleep sort: each entry spawns a thread which sleeps for a time based on the sort key, then returns its entry.

4 Likes

Sleep Sort is really cool.
I love it :slight_smile: my favorite.

1 Like

And it’s O(n)!

(sort of)

2 Likes