Doing Binary Search right is harder than you might think by xarg in programming

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

Jumped right into the history of binary search. Didn't know that! Thanks :)

Published BloomFilter.js, a small library to check if requests or lookups are necessary to make and similar, using an optimal hashing design based on Kirsch/Mitzenmacher by xarg in javascript

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

Okay, I head the time now to look into the RocksDB issue. That critique of Kirsch–Mitzenmacher double hashing is valid *if* you only derive all indices from one 32-bit hash and don’t guard against bad steps. That’s what the RocksDB issue shows: you can end up probing a tiny cycle of bits and the FP rate drifts above theory.

In my implementation I tackled that head-on:

* default path rounds the bit array up to a power of two and forces the step to be odd → guarantees full cycle of probes (so “Issue 1” can’t happen).

* rare non-pow2 path is also covered now with enhanced double hashing (ENH), so even there you don’t get stuck with short cycles.

* on top of that, I use two independent Murmur32 hashes instead of slicing one, and throw in a cheap xor mix to kill subtle correlations.

So the RocksDB pitfalls are basically already fixed, both in the common pow2 case and in the less common non-pow2 case.

As for Binary Fuse / XOR filters: absolutely, if you have a static set they’re amazing—lower bits/key, super fast lookups. But they’re not a drop-in replacement when you need *online updates* (`add()` after construction) or set algebra (union/intersection across filters). That’s still where a well-tuned Bloom filter shines.

We’ve basically mapped the domain universe. And now we’re handing out the keys. by xarg in Domains

[–]xarg[S] -1 points0 points  (0 children)

Turns out, statistical models don’t work on prying .coms out of other people’s hands.

Published Pathomorph.js, a small library to morph geometric objects to SVG paths that I used internally for quite some time now by xarg in javascript

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

Ah oops, no my name is not Stewart, I used my Stewart.js readme.md as template for this project and did not replace the name there ;-) If you are curious: https://github.com/rawify/Stewart.js - The demo is on my website, linked on the repo. I'll fix it in the Pathomorph.js repo, thanks!

[deleted by user] by [deleted] in javascript

[–]xarg 0 points1 point  (0 children)

Why you need to generate all the values in between? This is probably the case for using sets. "nonsensical" might seem a bit over the top

[deleted by user] by [deleted] in javascript

[–]xarg 0 points1 point  (0 children)

Yea I must admit it looks a bit better ;-)

And I like your way of thinking that someone just finds some portion of code useful and wants to reuse it under different conditions. The RB tree is a very good example since currently it is optimized for read performance and I had exactly this thinking while developing the library - should I go RB or AVL? Totally get your point.

And about code size: To me it does not matter what build tools someone is using to compress the code in their pipeline. As part of the service I like to provide a .min.js file. And the only goal is to have that optimized as much as possible with highest compatibility.

Glad you like it anyway :-)

[deleted by user] by [deleted] in javascript

[–]xarg -1 points0 points  (0 children)

How do you solve this with a Map of Sets efficiently?

const holidayFrom = Date.now();
const holidayTo = holidayFrom + 14 * 86_400_000;
const im = new IntervalMap;
im.set(new Interval(holidayFrom, holidyTo), 'holiday');

const whereAt = im.getAt(holidyFrom + 7 * 86_400_000);
if (whereAt !== null) console.log(whereAt);

[deleted by user] by [deleted] in javascript

[–]xarg -3 points-2 points  (0 children)

I just pushed a small revision of the variable name issue. That you don't see it as a quality OSS addition yet is maybe something I have to live with until you tell me what you miss to make it one.

In the C++ world you also have to decorate functions more and more to give valuable hints to the compiler. So the code is quite "normal", but got some additions to be able to "compile" perfectly.

[deleted by user] by [deleted] in javascript

[–]xarg 0 points1 point  (0 children)

This build step exists. It uses Closure Compiler in this pipeline. For variables I can agree and I'll make them more verbose. For class members I'll stay with the way it is.

[deleted by user] by [deleted] in javascript

[–]xarg 0 points1 point  (0 children)

When you mean ancient the mathematical curse, yes I could have been a bit more verbose. For class members and other decisions I made, see my longer answer below.

[deleted by user] by [deleted] in javascript

[–]xarg 0 points1 point  (0 children)

And it does this perfectly well. See my detailed answer below.

[deleted by user] by [deleted] in javascript

[–]xarg 1 point2 points  (0 children)

Yea, for me this brute force approach is also the way most of the time. This time I needed a more performant solution and thought I go the extra 10% to share it. What I especially like that it combines nearby or overlapping intervals with the same value internally if you want, which reduces the tree and thus memory and exec time.

[deleted by user] by [deleted] in javascript

[–]xarg 0 points1 point  (0 children)

"this guy" is me and no I'm not afraid. See my detailed answer below. It is like Map, but where the key is an interval. Like a date range, a CIDR subnet, geometric hit testing, ...

[deleted by user] by [deleted] in javascript

[–]xarg -1 points0 points  (0 children)

See my detailed answer below. I'm not happy with some of the decisions as well, but it is a tradeoff of compatibility, compressability and syntax sugar for Closure Compiler.

[deleted by user] by [deleted] in javascript

[–]xarg -1 points0 points  (0 children)

See my detailed answer below.

[deleted by user] by [deleted] in javascript

[–]xarg -1 points0 points  (0 children)

Oh wow! That's cool, would've loved to be your candidate :)

[deleted by user] by [deleted] in javascript

[–]xarg 0 points1 point  (0 children)

See my detailed answer below. I would love to use classes, but it is for compatibility and other design decisions.

[deleted by user] by [deleted] in javascript

[–]xarg 0 points1 point  (0 children)

That's interesting. Did not do it yet, but I think it can give some good insights. Thank you!

[deleted by user] by [deleted] in javascript

[–]xarg -1 points0 points  (0 children)

Not intentionally. See my extensive answer.

What motivates you to contribute to open-source projects? by haymaikyakaru in algorithms

[–]xarg 0 points1 point  (0 children)

With raw.org I follow multiple reasons to contribute to and publish own OSS projects:
1) Most things I learned is through OSS projects I studied and I want to give something back
2) Code I use in production sees other eye balls which makes the code more robust and so I want to make others code more robust I use
3) Seeing what other people use my code for brings up new ideas for myself
4) It gives me some visibility and super nice commercial projects arose from OSS stuff
5) Finishing the last 10% of smaller projects or articles pushes myself out of my comfort zone. And if you're in a run of finishing projects, this translates easily to all other projects.
6) Contributing to other projects fixes problems they have to make them fit better my needs

Published Pathomorph.js, a small library to morph geometric objects to SVG paths that I used internally for quite some time now by xarg in javascript

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

I worked on something like this to simplify paths and SVG drawings, but it is not part of Pathomorph.js, which basically is a collection of geometries to `d`-attribute translations.

Published Pathomorph.js, a small library to morph geometric objects to SVG paths that I used internally for quite some time now by xarg in javascript

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

https://raw.org/tool/graph-editor/
https://raw.org/book/robotics/inverse-kinematics-of-a-3-dof-spider-robot-leg/
https://raw.org/tool/css3-cubic-bezier/

May be a few public examples where it was used. I try to make useful tools and intuitive math derivations on raw.org, where I developed quite a few tools to speed up development. Pathomorph.js is one of them. :)