jueves, 23 de septiembre de 2021

Good Job Aaron

Today I read this HN thread about YJit and Tenderjit that is a great lesson, and there's a comment there, someone describing some traits of his. I'm quoting it here just to read it from time to time when I review my posts:

I've had the pleasure of meeting Aaron at a number of ruby confs. He's supportive from the largest all the way to the smallest.

My personal favorite thing he'll do is ask conference speakers questions that make the speaker look good/best-light-possible. Something slightly technical/challenging, not fully covered in the talk but definitely something the speaker can handle.

To be able to do this consistently means he knows the topic better than the speaker themselves (at least this has been true when I've been there).

This is in contrast to people who ask "gotcha" questions. Spend 3-4 minutes showing off their knowledge and then finally getting to the question which is to stump the speaker. I hate these kinds of people at conferences the most.

 

Shouldn't be hard, right? supporting people and trying to make them feel engaged and well about what they do, let people shine without having to point out that "actually,....", or "as I said in an earlier thread....", or ... you know.... 


miércoles, 22 de septiembre de 2021

Caught by a regex

I'm a big fan of regexes. 

I've not found yet a DSL that has proved so useful in so many situations (text handling, really).

But today, I got caught by something I didn't know, and that totally escaped me. It's not even in the sense of "now you have 2 problems". Because the problem at hand was perfectly suited for regular expressions. no capturing, no grouping, no back references, no (negative)?look(ahead|behind). A typo gone wild.

It's about `]`, and the fact that if it's paired with an earlier `[`, the regexp matches any character inbetween them. That's known, and what's also known is that escaping characters inside works a bit different, and also that `-` means "range", UNLESS it's in the first or last position.

But, What caught me today is that `]` (without escaping) works as a literal if there's no pairing `[`. 

  • /(/ -> invalid regexp
  • /)/ -> invalid regexp
  • /[/ -> invalid regexp
  • /]/ -> fine. O_O

This is so foreign and arbitrary I couldn't really believe it. I don't know if there's a deeper reason for this being this way, but I can't find a reason why it couldn't behave the same way as grouping parenthesis.

This was cascading from a regex like /[`~! @#$%\^&*()_+={\[}]|:;\"'<,>.?\/-]/ .

It is intended to check that there's at least 1 symbol in a string.

If you look closely, there no escaping for the ] in the middle, the regexp is still valid, but the bracketed part is smaller than what you'd think.  And it doesn't fail to compile the regex.

But to make things worse, just after the ']', there's a pipe symbol (because they are close in the keyboard). and now, this symbol is not treated literally anymore, but it counts as an alternative choice.

With this, what do we have here? 

The regexp matches either one of [`~! @#$%\^&*()_+={\[}] bracket, or the string ':;\"'<,>.?\/-'. This made it even more difficult to find, because some validations passed, while some didn't. If it wouldn't be for the '|' being just after ']', all validations would have failed.

Well... 2 level fuckup from a single regexp due to an missing backslash and the US keyboard layout.

How many problems do I have now?

martes, 21 de septiembre de 2021

7GUIs examples

I discovered 7GUIs from a guy in HN that posted his plain vanilla html/js/css implementations https://news.ycombinator.com/item?id=28600804 . 


The HN comments have some good insights on when DIY is no longer sustainable. And in the case of web development, it falls appart pretty early.


On my personal front end adventures, I'm trying material-ui, which I think combining react with that might actually alleviate a lot of the pains when developing a frontend as an "I-dont-care-much-how-it-looks-like-as-long-as-it-looks-okish".

I also liked tailwind a lot, but it's lower level, and really, I-dont-care-much-how-it-looks-like-as-long-as-it-looks-okish.

 

 Also, Look at the Red implementations of the GUIs. Amazing

jueves, 16 de septiembre de 2021

Small little grep+edit trick

This is so small, but so huge....

It's like many other finders you find in your editor of choice, but because it's such a generic and minimalistic tool, I keep up using it tenths of times a week.

Idk, this is more composable and functional and succinct than many things I find in the wild that claim to be so. 

And it is damn useful!

Also, even it's 4 lines of code, there's probably a thing or two you can probably learn from those. Here are some things I like and why I think it's High Quality Shit:

- It's short, you can inspect the words  it contains, and if you get more or less the programs it calls, it can only do one thing.

- It solves a real problem

- It has high density. All words there mean something, there's 0 boilerplate

- It is composed of smaller parts. It feels Forth-y

- The way it's composed is subtly nice (the existence of "e" function is needed to compose it that way)

- It's as configurable as the program it uses to grep. It inherits its flags

- It inherits its auto-completions

- You can learn a bunch of things from it

- It fits in your head

- It has that Iversonian "suggestivity"

- I wrote it, so it has that IKEA effect on me


Many more things like that in https://raimonster.com/scripting-field-guide/


Oh! I found https://github.com/junegunn/fzf/blob/master/ADVANCED.md#ripgrep-integration which is an even more advanced version of it. Not as cute though

miércoles, 15 de septiembre de 2021

Oh Yes You Can Use Regexes to Parse HTML!

This is Perl, and regexes, and parsing, so if you enjoy those kinds of things, you'll love the comment on this HN Thread. that points to this insane "oh yes, you can use regexes to parse HTML" .


Wow. We've seen all the "you can't parse html with regexes",  and if you were into Perl and knew about the superpowered regexes, you knew it was possible. 

And you might even remember that Regex::Grammars was some amazing Damian  Conway's thing that twisted regexes to their limits.  

Or, my Meta-II compiler implemented in a Perl regex...

 

But it's great to see all those twistings of the common tools. 

viernes, 3 de septiembre de 2021

Get Github Actions' container logs

 If you happen to use github actions AND you use service containers, you might want to show their logs, and GH doesn't do it (at least in some cases).


So, according to  https://github.community/t/how-do-i-get-the-logs-for-a-service/16422/2 , you can create a later step that prints the container logs:

docker logs "${{ job.services.mysql.id }}"

miércoles, 25 de agosto de 2021

A couple of jq tricks

 There's 2 jq functions I'm using a lot, and I don't see many people using: "join" and "fromjson".

The first one, is join, which joins arrays into a single string. I shared it in a HN thread about jq. That thread has some nice tricks, check it out if you do that kind of json parsing in the CLI.

The other one is "fromjson", and you use it like this:  

     echo '"{\"a\":1}"' | jq fromjson.a      # 1


A concrete practical example is in when fetching secrets from aws secretsmanager. A secret's content is a string, that is really a json.

     aws secretsmanager get-secret-value --secret-id  <secret-key> | jq '.SecretString| fromjson.key_of_the_json' -r