Programming

24452 readers
169 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 2 years ago
MODERATORS
851
852
853
26
submitted 11 months ago* (last edited 11 months ago) by popcar2@programming.dev to c/programming@programming.dev
 
 

I don't like front-end development but I enjoy writing things by hand rather than rely on one-off classes. Even in my blog, I tend to write a lot of HTML manually throughout the post, like creating a quick container to put two images side-by-side and center them, making blockquotes, the occasional nested list, in-line CSS, etc...

I've written some of it in VSCode and Joplin but I didn't find it comfortable to write in either of them. What editor/extensions do you use to make dealing with HTML easier? I'm currently looking at Emmet, but it looks a bit intimidating to learn.

Edit: I ended up using Emmet for writing HTML in general along with Espanso for quickly inserting some templates I use. It's working out pretty well!

854
 
 

IRL, I once listed my favorite bands across metal, rock, hip-hop, electronic, and drum n bass and was hit with "that's standard programmer music".

As someone with little physical human contact outside of work and actually meeting devs outside to find out they listen to the same music was a little surprising. That was a tiny sample though and this is the web though and people are from all over, what kind of stuff do you listen to? Favorite genres, artists, or just "everything" even noise?

855
 
 

It won't give you a standalone course in python but as a supplement outside of projects and something to see your code working in real time it's a great little tool. Been about a year since I used python and it was a good little refresher.

856
 
 

Computer scientists often deal with abstract problems that are hard to comprehend, but an exciting new algorithm matters to anyone who owns books and at least one shelf. The algorithm addresses something called the library sorting problem (more formally, the “list labeling” problem). The challenge is to devise a strategy for organizing books in some kind of sorted order — alphabetically, for instance — that minimizes how long it takes to place a new book on the shelf.

857
 
 

"Unbinding Paste somehow fixed [it] for me." "Paste stopped working for me after upgrading electron to 32.3.0. Downgrading electron back to 32.2.8 resolves the issue."

I experienced the same issue and same hilarious fix.

Neither right-click:paste or ctrl-v:paste work anymore for text copying. All other actions seem to work fine including copy. It is to note that right-click:paste works within the terminal window but nowhere else.

I am on 1.96.4 on Windows and it is working but the Insider build is not.

858
 
 

For those of you unaware: https://nushell.sh/

This is by far the most unique shell out there, since it doesn't use raw text as output/input to command line calls, but instead an actual data structure. It's like if every CLI call returned a database table, in a way.

859
 
 

Anyone using soucehut (sr.ht)? Can you please explain to me how you navigate the site?

I really like the minimalist approach and extremely fast website UI, but I just cannot navigate the site.

If I'm looking at source of a repo on https://git.sr.ht/ and want to see open tickets, how do I navigate to https://todo.sr.ht/ ? If I click on "todo" at the top, it takes me to my todo lists, not todo of the project I was just looking at.

860
13
submitted 11 months ago* (last edited 11 months ago) by j4k3@lemmy.world to c/programming@programming.dev
 
 

Figured I would just ask for the abstract basics. Just consider me an amateur noob. I was digging into ComfyUI code to look into integrating or rewriting a script of mine into a custom node for the first time. The source for custom nodes sourced through the ComfyUI node manager have some kind of Yarn package or system. I have no idea what that is or what it is used for and figured it might make a light conversation.

861
 
 

As in title, my company is seeing a huge uptick in abusive messages from Anaconda.com seeking licensing revenue.

They're hitting many people across the org with legal threats - many with zero control of whether a person uses conda or not. I don't use it in my job at all, and neither do my teammates.

FWIW - we're a small-ish growing startup that just recently crossed the 200 employee line. Our product is a database often used for AI and there are many packages within the Anaconda ecosystem that are owned by us, not them. So I don't know why they'd be hounding us for licensing since the primary reason we'd use conda is to contribute to conda - not consume it.

It's starting the conversation of needing to drop conda support for future releases. If they're going to be this utterly vile, then why would we spend the effort packaging for them?

It's gotten so bad that I've made FTC complaints over this. I'm tired of the near daily threats for something I have zero control over.

If anyone else is experiencing this, I highly recommend reporting the abusive comms to the FTC here - https://reportfraud.ftc.gov/ - also forward the emails to your HR/Legal team so they know to contact the state AG.

862
 
 

cross-posted from: https://lemmy.zip/post/30585875

If this issue gets 20 upvotes, the bot says it'll get added to the backlog to get fixed. Just posting it here to help it get some traction. We have ~40 days before it's simply closed.

Last month I posted this issue to the VSCode github about a bug where new instances of VSCode launched from a windows terminal fail to inherit the environment if VSCode is already running. I have to use Windows where I work and I often need different environments when working on different projects so I'd really like this issue to get fixed.

863
 
 

It looks like each instance wants an instance-specific login, but my federated account is searchable, so I should be able to link it. Problem is, I can't figure out how.

Help me, programming.dev

864
865
866
 
 

I wrote a program that turns the feed it receives from your webcam in ASCII art. It's open source: you can find the code on Github.

867
 
 

I have the following migration:

(Schema::create('user_images',function(Blueprint $table){ $table->id(); $table->binary('image'); $table->unsignedBigInteger('user_id'); $table->foreign('user_id')->references('id')->on('users'); });)

And the following corresponding model:

`class UserImage extends Model { protected $fillable=[ 'image' ];

public function user():BelongsTo{
    return $this->belongsTo(User::class);
}

}`

I am trying to create new UserImage records with UserImage::create but it is always failing, I am sending the image data using curl:

curl -v -F image=@$1 $URL/api/users -H "Accept: application/json"

I have tried so many things but I got different SQL-related errors, I am not sure how am I supposed to encode the image data to get them stored, I know that accessing $request->image returns only a temporary path of the image on the HDD.

868
869
 
 

Hi everyone!

I started learning Rust a couple days ago and I'm having fun with it. I'm trying to learn both for fun but also I plan on going back to Uni at the end of this year after roughly 5 years out of education.

I'm trying to think of projects I can do down the line to practice and for fun. Something I really want to build is a full stack web app (I have some basic knowledge of front end.)

Since I'm trying to learn rust, I was thinking of using something like Actix to build the server.

As for database stuff, I was thinking of postgres since that seems very in demand rn!

As for front end, I'm torn between using something like React which I'm somewhat familiar with or trying something like Yew to write it all in Rust!

I mostly would like some feedback on my plan (I understand there aren't many details given, this is mostly an idea a couple months down the line), if i need to change my scope, if theres anything I should change, any resources that might be helpful, or really any advice!

870
871
 
 

First, some context.

I’ve written a program that starts running when I log on and produces data every two seconds. This daemon keeps all the collected data in memory until it gets terminated (usually when I shutdown the system), when it will dump the collected data to a file on disk.

(These are questionable design decisions, I know, but not the point of this post. Though feel free to comment on them, anyway).

I’ve written another program that reads the data file and graphs it. To get the most current data, I can send the USR1 signal to the daemon, which causes it to dump its data immediately. After restarting the renderer, I can analyze the most current data.

The tech (pregnant women and those faint of heart, be warned)

  • The daemon is written in TypeScript and executed through a on-the-fly transpiler in Node.
  • The data file is just a boring JSON dump.
  • systemd is in charge of starting and stopping the daemon
  • The renderer is a static web page served via a python3 server that uses compiled TypeScript to draw pretty lines on the screen via a charting library.
  • All runs on Linux. Mint, to be specific.

As I’m looking for general ideas for my problem, you are free to ignore the specifics of that tech stack and pretend everything was written in Rust.

Now to the question.

I would like to get rid of the manual sending of the signal and refreshing the web page. I would like your opinions on how to go about this. The aim is to start the web server serving the drawing code and have each data point appear as it is generated by the daemon.

My own idea (feel free to ignore)

My first intuition about this was to have the daemon send its data through a Unix pipe. Using a web server, I could then forward these messages through a WebSocket to the renderer frontend. However, it’s not guaranteed that the renderer will ever start, so a lot of messages would queue up in that pipe – if that is even possible; haven’t researched that yet.

I’d need a way for the web server to inform the daemon to start writing its data to a socket, and also a way to stop these messages. How do I do that?

I could include the web server that serves the renderer in the daemon process. That would eliminate the need for IPC. However, I’m not sure if that isn’t too much mixing of concerns. I would like to have the code that produces the data to be as small as possible, so I can be reasonably confident that it’s capable of running in the background for an extended period of time without crashing.

Another way would be to use signals like I did for the dumping of data. The web server could send, for instance, USR2 to make the daemon write its data to a pipe. But This scenario doesn’t scale well – what if I want to deliver different kinds of messages to the daemon? There are only so many signals.

872
 
 

Hi! Sparrowhub maintainer here. Sparrow is an alternate to Ansible written on Raku. Users can create reusable tasks on many programming languages and run them via Raku SDK scenarios.

If you are interested in contribution, you may:

  • create new Sparrow plugins, it’s easy (no knowledge of Raku is required) so people could use them
  • start using Sparrow as is ( 280 plugins included )
  • contribute in Sparrow core
  • spread the news

Discord channel - https://discord.gg/xpBz6yTj or post your comments, questions here.

873
 
 

I'm currently working on a project in C where I have a choice between using a library for hash tables or simply creating my own hash table from scratch.

What would look better on a Github portfolio from an employability perspective?

874
 
 

I’m working through the vulkan tutorial and came across GLFW_TRUE and GLFW_FALSE. I presume there’s a good reason but in looking at the docs it’s just defining 1 and 0, so I’m sorta at a loss as to why some libraries do this (especially in cpp?).

Tangentially related is having things like vk_result which is a struct that stores an enum full of integer codes.

Wouldn’t it be easier to replace these variables with raw int codes or in the case of GLFW just 1 and 0?

Coming mostly from C, and having my caps lock bound to escape for vim, the amount of all caps variables is arduous for my admittedly short fingers.

Anyway hopefully one of you knows why libraries do this thanks!

875
 
 

This may make some people pull their hair out, but I’d love to hear some arguments. I’ve had the impression that people really don’t like bash, not from here, but just from people I’ve worked with.

There was a task at work where we wanted something that’ll run on a regular basis, and doesn’t do anything complex aside from reading from the database and sending the output to some web API. Pretty common these days.

I can’t think of a simpler scripting language to use than bash. Here are my reasons:

  • Reading from the environment is easy, and so is falling back to some value; just do ${VAR:-fallback}; no need to write another if-statement to check for nullity. Wanna check if a variable’s set to something expected? if [[ <test goes here> ]]; then <handle>; fi
  • Reading from arguments is also straightforward; instead of a import os; os.args[1] in Python, you just do $1.
  • Sending a file via HTTP as part of an application/x-www-form-urlencoded request is super easy with curl. In most programming languages, you’d have to manually open the file, read them into bytes, before putting it into your request for the http library that you need to import. curl already does all that.
  • Need to read from a curl response and it’s JSON? Reach for jq.
  • Instead of having to set up a connection object/instance to your database, give sqlite, psql, duckdb or whichever cli db client a connection string with your query and be on your way.
  • Shipping is… fairly easy? Especially if docker is common in your infrastructure. Pull Ubuntu or debian or alpine, install your dependencies through the package manager, and you’re good to go. If you stay within Linux and don’t have to deal with differences in bash and core utilities between different OSes (looking at you macOS), and assuming you tried to not to do anything too crazy and bring in necessary dependencies in the form of calling them, it should be fairly portable.

Sure, there can be security vulnerability concerns, but you’d still have to deal with the same problems with your Pythons your Rubies etc.

For most bash gotchas, shellcheck does a great job at warning you about them, and telling how to address those gotchas.

There are probably a bunch of other considerations but I can’t think of them off the top of my head, but I’ve addressed a bunch before.

So what’s the dealeo? What am I missing that may not actually be addressable?

view more: ‹ prev next ›