Search found 475 matches

by Tub
Fri Aug 16, 2019 8:30 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

For some reason, nobody considers encoding A as <uppercase> + <a>, even though they are considered "the same character" in any language I know. But with accents, that's different. Sorting and case-insensitive comparisons are solved problems - if you're willing to use existing libraries. Of...
by Tub
Wed Aug 07, 2019 7:48 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

Also NASE, I just occasionally use that stuff for mission-critical systems :roll: The way you derive the key from the data cannot be arbitrary, but using a cryptographic hash as you suggested seems sound. The avalanche effect guarantees properties about the randomness of the output of a cryptographi...
by Tub
Mon Aug 05, 2019 1:11 pm UTC
Forum: Computer Science
Topic: Computer Senses
Replies: 7
Views: 806

Re: Computer Senses

What makes you believe that counting inputs will tell you anything valuable about the quality of a trained machine learning algorithm?
by Tub
Tue Jul 16, 2019 8:37 pm UTC
Forum: Coding
Topic: C++ IF Statement Error?
Replies: 4
Views: 1049

Re: C++ IF Statement Error?

Things you should never ever code yourself: ⋅  Time, Timezone and Date handling ⋅  Crypto ⋅  parsers and serializers for XML, HTML, JSON etc ⋅  SQL query builders Nobody ever gets either of these things right the first time. For anything serious, use a well-te...
by Tub
Tue Jul 09, 2019 10:32 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

Thanks to marketing, I've seen dozens of incompatible definitions of "blockchain", most of them far removed from the distributed algorithm behind bitcoin. But you're the first to use the term blockchain for ephemeral data. In other words, I still have no clue what problem you're actually t...
by Tub
Tue Jul 09, 2019 1:28 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

Huh. C++ really doesn't have a Self keyword. I've been rust'ing too much. I'm not aware of any standard compliant way to get that typedef in a static context, but you don't need it: auto cb = std::bind(&std::remove_pointer<decltype(this)>::type::bar, this, std::placeholders::_1); You can also do...
by Tub
Mon Jul 01, 2019 11:38 am UTC
Forum: Computer Science
Topic: paper and pencil cyrptography
Replies: 3
Views: 1446

Re: paper and pencil cyrptography

You can easily do pubkey cryptography with a pen, paper and a couple of dice. Just look into existing schemes like RSA or elliptic curves. It just takes forever. For example, RSA recommends at least 2048-bit keys. If you have a reasonably short message (about a tweet full), encryption or decryption ...
by Tub
Mon Jun 24, 2019 9:06 am UTC
Forum: Coding
Topic: Puzzle: Find integer not present in an array
Replies: 9
Views: 1843

Re: Puzzle: Find integer not present in an array

We have an algorithm with O(n) runtime and O(n) memory, and we have several with O(n log(n)) runtime and O(1) memory. Here's one with O(n) runtime and O(1) additional memory. The idea is to re-organize the array such that each number x < n is at index x, with numbers >= n occupying an arbitrary posi...
by Tub
Sun Jun 23, 2019 2:51 pm UTC
Forum: Coding
Topic: Puzzle: Find integer not present in an array
Replies: 9
Views: 1843

Re: Puzzle: Find integer not present in an array

It's in linear time because it always does 32 iterations over the array If you're going to pretend that log(n) is a constant, why don't you go all the way? Your algorithm is bound to run in (2^32 * 32 * constant) steps, which is O(1) :roll: You don't need a bitmask over 2^32 numbers. If your array ...
by Tub
Sun Jun 23, 2019 12:51 pm UTC
Forum: Coding
Topic: Puzzle: Find integer not present in an array
Replies: 9
Views: 1843

Re: Puzzle: Find integer not present in an array

You don't need a bitmask over 2^32 numbers. If your array contains n numbers, then you just need a bitmask over n+1 numbers. After crossing out all the wrong numbers, at least one is guaranteed to remain. I'm wondering though: if you're allowed to modify the array, is it possible with less than O(n)...
by Tub
Tue Jun 04, 2019 9:50 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

Going to resolve this real quick. Quoting mdn on instanceof : The instanceof operator tests whether the prototype property of a constructor appears anywhere in the prototype chain of an object. For A instanceof A, you need A to * be a constructor (a function) and an instance * as a constructor, have...
by Tub
Wed May 29, 2019 7:29 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

Oh. I missed that rather trivial solution, too. It's true, this will also work for all of Function's parents, which is just the one you mentioned.

But no, it can be solved without reusing an existing constructor. I don't think defineProperty will help much.
by Tub
Wed May 29, 2019 10:45 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

I just realized that javascript's Function class has a unique property. All constructors are functions, so they inherit from Function. This includes the Function constructor: >> Function instanceof Function true A small challenge is thus: create a new variable A (with A !== Function) such that >> A ...
by Tub
Tue May 28, 2019 9:07 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

const /*or let or var*/ variable = someFunctionOf(variable) This works does not explode with var. Anything declared with var has a scope of the whole function, being initialized to undefined before its first assignment. It doesn't work with const or let because of their restricted scope and tempora...
by Tub
Sat May 18, 2019 10:00 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

It's also fast. Counting the time between starting the game and watching the last object pop in, the wasm implementation appears to be ~20-50% faster. Success. I wasn't happy with this. A bit of benchmarking later, the mesh generation code has been improved by another +120% on top of the previous i...
by Tub
Thu May 09, 2019 8:14 pm UTC
Forum: Science
Topic: Science fleeting thoughts
Replies: 445
Views: 65418

Re: Science fleeting thoughts

You were the one that brought up the book. Don't expect a recommendation from me. Anyone who claims that time doesn't exist is demonstrably wrong. Anyone who claims that time is "just an illusion" is misunderstanding the nature of scientific theories as descriptions of our universe. Anyone...
by Tub
Thu May 09, 2019 4:39 pm UTC
Forum: Science
Topic: Science fleeting thoughts
Replies: 445
Views: 65418

Re: Science fleeting thoughts

My point is that the entirety of the state of Conway's Game of Life is the position of the cells, and an evolution function which does not include time in the description, but only tells you the next position. Considering that time is discrete here, your evolution function implicitly works on a tim...
by Tub
Thu May 09, 2019 3:29 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

TIL that google will happily store and monetize all of your location data, but considers it a privacy problem when someone else does. :roll:

Xeio wrote:I can't decide if this is beautiful or horrifying:

It can be used for good or evil. I wonder, which is it?
by Tub
Thu May 09, 2019 9:38 am UTC
Forum: Science
Topic: Science fleeting thoughts
Replies: 445
Views: 65418

Re: Science fleeting thoughts

We can describe things in terms of time, but that doesn't necessarily mean that time actually exists. For example, it may be that everything in the universe can be described in terms of different fundamental dimensions and that dimensions like mass and time can be expressed in terms of units like s...
by Tub
Wed May 08, 2019 10:19 pm UTC
Forum: Science
Topic: Science fleeting thoughts
Replies: 445
Views: 65418

Re: Science fleeting thoughts

Is it a dimension, though? By any common mathematical definition, time is a dimension. If you want to uniquely identify an event within the universe (or a game of conway), you need 3 (or 2) spatial coordinates and one time coordinate. You can't go backwards, and forwards doesn't exist until the cha...
by Tub
Tue May 07, 2019 11:39 am UTC
Forum: Science
Topic: Is it possible to escape from a black hole using another black hole?
Replies: 56
Views: 6594

Re: Is it possible to escape from a black hole using another black hole?

I think the event horizons of Kerr black holes are oblate spheroids, or something similar, and the minor radius is smaller than the Schwarzschild radius. This should in principle allow two Kerr black holes that are rotating extremely quickly to pass by each other without their event horizons overla...
by Tub
Sat May 04, 2019 9:00 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

Update: I ended up solving the mutability problem by using std::Cell. Cells cheat the whole lifetime issue by disallowing getting a reference to the things inside. You can just copy values in, or copy the current value out. With those semantics, it's safe for them to allow changing the value inside ...
by Tub
Fri May 03, 2019 10:00 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

Would it make sense to map over the collection producing a collection of Option<Mesh> objects (Some if a mesh is generated) and then zip the two collections? Or can the (re)generation of one mesh depend on the (re)generation of another mesh during the same iteration? Yeah, I can push all the change...
by Tub
Fri May 03, 2019 2:00 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

Instead of writing wasm in a language I know (c++), I decided to learn rust first. It seems interesting, and rust-wasm is hip these days. Rust has come a long way since the last time I looked at it, and I'm impressed by its current design. Rust 2018 looks worth using. Except for the borrow checker. ...
by Tub
Thu May 02, 2019 9:17 am UTC
Forum: Science
Topic: Is it possible to escape from a black hole using another black hole?
Replies: 56
Views: 6594

Re: Is it possible to escape from a black hole using another black hole?

You have massless ice? I'm sure that's going to have excellent culinary applications. Can you make it tasty while keeping it at 0 calories? I'm not sure if I'm misunderstanding your question, or if you stopped reading halfway through my last post. Gravity wins. Your feeble contenders will be destroy...
by Tub
Thu May 02, 2019 8:00 am UTC
Forum: Science
Topic: Is it possible to escape from a black hole using another black hole?
Replies: 56
Views: 6594

Re: Is it possible to escape from a black hole using another black hole?

Or the probe could just be microscopic. Not much tidal force across a one micron robot. In these thought experiments, the best kind of probe is always a photon. Ok so what would happen if a black hole made of ice collided with a black hole made of lava (regular black hole)? The temperature of a bla...
by Tub
Mon Apr 29, 2019 4:48 pm UTC
Forum: Science
Topic: Is it possible to escape from a black hole using another black hole?
Replies: 56
Views: 6594

Re: Is it possible to escape from a black hole using another black hole?

But suppose I am in a spaceship in orbit about a stellar mass black hole a few Schwarzschild radii from its center. Now suppose the black hole is falling into a supermassive black hole. Surely I should not see anything strange happen to the black hole as we cross the event horizon of the supermassi...
by Tub
Mon Apr 29, 2019 10:27 am UTC
Forum: Science
Topic: Is it possible to escape from a black hole using another black hole?
Replies: 56
Views: 6594

Re: Is it possible to escape from a black hole using another black hole?

Is it possible to have a stellar mass black hole inside a supermassive black hole, such that some objects are outside both, some are inside both, and some are inside the supermassive black hole but outside the stellar mass black hole? Obviously they will merge eventually, but before they do . . . A...
by Tub
Sun Apr 28, 2019 10:24 pm UTC
Forum: Science
Topic: Is it possible to escape from a black hole using another black hole?
Replies: 56
Views: 6594

Re: Is it possible to escape from a black hole using another black hole?

You carelessly dropped your probe past an event horizon. No amount of acceleration can allow it to escape. Your first idea is thus to try accelerating it, via a nearby gravitational source. Why exactly is that supposed to help? Looking at simulations of black hole mergers , it appears as if the area...
by Tub
Mon Apr 22, 2019 10:30 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

Batching improves throughput, but also increases per-job latency. If the latency is greater than one frame, then I need to take care not to submit a job twice. As jobs are defined by (object-id, object-generation), I need - wait for it! - another multi-key Map (or Set). For now, I've ignored that pr...
by Tub
Sun Apr 21, 2019 7:31 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

Before going WebAssembly, I wanted to try boosting performance with WebWorkers. tl;dr: - doing the task in the main thread: 2-3 ms - doing the task in a worker: 20-100ms welp. This is a webgl game. The task is to prepare an object for rendering, and I have >1000 of these objects. They are prioritize...
by Tub
Tue Apr 16, 2019 9:24 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

Ah, so they don't just have different equality semantics, they're also immutable. That's certainly a lot more powerful.
by Tub
Tue Apr 16, 2019 4:46 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

Thanks for the insight. I'm having trouble coming up with consumers (besides Set and WeakMap). Surely there's some user code that'd be prettier with these types, but you can always implement your own comparison function. I can't find anything besides Map/Set were you have to rely on behind-the-scene...
by Tub
Fri Apr 12, 2019 7:15 pm UTC
Forum: Individual XKCD Comic Threads
Topic: 2136: "Election Commentary"
Replies: 13
Views: 4247

Re: 2136: "Election Commentary"

To be fair, the american election system actually is an unnecessarily convoluted way to add up votes.
by Tub
Thu Apr 11, 2019 2:43 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 10016
Views: 2032001

Re: Coding: Fleeting Thoughts

I really wish javascript's Map class had the ability to accept multiple keys. With the good old object-as-maps, you'd just concatenate all your keys; they had to be strings anyway. let m = {}; m[x + '|' + y] = 42. Somewhat expensive if you want to implement huge multi-dimensional arrays, but fine fo...
by Tub
Thu Apr 11, 2019 9:37 am UTC
Forum: Science
Topic: Event Horizon Telescope image
Replies: 24
Views: 3505

Re: Event Horizon Telescope image

Some members of the EHT team did a reddit AMA yesterday, where they answered many common questions (including yours) in great detail.
https://www.reddit.com/r/askscience/com ... s_here_to/
by Tub
Sun Apr 07, 2019 7:58 am UTC
Forum: Hardware
Topic: Smartwatch without a smartphone?
Replies: 3
Views: 6743

Re: Smartwatch without a smartphone?

Despite the lack of responses, I can't leave the thread hanging like this. After realizing that the battery lifetimes between a smart watch and my old casio differ by three orders of magnitude, I just ordered a casio again. If I have to recharge the watch every couple of days, then the maintenance o...
by Tub
Sat Mar 30, 2019 9:14 am UTC
Forum: Science
Topic: Miscellaneous Science Questions
Replies: 2962
Views: 730101

Re: Miscellaneous Science Questions

Although, does that ambiguity exist since it holds for the components (0.999...,0.999...)=(1,1)=(1,0.999...)=(0.999...,1) too? Go ahead and interleave these pairs. If interleaving is a bijection, all four of them must yield the same number. There is only a countably infinite amount of numbers with ...
by Tub
Fri Mar 29, 2019 10:30 pm UTC
Forum: Science
Topic: Miscellaneous Science Questions
Replies: 2962
Views: 730101

Re: Miscellaneous Science Questions

Hang on.. the discrete iterations of space-filling curves may be bijective, but the limits aren't. Space-filling curves are necessarily self-intersecting. You can use them to prove that | R² | <= | R |, and it's easy to prove that | R | <= | R² |, but that's just an existence proof. It's not constru...
by Tub
Fri Mar 29, 2019 7:35 pm UTC
Forum: Hardware
Topic: Smartwatch without a smartphone?
Replies: 3
Views: 6743

Smartwatch without a smartphone?

Hello, In 2006 I bought a casio watch. Today, I dropped it. Now it's dead. Looking at casio's innovative product lineup, I could just.. buy the same model again. But maybe I should try to be a bit more modern? I really just need a quick 5 minute timer (I like tea), the current date and time, and an ...

Go to advanced search