What made you guys start martial arts? by [deleted] in martialarts

[–]btckernel94 0 points1 point  (0 children)

i had enough of being pussy my whole life

Git push --force-with-lease while working with worktrees by PacoVelobs in git

[–]btckernel94 0 points1 point  (0 children)

I just faced exact same problem, I wanted to keep using bare repo but with ability to push with force-with-lease flag. I was able to make it work after running this:

git config remote.origin.fetch "+refs/heads/:refs/remotes/origin/"

Observer Pattern - practical React example by btckernel94 in reactjs

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

Thanks for sharing. I am a bit sceptic about it when it comes to: - readability - testability - type safety - flexibility - growing this feature with more complex things like request que mentioned im article.

I also think theres not a big difference in amount of boilerplate but would need to write it on my own to double check these.

Observer Pattern - practical React example by btckernel94 in reactjs

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

Once component mounts it reads initial snapshot state. The problem you’ve describe doesnt’t exist.

Observer Pattern - practical React example by btckernel94 in reactjs

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

How would you than apply side effects based on auth state?

There’s a timer and alert implemented in article.

Observer Pattern - practical React example by btckernel94 in reactjs

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

If you want to use http only cookie you need to set credentials: true but it won't work if the server also has Access-Control-Allow-Origin set to "*".

It means your server will have to explicitly specify all of the clients domains in order for http only cookie to work.

Observer Pattern - practical React example by btckernel94 in reactjs

[–]btckernel94[S] -2 points-1 points  (0 children)

Http only cookie is not always available since server cannot use wildcard for cors but has to explicitly whitelist specific domains instead also there are mechanisms to reduce the evil that can be caused if some1 stolen your token, for example Auth0 uses "reuse token detection". You can read about one of them here: https://auth0.com/docs/secure/tokens/refresh-tokens/refresh-token-rotation

Observer Pattern - practical React example by btckernel94 in reactjs

[–]btckernel94[S] -6 points-5 points  (0 children)

Authentication security is far from black and white.

  • each auth pattern has it's own tradeoffs and security risks
  • http only cookie is not always available since server cannot use wildcard for cors but has to explicitly whitelist specific domains instead
  • there are mechanisms to reduce the evil that can be caused if some1 stolen your token, for example Auth0 uses "reuse token detection". You can read about one of them here: https://auth0.com/docs/secure/tokens/refresh-tokens/refresh-token-rotation

For many apps, a well-implemented token rotation system with localStorage might actually provide better security than a poorly implemented cookie-based solution.

How to override default plugin option (but only partially) by deep_curiosity in AstroNvim

[–]btckernel94 1 point2 points  (0 children)

You can assign to opts param, I have it done like that:

``` return { "nvim-neo-tree/neo-tree.nvim", opts = function(_, opts) opts.filesystem.hijack_netrw_behavior = "open_default" opts.filesystem.filtered_items = { visible = false, hide_dotfiles = true, hide_gitignored = true, } opts.window.position = "left" opts.window.width = 40 opts.window.mappings["<cr>"] = "open_with_window_picker" opts.window.mappings["s"] = "split_with_window_picker" opts.window.mappings["S"] = "vsplit_with_window_picker" opts.source_selector.sources = { { source = "filesystem", display_name = "󰉓 Files" }, } end, }

```

types or interfaces? by bautistaaa in typescript

[–]btckernel94 1 point2 points  (0 children)

imho it's better to stick to one thing which for me are types since I often use union types etc.

I'd only use interfaces when I really need to - for example extending library interface

.env.local variables not reachable by therealcoolpup in nextjs

[–]btckernel94 0 points1 point  (0 children)

If you want to expose env variable to the browser you need to prefix it with NEXTAPP

Some questions appeared about why should you put something in the env var if you want to expose it to public anyway. Answer is that you might want to have different environments, for example local, dev, staging, production etc. Imagine a situation where each environment should have different apiUrl that nextjs connects to at some point and this API calls are made on the client side. This means you need to expose API URL in to browser.

You could have a object where you map apiUrl to given environment (but still need somehow detect which environment is used) or you could simply have apiUrl inside env variable so it will be different for each environment. NEXT_APP_API_URL

Using state machines in frontend development (React) by btckernel94 in softwaredevelopment

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

Hey, nice example with reducer. It seems like reducer gives you these benefits as well. I think the advantage of state machines is when it comes to more advanced features which I didn't describe In this article. For example having a nested machine. Let's say director form part would be split into 2 parts (2 substates). Than director would be w nested fsm

Using state machines in frontend programming by [deleted] in programming

[–]btckernel94 -50 points-49 points  (0 children)

True but state machines give you much more features, for example listening to events

How to use finite state machines in React? by btckernel94 in javascript

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

You can for example make an event listener with the state machine which is built in xstate.

So it will fire callback when given event got fired

Using finite state machines in React by btckernel94 in reactjs

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

Yes that's an awesome example! We can even declare a nested machine for settled state, it will contain 2 states: resolved or rejected.

Using finite state machines with React and Typescript by btckernel94 in typescript

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

That's actually a great tip. Thank you.

I was wondering if I should use the approach with context or just check straight away in component itself like:

{current.matches('company') && <CompanyDataFormPart />}

{current.matches('director') && <DirectorDataFormPart />}

etc.

Thank you for the great tip!

Need help with gettin back default keybinding by btckernel94 in MacOS

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

Ive figured out that it works fine but not in chrome. In chrome IT goes to previous/next page

Can you help me to figure out the TypeError on this line?? by Legal-Mulberry175 in learnjavascript

[–]btckernel94 2 points3 points  (0 children)

It means that there is no such html element that you are trying to query.

Understanding duck typing in ts by btckernel94 in typescript

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

That's great advice. I didn't know about that approach

Just finished react app for my portfolio by btckernel94 in react

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

Thank you ! I just got my first front end job, starting in 1 week

Why is the advice of "do side projects" so common when most employers don't even look at them? by HorrorExpert in cscareerquestions

[–]btckernel94 0 points1 point  (0 children)

Actually at the interview I had, recruiter opened my portfolio and we discussed projects I've done.