hallettj

joined 1 year ago
[–] hallettj@leminal.space 48 points 2 weeks ago (11 children)

The article doesn't suggest using Control+C. It talks about dedicated copy and paste key codes, and you can program your keyboard to map those codes to whatever keys you like. They suggest Fn+C.

[–] hallettj@leminal.space 1 points 2 weeks ago

That's a good point! The string is in there, and I can see it with strings. But in my research so far it's looking like making a simple string substitution might not be an option. The replacement string would be a Nix store path which would be longer. That would shift over subsequent bytes in the binary which it sounds like would produce alignment issues that would break things.

Apparently it's ok to change the length of the ELF header, which is what patchelf does. But shifting bytes in the ELF body is a problem.

Now what I haven't verified yet is whether the embedded binary is in the body or in the header. If it's in the header - or even if just the interpreter string is in the header then I might be good to go.

[–] hallettj@leminal.space 4 points 2 weeks ago

My ten-year-old is a big fan of the books - and honestly so am I. I hope the series does them justice!

I'm still working on the character voices for our reading. There are a lot of them so I have to keep coming up with new ideas. I think some accents help to give character to the different dragon factions. I'm doing IceWings as Russian, RainWings as Alabaman, Outclaws as Western movie cowboys. I could throw Minnesotan in there, but I'm not sure which group would be best for it.

[–] hallettj@leminal.space 6 points 3 weeks ago

I was also thinking Nestlé before I clicked through. They want to corner the market on water. WTF!

[–] hallettj@leminal.space 5 points 3 weeks ago

I agree that detentions in El Salvador are the issue to push on since those are a combination of humanitarian crisis, and constitutional crisis. The MAGAs don't seem to have any compunction about trading people's lives for a little political capital.

Abrego Garcia puts a face to the people who have been sent there. We need to get back everyone, not just one guy. But people identify more with a person than an idea, and a group of people can blur into an idea if you don't have any specific names or faces in mind.

[–] hallettj@leminal.space 8 points 3 weeks ago (1 children)

I'm not positive I'm correctly matching the title to the episode, but I'm sure I remember this one.

I think it's,Profit and Lace

[–] hallettj@leminal.space 1 points 3 weeks ago* (last edited 3 weeks ago)

Whether or not an unsecured human poses a direct danger to another human in a crash, there are negative externalities to self-harm. One is that family members may be deprived of an important source of income and emotional support if you are killed in a crash. But the most directly-measurable cost is hospital expenses. At first glance medical expenses are another factor that affect only yourself. But in reality in the US emergency room care is guaranteed regardless of ability to pay, so plenty of ER costs are paid by hospitals or by governments. Emergency and non-emergency healthcare costs may be covered by Medicaid or Medicare - in other words, paid for by taxpayers. Maybe you can afford whatever treatment you might need, but policy must take into account people who cannot. That means that a personal choice not to wear a seatbelt, in aggregate, puts measurable costs on people who are not you.

Societal medical costs are discussed most prominently in relation to smoking. A study from last year estimates that healthcare made necessary by smoking costs an average of $2700 per person per year. That's a major part of the justification to tax cigarette sales. Healthcare costs caused by not wearing a seatbelt aren't as high, but are still substantial. Here's a study that found that hospital costs are 84% higher for people injured while not wearing a seatbelt vs wearing a lap & shoulder seatbelt.

Cost savings from seatbelt requirements might be smaller than savings from reduced smoking. But on the other hand the measurable burden of wearing a seatbelt is tiny. Policy should be based on the measurable costs & benefits of its requirements, and seatbelt requirements are a very clear-cut example of a net-benefit analysis.

You made an argument about the violation of personal liberty. When thinking about cost vs benefit there are two ways to look at this:

  1. Intrinsic value of liberty: I don't know of a measurement of harm from restricting personal liberty in the specific case of seatbelt use. We have to draw a line somewhere on where personal liberty must be restricted to prevent obvious, unacceptable harm like murders. Considering the data, and the low burden of compliance seatbelt requirements seem to me to be an obvious case where restricting liberty as a worthwhile cost of harm reduction. Until there is some metric that shows that restriction of liberty may be more harmful than cost savings in this case I have to say, that's like, your opinion man.
  2. Individuals are the best judges of their specific situation: Policy needs to consider the inevitable outcome of people exercising their right to implement bad judgement. If this were a case where a reasonable analysis could conclude that not wearing a seatbelt in some situations is a good decision then it would be a different story. But it's not. Data overwhelmingly shows that seatbelt use is the right decision in every case while driving. And data also shows that a high proportion of people make the wrong choice, likely due to a highly-inflated sense of their own invulnerability. Here's an analysis of how seatbelt requirements influence good judgement in several states.

I don't want to dismiss personal liberty. I think it is important to be able to make our own decisions. But it's also important to prevent extraordinarily-problematic decisions in certain cases. With seatbelts (I'm assuming we're not debating the cost of building seatbelts into cars at the moment) the measurable cost as far as I'm aware is the time taken to put the seatbelt on, which is negligible. Maybe there is a real cost to one's self of individualism to be required to put that seatbelt on. If the cost is real, there must be some way to measure it. Maybe that could be evaluating happiness, or creativity, or lifetime earnings, or some such thing. If we want to take this factor into account in cost-benefit analyses we have to have a measurement. We can't apply some arbitrary value because some people are going to say "infinite", and others are going to say "zero", and every value in between. Not only are those subjective opinions - those are self-evaluation estimates which humans tend to be bad at. I'm going to speculate that self-evaluations of the importance of liberty in the abstract is one of those areas people tend to get wrong. We need some kind of objective metric.

Edited for clarity

[–] hallettj@leminal.space 5 points 3 weeks ago

Write a NixOS module, publish it in a flake in the nixosModules output, import that flake in your flake-based NixOS configs.

[–] hallettj@leminal.space 2 points 3 weeks ago

I use obsidian.nvim. It's a Neovim interface to my Obsidian vaults, so I can work on my knowledge base in whichever app works best in the moment.

[–] hallettj@leminal.space 3 points 4 weeks ago

Less is not an editor, it's a "pager" which is a read-only viewer for files, or for command output that doesn't fit in a single screen, or whatever. Generally to control which you want programs use you set the PAGER environment variable.

The old grandaddy pager was called "more", as in "there's more text than fits on the screen". The successor is called "less". For most purposes, less is more.

[–] hallettj@leminal.space 1 points 1 month ago

Oh, this is a good tip!

[–] hallettj@leminal.space 4 points 1 month ago

I heard Superman gained the ability to fly during the first TV series because doing the special effects for flying was easier than for jumping.

 

I'd like a treesitter query that matches a Rust struct together with all of its attributes. For example,

#[derive(Debug)]
#[serde(rename_all = "camel_case")]
pub struct MyType {
    pub foo: i32,
}

The lines beginning with # are attributes that are logically connected to the struct declaration. But the treesitter grammar for Rust parses attributes as adjacent nodes, not as children of the struct declaration:

  (attribute_item ; [27, 0] - [27, 16]
    (attribute ; [27, 2] - [27, 15]
      (identifier) ; [27, 2] - [27, 8]
      arguments: (token_tree ; [27, 8] - [27, 15]
        (identifier)))) ; [27, 9] - [27, 14]
  (attribute_item ; [28, 0] - [28, 35]
    (attribute ; [28, 2] - [28, 34]
      (identifier) ; [28, 2] - [28, 7]
      arguments: (token_tree ; [28, 7] - [28, 34]
        (identifier) ; [28, 8] - [28, 18]
        (string_literal)))) ; [28, 21] - [28, 33]
  (struct_item ; [29, 0] - [31, 1]
    (visibility_modifier) ; [29, 0] - [29, 3]
    name: (type_identifier) ; [29, 11] - [29, 17]
    body: (field_declaration_list ; [29, 18] - [31, 1]
      (field_declaration ; [30, 4] - [30, 16]
        (visibility_modifier) ; [30, 4] - [30, 7]
        name: (field_identifier) ; [30, 8] - [30, 11]
        type: (primitive_type)))) ; [30, 13] - [30, 16]

How can I get produce a query that I can use in mini.ai that matches the struct, and all attributes?

I've tried this query using Neovim's new built-in :EditQuery command:

((attribute_item)* . (struct_item)) @custom_capture.outer

It looks like it does what I want. But when I try using @custom_capture.outer in mini.ai it matches the struct declaration, but not the attributes.

I tried using #make-range! like this,

((attribute_item)* @_start . (struct_item) @_end
  (#make-range! "custom_capture.outer" @_start @_end))

That matches the struct and the second attribute, but does not get the first attribute. I'm guessing that's because the . specifies that nodes must be adjacent, and the second attribute is the only one that is adjacent to a struct_item. Following that thinking I tried this,

((attribute_item)? @_start . (attribute_item)* . (struct_item) @_end
  (#make-range! "custom_capture.outer" @_start @_end))

That gets the struct and all the attributes, but only if my cursor is on the first attribute line when I use the textobject. If my cursor is on any subsequent line then I get the second attribute and the struct, but the first attribute is missed.

One problem is I'm not clear whether ((attribute_item) . (struct_item)) matches an attribute_item and a struct_item that are adjacent, or matches an attribute_item that precedes a struct_item, but does not also match the struct_item. I tried experimenting with the second interpretation and used this query,

(((attribute_item) 
  . [(attribute_item) (struct_item)])* @_start
  (struct_item) @_end
  (#make-range! "custom_capture.outer" @_start @_end))

That captures what I want, but in some cases if I have two struct declarations and I try to match only the second one the query selects both structs instead.

Is that the way to do a lookahead? Or is there another way?

I've kinda hit a wall looking at documentation, other examples, and running my own experiments. Does anyone have any pointers to help understand these queries on a deeper level?

Edit: It looks like this stuff is in flux, so I should mention that I'm using the latest nightly as of March 2 2024, and I made sure that all of my plugins are up-to-date.

view more: ‹ prev next ›