HN user

gnosek

65 karma
Posts0
Comments37
View on HN
No posts found.

[yet another reference to Ansible, sorry! :)]

This looks like infinity times better than Ansible in some cases and somewhat worse in others (python.call every time I'd need to access a previous operation's result feels clunky, though I certainly understand why it works that way).

Do you think it would be possible to use Ansible modules as pyinfra operations? As in, for example:

  - name: install foo
    apt:
      pkg: foo
      state: present
could be available as:
  from pyinfra import ansible

  ansible(name='install foo').apt(pkg='foo', state='present')

where the `ansible` function itself would know nothing about apt, just forward everything to the Ansible module.

Note 1: I know pyinfra has a way to interface with apt, this is just an example :) Note 2: It's just my curiosity, my sysadmin days are long gone now.

If I understand correctly, you mean turbo roundabouts https://www.ms2soft.com/resources/turbo-roundabouts/ ?

If so, IMO they're the best thing that happened to roundabout design ever. You do need to choose a lane before entering but it's similar to how you'd choose a lane on a traditional two-lane roundabout. However, then you don't change lanes while on the roundabout, with ~zero visibility to the other lane while turning in a fairly tight circle.

This may differ across countries but around here you're supposed to: * pick the inner lane unless you're taking the first exit (to the right) * change to the outer lane just before your exit

which is about infinity times more stressful in traffic (you have very little time, it's hard to see the outer lane and the outer lane has right of way). It would work fine if everybody followed the rules but 1. they don't since it's unsafe in a tragedy of the commons sort of way and 2. then you end up with an informal turbo roundabout anyway.

A compromise that's becoming fairly common is a "soft" turbo roundabout where the lanes are divided not by ridges but by solid lines you can't cross only legally, not physically :)

or

    fn twiddle<I>(foozles: I)
    where
      I: Iterator<Item=Foozle>
(or probably IntoIterator<Item=Foozle>). `impl T` is (modulo some details I don't remember right now) just syntactic sugar for this.

Same. It takes a little effort to read but it's understandable and it does feel Croatian or thereabouts. On a somewhat funny note, Chrome decided to translate the page in Interslavic from Czech to Polish and did a passable job.

What I find fascinating about Slavic languages is that I can speak Polish in Slovakia*, get responses in Slovak and mostly understand each other. It has basically zero chance of success in the Czech Republic to the point where it's easier to find an English speaker. I speak neither Czech nor Slovak and I cannot really distinguish them but I had this experience multiple times. In written form, both are similarly understandable to me (I can get the gist and guess the rest).

* the caveat about szukanie czegoś do picia still applies though.

It really depends on what the meaning of None is.

Exactly. This will generally be application specific so we can't choose The One Right Definition for adding `Option<i32>`s.

Yours make sense if it means "zero", but that's far less useful.

Not in my experience but I agree there are different situations. Personally, I'd default to `Option<i32>::None` meaning "no number there, so just skip it"[1] and prefer `Result<i32, E>::Err` to denote "there should be a number here but we don't have one", which would behave like a SQL NULL (propagate in all calculations).

1. What's the length of data in a header-only packet? I wouldn't say it's zero, especially when trying to fit a read() like API on top of a framed protocol (read() returning Ok(0) marks the end of file).

I agree with all your other points but

> We can’t perform arithmetic on an Option<int> any more than we could on a List<int>.

Why not? One sensible definition is (...)

It's not the only sensible definition. It would be equally sensible to implement it as:

    Some(x) + Some(y) => Some(x+y)
    Some(x) + None => Some(x)
    None + Some(y) => Some(y)
    None + None => None
Rust 1.43 6 years ago

Exclamation mark. e.g.

    println!("hello, world");
or
    todo!();
are macro invocations.
    ifconfig enp2s0:1 192.168.1.42
Now try
    ip addr add dev enp2s0 192.168.42.1/24
and observe how ifconfig ignores the second IP on the same interface. enp2s0:1 is an alias to enp2s0, not enp2s0 itself. To replicate your ifconfig command, you'd use
    ip addr add dev enp2s0 192.168.1.42/32 label enp2s0:1
and then it shows up in ifconfig as well.

In Poland the in-house bakery in a grocery store is the cheap and convenient way to get bread if you can't be bothered to get actual quality (not made from deeply frozen dough).

So if the Polish baseline is super fancy for NL, NL is better than UK and UK baseline is artisanal US bread, I wonder what baseline US bread looks like. It's made of sponge and sugar?

Terraform 0.12 7 years ago

Long-time user of Terraform here, never used CloudFormation. Where does CloudFormation beat Terraform?

Two ways to do this with window functions (there's probably a better one but this is what I came up with quickly):

1. Subquery

    SELECT * FROM (
        SELECT u.user, i.text, row_number() OVER (PARTITION BY i.user ORDER BY i.pos) AS row
        FROM users u INNER JOIN items i USING(user)
    ) numbered
    WHERE row <= 3;
2. CTE
    WITH numbered AS (
      SELECT u.user, i.text, row_number() OVER (PARTITION BY i.user ORDER BY i.pos) AS row
      FROM users u INNER JOIN items i USING(user)
    )
    SELECT * FROM numbered WHERE row <= 3;

Same thing, really. CTE looks a bit clearer, subquery seems to generate a faster plan but I don't really have a large enough dataset handy for it to make a difference.

Of course. I'm not telling anybody to run on kimsufi, like I'm not running kimsufi myself, but on brand-new Supermicro machines that check all your boxes.

Kimsufi is still dedicated hardware (however low-end) that costs 1 figure instead of 5/6. For normal server-grade hardware it's just 5x cheaper than AWS, not 20x.

https://www.kimsufi.com/us/en/

Granted, that's the bottom of the barrel (single disk, no IPKVM etc.), but $100 keeps you running for over a year. Better servers are easily available as well, usually a couple of times cheaper than AWS.

Is this a US thing? Based on HN only, I'd never know there's anything between the public cloud and racks of own hardware that you have to wire up and maintain.

I have a bunch of quad core 32 GB machines with dual 480GB SSDs for less than $100/month each (and that's a rather expensive provider with great support, you'll cut the price almost in half with e.g. SoYouStart).

Yes, AWS is convenient, but it's far from the only thing in the world.

It comes down to proportions. Let's say 10% of widgets are awesome and the remaining 90% are not, regardless of colour. Per parent's post, let's assume 1/12 of the widgets are colourful. So now (rounded roughly):

  - 9,2% -- awesome, non-colourful
  - 0,8% -- awesome, colourful
  - 82% -- meh, non-colourful
  - 8% -- meh, colourful

If you're choosing freely, you'll (hopefully) end up with the awesome top 10% (1/12 of them being colourful). However, if you're forced to make 1/3 of your widgets colourful (and there's only 1/12 of them overall), you end up with:
  - 6,7% -- awesome, non-colourful
  - 0,8% -- awesome, colourful
  - 2,5% -- meh, colourful

The previously "excluded" (or rather, not promoted) group is exactly just as good as the rest, it's just not numerous enough -- if you want 1/3 of colourful widgets naturally (instead of the expected 1/12), their averages have to compete against the rest's best, and that's where the perceived inferiority comes from.

I'm a fan of Ansible, so let me reply to a few of your points :)

1. Playbooks are not a complete programming language for a good reason. You just get a simple linear flow of tasks with limited loops and conditions, so they're hard to make unreadable, unlike full-blown programming languages, like Python in Fabric or Ruby in Chef.

2. Yes, using shell commands for things that can be done using modules is frowned upon, but nobody is going to physically frown at you, so don't worry about it too much :) I drop down to shell/command/script modules whenever I need to without giving it a single thought.

3. Yes, the modules are often less powerful than the underlying tools. The other side is that they return nicely parsed data and changed/not changed status, so you can analyze their results more easily than shell commands.

4. Yes, ansible has immense advantages over shell scripting whenever one or more applies (generally the "manage a fleet of servers" scenario, not the "set up a dev box" one): - you need to coordinate configuration between multiple machines (sshing back and forth is just clumsy in comparison) - the playbook is to be used more than once (e.g. evolving configuration) -- I can't imagine my life right now without diffs and check mode. This also makes developing/debugging playbooks much easier than scripts, e.g. I recently wrote a hairy migration tool as a playbook and could easily see all the changes it would do without applying them - some things are just easier in ansible (template and lineinfile come to the top of my head, plus everything is parsed for you into easily usable data structures)

5. I'd probably use ansible to set up my own machine if I ever got to automating the task, but you're right: learning ansible just for that makes little sense.

There is Docker daemon and there is Docker CLI. Both have separate scopes.

Docker CLI is glorified curl, everything happens in the daemon (containerd being logically -- but finally not physically -- part of the daemon).

ls -U avoids the default sort by name. Without -U you get all the names at once at the end of the directory scan. With the option you get them one by one (in some unspecified order) and can make sort of a progress bar for counting files in large directories:

    ls -U huge_dir | awk 'NR % 100000 == 0 { print NR } END { print NR }'
(prints the count every 100k files and the total at the end).