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/

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 Damian Conway's Regex::Grammars was some amazing weird Conway thing that twisted regexes just to test 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

miércoles, 28 de julio de 2021

More on Writing, Notation, Symbols, and Emoji

Since My "On Writing" post, a few posts came through HN that touched somehow on the communication styles, context, and missconceptions on sharing knowledge.

- What happened when I stopped using emojis. That reasonates with my thinking a lot. I'm trying to use only the modern version of '+1' and simple ':)'. The other ones dumb down the expressivity to a baseline that brings nearly 0 info. On the other hand, knowing that old reddit's '/s' has its own family of symbols and meanings made me think that well used, a short symbol can convey the a lot of info (https://toneindicators.carrd.co/). On Context and the power of understanding "where that person is coming from", there's this great example on Greg Wilson's talk What Everoyone in Thech Should Know About Teaching and Learning where it explains how in examining the novice's mistakes, you can infer what he/she didn't understand, and what's the best explanation or example to give in order to solve the enigma and make it 'click'. (As an aside: I think it's a great example of why human interactivity is not redundant once you have docs and wikis.)

Which brings us to APL (again), and its notation. I've been more and more excited by APL, and I'm following now some APLers on youtube, for example Rodrigo Girao which does great short beginner videos on APL solving leetcode problems. Also, subscribed to the shakti mailing list, and reading 'mastering dyalog' when I have some time.

 

On the strict writing side, I found a couple of courses and docs in https://developers.google.com/tech-writing and https://developers.google.com/style/highlights that deserve a good read. I just skimmed them, but well.... something >> nothing.

sábado, 24 de julio de 2021

Cypress, React and Emacs backup/lock files

 So I'm dealing with some javascript lately, and it took me a while to figure out that some of the javascript tooling ("cypress open", or "yarn start" a react app) fails to refresh correctly (in fact exits with an exception) every time you modify a file that it is watching.


So, if autorefresh is "on", you can't touch any file.  Not good.

Found out that the cause of those failures are both emacs lockfiles and backup files. They are created in the source directories, and then, js tries to load them, or to examine them somehow, and js falls flat on its face.

(setq make-backup-files nil  

         create-lockfiles nil)  

That should do it.



domingo, 11 de julio de 2021

Deploy and SPA and getting 404 errors? WTFs that become normal

So, deploying an SPA to an S3 bucket, or github pages involves hacking your way around 404's.  

I did not know this one previously, but once you understand what happens under the hood, it makes sense, the web file server can't understand about any kind of paths besides index.html.  What feels strange is that the "official" ways of deploying such "modern" apps feels like it's using a hack, relying on this catch-all solution of overwriting the 404 page to serve index.html (and potentially hacking it's router), or create an ad-hoc 404.html page and put the hack there.  

Finding all info in random blogposts, stackoverflow threads, gists.... The whole thing seems so fishy... but I've come assume that it's just the way it is. That's the full story. Accept it and move on to more interesting things (like fighting CORS or Same-Site Cookies on buggy browsers)

  • https://github.com/rafgraph/spa-github-pages
  • https://medium.com/swlh/how-to-host-your-angular-reactjs-vuejs-spa-on-github-pages-2d9ab102ac7b
  • https://dev.to/alexeyromanchenko/how-to-deploy-spa-as-a-static-website-using-aws-s3-1adg
  • https://gist.github.com/bradwestfall/b5b0e450015dbc9b4e56e5f398df48ff
  • https://johnlouros.com/blog/using-CloudFront-to-serve-an-SPA-from-S3