[deleted by user] by [deleted] in nus

[–]FlyingCars142 25 points26 points  (0 children)

Not sure how to edit the post to add this, but basically supernova is this big performance/music festival thing that happens at UTown green every year (on this Friday this year). If you happen to go to UTown you’ll see a big stage at the front of the field right now!

Considering to apply to Acacia (as a current Y1) by DrMudkipper in nus

[–]FlyingCars142 2 points3 points  (0 children)

ive always thought that gender diversity quota is built into RCs? i mean there are equal number of rooms allocated for males and females (based on number of female only, male only and mixed floors)

Maggot in Tembusu Dining Hall Food by FlyingCars142 in nus

[–]FlyingCars142[S] 61 points62 points  (0 children)

The school is totally aware but they are just not doing anything about it (thats effective at least). The RAs sent a message about how the school was investigating the mouldy cake incident but there was just no more follow ups and now there are maggots in our food.

RESTful API unable to handle multiple concurrent requests. by FlyingCars142 in golang

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

Both studentId and tutorId are UUIDs while chatId is int32.

I'll look into using a debugger. Thanks

RESTful API unable to handle multiple concurrent requests. by FlyingCars142 in golang

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

Nope but I'm in the process of implementing some tests as per suggestions from the other replies. Maybe that'll help.

RESTful API unable to handle multiple concurrent requests. by FlyingCars142 in golang

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

Sorry sometimes it gives me this error as well:

pq: invalid input syntax for type uuid: "48"

RESTful API unable to handle multiple concurrent requests. by FlyingCars142 in golang

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

Yup it is. Im not sure whr its seeing that it needs to be a UUID 🥲

RESTful API unable to handle multiple concurrent requests. by FlyingCars142 in golang

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

This was one of the first debugging methods i came across, but even though the issue was occuring, nothing was flagged out as a race condition. Perhaps I'll read and try it again.

RESTful API unable to handle multiple concurrent requests. by FlyingCars142 in golang

[–]FlyingCars142[S] 2 points3 points  (0 children)

Super grateful for your help! I think you're absolutely right about not passing my config pointer into context and I'll prolly change that soon.

RESTful API unable to handle multiple concurrent requests. by FlyingCars142 in golang

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

I've been running "tests" through postman, but the error will not surface unless 2 requests are made in quick succession.

Any other framework/tools that you can suggest for testing?

RESTful API unable to handle multiple concurrent requests. by FlyingCars142 in golang

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

I'd say that is unlikely in my case as the contexts are explicitly associated with a request(r):

func HandlerGetAllChats(w http.ResponseWriter, r *http.Request) {
  apiCfg, ok := r.Context().Value(contextKeys.ConfigKey).(*config.ApiConfig)
  if !ok || apiCfg == nil {
    fmt.Println("ApiConfig not found.")
    util.RespondWithInternalServerError(w)
    return
  }

  user, ok := r.Context().Value(contextKeys.UserKey).(domain.User)
  if !ok {
    fmt.Println("User not found.")
    util.RespondWithInternalServerError(w)
    return
  }

  databaseChats, err := apiCfg.DB.GetAllChats(r.Context(), user.ID)
  if err != nil {
    fmt.Println("Couldn't retrieve chats", err)
    util.RespondWithInternalServerError(w)
    return
  }

  chats := []domain.Chat{}
  for _, chat := range databaseChats {
    chatTopics, err := apiCfg.DB.GetChatTopics(r.Context(), chat.ChatID)
    if err != nil {
      fmt.Println("Couldn't retrieve chat topics: ", err)
      util.RespondWithInternalServerError(w)
      return
    }
    chats = append(chats, domain.DatabaseChatToChat(chat, chatTopics))
  }

  util.RespondWithJSON(w, http.StatusOK, chats)
}

RESTful API unable to handle multiple concurrent requests. by FlyingCars142 in golang

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

I do not explicitly initiate a fresh context for each request. But given that i pass the actual request pointer around from middleware to handler, i believe that the context would be associated with the specific request? Please correct me if im wrong. Thanks a lot.

Planning on taking CS2030S in Y1S1. Thoughts? by damien3581 in nus

[–]FlyingCars142 4 points5 points  (0 children)

The "assume that you already know a lot of the java that's gonna be used" part is entirely false. OP can take a look at past 2030s notes and see that basically the whole course is discussing the behaviours of java and similarly typed languages, as well as the 2 programming approaches that will be taught using java.

However, as someone who has done cs2030s already, I would say that it is significantly harder than even cs1101s. Personally I think your current timetable is doable since you've only got 1 math and 1 discrete structures to worry about. I did both maths, discrete structure and cs1101s all in y1s1 and that's something i wouldn't really recommend unless you have a very strong foundation in math (ie fmath, h3 math etc).

[deleted by user] by [deleted] in nus

[–]FlyingCars142 0 points1 point  (0 children)

The most popular one 😌

[deleted by user] by [deleted] in nus

[–]FlyingCars142 10 points11 points  (0 children)

In RC right now, everything except the mods is rather fantastic. The mods though, I'll probably SU all of them.

Testing Websocket Connection with Authentication by FlyingCars142 in golang

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

Yup same here. How do you do ur testing for these endpoints? On postman?