HNHacker News
TopNewBestAskShowJobs

bluetech

254 karma · joined April 10, 2009

submissionscomments
bluetech··on Tuning async IO in PostgreSQL 18
Which Linux version did you use for the io_uring tests? Unless I missed it I don't see it mentioned.
bluetech··on Context should go away for Go 2 (2017)
> `ctx.Value` is an `any -> any` kv store that does not come with any documentation, type checking for which key and value should be available

The docs https://pkg.go.dev/context#Context suggest a way to make it type-safe (use an unexported key type and provide getter/setter). Seems fine to me.

> What if you just use a custom struct with all the fields you may need to be defined inside?

Can't seamlessly cross module boundaries.

bluetech··on FAA authorizes Zipline to deliver commercial packages using drones
That's not going to happen. Check out "induced demand".
bluetech··on Java 20 / JDK 20: General Availability
Some discussion on zio in loom-dev mailing list recently: https://mail.openjdk.org/pipermail/loom-dev/2023-March/00535...
bluetech··on All About E: A Language That Infiltrated JavaScript
> Object.freeze does make an object immutable

If you look at the Hardened Javascript example:

    const makeCounter = () => {
      let count = 0;
      return harden({
        incr: () => (count += 1),
        decr: () => (count -= 1),
      });
    };
The "counter object" here is mutable. I think that's what they mean.
bluetech··on PostgreSQL 15: Stats Collector Gone? What’s New?
What advantage does pg_repack have when you only rebuild an index? Or do you mean it has advantage when pg_repack is run on the entire table?
bluetech··on The Effects of Finland's Possible NATO Membership (2016) [pdf]
> One possible solution currently considered is to ask Article 5 protections from NATO for the duration of the membership process.

The report discusses this, and mentions two reasons against doing that:

- What happens if you do it, and then the referendum votes against joining? You're screwed from both ends.

- Due to the previous reason, there will be extreme pressure to vote for joining in the referendum, making it not very democratic.

bluetech··on Fuck Domainparkers
Basically, their answer is yes.

First, under this system, long-term speculation is not really viable, due to the high tax. So the buyer must have some reason for paying higher than the price you set, which you don't see, i.e. you under-utilize the asset. Google/Facebook ads work this way - every slot is always up for auction. Also similar dynamics in partnership agreement's "shotgun clauses", etc.

Second, you can always factor in your sentimentality into your price, then the buyer will buy your neighbor's house instead. But you have to pay for it in the form of a higher tax. This is like a penalty for obstructing economic efficiency.

Third, this system pretty much does away with the strict idea of private property, into what they call "partial common ownership". It's basically a way to have shared ownership (as in communism) without the central planning, i.e. in a way that might actually work. (In fact, it quite reduces the role of government.)

I'm not advocating for this system, but I think it's fun to think about.

bluetech··on Fuck Domainparkers
The book Radical Markets proposes the following tax (to replace most other taxes), quote:

Every citizen and especially corporation would self-assess the value of assets they possess, pay a roughly 7% tax on these values and be required to sell the assets to anyone willing to purchase them at this self-assessed price.

bluetech··on Dependency Confusion: How I Hacked Into Apple, Microsoft and Other Companies
Java actually doesn't need to add any features for it to support this, it needs to remove them. I recommend reading this excellect article: http://habitatchronicles.com/2017/05/what-are-capabilities/

The gist is:

Rule #1: All instance variables must be private

Rule #2: No mutable static state or statically accessible authority

Rule #3: No mutable state accessible across thread boundaries

bluetech··on Dependency Confusion: How I Hacked Into Apple, Microsoft and Other Companies
This is so obviously what needs to happen, it's really surprising it's not a feature in all major languages by now. I bet in 10 years time, giving dependencies complete control would seem crazy.

Here is an interesting proposal on how to possibly get there in JS with import maps: https://guybedford.com/secure-modular-runtimes

Deno uses ambient permissions for the entire process and unfortunately missed the opportunity to do it right.

bluetech··on Htop Explained
PSI is a perfect fit for htop. I sent a PR to add it some time ago (https://github.com/hishamhm/htop/pull/890) but it hasn't been merged yet.
bluetech··on Companies may be losing millions due to emails buried in collapsed Gmail threads
We've been using it for some time as well, not even with a random value, just `X-Entity-Ref-ID: null` works too. Found it through some obscure StackOverflow answer.
bluetech··on Formally Specifying UIs (2018)
React has a built-in useReducer hook now as well: https://reactjs.org/docs/hooks-reference.html#usereducer
bluetech··on Our Software Dependency Problem
I think object-capabilities are one way to have much safer code reuse. Suppose a dependency exports a class UsefulService. In current languages, such a class can do anything - access the filesystem, access the network, etc. Suppose however that the language enforces that such actions can only be done given a reference to e.g. NetworkService, RandomService, TimeService, FilesystemService (with more or less granularity). Therefore if UsefulService is declared with `constructor(RandomService, TimeService)`, I can be sure it doesn't access any files, or hijacks any data to the network - nor do any of its transitive dependencies.

The method of sandboxing using OS processes + namespaces and what not is too heavy and unusable at such granularity.

The method of per-dependency static permission manifests in some meta-language is also poor.

The method of a single IO monad is too coarse. Also using any sort of `unsafe` should not be allowed (or be its own super-capability).

Obviously there are many tricky considerations. [For example, it is anti-modular - if suddenly UsefulService does need filesystem access, it's a breaking change, since it now must take a FilesystemService. But that sounds good to me - it's the point after all.] But does any language try to do this?

bluetech··on Ripgrep is faster (2016)
One reason I still use git grep is this: I have some minified .js files in the repository, which I don't want to be included in grep results. So I mark the files as binary in gitattributes, then git grep just says "Binary file foo matches".
bluetech··on Nike Says Its $250 Running Shoes Will Make You Run Much Faster
It is not as clear cut as you say, there appears to be some scientific discussion on this: https://en.wikipedia.org/wiki/Endurance_running_hypothesis
bluetech··on Nike Says Its $250 Running Shoes Will Make You Run Much Faster
Have you heard of persistence hunting? Here's is a short documentary from the BBC: https://www.youtube.com/watch?v=826HMLoiE_o

It is believed to be one of the oldest hunting techniques, and so would indicate that humans are in fact meant to run long distances. According to Wikepedia, the runner runs for "about two to five hours over 25 to 35 km (16 to 22 mi)".

bluetech··on WebAssembly is more than the web
I think it would be neat if WebAssembly were embedded in other languages, like it is in JavaScript now. For example, suppose Python had a WebAssembly engine. I bet that could replace a lot of C extensions, and it would be as portable/universal as pure Python code, so no need for C compilers, OS-specific binary packages, etc.
bluetech··on Djbsort: A new software library for sorting arrays of integers
I liked this bit, using the fastest compiler for each primitive:

> ./do tries a list of compilers in compilers/c, keeping the fastest working implementation of each primitive. Before running ./do you can edit compilers/c to adjust compiler options or to try additional compilers.

bluetech··on Critical vulnerability of NPM package macaddress
Well, surely you put the line somewhere? Would you depend on `leftpad`? How about `is-odd`?

Your view of dependencies is very idealistic. And if I'd venture to guess - apologies if I'm wrong - young, at least to programming. I'm saying this because you don't tend to hear such phrases once reality hits.

Everything you said can be flipped:

> If I import this code in my codebase directly instead of using a library, it suddenly becomes my "responsibility" if it breaks.

I have full control & understanding of the code; I can adjust & trim so it fits as much as possible. If it breaks, I can fix it directly.

> And when we're talking about a FOSS side-project, I don't have that kind of time.

Copying/hand rolling some trivial code is often faster than deciding among a dozen libraries which do the same thing, reading their docs, their issue pages and open PRs, adding and integrating to my project.

> Third-party libraries means I get any improvements and bug-fixes for free.

I must keep the dependencies updated. I must read changelogs and hope nothing breaks.

> And if it breaks, I get to talk with the original maintainer to figure it out

I must use inefficient communication with a more-often-than-not absent maintainer in order to resolve my problem instead of fixing it directly.

> I suddenly will be alone trying to figure out what I did wrong

I am able to be self-reliant in fixing the problem, because I wrote the code and I understand it.

I do not have to trust the maintainer of the package or the maintainers of any of its transitive dependencies to be competent or non-evil.

---

For some things this is worth it. IMO for generating 16 random bytes it is not worth it.

bluetech··on Critical vulnerability of NPM package macaddress
Please see the comment I replied to.
bluetech··on Critical vulnerability of NPM package macaddress
A dependency for uuid4 is hardly needed:

  crypto = require('crypto');

  function uuid4() {
      const bytes = crypto.randomBytes(16);
      bytes[6] = (bytes[6] & 0x0f) | 0x40;
      bytes[8] = (bytes[8] & 0x3f) | 0x80;
      return bytes.toString('hex').match(/(.{8})(.{4})(.{4})(.{4})(.{12})/).slice(1).join('-');
  }
bluetech··on Buffered Channels in Go: Tips and Tricks
A buffered channel can be implemented with two unbuffered channels + a goroutine + an array.
bluetech··on How JavaScript works: Event loop and the rise of Async programming
It can be changed at runtime. From proc(5), system wide limits:

/proc/sys/kernel/pid_max

> PID_MAX_LIMIT, approximately 4 million

/proc/sys/kernel/threads-max

> FUTEX_TID_MASK (0x3fffffff), [approximately 1 billion]

For per-process limit, increase RLIMIT_NPROC.

bluetech··on Functor-Oriented Programming
On the other hand, from Linus Torvalds:

> I will, in fact, claim that the difference between a bad programmer and a good one is whether he considers his code or his data structures more important. Bad programmers worry about the code. Good programmers worry about data structures and their relationships.

https://lwn.net/Articles/193245/

bluetech··on IP Accounting and Access Lists with Systemd
systemd should have a "whitelist" mode, where everything is locked down by default. Or at least, some /usr/share/doc/systemd/locked-down-example.service file with all of the relevant options set to "secure mode". It can be hard to follow all of the new features :)
bluetech··on Chrome OS KVM - A component written in Rust
The line above has this:

    // This is safe since we check the return value.
    let sock = unsafe { libc::socket(libc::AF_INET, libc::SOCK_DGRAM, 0) };
    if sock < 0 {
        return Err(Error::CreateSocket(IoError::last_os_error()));
    }
I think in this case it would be better to put the return value check within the unsafe block, this way the unsafety does not "leak out" of the block, so to speak, so it is easier to audit. Of course in such a trivial case it does not matter much.
bluetech··on WordPress 4.8.1 still vulnerable to Host Header Attack
Django has an ALLOWED_HOSTS setting, which must be provided even in debug and test configurations. I'm surprised Wordpress doesn't have a similar setting; accepting any arbitrary Host can only cause trouble (at least for those uninformed sites which don't already prevent it at the web server level).
bluetech··on Nginx Unit
I'm happy to see this. nginx itself is excellent software, I'll be happy to use similar tech for the application server as well (instead of uwsgi).

There are a couple of options I'd like to see added to the Python configuration though before I could try it:

- Ability to point it at a virtualenv.

- Ability to set environment variables for the application.

Page 1 of 3Next →