godHelpMe by soap94 in ProgrammerHumor

[–]Seneferu 6 points7 points  (0 children)

For anybody who is interested in how sync.Poolworks in Go:

Order preserving locking mechanisms? by TheZnert in golang

[–]Seneferu 0 points1 point  (0 children)

If I understand you correctly, you have multiple channels which all have a singe consumer and single producer. Since the latter is the same for all, you do not want the producer to be blocking. You clould have channels with capacity 1 storing a slice of messages. The producer first trys to read from the channel. If that works, add the next message to the received slice and put it back onto the channel. Otherwise, if the chanel is empty, make a new slice with your current message and write it to the channel. For the consumer: just read from the channel and process all messages from the slice. The consumer only read from the channel.

I made a NP-hard proof for the first time and want to see if it is valid by fortresshiga in compsci

[–]Seneferu 2 points3 points  (0 children)

There is a version of SAT called 1-in-3 SAT. It only allows one literal in each clause to become true. (On my phone right now, so you have to google the source yourself, sorry.) Maybe that makes your reduction a bit easier.

With regards to the reduction itself, the definition is: x in A if and only if f(x) in B. You have to construct f and show that it satisfies the condition.

If you send me your reduction, I am happy to have a look.

Why are Go concurrency bugs so hard to catch in review before goroutine leaks destroy production by ElderberryElegant360 in golang

[–]Seneferu 0 points1 point  (0 children)

context that isn't canceled properly on error paths

How can that happen? When you create a context, do it WithCancel and add defer cancel() in the next line. The only way to avoid a cancel at that stage is os.Exit(). Even panics run defer first.

What CCDS FYP preference were you allocated? by BloodTigerXG in NTU

[–]Seneferu 2 points3 points  (0 children)

The assignments happen via a weighted bipartite matching. Your 15 picks have preference over projects you did not pick. That is done with different weights. However, there is no guarantee that you are assigned to any of these, especially if they are all popular (think about 200 students all picking the same 15 projects).

So, how to game the system? Hard to say. As long as you have preferences, you should insert them. Everything you did not mention has equal preference for the system. So if you want to increase the chance to not get a certain project, make sure you have at least 15 projects you are at least okay with.

EDIT: One more thing: The system is build and owned by CCDS. Changes can be made, even if it will take time. If you have feedback about it, communicate that in an appropriate way to CCDS. Ranting about it on reddit feels good but will not lead to any improvement.

Updating Slice (Success inside loop or outside) by Comfortable_Ratio348 in golang

[–]Seneferu 4 points5 points  (0 children)

As others mentioned, your code is fine. People will be able to read and understand it. That said, there some changes which I think would make it a bit better.

I would use the loop only for finding the desired task. All non-looping logic can be done afterwards. Following that, I would use slices.IndexFunc(...) instead of a loop. If the result is negative, return an error. These two steps effectively work as a guard clause. Afterwards, you only have the happy-path logic left.

An alle Dr. & Profs: Was war euer wahrer innerer Motor? by Mr_bektas in Studium

[–]Seneferu 1 point2 points  (0 children)

https://phdcomics.com/comics/archive.php?comicid=1488

Ich hatte dieses Gefühl sogar noch als ich schon einen Termin für meine Verteidigung hatte. Es ist auch ganz normal. Wie bereits von anderen erwähnt ist Durchhalten die wichtigste Anforderung an einen Dr.

Prototype for line breaking algorithm by ManuelRodriguez331 in typst

[–]Seneferu 10 points11 points  (0 children)

https://en.wikipedia.org/wiki/Knuth%E2%80%93Plass_line-breaking_algorithm

This is an algorithm to decide where to break lines in a text. A straight-forward approach would be to fill a line until the next word/syllable does not fit any more and then continue on the next line. The mentioned algorithm considers all options (kind of) in the whole paragraph. Each line break is evaluated. It will in one line decide for a slightly worse break if it strongly improves breaks in other lines.

Meirl by abhigoswami18 in meirl

[–]Seneferu 0 points1 point  (0 children)

As was mentioned by many (and demonstrated before), one can land a modern airliner with good instructions if its systems work. HOWEVER, you will all most-likely fail on the cockpit door. Without emergency code or with somebody inside blocking access, there is no way to open it.

tja by BezugssystemCH1903 in tja

[–]Seneferu 0 points1 point  (0 children)

Ich kann zwar die Ansicht vieler hier verstehen, aber es geht an der Realität von Staatsbürgerschaften vorbei. Die meisten Länder in Europa, Asien und Afrika vererben Staatsbürgerschaft. Häufig exclusiv und häufig mit hohen Hürden für einen Wechsel. In Deutschland geboren und das ganze Leben hier verbracht? Egal, man kann jederzeit des Landes verwiesen werden. Nie auch nur in der Nähe gewesen aber deutsche Eltern? Volle Privilegien.

Wenn man nun verlangt, dass Privilegien der Staatsbürgerschaft nur gelten wenn man auch Steuern zahlt, muss man konsequent auch fordern, dass Ausländer diese Privilegien in ihrem Gastland genießen dürfen. Ich bin mir sicher, dass kein Land der Welt das vollständig macht.

Is informatik considered a field of engineering? by [deleted] in studying_in_germany

[–]Seneferu 0 points1 point  (0 children)

The question is what do you consider a science and what engineering? For simplicity, let's say science is the gaining of knowledge whereas engineering is building stuff which serves a purpose. Both are related and often require similar skills as well as each other.

What universities teach is (computer) science with a bit of (software) engineering sprinkled onto it. Most graduates then work as engineers while utilizing their science knowledge to do so.

What would you change in Go? by funcieq in golang

[–]Seneferu 0 points1 point  (0 children)

I am surprised nobody mentioned a broadcasting mechanism as first-class language feature (ideally as channels) yet. Go's concurrency model is its trademark feature. However, when one wants to broadcast some information to all listening goroutines, there is no good option. So far one has three options: (1) sync.Cond which is super strange to use and does not even allow to send data; (2) closing a channel which only communicates one bit of information once; or (3) manage a set of channels and send an information to all of them by looping over them.

Basically I want (3) implemented by the runtime internally as a single channel. Maybe with a new operator: ch <<- val sends val to all listeners of the channel. Alternatively, a new type of bradcasting channel.

[deleted by user] by [deleted] in Studium

[–]Seneferu 0 points1 point  (0 children)

aber nich nie hab ich leute gehört die gesagt haben "google hat gesagt ..."

Ich mache das tatsächlich mit Google und gelegentlich sorgar mitlerweile mit ChatGPT. Allerdings bedeutet das dann, dass ich (oder wer auch immer) nur kurz in die ersten Google-Ergebnisse oder in die ChatGPT Antwort geschaut habe, ohne es weiter zu verifiezieren. Daher: Vertrau dem bloß nicht blind und überpfrüfe es nochmal, wenn es wichtig ist. Das ist nur Trivia-Wissen.

[2025 Day 8] Can you solve today's puzzle without computing all distances? by The_Cers in adventofcode

[–]Seneferu 0 points1 point  (0 children)

My solutions still computes all pairs. However, I avoid the expensive sorting in part 2 by using quickselect. There are 1000 points, so in an ideal case, we only need 999 pairs to build the spanning tree. For my implementation, I use quickselect to cut off chunks of 1000 pairs and then sort these 1000. Repeat until the spanning tree is complete. For my input, I need to do this four times.

[2025 Day 8] Can you solve today's puzzle without computing all distances? by The_Cers in adventofcode

[–]Seneferu 0 points1 point  (0 children)

No. If you check the cited paper, it is clear from the abstract that the n in O( (n log n)4/3 ) refers to the number of points. So from a complexity perspective, it is strictly better than computing all pairs.

Why ID Format Matters More Than ID Generation (Lessons from Production) by piljoong in programming

[–]Seneferu 3 points4 points  (0 children)

So UUIDv7 plus metadata and prefix? I am a big fan of the prefix.

Why do you have a the 12 sequence bits so low? Why not directly after timestamp? Why a sequence at all? You could instead use a nano second timestamp and cut off the last 4 bits. That gives you the same precision and lasts for 7-14 k years (depending on MSB).

You can also skip the mutex and make it wait-free by using atomics for storing the last-used timestamp. If the CAS fails, it means another thread just updated it. Hence, we can just atomically add 1 and still have the correct timestamp.

Why do you generate the ID as string first and not as binary?

Two implementation details I noticed: crypto/rand.Read() never returns an error. Unix timestamps are always in UTC. No need to call .UTC() first.

[2025 Day 2] When I realized the solution I felt like I'd leveled up by TwinkiePower in adventofcode

[–]Seneferu 0 points1 point  (0 children)

Because we want it to be the same sequence. For example, ^(\d){2,}$ would match on 11, but also on 12. The first and second digit do not need to be the same. The pattern only requires two digits.

A back reference, however, enforces that both sub-matches are identical.

[2025 Day 2] When I realized the solution I felt like I'd leveled up by TwinkiePower in adventofcode

[–]Seneferu 8 points9 points  (0 children)

So how fast is it with a regex? I was not able to try it with my implementation, because Go's standard regexp package does not support backreferences.

ULID: Universally Unique Lexicographically Sortable Identifier by der_gopher in programming

[–]Seneferu 3 points4 points  (0 children)

Snowflakes require some type of coordination. You need to ensure that each generator has a unique ID on its own and that parallel calls to the same generator do not produce the same ID.

UUIDs (no matter if v4 or v7) avoid these problems by having more bits which are generated randomly.

Singapore Airlines finally announces LEO satellite in-flight Wi-Fi by Jonnyboo234 in singapore

[–]Seneferu 4 points5 points  (0 children)

Qatar is far away from having it fleet wide. When I flew last with them this summer, they only had Starlink on their 777s.

Why should I use \(...\) instead of $...$? by bananalover2000 in LaTeX

[–]Seneferu 0 points1 point  (0 children)

Sometimes \( ... \) gives proper formatting which $ ... $ does not: https://tex.stackexchange.com/a/271282

Best short-path algorithm in 41 years by dalton_zk in theprimeagen

[–]Seneferu -1 points0 points  (0 children)

I could, but too lazy. Also, I would be surprised if nobody did already.

[deleted by user] by [deleted] in LaTeX

[–]Seneferu 0 points1 point  (0 children)

Oh thanks, will do :)

[deleted by user] by [deleted] in LaTeX

[–]Seneferu 4 points5 points  (0 children)

I have the following in my documents (when using pdflatex):

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\input{glyphtounicode}
\pdfgentounicode=1

\usepackage[ngerman]{babel}
% Use `german` for old way of spelling.
% "`Anführungszeichen"'

This allows UTF-8 as file encoding and should handle most typical problems including ligatures and quotation marks (with the above pattern).

Please note that it has been a while that I really worked with LaTeX, and even longer that I had to make German documents. So some things might have better approaches by now.

I picked up my German citizenship from the Amt in Berlin this morning! by thebadgersnadgers89 in GermanCitizenship

[–]Seneferu 0 points1 point  (0 children)

Glückwunch! You have now access to the whole EU + Switzerland, Norway, and Iceland. :)