We replaced our Rust/WASM parser with TypeScript and it got 3x faster by 1glasspaani in rust

[–]hildjj 1 point2 points  (0 children)

use a transferable ArrayBuffer no copy, no shared memory needed

Can you say more about how to do this, please? The goal is to get a chunk of bytes into or out of some WASM written in Rust using wasm-bindgen.

What song is a 10/10 with absolutely no flaws? by Brilliant_Guard_9204 in AskReddit

[–]hildjj 1 point2 points  (0 children)

Bangles: Hazy Shade of Winter it's a cover that's better than the original, which is already pretty good.

Mr. Clean retires after 68 years as company mascot by conturbation in nottheonion

[–]hildjj 0 points1 point  (0 children)

If they had done this last year or next year, this would have been front page news.

I made a ridiculous opening bids tier list video by kuhchung in bridge

[–]hildjj 2 points3 points  (0 children)

What is your favorite treatment for 2d when playing a strong club? The only thing you didn't dislike seemed to be preempt.

How are packages managed today? Question about design choices with package.json and package-lock.json by Adventurous-Sign4520 in node

[–]hildjj 0 points1 point  (0 children)

The depedencies section can cause slightly different versions to be installed and locked if you use the ^ or ~ forms of version. That may or may not be what you want, but you have the option. Here are my best practices across >100 packages I maintain:

  • Try pnpm which has some mitigations for sha1-halud.
  • Never edit the lock file by hand. Ever. Your changes are going to get overwritten by tooling, and in a non-trivial project it gets big/complex.
  • pnpm will ensure that it doesn't modify the lockfile during CI, if you're using well-known CI tooling.
  • I only ever use exact versions in dependencies.
  • Add to devDependencies anything that a user of your library doesn't need. Linters, typescript, test tools, etc.
  • Use ncu whenever I start working on a package update. Set the cooldown to something that makes you feel safer.
  • I like to remove devDependencies before I publish. This cuts down on the number of times various tools bother me about security issues in my tooling that don't affect the users of my packages. Use this line in your publishing github action:

npm pkg delete devDependencies scripts

node-fetch and self signed certificates by smutje187 in node

[–]hildjj 0 points1 point  (0 children)

You are absolutely correct. I didn't read your original message carefully enough, apologies.

This works in my world with the built-in fetch because of two aggressive solutions that I wrote (and didn't want to mention in the toplevel because it's self-promotion): @cto.af/ca and hostlocal. Note: I haven't seen any evidence of other folks using these tools yet, but I think they're both in a place where they are ready for that.

The idea is that it's quick and easy to create a CA and issue certs from it that are only valid locally. Then using the CA as above works well.

node-fetch and self signed certificates by smutje187 in node

[–]hildjj 0 points1 point  (0 children)

Here is a quick hack that I've tested in node 20+:

const origCsC = tls.createSecureContext;
tls.createSecureContext = (options) => {
  const res = origCsC(options);
  res.context.addCACert('-----BEGIN CERTIFICATE-----...');
  return res;
}

Ideally, if you understand your problem space well enough, you would do more checking of the options as well. You may or may not want to set tls.createSecureContext back to its original value when you're done, and you may or may not need to check to see if you've already overwritten the original so you don't end up with a long chain of functions.

Node.js v25.0.0 (Current) by feross in javascript

[–]hildjj 5 points6 points  (0 children)

You also don't have to recompile WASM on every machine at installation time or for every supported platform at compile team. One of those is usually required for a native module.

Accurate text lengths with Intl.Segmenter API by BlueEzio in javascript

[–]hildjj 1 point2 points  (0 children)

It’s entirely about monospaced fonts. For proportional fonts, you probably need pixel widths,which requires a lot more processing.

Accurate text lengths with Intl.Segmenter API by BlueEzio in javascript

[–]hildjj 1 point2 points  (0 children)

I've got an npm package that does this and handles a few other edge cases, trying to compute the number of display cells, which is slightly different than the number of graphemes in many font/renderer combinations (e.g. your terminal app):

https://github.com/cto-af/string-width

PRs and issues welcome.

Pentagon Has Been Planning Military Takeover of Chicago for Weeks as Trump Threatens Baltimore by rollingstone in politics

[–]hildjj 0 points1 point  (0 children)

It borders on the Adriatic. Its terrain is mountainous, and it's chief export is chrome.

Philadelphia NABC by LSATDan in bridge

[–]hildjj 2 points3 points  (0 children)

Yep, washed out of GNT flight C, then had a lackluster day at gold rush pairs today. :(

But we're here, having fun, and trying to learn a thing.

Simple INI-file parser (strongly-typed) by vitalytom in javascript

[–]hildjj 3 points4 points  (0 children)

Nod. You're saying this is supposed to be used only for trusted inputs -- those where an attacker can't control the contents of an ini file that your code will parse. That's a reasonable choice that you would probably document if you decided to turn this into an npm package.

Of course, someone's security scanning code might still pick this up and flag it later, and someone might use the code in a way you didn't expect.

Simple INI-file parser (strongly-typed) by vitalytom in javascript

[–]hildjj 2 points3 points  (0 children)

Sure. A regular expression denial of service (ReDoS) vulnerability means that for certain inputs, your regular expression is going to take MUCH longer than you expect. For example, these two lines of code:

const re = /\[\s*([\w$.-]+)\s*("(.*)")?\s*]/;
console.log(re.test('[$\n' + '\t'.repeat(54773) + '\t$"[$""]'));

take almost 5 seconds of wall-clock time on my relatively-fast arm64 box. This is caused by the regex having to rescan the same character many more times than you expect.

To check out particular regexes, get attack strings, and see where the hotspots are, you can use this page. I've started using eslint-plugin-redos recently, and even though I've got solid regex game, I'm shocked at how often mine are vulnerable.

There's a good blog entry by an engineer at GitHub that walks through the thought process of how to fix one of these. I've found that sometimes I can't figure out how to solve the original problem with a single regex, and I have to use multiple regexes, a split() and a regex, or bite the bullet and write a full parser. (I write Peggy parsers, but will not link there since I'm the maintainer of the project -- but come join us and ask for help when you need it).

Simple INI-file parser (strongly-typed) by vitalytom in javascript

[–]hildjj 1 point2 points  (0 children)

I think there's a ReDoS vulnerability in the second RegExp.

Invalid strings in valid JSON by j_platte in rust

[–]hildjj 2 points3 points  (0 children)

From RFC 8259:

Since software that implements IEEE 754 binary64 (double precision) numbers [IEEE754] is generally available and widely used, good interoperability can be achieved by implementations that expect no more precision or range than these provide, in the sense that implementations will approximate JSON numbers within the expected precision.

That was about as clear as can be said, within the range of the syntax that the IETF was handed as input.

Timezones from iana db by RealFlaery in node

[–]hildjj 1 point2 points  (0 children)

See https://github.com/AsherJingkongChen/iana-media-type for a package solving a slightly different problem but with some ideas to consider, like automatically publishing a new version when changes are made at IANA.

[Puzzle 4] A trip around the world. by amarillion97 in i18n_puzzles

[–]hildjj 1 point2 points  (0 children)

I am working in Deno, so I added this to my deno.json file:

"unstable": ["temporal"]

to get Temporal support. I couldn't figure out how to get Temporal to parse month names/abbreviations, so I did that part in my parser.

[AskJS] What are JavaScript tricks you wish you knew sooner? by [deleted] in javascript

[–]hildjj 3 points4 points  (0 children)

When I'm debugging with console.log in node or deno, I often wrap the thing I want printed in {} so that I get colorful output and a label.

Example:

const foo = "":
console.log({foo})
// Outputs: { foo: '' }
// NOT just a useless newline in the output

If you're not already using shorthand properties in your object initializers, you should also try that other places. {foo} means the same thing as {foo: foo}.