lunes, 10 de diciembre de 2018

bash and python pills

So you know bash sucks, but it's the best we have to do process orchestration and pipes and all that kind of stuff.

Here are a few lists of knowledge pills that are kind of related.

  • You are writing bash, and there's clearly a list of things (patterns) you do over and over. Here's a list of some common things
  • You have some shellscripts but some depend on linux/bsd programs and you'd like to make them pure bash. Or you're just the curious type that wants to know "what would this look in pure bash".
  •  Until you realize you should start moving all your bash crap to something different. What about python?
  • Python is great, but it's not without wtfs.

sábado, 8 de diciembre de 2018

Dark themes for the browser

If you're spending many hours a day at your computer, chances are the white background of the average web site causes some visual stress to you (that's why we use low contrast themes in our editors and terminals.)

Changing css styles of websites you visit can be done with userstyles (custom css's loaded by your browser), but until now, all plugins I've found to manage them sucked in one way or another. Here's my experience:

The most successful strategy I had until 2 days ago was using stylus with one of its "Global dark style", but the problem with those generic themes is that some pages go very wrong with them, and then you have to manually disable them for those sites, and maybe find an ad-hoc dark style for them.

That was the case with Slack, HackerNews, Reddit, Github (which are 80% of my browsing anyway).

But this week I discovered Dark Reader, and I'm so happy with it I can't believe it.

Just give it a try. It just works.

EDIT: I'm noticing added load and lag when loading some pages, but for now it's nothing that outweights the benefits, so for now, it stays

jueves, 29 de noviembre de 2018

prefer duplication over the wrong abstraction

From: https://www.sandimetz.com/blog/2016/1/20/the-wrong-abstraction

  1. Programmer A sees duplication.
  2. Programmer A extracts duplication and gives it a name.
    This creates a new abstraction. It could be a new method, or perhaps even a new class.
  3. Programmer A replaces the duplication with the new abstraction.
    Ah, the code is perfect. Programmer A trots happily away.
  4. Time passes.
  5. A new requirement appears for which the current abstraction is almost perfect.
  6. Programmer B gets tasked to implement this requirement.
    Programmer B feels honor-bound to retain the existing abstraction, but since isn't exactly the same for every case, they alter the code to take a parameter, and then add logic to conditionally do the right thing based on the value of that parameter.
    What was once a universal abstraction now behaves differently for different cases.
  7. Another new requirement arrives.
    Programmer X.
    Another additional parameter.
    Another new conditional.
    Loop until code becomes incomprehensible.
  8. You appear in the story about here, and your life takes a dramatic turn for the worse

martes, 27 de noviembre de 2018

Book: Amusing Ourselves to Death




You've read 1984, you've read "A Brave New World", you've read "The Information" (you should), you've read McLuhan, and you want more connections between those, Amusing Ourselves to Death. It's like a missing (darker) chapter from "The Information", or an update to "A Brave New World".

Filled with data, and very up to date (being written in 1986).  I'd love to see an extension to it talking about the nonsense of information flood and "And now ... this" we're in now.  Neil Postman hints at gamification without naming it and speaks with great clarity about the continuous amusement we're in nowadays. Slot machines aren't mentioned in the book, but the fact that now we know many successful platforms/services/soma base engagement on the same algorithms than slot machines makes the book scary when looking at both directions from when it was written. Both as constataion of facts and premonitory.

Here's a very nice review about it, (funnily enough with nice pictures to help the reader)

lunes, 26 de noviembre de 2018

A Philosophy of Software Design



I finished "A Philosophy of Software Design" by John Ousterhout (creator of tcl): https://www.goodreads.com/book/show/39996759-a-philosophy-of-software-design.



The book contains some tips and tricks to keep complexity low, and some concerns against some mainstream trends (agile, short methods, etc..). 

I was expecting a bit more, given that the trigger for me was this review [https://lethain.com//notes-philosophy-software-design/]  that already covered 90% of the value of the book.  

The author did a talk (https://www.youtube.com/watch?v=bmSAYlu0NcY) which covers also many of the good points.

Overall the book is a nice conversation starter. It's packed with good advices but it feels a bit short and sometimes simplistic. Maybe it's removing complexity even in the tips, so keeping it "obvious" is part of the magic. 

I'm still deciding if it's meta-genius.

viernes, 23 de noviembre de 2018

overlapping screens

I recently bought a screen, and funnily enough, this shiny new thing is not sufficiently tall to be placed just behind my laptop screen without overlapping.

The bottom centimeter of the screen is behind the laptop screen.

And this is a huge problem because emacs' minibuffer is what is hidden.

But luckily, ratpoison has this option called "padding".

set padding 0 0 0 50

Maybe it's clearer with a picture.

So this is my stupid trick of the day.

Yes, books would work too.

jueves, 8 de noviembre de 2018

Regex madness

I'm a big fan of regexes, the problems they solve, and the problems they create. It reminds me of Perl :p

Lately I've encountered a couple of very twisted uses of them worth a post.

First of all is a very nasty way of using the regex engine as a sintactic transformer that ends up validating arithmetic operations. Totally nuts.


Second one is a kind of "sed for power users". It's about internals of sed at a user level (as strange as it seems).


After reading drregex post I started hunting for that Abigail's slides on how to solve sudoku using regexes.


And here is Brian d Foy explaining how to parse json with a single regex.


Last one is my metaII bootstrapping parser. A single regex to bootstrap the metacompiler. I guess it also counts as crazyish.