Programming

17432 readers
224 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
26
 
 

The point of this post is to find out if people are interested in reading such stuff or it's not worth the trouble.

So I'm a software engineering graduate who grew up and still in Syria, and we can say we have pretty special conditions we live in, power is out most of the time, and the internet connection isn't that good, plus the shit ton of sites that are blocked by US sanctions (even GitHub acts like a removed here), not to mention I have pretty old hardware that I love to use the most of it.

So most of the times I come up with weird workarounds and manual interventions to get stuff working, so I'm thinking about sharing such workarounds and so, both in English and Arabic if people want that too.

I've been using GNU/Linux for quite some time some time so most of my adventures happen on these systems.

So, I would appreciate it if you guys let me know what you think of this, and if you find it worth reading, I don't actually have any idea of where to post my tiny adventures (it's mostly gonna be your usual text and images)

27
28
29
30
 
 

cross-posted from: https://lemm.ee/post/46066494

I followed the recommended processes for adding images to my app, and it is being displayed correctly on the layout preview, but not at all on the app. I have vector assets, webp, png images, but none are being displayed.

The project is too big to put here in its entirety, but please ask for any snippets that could help you solve the issue. I've tried searching the web and asking LLMs and neither could help, so please help me, fellow humans.

31
32
33
 
 

🚀 NextCloudTalkAutomationBot: The power of a SIEM… without the SIEM! 😆 - A powerful and flexible bot for sending system notifications and Event Logs through messages via Nextcloud Talk. 💬 ✨ Key features: run Bash scripts/commands, using #Nextcloud Talk as your output screen 📺; receive real-time CPU, storage, #Docker #Container status, and Nextcloud/Wireguard authentication logs 🔐 #ServerMonitoring #SelfHosting #RaspberryPi#EventLogging

34
102
submitted 2 weeks ago* (last edited 2 weeks ago) by mesamunefire@lemmy.world to c/programming@programming.dev
 
 

Its come full circle, AI job applicants sending resumes to bots.

35
 
 

wrote a program for y'all gooners here

Don't bother thanking me 😁

36
 
 

There was a lot of engagement in the communities I participate up until a couple of years ago. People were interested and actively discussing a lot of topics. There were a lot of newbies asking questions and people proposing different ways for tasks.

Is it just me or did it reduce a lot? LLMs? Company forums? Other forums I did not move to (e.g. discord)? Reduced interest? Or is it just subjective?

37
 
 

A bookmarklet is a bookmark whose URL is JavaScript code instead of a site. It might be, for example,

javascript:document.querySelector('video').playbackRate = Number(prompt("speed")) || 1; void(0)

// formatted version:
javascript:
document
  .querySelector('video')
  .playbackRate = 
  Number(prompt("speed")) || 1; 
void(0)

so that if you click the bookmark, it sets the speed of the video to whatever you want (e.g. 3.7).

You could also run this directly in the URL bar (in some cases -- I think desktop Chrome does that), or you can simply type alert() into the dev console (desktop Firefox prefers this for security reasons).

Is running my own arbitrary JS like this a thing on mobile? I'm on Android but I'm not sure if Brave disabled it -- I vaguely remember it working once, but it doesn't anymore. No luck on Firefox either. Maybe there's a workaround?

38
 
 

Testcontainers is a library that starts your test dependencies in a container and stop them after you are done using them. Testcontainers needs Docker socket access for mounting within its reaper, so I made a (for now minimal) different library that does not need Docker socket access. It also works with daemonless Podman.

39
 
 

So I'm a database engineer taking some computer science courses and got an assignment to write about symbol resolution. The only reference to it I could find was this https://binarydodo.wordpress.com/2016/07/01/symbol-resolution-during-link-editing/ then a stack over flow of someone asking a similar question to this. I took that to mean "Linking names of any variable, object, etc. in a program to the object in memory" and rolled with that. Hoping someone can clarify if my understanding is correct! Would ask teacher, but weekend and wanting to get this done today.

Here is what I wrote so far.

Symbol resolution is the task of taking something that was referenced by name in a program, and connecting it to the specific item in memory. In a program you can call functions in the program, functions in other programs, objects already created, variables, or even variables created by other objects. All those items are going to exist in memory, on the hard drive, or might be moved to the registrar of the CPU. Symbol resolution is the converting of the names of the items in the program to pointers the computer can use to modify it whenever that name is referenced. When you update a variable, it will need to know where in RAM it is stored, and converting the name of the variable to that address everywhere it is referenced is the process of finding it. Effectively binding an address in memory to that reference.

By doing this, software can work with the exact same variables multiple times, as it it looking in the same place. If a variable is updated, it will know as it’s looking in the proper place in RAM. When working with Object Oriented Programming, it is what defines the differently named objects of the same class as separate parts of memory. Object A of Class Object1 will be bound to a different bit of memory than Object B of Class Object2.

When it goes through resolving symbols, it has to do it in the same order every time, otherwise the programs would run inconsistently. In python for example, it follows the LEGB rule (Scope Resolution in Python | LEGB Rule, 2018). So when trying to find if a variable is the same as another variable, it goes in order of Local, Enclosed, Global, Built In. So it tries to match the reference to anything local, anything in the function, anything global, then tries to match any reference to built in keywords or functions.

As an example:


# Global variable
greeting = "Hello"

# Function that uses global variable
def say_hello(name):
    return greeting + ' ' + name

# Another function that has its own local variable with the same name
def say_hello2(name):
    # Local variable 'greeting' shadows the global variable
    greeting = "Good day"
    # Here, 'greeting' resolves to the local variable instead of the global one
    return greeting + ' ' + name

# Main block
if __name__ == "__main__":
    print(say_hello("Alice"))       # Resolves 'greeting' as global
    print(say_hello2("Bob"))         # Resolves 'greeting' as local within greet_formally

We can see we have two variables both called “greeting”, but they hold different values. In this case using symbol resolution it is able to resolve the “greeting” inside of say_hello2 as having the value “Good Day”. Then it resolves “Greeting” inside of “say_hello” as “Hello”, because when looking for where to link it followed the LEGB rule. In say_hello2, we had a local “greeting”, so it connected to that one and stopped looking for a connection, never making it to the Global “greeting”. If we had an external file we connected with “import” it would then check inside the imported file to try to resolve the names of any variables, functions, or objects. By doing it in this order it will always get the same result and have consistent outcomes, which is essential for programs.

Scope Resolution in Python | LEGB Rule. (2018, November 27). GeeksforGeeks. https://www.geeksforgeeks.org/scope-resolution-in-python-legb-rule/

I know it's a longer post, but thank you for your time!

40
 
 

Hi programmers,

I work from two computers: a desktop and laptop. I often interrupt my work on one computer and continue on the other, where I don't have access to uncommitted progress on the first computer. Frustrating!

Potential solution: using git to auto save progress.

I'm posting this to get feedback. Maybe I'm missing something and this is over complicated?

Here is how it could work:

Creating and managing the separate branch

Alias git commands (such as git checkout), such that I am always on a branch called "[branch]-autosave" where [branch] is the branch I intend to be on, and the autosave branch always branches from it. If the branch doesn't exist, it is always created.

handling commits

Whenever I commit, the auto save branch would be squashed and merged with the underlying branch.

autosave functionality

I use neovim as my editor, but this could work for other editors.

I will write an editor hook that will always pull the latest from the autosave branch before opening a file.

Another hook will always commit and push to origin upon the file being saved from the editor.

This way, when I get on any of my devices, it will sync the changes pushed from the other device automatically.

Please share your thoughts.

41
42
 
 

I'm trying to see how active a project is, but dependabot spam makes it annoying to find actual commits and to know if those commits are relevant.

There's no need for me to know chai was updated from 5.1.1 to 5.1.2, I want to see what were the most recent actual features implemented.

43
44
45
 
 

The title. I have read many technical books (mostly compilation, programming languages & automata) , blogs and whatnot, and recently borrowed the above mentioned book Volume4 (combinatorial problems) from a local library. Just to give a try since Knuth is such a respected person in computer science.

It is by far the most frustrating and maddening book i ever laid my eyes upon. The author doesn't make the slightest effort to explain why something is useful, changes examples before explaining why previous example is interesting or how it shows why X is useful. On page 8, he says that "Graeco Latin squares allowed to François Cretté de Palluel to do with 16 sheeps, what otherwise would require 64 sheeps". How & why ?? No fucking clue. I know i am not the smartest person on earth, but i would love a little hand holding here, you know to explain a concept he introduced 2 pages previously, and gave 3 random anecdotes about.

The writing style is a complete opposite of what I (and I believe, what are most people ) am expecting. If you know something, it won't be useful, and you don't know something : don't count on the book for explanation. I had the physical urge to slap Knuth. It's absolutely maddening.

He then goes on his little hobby to gather 5 letter-English-words, and gives some fancy looking graphs with fancy names (3 cubes, Petterson graph, Chvatal graph). For all what i know, it could be graphs called 42 and graph Blabla. Again no clue how it's useful, nor why it's interesting. He introduces some definitions and theorems.

I am on page 26 (thr book is thicker than a bible) i think i am done. This book will not make you a better programmer, i have no idea who and for what reason could possibly find it useful?

If you think i am overreacting and should continue reading, please tell me so, but i don't expect it to get better

46
47
-47
Ghostty 1.0 is Coming (programming.dev)
submitted 3 weeks ago* (last edited 3 weeks ago) by CodiUnicorn@programming.dev to c/programming@programming.dev
 
 
48
 
 

Our workflows and productivity metrics regularly ask knowledge workers for things that do not make good knowledge work.

Bloggers on reddit lament how much “meta-work” and “not-work” exists in tech. They kvetch about the conversations and the waiting. They consider the principal engineer’s calendar, packed with meetings, quod erat demonstratum that those roles are “easy” and “airware.” They insist that, if they could manage to not get caught, they could keep several such positions simultaneously and never under-deliver on any of them. None of these jobs, they claim, ask them for all that much code.

49
 
 

I'm working on a python program, and i need to sync the results to an ipad as a todo list (with checkboxes)

I had been using google keep, and manually copying /pasting the data over from my cli based app. I will be out of the country for 2 weeks, so im updating my software to no longer being cli, and ideally syncing the final list to google keep or something similar, since someone else will be running the software. You know how normies get when they see a terminal window..

tried this googlekeepapi thing i found online, but the authentication was very complicated and i couldn't get it to work. There is no specific reason we need to use google keep, was just the first thing that came to mind when we set this system up, and it works well and is cloud based.

Do yall know of any service where i can programmatically generate checkbox lists, and sync them over the web?

I should note i do not have a server available to self host. could potentially spin something up locally with a raspberry pi, but would prefer not to have another potential point of failure.

50
view more: ‹ prev next ›