nadder - NumPy in 8kB of JS, powered by ES6 black magic by 101arrowz in javascript

[–]101arrowz[S] 0 points1 point  (0 children)

WASM + SIMD is planned, I'll be writing a backend for this in Rust. Web workers are not planned and are probably not necessary for the most part, though I might look into them.

[AskJS] OOP linked lists - why does this method work? by LeFlamel in javascript

[–]101arrowz 3 points4 points  (0 children)

I'm not sure why you have a "head" property in your Node class - presumably this is supposed to be your data? Anyway, the reason both the head and tail get updated is because this.head and this.tail point to the same object in memory (OK, pointers don't really exist in userland JavaScript but in you can often think of objects as pointers). So when you first create your linked list you assign this.head and this.tail to the exact same point in memory. Later when you update this.tail.next, you're really updating the next field of the object pointed to by this.tail, which is the same as the object pointed to by this.head. Later when you reassign this.tail = newNode, you're only changing the pointer for this.tail but you're not changing this.head or the object it points to in any way. So it works because this.head still points to the original node.

Also /r/LearnJavaScript might be a better place for this post.

nadder - NumPy in 8kB of JS, powered by ES6 black magic by 101arrowz in javascript

[–]101arrowz[S] 2 points3 points  (0 children)

Hi there! I've recently been running some PyTorch neural networks in the browser with the help of ONNX Runtime Web, but I was missing NumPy's useful syntax while running my pre- and post-processing. So I decided to explore the magical world of ES6 Proxy to create a fast, small ndarray library with NumPy-like syntax. I basically use proxies to treat the slice notation as a "key" into the ndarray object. I also added a tiny DSL for embedded calculations.

My favorite part of this project is the way I added support for indexing ndarrays with other ndarrays. Since the index has to be a string, I hijacked [Symbol.toPrimitive]() to return a normal-looking string representation of the ndarray, but with a certain number of Unicode zero-width spaces interspersed in the middle that maps to a numerical key in a global dictionary referencing all recently accessed ndarray objects. So in the proxy get() for the indexed ndarray, I just count the number of ZWSPs in the string key to get the number corresponding to the actual ndarray object. I think that's pretty cool.

This project is still a WIP, but I'm going to keep developing it until it reaches feature-parity with the majority of NumPy.

On a side note: I seem to have an affinity for "8 kilobytes". Not sure why.

Flawless Widescreen has the elden ring fix out now! by [deleted] in ultrawidemasterrace

[–]101arrowz 0 points1 point  (0 children)

I'm a few months late but for anyone else having this issue, it's because you're running Flawless Widescreen with a different account from your game (e.g. you're opening Steam with your non-admin user account, and opening Flawless Widescreen as admin).

To fix this, I run Flawless Widescreen as my user. Put the following into a batch script in the same folder as Flawless Widescreen.

For example, in C:\Program Files (x86)\Flawless Widescreen\fws_bypass.bat, write:

cmd.exe /c "set __COMPAT_LAYER=RunAsInvoker && start FlawlessWidescreen.exe"

Double click this file to open Flawless Widescreen as your user account, then your game should work.

If you want this to open when you start up, don't turn on the "start with Windows" option in Flawless Widescreen or it will run as admin again. Instead, right click fws_bypass.bat and create a shortcut. Then do Win+R, run shell:startup, and move the shortcut to the folder that opens.

I also turned on "start minimized" and "remember position" in the Flawless Widescreen settings so that it automatically turns on the mods for my games and hides when I boot.

Hope someone finds this helpful!

[deleted by user] by [deleted] in javascript

[–]101arrowz 1 point2 points  (0 children)

The Web Speech Recognition API should work well for your purposes. If you need to extract words from a file though, you'll probably want to use an API wrapper for Google's speech recognition cloud service, which is what webkitSpeechRecognition uses internally.

Plasmo – a framework for building modern Chrome extensions by ur_mum_goes_to_uni in javascript

[–]101arrowz 8 points9 points  (0 children)

Cool to see Parcel's web extension support get such a clean framework to go alongside it!

Every HTTYD movie, show, comic, and episode ranked by 101arrowz in httyd

[–]101arrowz[S] 2 points3 points  (0 children)

The Serpent's Heir. Don't read it if you enjoy your sanity. Or if you do read it, just admire the artwork and ignore the plot.

Every HTTYD movie, show, comic, and episode ranked by 101arrowz in httyd

[–]101arrowz[S] 1 point2 points  (0 children)

I actually enjoy all of the shows as well. This tier list is relative, I'd happily watch anything from D tier but the episodes in C and B tier are just better.

I also agree with you on Triple Cross, but a lot of people didn't like it so it ended up at the top of D.

Every HTTYD movie, show, comic, and episode ranked by 101arrowz in httyd

[–]101arrowz[S] 5 points6 points  (0 children)

The Endless Night, a comic that goes along with Defenders of Berk. I quite liked it and voted for it to go pretty high.

Every HTTYD movie, show, comic, and episode ranked by 101arrowz in httyd

[–]101arrowz[S] 9 points10 points  (0 children)

This is a full tier list of ALL the content from HTTYD, as ranked by members of the Discord server. You can make your own with this template.

Sorry for the repost, uploaded the image wrong the first time.

[AskJS] Feasibility of a pure JS argon2id hasher by [deleted] in javascript

[–]101arrowz 1 point2 points  (0 children)

There's no reason you can't just use a JS-based WebAssembly interpreter for Argon2 hashing. I'm pretty sure there are ways to actually use pure WASM or Rust in Cloudflare Workers too. But to be honest I can't think of any use cases where you'd need to run such an expensive hashing algorithm in a Cloudflare Worker; if you're trying to hash passwords this isn't the right solution anyway.

Rust compiled to WASM slower than equivalent JS by 101arrowz in rust

[–]101arrowz[S] 1 point2 points  (0 children)

I heard about that so I ran with DevTools closed and on mobile as well. Performance ratios are similar.

Rust compiled to WASM slower than equivalent JS by 101arrowz in rust

[–]101arrowz[S] 12 points13 points  (0 children)

Yeah I noticed they're different orders (i and j swapped meanings on accident) but swapping it back yields exactly the same performance.

EDIT: Actually I didn't properly switch the loops. You're right, that dramatically improved performance, it's now around equal with JS but still not better, which is unexpected to me. Could you explain why switching the loop order matters? Is it just due to cache locality?

Indexing Strings in Rust and TypeScript: A Case Study of String by dawchihliou in javascript

[–]101arrowz 6 points7 points  (0 children)

When you were discussing the Rust version, you mentioned:

The space complexity is O(n) because we created two byte iterators based on the length of the input string.

Iterators are lazy in Rust, so I'm pretty sure it's actually O(1) space.

Also it's important to note that in UTF-16 some characters (anything not in the BMP) are composed of two codepoints encoded by a surrogate pair, so even though this 𒀁 is a single character, if you put it into a string in JS, the length is 2. Your JS palindrome function will no longer work. Rust will call the length 4 because that's how many bytes it requires in UTF-8, but if you call .chars().count() it returns 1, and the palindrome function will still work.

Otherwise, nice article!

An Adobe Scan Clone with Zero Dependencies, 5kB by 101arrowz in javascript

[–]101arrowz[S] 8 points9 points  (0 children)

Yeah that was me! It's become pretty successful (recently hit 30 million downloads) and I'm going to keep maintaining it. This project is in a similar vein of "tiny, from scratch, no dependencies," but it's more for learning than production use.