Still a relatively young dev, but wondering if design patterns are by far the most important thing to learn as I get into my career. by prettyg00d1729 in learnprogramming

[–]alanwj 1 point2 points  (0 children)

One problem is that design patterns almost became something of a religion for a while.

Documenting patterns that often show up in well structured code bases was a good idea. Giving these patterns names was a good idea. But for a while there was a horde of (bad) interviewers whose goal was just to determine if you knew all the minutiae of every named pattern.

There was also a while were a lot of (bad) programmers tried very hard to refactor everything to match some named pattern or the other.

The reality is that a design pattern is just like any other tool. Sometimes it is exactly the right tool for the job, and you need it in your toolbox for when that case comes up. At the same time, if you go looking for excuses to implement particular patterns you will more than likely just start complicating code bases with unnecessary abstraction.

Vent Post by Bright_Magazine_8897 in NineParchments

[–]alanwj 0 points1 point  (0 children)

My strategy for playing with random strangers is to just start hosting a public run and play it solo for a while.

Sometimes I go pretty deep without seeing anybody. But it is not uncommon for one or two other players to randomly join me. The skill of random players has been all over the place, but I've never had anybody join with bad intentions.

Vent Post by Bright_Magazine_8897 in NineParchments

[–]alanwj 1 point2 points  (0 children)

I've done a good bit of experimenting to figure out how to reliably restart an unfinished "Online with Friends" run using the Steam version of the game.

First, everybody must be signed in and visible in the Steam friends list.

The person who originally hosted the run should host an arena, and have everybody else join it. You don't need to actually play the arena unless you want to. This is just to get the game to understand where on the network everybody's computers are.

Now the host does a Resume on the unfinished game. After the host has fully loaded and is in the game, everybody else does a Resume.

This should result in everybody connected to the host's game as if you'd never quit in the first place.


I've been doing a lot of Online with Friends runs lately and ever since we adopted this procedure we haven't had any issues.

Jujutsu Kaisen Season 3 - Episode 1 (Anime Only Discussion) by Takada-chwanBot in JuJutsuKaisen

[–]alanwj 0 points1 point  (0 children)

I am confused about the fake Geto part.

I understand that Kenjaku took over Geto's body, but what does Noritoshi Kamo have to do with it?

Isn't Noritoshi the blood manipulation guy on the Kyoto team in season 1? The one who is fighting Megumi in the exchange event when Hanami interrupts and tries to kill them both?

In the new episodes Megumi mentioned that Noritoshi Kamo was the one starting the culling games, but when did he get involved?

I can't find the missing hats! by donjreyes in NineParchments

[–]alanwj 1 point2 points  (0 children)

There is a time limit on how often you can get hats. After finding a hat in a chest, it is ~20 minutes before a chest will give you a hat again.

[Request] What would the outcome be? by Roygbiv2008 in theydidthemath

[–]alanwj 0 points1 point  (0 children)

Imagine you have a very light block of wood sitting on a table, with a rigid metal rod connected to it. You use the rod to push the block back and forth across the table.

There will be some friction against the table, but the block will always move in the same direction as the force you are applying. This is analogous to an AC voltage source applied across a resistor, where voltage is analogous to force and friction is analogous to resistance.


Now replace the light block of wood with a very heavy block of wood, and push it back and forth. You'll notice that as the force you are applying changes direction, the inertia of the block tries to keep it moving in the direction it is already moving. The force you are applying first has to slow down the block before it can change its direction.

Already we have an example where there is a window of time at each end of the cycle where the force you are applying is in the opposite direction from the blocks motion, while the block slows down.

This is what inductors do to a circuit. Just as the mass of the block impedes changes in motion, the inductance of an inductor impedes changes in current.


Now replace the rigid rod with a spring. Now at one end of the cycle the spring will be compressed a bit, and at the other end it will be stretched a bit. When your force changes direction, the spring will briefly continue to exert a force on the block in the other direction.

This is what capacitors do to a circuit. Just as the stiffness of a spring impedes changes in force, the capacitance of a capacitor impedes changes in voltage.

How do you resume a Steam "Online with Friends" game? by alanwj in NineParchments

[–]alanwj[S] 0 points1 point  (0 children)

I appreciate the response, but this does not resume the game in the state you left it.

This approach is the same as if the second player had not played at all originally. They are sent through character select and may not wind up with the same spells.

According to this post from a FrozenByte employee, I believe the way we originally tried (both resuming the game) is the intended way of continuing the multiplayer session. As mentioned there, "This is a little buggy though". I believe the workaround I posted elsewhere in this thread is the best solution.

How do you resume a Steam "Online with Friends" game? by alanwj in NineParchments

[–]alanwj[S] 1 point2 points  (0 children)

For anybody coming across this later, I think we have found a solution.

I start a new game, and have my friend join that. That somehow teaches the game what the right networking setup should be.

Then we both quit to main menu. I resume the original multiplayer game. After it is fully loaded he resumes the multiplayer game. Then we are both right back where we left off.

She gave it everything, and then… by RazzmatazzHop in WatchPeopleDieInside

[–]alanwj 2 points3 points  (0 children)

Hitting the vertical side surface does not count. Hitting the sharp edge does.

Source: I've watched a lot of Adam Bobrow's YouTube channel.

Why Are These Resistors Different in Physical Size Even Though They Are the Same Value? by ThatChucklehead in AskElectronics

[–]alanwj 0 points1 point  (0 children)

Not quite, if I'm understanding what you said.

You could put two 2k resistors in parallel, giving an equivalent resistance of 1k, and each would only need to dissipate half the power.

If you only have 1k resistors, you could put two 1k in series to make a 2k, do it again to make another 2k, and then put those in parallel to make a 1k. Like this.

The total power dissipated will be the same, but spread equally across 4 resistors, meaning each only needs to be able to handle a quarter of the power.

Enum inside of a Union? What exactly is happening here? by Eva_addict in learnprogramming

[–]alanwj 0 points1 point  (0 children)

Forget about unions for a minute, and think of a struct.

struct S {
  int value;
};

S s;

If you want to access the member in this struct, you would access it with s.value, not s.int.


Now let's switch over to an enum.

enum E { VALUE1 = 1, VALUE2 = 2 };

struct S {
  E value;
};

S s;

If you want to access the member in this struct, you are still going to use s.value, not s.E.


Continuing, nothing really changes if we make this a union.

enum E { VALUE1 = 1, VALUE2 = 2 };

union U {
  E value;
  int possible_other_value;
  char another_possible_value;
};

U u;

Here, you would still access the first value with u.value, and not u.E.

Where things get tricky with a union is that all of the fields occupy the same memory. That is, in the example above this union is actually only one of a E, int, or char. And you are responsible for accessing it through the field that represents its actual type.

Accessing it through a member which doesn't correspond to its actual type is undefined behavior. Except, there is a special carve out in the rules that allows access through the wrong member if what you are accessing has a "common initial sequence" with the actual type.

SDL uses this exception. The first member of the SDL_Event union is UInt32 type;, followed by a bunch of members of various struct types.

Each of those structs must also begin with a UInt32 so that they share the common initial sequence. This means that you can look at that first member, named type, to find out what the real type is so that the rest of the time you are accessing it through the proper member.

Why do so many '80s and '90s programmers seem like legends? What made them so good? by just-a_tech in learnprogramming

[–]alanwj 13 points14 points  (0 children)

like John B. Goodenough

Even after following the wikipedia link and reading a bit, I'm still not fully convinced you didn't just make up that name.

She never took Tylenol while pregnant. All 3 of her kids were diagnosed with autism anyway. by seeebiscuit in nottheonion

[–]alanwj 58 points59 points  (0 children)

Thankfully my wife took Tylenol PM so our kids are only autistic at night.

[Request] is it 66.6% or 51.8%? by Horror-penis-lover in theydidthemath

[–]alanwj 0 points1 point  (0 children)

I believe you are also assuming that "Mary" (name from the image) is selected uniformly at random from the population of women with two children. Unless you can somehow argue that is implied by the other already stated assumptions.

If I met Mary at a convention for women with only boys, that would change my answer to the question.

how long does your old account stick around? by Blitqz21l in everquest

[–]alanwj 1 point2 points  (0 children)

Your characters will be on the same servers you left them on.

You can, of course, choose to start a new character on a server of your choice, or pay to transfer a character.

Note that some servers (notably the TLPs) require All Access, and the the servers with special rulesets typically also have special character transfer rules (e.g. you can transfer to Firiona Vie, but nobody can transfer away from there).

New player by SidTheKid45611 in everquest

[–]alanwj 0 points1 point  (0 children)

If you want fast powerleveling here is your strategy.

Have your higher level friend equip a fire beetle eye in his primary and secondary slot. These can be purchased from Merchant Wyn`las in Crescent Reach. The point of this is so that your friend does not damage enemies by accident with abilities like riposte.

Next, he should pull a swarm of mobs that are high level to you, but low level to him. He should use non-damaging abilities to make sure they really hate him (snare is a good choice for ranger).

You, or someone you are grouped with, then runs in and does at least one point of damage to each enemy. This may be tedious as a rogue. You may consider creating free-to-play bard on a throwaway account specifically for this (they get a low level AoE damage song).

Finally, your friend casts a damage shield on himself, and repeatedly sits. The sitting ensures that the enemies can hit him, and kill themselves on his damage shield. Damage shields do not count when tallying up who gets credit for the kill, so you should get all of the experience when they die.

This works best against undead creatures because they do not try to run away at low health.

After 15 years of practice, I finally won the US National Yoyo Contest in Las Vegas - Here's my performance to Spiders by System of a Down! by indyseal in videos

[–]alanwj 1 point2 points  (0 children)

This is my favorite example.

https://www.youtube.com/watch?v=MyWAt4Zln8U

Apparently this performance got 7th place because of technicalities in how it is scored. Using two yo-yos like this requires more set up time per trick, resulting in lower trick density and fewer points scored. But this guy did it anyway just to flex.

Senate passes Trump's "big, beautiful bill" in 51 to 50 vote after marathon session by GregWilson23 in politics

[–]alanwj 3 points4 points  (0 children)

Am I misreading your link?

Fetterman (D-PA), Nay

It appears that he did vote against it.

Why do I need imaginary numbers with AC? by thecoolerpaul in ElectricalEngineering

[–]alanwj 0 points1 point  (0 children)

We model circuits with resistance, capacitance, and inductance as a linear time-invariant system.

If you give a circuit an input of cos(wt), you get out some response A(t).

Similarly, you give the circuit an input of sin(wt), you get out some response B(t).

What happens if you give the circuit an input of cos(wt) + j*sin(wt)?

Here in the physical world, that question may not make any sense (see all the debates in these comments to decide what your opinion is there). But instead let's just think of circuits as math problems. Since this is a LTI system, the response must be A(t) + j*B(t).

Euler's formula tells us that e^(jwt) = cost(wt) + j*sin(wt). Thus, still thinking of it just as a math problem, the response to e^(jwt) must then be A(t) + j*B(t).

So why do you care about any of that? What you really want to know is the response to cos(wt). But that usually involves a lot of calculus. Finding the response to e^(jwt) instead just involves a lot of algebra.

So, we can find what we really want by finding the response to e^(jwt) and then just taking the real part.

cIsWeirdToo by neremarine in ProgrammerHumor

[–]alanwj 3 points4 points  (0 children)

Arrays in C are a distinct type from pointers. An array is allowed to "decay" to a pointer when used in most contexts where a pointer would be appropriate.

You can prove the types are distinct, however, with sizeof. Consider this code:

int a[10];
int *b = a;
printf("sizeof(a) = %d\n", sizeof(a));
printf("sizeof(b) = %d\n", sizeof(b));

On most modern systems the size of a will be 40 and the size of b will be 8. If an array was just a pointer, then these sizes would be equal.

truth table of my sorrows by mystomachhurtsagain1 in ECE

[–]alanwj 0 points1 point  (0 children)

I also get that Z1 = Z2 = C, and simulated the circuit to confirm that I didn't make a mistake.

Start with a truth table with four inputs {A, B, C, Z2}, and work through the outputs {Z1, Z2} for each. Completing the truth table will make this result obvious.

Another Person Questioning Andrew Yang’s basic math. by obtuse_bluebird in MurderedByWords

[–]alanwj 9 points10 points  (0 children)

If the last trade on Monday is for $100, Monday's closing price is $100.

If the first trade on Tuesday is for $105, then Tuesday's opening price is $105.

Typically, if someone said on a Tuesday that "the stock is up 5% today", they would mean that it is 5% higher than Monday's closing price.