What does it mean to associate a table/record

I know this is such a basic question but I can't seem to find an answer online, (yes I know a table and a record is different)

If I am to say, I associate this record, or this associated record. Is "that" record the one with a foreign key, or the one which has a foreign key referencing it?

Thanks

reddit.com
u/BrotherManAndrew — 22 hours ago

Proper design for handling different type of chats

I was studying a bit on discord and wanted to for fun try to make a copy (Free time during summer so why not, plus free practice) So I was looking at things and a question came up to me, what would be the proper way to handle multiple different types of chats, (No OOP) but in a FP lang, But I think the distinction doesn't really matter

I thought of a few different ways but I would like to know which one would be be best. I am not a sql wizard, just a newb who knows a bit and would like some opinions on design

So imagine we had

- Direct Message

- Groupchat

- Server

There's 2 approaches that come to mind.

  1. We have one table called rooms, or chats or whatever ye call it. Within there is a column that describes the TYPE of the chat (DM, Gc, etc) Now depending on the type of the chat there will be different tables that reference it that is to say.

If I create a server there will now be a moderation table, and this moderation table only has relations to chat's with typeof server. So for the applications end, depending on the type of the chat it will be treated differently and different relations may be made for it. But it is still a chat

This doesn't seem too bad to me but maybe there is some caveat that I have not thought of yet, something immediate that comes to mind is maybe handling all these types would be harder, but it can't really be that difficult, you just have different modules (like in FP) that handle the different types of chats. And likewise, there will only be one memberships table and it will be the applications duty to ensure that for example a direct message will only have 2

Hard decoupling strategy, in short. Direct messages have their own table, it's memberships is it's own tables, etc.

Servers has it's own memberships tables, it's own channels tables, it's own roles tables. and on and on and on.

I think the latter might be better for decoupling and make things simpler, but it might introduce a lot of duplicated code, whereas the former has less duplicated code but may be harder to maintain. Can ayone give any opinions? I am not a DB guy and wouldn't really know

reddit.com
u/BrotherManAndrew — 1 day ago

Is there a way to gain mandible growth without recessing the Maxilla?

I've been researching things like twinblock and herbst (yes I will ask an orthodontist once I can) but in the meanwhile, all of these end up recessing or limiting growth of the Maxilla which isn't really good either

Is there a solution to grow the Mandible to deal with a overbite while at the same time not recessing the maxilla?

reddit.com
u/BrotherManAndrew — 12 days ago
▲ 10 r/roblox

Remember a shooter game called "test game"

it was like 5 years ago maybe 2019, it was a game called, "test game" or something similar, it was a simple shooter game with multiple maps where you would just shoot or use a knife ingame, I remeber there was like a laser you could use?

It was a really fun game I remember there was a map with some balloons, or another map with a sort of factory and in the back like truck loading area with another area with some greenery

Just if anyone remembers something similar tell me! I think the game is eventually deleted though

reddit.com
u/BrotherManAndrew — 13 days ago
▲ 2 r/elixir

Is this the right way to stopping a request when there is no refresh token? (send_resp)

In my application I have a pipeline

  pipeline :auth do
    plug(AppWeb.RefreshPlug)
    plug(AppWeb.Auth.Pipeline)
    plug(AppWeb.Auth.SetAccount)

    # we can always run conn.assigns.account
  end

My refresh plug works in a way that if there is a refresh token it will issue a new access token in the header, otherwise...

defp put_access_token_in_headers(conn) do
    refresh_token = get_session(conn, :refresh_token)

    case refresh_token do
      nil ->
        put_status(conn, 404)

      _a ->
       # some code
    end
  end

We return a 404, Nice and good, my expectation was that the response would be sent there, however it still went to the next plug and then finally my application via the guardian library decided to give a response from there being no access token, not the core issue and I started to get worried,

what if functions run in general on conn’s with bad status codes!!! I don’t know if that’s a real concern maybe someone knows but anyways

I was thinking okay, what if I just use Halt, but that made it so I didn't get any response at all, so I would just want to stop there and send the response maybe, send_resp https://plug.hexdocs.pm/Plug.Conn.html#send_resp/1

So I just added send_resp(conn, 404, "No refresh token"), it seems to work, but is this the proper way to do it? And the question above, in pipelines is it good to just stop the connection and send_resp when there is a bad status code or something you don't like?

edit: In retrospect the post title isn't very clear about what the post is about, sry about that

reddit.com
u/BrotherManAndrew — 22 days ago
▲ 30 r/reactjs

Why does useEffectEvent use the latest commited values from render and not just the latest values from render?

I was reading the react docs for useEffectEvent which I came to this part https://react.dev/reference/react/useEffectEvent at the beginning it says

“Effect Events are a part of your Effect logic, but they behave more like an event handler. They always “see” the latest values from render (like props and state) without re-synchronizing your Effect”

This makes perfect sense to me, but lower down then it says “callback:
A function containing the logic for your Effect Event. The function can
accept any number of arguments and return any value. When you call the
returned Effect Event function, the callback always accesses the latest committed values from render at the time of the call.”

Emphasis on the “Latest commited values” Why would the useEffectEvent access the latest commited (shown on screen values) values instead of the latest values from the render like all the other hooks seem to do? Is there any real distinction or difference between the two? Is "commited" here just not the terminological term?

I am sort of confused and would like some clarification, thanks

u/BrotherManAndrew — 29 days ago
▲ 3 r/elixir

What happens if an overrided function is not pattern matched on?

Hi, so I wanted to implement a system in Guardian DB where the token is only stored if it's of type refresh, My idea was to have it so the extra fancy callbacks of Guardian DB only get applied if the token is of type refresh

So the top level Guardian.ex file has something like this

\def after_encode_and_sign(_r, _claims, token, _), do: {:ok, token}``

And

defoverridable after_encode_and_sign: 4,defoverridable after_encode_and_sign: 4,

Now I haven't implemented the pattern matching yet but it really wouldn't be that hard to in the function signature, my after_encode_and sign looks like this

def after_encode_and_sign(resource, claims, token, _options)     do
    with {:ok, _} <- Guardian.DB.after_encode_and_sign(resource, claims["typ"], claims, token) do
      {:ok, token}
    end
  end  def after_encode_and_sign(resource, claims, token, _options) do
    with {:ok, _} <- Guardian.DB.after_encode_and_sign(resource, claims["typ"], claims, token) do
      {:ok, token}
    end
  end

```

Sorry if it looks sort of ugly once I post it so imagine in my implementation file I will have it so the token that's pattern matched someway or another (still figuring that out) will only work if it's of type refresh right?

but I think in my case it will be in the function signature which is where my question really shines

If for some reason, it does not match and there was an access token or something else ridicoulous, will it still run the default after_encode_and_sign that just returns the token? (seen above) defined in the guardian.ex dep

In short, if an overrided function is not pattern matched on, will the original version then be ran?

reddit.com
u/BrotherManAndrew — 2 months ago
▲ 17 r/elixir

Idiomatic way to see if a collection of values are all equal?

In my application I want to check if 3 variables equal to the same value, I mean I could try to chain a bunch of == but that seems very superfluous unnecessary. What is the proper way to see if a collection of values are all equal?

reddit.com
u/BrotherManAndrew — 2 months ago
▲ 4 r/elixir

Confusion about how tokens are stored in sessions

Hi, I was implementing some code for guardian authentication from the tutorial linked here: https://www.youtube.com/watch?v=58o66XhsWj8&list=PL2Rv8vpZJz4zM3Go3X-dda478p-6xrmEl&index=8

and I came across this line of code

plug Guardian.Auth.VerifySession

I understand that it finds the token from the session (which is a place where data from subsequent requests are stored) but how is this token stored in the session in the first place ? Is it when the user registers that the server takes the token and both gives it to the user as well as storing it in the session ? Is it when the user logs in (sending a request) and gives the token to the server which is then placed into the session ? How does the session even work elixir/phoenix wise!?

This is confusing to me, and any help would be appreciated !

u/BrotherManAndrew — 2 months ago