Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
OskarS
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
61 ms
·
721.
▲
by
OskarS
7y ago
All that is certainly true, but we're talking about a function that dates back to the 70s here. It predates all of those nice error handling concepts (exceptions, Result<T>, multiple return values), so it's pretty sensible f
722.
▲
by
OskarS
7y ago
I did not know any of this, and now suddenly I have the overwhelming urge to type this into a terminal and see what happens: kill -KILL -1 But I'm going to restrain myself :)
723.
▲
by
OskarS
7y ago
It depends a little bit on what the acceptable answer is. If it's "stream/generate a list of possible strings", then the length of that list is probably O(2^n), so the fact that my recursive descent thing is exponential
724.
▲
by
OskarS
7y ago
I have a hunch that the actually fastest version is to change all those "||" to "|" in the original version. Short-circuiting and adding branches probably just slows the whole thing down compared to just running the comp
725.
▲
by
OskarS
7y ago
Yeah, ok, though I'm not sure what that will prove. As I said, it's really just a case of writing a backtracking recursive thing. Here it is in prolog: letter(a, X) :- string_to_list("._", X). letter(b, X) :- s
726.
▲
by
OskarS
7y ago
O(n!) is wrong. For an string of length n, there are n-1 gaps in it, and each gap could or could not hold a space, which gives you 2^(n-1) possibilities. The algorithm is at worst basically O(n*2^n). Exponential for sure, but not factorial.
727.
▲
by
OskarS
7y ago
If you're going to be using any system like this (either watch or inotifywait), be careful. It's a good chance it's going to run in an "intermediate" state when it's not supposed to run and can do harm to your
728.
▲
by
OskarS
7y ago
That is extremely cool.
729.
▲
by
OskarS
7y ago
Can these functions be closures that close over a bunch of data that isn't hard-coded into the functions? I don't know erlang, but imagine the erlang version of this python code: def adder(v): return lambda x: v + x
730.
▲
by
OskarS
7y ago
I certainly learned vi from vi (or I guess vim to be specific). The start page says "type :help or press <F1>", which led me to the help pages (and maybe doing vimtutor, can't quite remember), and then I "learned
731.
▲
by
OskarS
7y ago
I always hesitate to sit in them because I always get the impression that they’re dirty. I think that’s a problem with them being white: every speck of dirt stands out. I agree though: very comfortable to sit in.
732.
▲
by
OskarS
7y ago
It's not a pedantic argument. A leaky abstraction is a thing when you have some kind of abstraction where the user is supposed to not have to know anything about the implementation details, but where implementation details accidentally
733.
▲
by
OskarS
7y ago
This is not a leaky abstraction. JavaScript doesn't pretend that the numeric type is anything other than an IEEE-754 float. It would be a leaky abstraction if JavaScript said "this type can represent all real numbers!" but th
734.
▲
by
OskarS
7y ago
I agree it's rather strange to ask for who has the lowest energy usage when you're a cloud customer. "I want to rent this computer to do X, but it shouldn't consume any electricity" is not a reasonable demand. Howev
735.
▲
Windows 10 search bar bug frustrates users
(bbc.com)
2 points
by
OskarS
7y ago
|
0 comments
736.
▲
by
OskarS
7y ago
Yeah, exactly :) when in SSO mode, it stores the size as a delta occupying a single byte, but when in heap-allocated mode, it stores the size as a an 8-byte size_t, and you require a branch to check which case is the right one. You can see
737.
▲
by
OskarS
7y ago
In addition to what other people have said, the move semantics introduced in C++11 made a lot of the benefit of CoW moot: the point of CoW is to have a cheap copy operation, but most of those cheap copy operations can be replaced by even ch
738.
▲
by
OskarS
7y ago
I think it's to avoid a branch in `size()`. If you use this trick, you have to check the flag if it's a small in-situ string or a "regular" heap-allocated string, because they they calculate size differently. In the stan
739.
▲
by
OskarS
7y ago
Yes, very true, I was sort of assuming that the Hacker News folks would know to check for "https" and that any person offering a curl|sh solution would be sane enough not to offer it over http. But yeah, it's a good point tha
740.
▲
by
OskarS
7y ago
I mostly agree that curl to shell isn't terrible, but he misses the big negative security implication: the shell scripts are unsigned. It is almost always far, far easier to hack into somebodies website and replace replace "good s
741.
▲
by
OskarS
7y ago
Presumably OpenOffice could pass along a thing that says "please print this PostScript file" so that the printer software knows which type of file it is printing and doesn't have to guess with "file". OpenOffice k
742.
▲
by
OskarS
7y ago
Of course you can , but for the vast majority of cases, you shouldn’t . Floating points aren’t designed to solve the problems financial calculations bring, they’re designed for general purpose math and efficiency. If you’re programming a
743.
▲
by
OskarS
7y ago
> Edit: Oh, I get it now, you can't tell whether or not a given long-running program will eventually produce the target string without solving its halting problem. Exactly right! I kinda think that these non-computable problems are
744.
▲
by
OskarS
7y ago
A notable thing about unix commands is that they're usually very short: "cd", "ls", "grep", "sed", "cat", etc. This is obviously a remnant of earlier times, but I actually think that it
745.
▲
by
OskarS
7y ago
The general principle here, which is quite foundational in computer science and the theory of complexity, is that of "Kolmogorov complexity". The Kolmogorov complexity of a certain string (roughly speaking) is the shortest compute
746.
▲
by
OskarS
7y ago
It's arguably the most famous Quine of all, so famous that it has a pompous name! It's called the Omega combinator in lambda calculus, and is a stepping stone to the more famous Y combinator. If you think it's cool, the Y com
747.
▲
by
OskarS
7y ago
So the problem here is that in this line: if( value < (double) LONG_MIN || value > (double) LONG_MAX) return( 0); The cast of LONG_MAX to double rounds upwards (which is allowed by the standard, which says that ro
748.
▲
by
OskarS
7y ago
> ...but it kind of feels a bit "old man yells at cloud" - and that's not bad, I just thought there was value in debate. Yes, that is a very accurate description of how I feel when making this argument :)
749.
▲
by
OskarS
7y ago
I'd argue that it's not benign. I think there are very real costs. First off all, "misuse" of autocomplete can be very annoying. Some autocomplete system autocompletes when you press tab, some when you press enter. Many
750.
▲
by
OskarS
7y ago
You know, I realize I'm the weird one here, but: when writing code, I almost always turn off autocomplete. Sometimes you basically have to have it on (when the language is demands it) but I usually turn it off. It's too much visua
More ›