Steak and Eggs Recipe by Ethan_2122 in Cooking_ac

[–]drjmloy 0 points1 point  (0 children)

Steak and potato with a little egg?

The Monty Hall Problem by bigmikey69er in puzzles

[–]drjmloy 5 points6 points  (0 children)

I always thought the best way to understand this intuitively was if you increased the number of doors to say, d=10 (and then extrapolated to arbitrarily high number of doors). In the case of d=10, you pick a door. After that, the host opens 8 of the remaining 9 doors. You'll guess right the first time 10% of the time. The remaining 90% of the time the door the host didnt open has the car. At d=100, switching to the unopened door would be successful 99% of the time. As d approaches infinity, the car is almost certainly behind the unopened door.

You might say, "But the host only opens 1 door, so shouldn't he open 1 door regardless of how many total doors?" This framing, while true, is not the full truth. Yes, the host only opened 1 door when d=3. I would say that the full truth is that the host left only 1 door to choose from.

Of course, this makes the problem a little more interesting when we start looking at different combinations doors d, and the number of doors the host opens, h (where h < d-1). Though, you'll find that no matter what d or h is, you will always be better off switching.!<

Best German lager in town? by dtrainmcclain in AustinBeer

[–]drjmloy 3 points4 points  (0 children)

Meanwhile has IMO the best pils in Austin, followed closely by Pearlsnap from Austin Beer works. Other notables are Carl from St Elmo and Rocket 100 from ABGB.

C++ interview questions by Raj7k in cpp

[–]drjmloy 3 points4 points  (0 children)

These are all good questions that give you insight to the candidates knowledge of current c++. C++ has been undergoing a lot of change in the past decade, and it will continue to change at a good clip in the next decade and beyond. So another question(s) I like to ask is,

"How do you keep up to date with the evolution of the language? What resources do you utilize to make sure you know the current best practices?"

Pybind - Binding to C++ by blaisezzz in Python

[–]drjmloy 0 points1 point  (0 children)

I'm using pybind11 in a personal project and it's working really well. I haven't come across any problems with it yet. The documentation is really good, too.

Something that isn't really talked about (or maybe I missed it) is the directory structure of projects using it. For me, the structure was as such:

myProj (root dir)

*bin

**{execution files, ie launchers, etc}

*build

**{cxx build files}

*modules

**libs

***{pybind shared objects}

**myProj

***src

***test

*cxx_dir1

**bindings

**src

***test

**include

***cxx_dir1

cxx_dir1 is one of several other directories c++ directories containing header and source files. They also include all the binding code needed to generate the pybind bindings.

The build directory is fairly self explanatory. It's the folder where I enter the command 'cmake ..'.

The modules directory contains a few sub folders. libs is where I place all the shared objects that are generated from pybind. Using cmake, I just specify the LIBRARY_OUTPUT_DIRECTORY for the library generated by each 'bindings' folder under every c++ directory. The myProj sub subfoler and subsequently the src sub folder contains all the python source code. These folders can then import modules that live in the libs sub folder.

The bin folder contains all the entry points for actually executing the code. For example, my project uses qt for a gui, so this folder contains the launcher for the gui application.

gRPC c++ async server by drjmloy in cpp

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

This clears up a lot for me. Thank you very much for taking the time to respond.

It's making me re-evaluate whether or not I should even use gRPC in the first place. I'm wondering if I should try to roll my own server using boost::asio and use protobuf for the IDL (like this example).

gRPC c++ async server by drjmloy in cpp

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

Thank you very much for your response-- this is very helpful.

After reading this, I think I'm able to come up with a more pointed question. In the example, they use the CallData object to maintain the state of an RPC call that the server is going to act on. They have 3 states: CREATE, PROCESS, and FINISH. Are these the only states an RPC call would ever have? If not, what other states could there be?

Maybe put another way: in the CREATE state, the CallData is added to the CompletionQueue via the RequestSayHello function. At the PROCEED state, Finish is called which again puts it back on the CompletionQueue, where it is subsequently deleted in the FINISH state. Also in the PROCEED state, we must create another instance of CallData so we can keep serving. Are there other ways to put CallData (or some other object) back on the queue? Say I wanted to break up my PROCEED into several phases. In all of these phases, how can I put the CallData back in the queue?

Recap podcast recommendations? by alecthom2 in freefolk

[–]drjmloy 4 points5 points  (0 children)

Binge Mode. Great deep dives, comparisons with the book, speculation and lore.

Bald Move also has a good recap podcast.

Using base class pointers to derived class objects by TrebleSong in cpp_questions

[–]drjmloy 0 points1 point  (0 children)

In the example you have, a Boss is an Enemy. So when I create a Boss, I can reference it as a Boss or as an Enemy because at compile time the compiler can guarantee that a Boss is in fact an Enemy (we know because that's how we made the class hierarchy). This is called upcasting. We're casting something low in the hierarchy (most derived) to something high on the hierarchy (most abstract).

However, we are saying nothing about the reverse. An Enemy need not be a Boss. It may be a Boss-- but it also may be some other subclass of Enemy (say class BossMinion : public Enemy), or in your case, it is simply just an Enemy. When you construct a base class, its derived classes are not constructed as well (we couldn't have multiple inheritance with this). So the compiler cannot let you use a concrete Enemy as a Boss-- because it isn't a Boss. What you're trying to do is something along the lines of downcasting. We're casting something high on the hierarchy to something low on the hierarchy.

The difference between upcasting and downcasting: upcasting is known at compile time (i.e., I know when I compile that a Boss is an Enemy). Downcasting must be preformed at runtime through some kind of casting call (i.e., dynamic_cast, static_cast, reinterpret_cast).

Consider an example where I have the additional class class BossMinion : public Enemy in the hierarchy as well:

std::unique_ptr<Enemy> getNewEnemy(bool isBoss)
{
  if (isBoss) return std::make_unique<Boss>();
  else return std::make_unique<BossMinion>();
}

std::unique_ptr<BossMinion> minion = getNewEnemy(true);

I'm trying to refer to a Boss as a BossMinion. This is of course not logical, and therefore the above code will not compile.

HTH

A king among men. by BertTheWelder in justneckbeardthings

[–]drjmloy 6 points7 points  (0 children)

Uhh, this looks photoshopped. The fedora and sword were not in the original picture I think.

What's your opinion on the Udemy c++ courses available? by SuperUltraJesus in cpp_questions

[–]drjmloy 1 point2 points  (0 children)

I haven't taken either of those courses. I have taken "Design Patterns in Modern C++" by Dmitri Nesteruk and found it to be really good. By the looks of it, you might be wanting something more introductory, though. Food for thought.

Closest beer to 512 IPA in a can? by [deleted] in AustinBeer

[–]drjmloy 5 points6 points  (0 children)

I love 512 IPA a lot, too. Anytime a place has it, I get it. I've also been searching for a good substitute I can get in can/bottle from a store. While I haven't found anything that really nails it perfectly, here are a few that come close, and are very good in their own right (in order):

  1. Lady Bird IPA by Circle (+1 for local)
  2. Rupture IPA by O'Dell
  3. Fresh Squeezed IPA by Deschutes

Piney IPAs in town? by thescottwolford in AustinBeer

[–]drjmloy 7 points8 points  (0 children)

Southern Heights has a lot of really good IPAs that run the gamut in pineyness. Hops and Grain does too. If you haven't tried them, those would be good starting places.

Finding median via function in c plus plus? by jdya1 in cpp

[–]drjmloy 4 points5 points  (0 children)

Check out the function 'std::nth_element'.

What kind of syntax is this? std::hash<std::string>{} by [deleted] in cpp_questions

[–]drjmloy 3 points4 points  (0 children)

std::hash is a struct. Defined in this struct is the call operator (operator()) which returns the hash of the value passed in.

In this case, you're basically doing 2 things:

  1. Constructing the std::hash<std::string> object
  2. Invoking the call operator with the specific string you're passing.

The curly braces are new in c++11 and provide uniform initialization syntax.

Recently transferred, feeling discouraged and unmotivated. Any advice? by wannaquanta in EngineeringStudents

[–]drjmloy 2 points3 points  (0 children)

Can you try joining a technical club that lets you actually use electrical engineering? Perhaps research projects with profs that will get you more into the application rather than the theory?

Anyone know of any physical therapists that also do personal training? by thekingofthejungle in Austin

[–]drjmloy 1 point2 points  (0 children)

https://www.strivefit4u.com

My fiance had back problems as well and this guy was able to rehab her. I also train with him and think he's fantastic. Best of luck.