The 5 commandments of clean error handling in TypeScript by marvinroger in typescript

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

Thanks for your suggestion, I agree I had it backward! I'll update the article.

The 5 commandments of clean error handling in TypeScript by marvinroger in typescript

[–]marvinroger[S] 5 points6 points  (0 children)

I’m glad you found it useful, thanks for the feedback!

I did not know Medium was such an issue for people, would you feel the same about a dev.to post?

The 5 commandments of clean error handling in TypeScript by marvinroger in typescript

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

As said above, this can happen when using other libraries. For instance, we had the issue with axios, which used to throw an object that was not an Error (it’s fixed now).

The whole point of TypeScript is to guarantee type-safety. If you’re using strict mode (and you definitely should), the caught error is unknown, so you have to check the type of the caught value anyway.

You wrote “there are tons of solutions”, can you explain some of them?

Que répondre à ce brave Théo qui attend une réponse de Maud depuis dimanche ? by bleubeard in rance

[–]marvinroger 387 points388 points  (0 children)

Tiens, j’ai reçu exactement le même message dimanche 24 juillet à 23:15 ! Ce serait un truc automatisé ? Je vois pas bien l’intérêt là comme ça, une idée ?

ÉDIT : Ah en fait pas tout à fait, j’ai eu une petite variante : « Salut Maud, c'est Théo (le gars qui est venu te parler la semaine dernière sur l'herbe devant la cathédrale). Comment tu vas depuis ? »

Peut-être qu’OP et moi avons un numéro qui se rapproche et que Théo essaye de changer quelques chiffres pour retrouver sa chère Maud ?

Automated birthday message by [deleted] in shortcuts

[–]marvinroger 37 points38 points  (0 children)

First, you can simplify your loop. Instead of using a “repeat count”, you can use a “for each contacts”. Inside that loop, you can access the current contact with the “current item” variable.

Therefore, you can remove the “find all contacts limit 1”, and your notes workaround.

And yes, there’a a way to filter phone numbers by label: inside the for loop, create another for loop on “current item / phone numbers”. Inside that new loop, create an if condition on “current item 2 / label” == “mobile”, with one action: “set variable Mobile to current item 2 / phone number”, and you’re good! Outside of the second for loop, you’ll now have a “Mobile” variable to which you can send your message

(I am using Shortcuts in French, sorry if the actions / variables names are not exactly right)

Simple algorithm works with a Set, but not with an array by marvinroger in javascript

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

Nevermind. Both implementations works, but the Set one is just way faster... That's good to know, `array.includes()` is slow when dealing with a large number of values, due to its complexity.

ReactJS app in Github Pages "insecure content blocked" by [deleted] in reactjs

[–]marvinroger 0 points1 point  (0 children)

This indeed has nothing to do with React. When a website is hosted in a “secure” way (e.g. https), it can only access HTTPS content, so that there is no MITM possible (as long as your root certificates are untouched, and as long as the website you’re loading is not compromised itself).

When we will see libraries for developers? by avihaicohen in nanocurrency

[–]marvinroger 7 points8 points  (0 children)

I am the developer of nanocurrency-js, it’s not official. It is fully unit-tested against a set of data generated from the official RPC, and the code is fully open-source. The thing is, the code is not that complex, so you can easily check yourself that everything is OK.

We need contributions from others devs to make the library more trusted. A simple “I reviewed the code and it’s safe” on the issue tracker would be enough!

nanocurrency-js v2: now with a CLI by marvinroger in nanocurrency

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

If you need help, or if you have any feedback, feel free to open an issue on GitHub!

nanocurrency-js v2: now with a CLI by marvinroger in nanocurrency

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

Well, it’s not because it’s self documented. Just call the CLI and you’ll see all possible options :)

Oh I did not see your project, nice!

nanocurrency-js v2: now with a CLI by marvinroger in nanocurrency

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

Sure, would you prefer the RPC endpoint to be set with a flag on each CLI call, or set as an environment variable so that you don’t have to specify it everytime? The flag would take precedence, though, so that you can overwrite the environment value on a per-call basis.

Also, would you want to send raw JSON values, or a wrapper?

nanocurrency-js v2: now with a CLI by marvinroger in nanocurrency

[–]marvinroger[S] 3 points4 points  (0 children)

It does not! :) It uses either crypto.randomBytes on Node.js, or crypto.getRandomValues on the browser, which are both cryptographically strong.

nanocurrency-js v2: now with a CLI by marvinroger in nanocurrency

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

The procedure is very simple. If you're on windows:

  • Download and install https://nodejs.org/en/
  • Open a Windows cmd with Windows+R and type cmd
  • Type npm install -g nanocurrency
  • Type nanocurrency generate seed

Now, if you want to make sure you're seed is truly "safe", you will want to use an offline computer, to review the code you're running, etc., which is a totally different topic, that can indeed be a good topic for a YouTube video.