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



sábado, 10 de julio de 2021

viernes, 9 de julio de 2021

Show other revisions of a file with magit

Magit proper offers magit-find-file and magit-find-file-other-window, that ask you for both revision and file. At least they autocomplete with sane defaults. 

The thing is my usecase is 99% "current-file in previous-branch in a split window".

As easy as

(defun rgc/magit-find-file-dwim ()
  (interactive)
  (magit-find-file-other-window (magit-get-previous-branch) (buffer-file-name)))

You get a nice command to open the current file from the previous branch you visited in your repo. 

Often, next immediate  command is m-x ediff-buffers RET. (yeah, maybe adding that would make it even more dwim).

If you'd want to do it in the command line, something like 

    git show branch:file

Would do, but you'd have to type both branch and filename.

 

domingo, 4 de julio de 2021

Taming Zoom with Ratpoison, part 2

 It's been already 2 years since the last zoom hack, and it worked fine for some time, but since January 2021, Zoom was behaving even worse on my ratpoison setup. Hijacks of popup windows left me without being able to join zoom with any sort of confidence.

A temporary solution is to use ratpoison's tmpwm, but there's another wrinkle there. In the latest official ratpoison release (1.4.9, from 2017), there's a bug that makes ratpoison not be able to go back from a tmpwm if you have multiple screens. It is fixed in the git version, but having to compile your own WM is yet another yak to shave. (Even more when using nixos). 

So I spoke to a coworker who's a StumpWM user and asked if stump had those issues.

So, it turns his hack worked, and it consists of changing the .config/zoomus.conf. Changing config files on proprietary applications reminds me of my reverse-engineer times on Windows 98.


Anyway:

sed -i 's/enableMiniWindow=true/enableMiniWindow=false/' ~/.config/zoomus.conf


Thanks, Tim and good luck!

sábado, 3 de julio de 2021

Anomalies and Resilience in software

A great read of a mars story and great lessons on software design, systems thinking, and probably resilient software.

https://mars.nasa.gov/technology/helicopter/status/305/surviving-an-in-flight-anomaly-what-happened-on-ingenuitys-sixth-flight/

 

 

If you want to really go into detail in the greatest space story ever, dont' miss this one from the Moon landing: https://www.youtube.com/watch?v=B1J2RMorJXM

domingo, 6 de junio de 2021

Patching via AST in python

Even though I'm lately 75% Clojure and 25% apl/j/k, there's always a spot for a nice python article about patching thousands of lines of code via converting the source code to AST and back to text:

https://engineering.soroco.com/abstract-syntax-tree-for-patching-code-and-assessing-code-quality/ . The corresponding HN thread: https://news.ycombinator.com/item?id=27419237

Reminds me of https://www.debuggingbook.org/ .


Which also reminds me of this clojure https://github.com/bfontaine/grape and https://github.com/borkdude/grasp, that allow you to search clojure code not just by text but by patterns of code, without taking spacing or variable names into account.

And segway to clojure here's some sophisticated clojure codebase walkthrough: https://news.ycombinator.com/item?id=27385208

And last, some good food for thought on leveling up the engineering skillset: https://skamille.medium.com/an-incomplete-list-of-skills-senior-engineers-need-beyond-coding-8ed4a521b29f . Although each one of those make sense, the environment in which one works makes them easier to realize/work.