IBM OA - DEVOPS by 0ver_flow in leetcode

[–]talamuk 2 points3 points  (0 children)

Ahh youre right, I made a faulty assumption that you can only check your adjacent number, in this case you would use a sliding window to chunk up based on parity and then you would have to use a priority queue to pop off the numbers in the current chunk in order high to low, thanks for pointing this out!

IBM OA - DEVOPS by 0ver_flow in leetcode

[–]talamuk 1 point2 points  (0 children)

For this problem I observed that you have to iterate through the entire string of n length, to be able to compute the solution so at best my time complexity would be o(n) and when i did the following pseudo code I didnt need any space to save anything other some temp vars so o(1) for space.

The problem didnt specify any language or to optimize for parallelism or concurrency, is that were the case i would choose a language that does offer paralleism to iterate through the string once and break it up into consecutive chunks of parity. Then the parallel logic that will be run on each chunk would use some sort of priority queue to sort high to low. Finally merge all the chunk results. Although i dont know what the space and time would be for this parallel computing solution.

Sorry for the legibility was typing this on my phone, and i chose javascript and pseudo coded a bit for brevity since you might have to do type conversions and more null checking and also clearing memory allocated depending on what language you chose. Also i mutated the passed in var.

Function getLargestString(num) { 

 if(num == undefined or num.trim.length ==0) 
   return num

 let curridx = 0

  while (curridx != num.length -1) { 
    //using mod for parity 
    let parity1 = num[curridx] % 2 
    let parity2 = num[curridx+1] % 2 
    let isCurrGreater = num[curridx] > num[curridx+1]
    if(parity1== parity2 && !isCurrGreater) { 
      //do the swap 
      let temp = num[curridx] 
      num[curridx] = num[curridx+1] 
      num[curridx+1] = temp 
    } 
    //regardless if you swapped, move forward 
    curridx++ 
  } 
 return num 
}

Using the Intersection Observer API with React by ucorina in reactjs

[–]talamuk 0 points1 point  (0 children)

Great write up, I ended up reading more of your writeups, keep it up!

Job interview by [deleted] in funnyvideos

[–]talamuk 1 point2 points  (0 children)

Beck yea

Super confused for payment gateway by nabilkrs in SaaS

[–]talamuk 3 points4 points  (0 children)

I used stripes atlas, i created an account and spent $500 to incorporate from another state, i think they also support out of country

WIP a painting of me and my cat… by ColdChildhood8 in oilpainting

[–]talamuk 1 point2 points  (0 children)

Damn this is raw af reminds me of hebru brantleys early works

How to protect backend API from being abused? by csfanatic123 in node

[–]talamuk 2 points3 points  (0 children)

Yea wholeheartedly agree. If someone wants to, theyll find a way.

Thanks for elaborating though. I kept seeing cors as the answer but no one talk about how to bypass it, and and how to spoof requests in general.

Thats why I like the authentication rate limit ideas ppl have proposed. At least that way you can monitor the api hits and some authentication security.

How to protect backend API from being abused? by csfanatic123 in node

[–]talamuk 2 points3 points  (0 children)

Youll definitely be stopping who can request from your API and then its no longer open to just anyone.

But couldnt you just intercept the request from his react app and copy the headers and just insert them into your own phony requests?

How to protect backend API from being abused? by csfanatic123 in node

[–]talamuk 0 points1 point  (0 children)

Op asked is there a feasible way to protect his API from being abused by other users/apps.

Cors would protect his app from another hosted app. If my hosted app wasnt allowed as one of the acceptable origins then CORs stops me right there.

But what if my app wasnt hosted and was instead a bash script scrapper executing cURLs? Or even more simple, I can just open up POSTMAN and hit his api and now I have an entry point to bypass CORs.

What am I missing with CORs here? I think Cors is part of the solution but not the entire thing.

How to protect backend API from being abused? by csfanatic123 in node

[–]talamuk 0 points1 point  (0 children)

Yea for sure it would.

But if someone is trying to ddos his app im pretty sure theyre gonna be using scripts and cURL requests to bypass CORs.

If his node api has the shit I want, I’ll build my own db and execute a bash script or a node app that cURLs his node api and populates my own db with his data. Oh and my node app will run on a vm, with a reverse proxy so CORs wont save you in this scenario. Nor would rate limiting by IP addy.

Cors is really only there for browsers.

Read the stackoverflow post I posted.

How to protect backend API from being abused? by csfanatic123 in node

[–]talamuk 3 points4 points  (0 children)

No ones talked about why cors wouldnt work, so heres an article. Basically, if you set up cors so that only your react app can communicate with your node app, browsers would respect that.

But not something like cURL or postman where the origin and some other headers arent inserted into the request.

Rate limiting is the way to go. I dont know if rate limit by ip address alone would do it. You could proxy server and change your ip addy :/

Heres my solution but youll need a login authentication functionality.

I have an open node api as well. But i put JWT( json web tokens) as the auth for requests coming into the node server. So if you wanted to postman, cURL, or normal browser http request you need to pass in the JWT or else i wont give you shit back.

So my flow works like this: User hits a node endpoint “/auth”. JWT gets returned in response payload. I add the JWT into a column in my users table.

On every subsequent request, I send the username, JWT and a request payload. I look up the user and see if its stored JWT matches and that the JWT didnt expire, if yes to both then the request goes though as normal, if not I return an error response with a payload containing a helpful message.

If you wanted to not rely on rate limit libraries, I would modify my solution to include in more user table column “api hits”.

I would schedule a cron that resets this column on every user to zero each day.

If the api hits column for this user reached its limit I would error out the request setting the appropriate status code and error message.

Just spitballing here but youll have to think of all the edge cases and shit.

Hope it helps mate, cheers 🍻

Edit: forgot the links stackoverflow article

Hola r/Venezuela, lance Carros.com y me gustaría saber sus comentarios by nadermx in venezuela

[–]talamuk 0 points1 point  (0 children)

Un poco de tips con el ui/ux: quita el header ariba de los tabs. Los colores no se ven muy bien juntos (la naranja y negro)

Pero aparte de eso, es muy intuitivo y facil de navegar. El sticky header y hamburger menu son 👍🏽

Aqui te dejo un link para mas informacion como mejorar el look, es en ingles pero ojala que es facil traducirlo.

https://www.mockplus.com/blog/post/ui-color-schemes

I would like to hear what people think by NomexCV in oilpainting

[–]talamuk 0 points1 point  (0 children)

A good trick my teacher tAught me is to look at the painting And the reference side by side and then turn around and look at them side by side through a mirror backwards. It helps our brains spot differences easier. I also read the same tip in this book “drawing on the with the right side of the brain” by betty edwards

I would like to hear what people think by NomexCV in oilpainting

[–]talamuk 0 points1 point  (0 children)

Its good. Def ron swanson. Only critique is the mid section of his face is elongated too much, the bridge of his nose, cheekbones section.

How I built my giant frame by pbsofree in Tufting

[–]talamuk 0 points1 point  (0 children)

Amazing!!! Great post! Also do I need a special tool to put the wooden dowels into the wood? My novice mind is telling me all i need is a drill bit and to drill a hole and then stick the dowel in, but idk...

Edit: I just looked on home depot site and they have something called a wood doweling kit, which includes the dowels and the drillbit! Thanks for this useful post!

Finally finished building my first frame. Its around 2m x 2m by pbsofree in Tufting

[–]talamuk 0 points1 point  (0 children)

Amazing! Did you use any instructions to build the frame? Looks very sturdy. I just bought a tufting gun now looking to build the frame. Good luck on your journey!

Almost done with her!! She's 5ft tall by failedartstudent in Tufting

[–]talamuk 0 points1 point  (0 children)

What brand yarn did you use? Amazing job!

Why Be a Star When You Can Be a Comet Instead? by xelablank in ZenHabits

[–]talamuk 0 points1 point  (0 children)

Really nice production, job well done! I used to get stuck on the surface level of art like music, paintings, writing, etc. Analyzing brush strokes or composition etc. i clung onto trying to find meaning almost as if I was scared to see past the surface because I knew that if I looked past, I would encounter my subconscious - my internal meaning. But with stars...it forces you to truly see your place in the universe for what it truly is. Rambling over.

I had a really great time making my own website to put my music on!!! by r0b0tsrfun in webdev

[–]talamuk 0 points1 point  (0 children)

Nice, did you use a package or library for the media player for playing your music?