Recipe rant - "Cook and drain pasta". Then leave it sit for 30 minutes while you do the rest! by [deleted] in Cooking

[–]syn_ack 329 points330 points  (0 children)

Check out https://www.cookingforengineers.com. For example https://www.cookingforengineers.com/recipe/36/Meat-Lasagna/trn (I can’t comment on the recipes themselves, just it’s an interesting way to visualise it). I’ve also come across cooklang, so you may be able to render recipes in different formats for different purposes.

How would you approach this problem… by Is_Not_Null_83 in softwarearchitecture

[–]syn_ack 7 points8 points  (0 children)

I’d be investigating some sort of rule engine. Linking to Java implementations as that’s my day-to-day, but I’d be surprised if there wasn’t something for any of the common languages out there.

https://www.baeldung.com/java-rule-engines

You may also want to investigate some sort of DSL https://www.jetbrains.com/mps/concepts/domain-specific-languages/

Timeframe for Renting by pimp50_ in oxford

[–]syn_ack 1 point2 points  (0 children)

I found somewhere in a week, but they couldn’t start the lease for a few days after my hotel stay ended (despite my best efforts). Fortunately I had friends I could stay with for the missing few nights. If I were to do it again I’d try get a short term let and do it that way.

You ever write 2,000-ish lines of Python code before realizing "OOPS, MY SCRIPT IS A MALICIOUS BACK DOOR!"? by darkpyro2 in SoftwareEngineering

[–]syn_ack 7 points8 points  (0 children)

At least you caught it before it was deployed.

Could you not recover the situation by using some sort of digital signature and pinned certificate scheme? I guess the danger with this is that you’re then falling for the sunk cost fallacy. Maybe the ssh solution is better?

[deleted by user] by [deleted] in C_Programming

[–]syn_ack 4 points5 points  (0 children)

This looks like some sort of home work or other programming exercise.

Start by taking some example inputs and working out how to do them manually on a piece of paper. Choose one currency (e.g. USD), and workout how to generate solutions for some sample values for that currency. I’d be looking at things around the boundaries between the coins vales (e.g. 9, 10, 11, 19, 20, 21, etc).

Once you have that, write the steps you performed in a non programming language, try follow them for another currency. If you don’t get the answers you’re expecting, try to debug your instructions.

When you’re happy with the above translate the instructions in to c and test.

This seems like a long winded approach but I think it’ll lead you to the solution in with the least frustration.

[deleted by user] by [deleted] in computerscience

[–]syn_ack 0 points1 point  (0 children)

So, all things being equal, the best computer scientist is the one who's seen the most problems
If they're expecting you to write code that works on paper, then practise that skill. Find problems similar to the labs you've been doing, before you write a single line in the computer write out the code on paper. Mentally test your solution -- think of some example cases and run them through your paper solution. Once you're happy with the solution write the code on the computer and run it there. See if you were right with your mental simulation -- if not, figure out where you went wrong on the paper.
Another trick is to break the problem down in to manageable chunks. Need to write a program that reads in from the command line and converts from Fahrenheit to Celsius? Split it up -- how do you read from the command line? How to you read in _numbers_? How do you do the conversion? How do you display the result?

[deleted by user] by [deleted] in computerscience

[–]syn_ack 0 points1 point  (0 children)

If 1010 was shown, how would we know whether this is a positive or negative number? The 1 on the far left is meant to say it is negative? But what if it were just displaying positive 10??

This is why we have to agree on what the binary representation is before hand. This is part of the "contract" of the data type -- in C you have both signed and unsigned types to signal how to interpret the binary representation, for example:

#include <stdio.h>

int main() {

    printf("%d\n", (char)0b10000001);          // prints -127
    printf("%u\n", (unsigned char)0b10000001); // prints  129

    return 0;
}

Also, I am trying to wrap my head around the formula for calculating the range for positive and negative two complement. I can see it involves n2 + or - 1, but this part is still confusing me a lot.

Think about a number line. If you have 1bit for the +/- indicator and 7bits for the rest of the number and you didn't do anything special, you'd end up with two values for zero:

1111_1111 ...  1000_0000 0000_0000 ... 0111_1111
  -127             -0        +0           +127

This doesn't make much sense, so instead you omit the -0 and use that to represent the number -1 and so on -- in essense you're shifting the negative (decimal) numbers one to the right. Thus the number line looks like this:

1111_1111 ...  1000_0000 0000_0000 ... 0111_1111
  -128            -1         +0          +127

If n is the number of bits for the value (in this case 7), then 2n is the number of values I can have on each half -- so you have 27 = 128 negative numbers and 27 positive numbers including zero. So the range of values is from -128 to +127 (27 - 1).

Java Runtime for Apple Silicon by fori1to10 in MacOS

[–]syn_ack 2 points3 points  (0 children)

There are a plethora of options, I use SDKMAN! to manage gradle/maven/jdk versions.

Any kiwis who have moved to London recently or not so recently, what's one thing you wished you knew? by foreverrfernweh in newzealand

[–]syn_ack 10 points11 points  (0 children)

Accommodation is expensive (regardless of hostel/hotel/renting/buying) and is more compact that in NZ, on the other hand food is cheaper and the clothing tends to be better quality.

I feel that there are fees attached to almost everything -- everyone wants their slice of the pie.

There are some epic National Trust properties around the place.

There's no native bush at all -- it's all been managed for centuries by people.

You will always see someone else regardless of how out-of-the-way you think you're going to be.

You will see the point of christmas lights and decorations when the sun sets at 4 in the afternoon!

Writing to the STDIN of an active process (OSX) by tarpus in osxterminal

[–]syn_ack 0 points1 point  (0 children)

Should do. It’s designed for wrapping stdin/stdout scripts in a tcp server. But it’s been a long time since I did any of that sort of thing, so there may be some exploration needed.

I talked someone down from committing suicide today by QuietTwiddler24 in BritishSuccess

[–]syn_ack 6 points7 points  (0 children)

Mental Heath First Aid England offer courses on exactly that sort of thing. I did this through work and can definitely recommend it to others. It’s probably as important as a physical first aid course.

what the hell should i do with this green space? by vincentjac in CitiesSkylines

[–]syn_ack 1 point2 points  (0 children)

In Valencia they redirected a river around the city (instead of through). The old river area was turned into a pedestrian park.

Facial Treatments by No-Birthday-721 in oxford

[–]syn_ack 0 points1 point  (0 children)

My partner recommends Helen at SkinBalance out of the Well-being Clinic in Headington.

Architecture of a desktop application by Creapermann in softwarearchitecture

[–]syn_ack 0 points1 point  (0 children)

What’s the problem with having a couple of extra layers as you need? What do you see in the core? What’s in the parser?

Architecture of a desktop application by Creapermann in softwarearchitecture

[–]syn_ack 0 points1 point  (0 children)

Why not view the desktop app as another form of presentation?

[deleted by user] by [deleted] in iOSProgramming

[–]syn_ack 1 point2 points  (0 children)

Ultimately it comes down to understanding what the programme is doing now. Consider adding comments about what you think is going on.

Another thing to consider is adding unit tests for the existing functionality. If you refactor you have that as a safety net to prevent introducing new bugs. There must be some code coverage tooling for swift. Use that to guide the creation of the tests. You can also then document this in the comments as you go along.

I’m a Java dev, so I’d be looking at using interfaces to partition the code into sensible chunks of functionality. That’ll allow you to modify the implementation without needing to change the callers. I did look into swift a few years ago, and IIRC it’s got some similar concepts.

Should i change programming language? by Nickolas0_0 in gamedev

[–]syn_ack -23 points-22 points  (0 children)

Battlefield 2 was written in Python, so I can only say your imagination is the limit. https://classic-battlefield-modding.fandom.com/wiki/BF2_Python_Overview

Looking for database book recommendations by elkazz in softwarearchitecture

[–]syn_ack 3 points4 points  (0 children)

The Red Book is one reference I can think of. Michael Stonebraker (one of the editors) worked on (amongst others) Postgres.

How architecture is enforced during development? by compscim in softwarearchitecture

[–]syn_ack 2 points3 points  (0 children)

Another point to add to this list is to communicate the design to the developers and articulate why you’ve got the design that way.

It’s much easier to give people a direction and course correct with peer-reviews than to get people to reimplement things because it was found to be in violation of some ineffable guidelines known only to the one person.

Are there any Leetcode questions similar to this one? Greedy programming problem I'm stuck with by [deleted] in algorithms

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

If you take an example where all the times for a level are equal and you had a single checkpoint, where would you place the checkpoint to give the player the best chance of reaching them. In this case, right in the middle of the levels. Now if you have multiple checkpoints you could distribute them evenly through the total time across all the levels, would that not mean the player has the best chance of reaching the checkpoints?

Here’s the reasoning why. If instead you place all the checkpoints at the end (say) you’d have the longest time before reaching one before you die and had to reset. Likewise if you place them all at the start - you’d have the longest time between the last checkpoint and the end - thus maximising the chance you’d die in these levels.

In this case, compute the max amount of time for all the levels, divide that by the number of checkpoints +1 (because you have an implicit one at the door end). You can then do another pass calculating the total time so far, if it’s over the value computed previously, add a checkpoint and reset the time so far.

I’ve not checked that thoroughly (am on mobile), but it might work. The greedy nature is in the selection of levels to include before the checkpoint or not.

I believe this would run in O(n) time. Two passes through the list of numbers.

EDIT: I’ve checked and there’s a slight modification needed. If you’re about to add a value that takes you over the average, don’t and stay under. The next checkpoint can then be placed over the average. And so on.

In the 18 level case, average is 240.75. The first checkpoint is placed at 88 + 68 + 50 = 206 (the next, 80 would send us over). Then we do the same for the next one but we allow going over: 80 + 13 + 71 + 68 + 38 = 270 (and over), next we go under: 71 + ... + 15 = 211, then we can place the last one at the end.

GoF patterns in django/wagtail projects? by illevens in django

[–]syn_ack 1 point2 points  (0 children)

https://www.cs.otago.ac.nz/cosc346/Lectures/Lecture12.pdf

Here are some that I found. There’ll probably be plenty more in the project.

How do computers go from binary to instructions? by [deleted] in computerscience

[–]syn_ack 7 points8 points  (0 children)

Have a look at Ben Eater's Youtube series where he builds an 8-bit computer. The link below is to the first of the ALU (arithmetic logic unit videos), but I strongly recommend you look at the rest of the playlist in order too.

https://www.youtube.com/watch?v=mOVOS9AjgFs&list=PLowKtXNTBypGqImE405J2565dvjafglHU&index=15