How did I run that code again? Tools to help recall
hippocanvas.com
hippocanvas.com
In the physical world or in GUIs if there's a concise bit of large text in front of you it can be hard to ignore. But the command line is a barren wasteland until you take action. This tip basically brings what the author sees as a minimal documentation / GUI to every project via a command that they run by habit now upon project entry.
There's also a good point that documentation is a PITA and so you should try to make a doc generating tool that extracts the most critical info you need to use a given project from the code itself so you don't have to repeat yourself. The author determined that aliases set in the project are such critical info for example.
I think it would be fun to write a 'universal' `help` tool that took some of these heuristics and tried to produce minimal docs from any directory that was discernibly part of a coding project. Delightfully open-ended and unsolvable, probably needs some machine learning sprinkled on top as well.
On my iPhone Firefox screen real estate, nearly 2/3rd were taken over by website’s navigation area (or is that the floating outline index of the article itself?).
Despite that challenge, I doggingly read on with the main portal that mainly and underwhelming overtook 1/4th the screen.
Good article. Hell of a website although.
- make test
- make build (or run if it's an interactive app)
- make publish
Publish runs test + build and uploads it to "production".For Go projects I've started to move to Magefiles though: https://magefile.org
I love go but the only example on the site is bad, and there is not any others. Also, executing commands in go is tedious and verbose w/o helpers. The "Why" on the page fails to convince me as well.
How is a makefile too much whitespace?
Is there any good examples of mage being used in a larger project? preferably a popular one?
The test/lint/build phases of my magefiles are mostly the same as makefiles. What differs is the publish command:
There I can make use of (for example)native AWS libraries to do complex deployment processes with error checking and validation. All this is of course doable with makefiles, but it gets very tedious compared to a "real" programming language.
There's also task (https://taskfile.dev/), which is YAML-based and might work well in an environment where everything else is YAML anyway, and makesure (https://github.com/xonixx/makesure), which is pretty similar to just, but didn't really click with me.
just push
just testThe main things I have figured out are, 1) use a script to contain all the stuff I know I will not remember, 2) structure projects so that there is a script for each environment I have to work on, 3) be rigorous in making all that structure the same because I know I will not remember where the script is if it's different, 4) use aliases (also, btw, listed in my .bash_profile) to execute them so I am not confused and 5) make sure to write all the fussy details in those scripts and keep them up to date and refactored frequently.
If you can't run your project without pouring through documentation, you need to fix that. Projects should be easy to get back into after a long absence. In a business, it makes onboarding cheap and easy.
The most illuminating experience for me was doing this for a Python 2.7 project, cloning the repo, running nix-shell, and it Just Worked. I was shocked (in a good way)
IMO, every project should have one single CLI presenting the developer with everything she or he can do (pull or update dependencies, build, run, test, …). Just like applications come with a UI for the user (whether the user is a real person or just some other application), every project should have a proper user interface for the developer.
The file contained what project or uni module it was for, and any significant commands (build & run one-liners), and links to documentation. Some of them had a couple of extra commands to run those one-liners if given a relevant parameter (such as “./wtf make”), like tokamak-teapot's run command but with a little extra typing. Basically a README that could potentially do a few actiony things.
Not something that I kept up in later life though. It was helpful for just me when I had a significant bunch of things actively going on or being referred back to, and particularly useful when the work was part of a group project or otherwise shared to others.
This is not necessarily the best solution, as you have to name even very simple commands, but it's not so hard. What I wished was for bash to have two histories, a global history and a per directory history, so I can look at what commands are typically run in a directory. I hear it is easier to do in zsh, but I have no working solution.
I explain my strategy here: https://tech.genericwhite.com/remembering-details-of-program...
Feedback welcome.
It's maybe a little too weird to be able to practically recommend generally. (It's very difficult to deal with unhappy cases; you really need to know what you're doing to work through those). But, the promise of being able to have a development environment made available with a single command by having declared the programs a package is built with is really neat.
By adding a line like `#!nix-shell -i python ...`, it means that I could just run this Python script with "nix-shell generate.py".
It's not that installing jinja itself is hard.. it's just that it's a nicer "Developer Experience" to jump back into the project without having to fiddle with re-installing stuff.
Yep.
haha Sounds like me!
What happens is that I spend almost all of my time and energy on third tier priorities and problems because I’m a coder, and if things have clear cause and effect I’m going to automate that shit the first time it pisses me off or embarrasses me or a peer.
The longer I’m on a project the more bimodal is my set of focuses. Really big picture, and niggling little minutiae. God knows what it’s like for someone interviewing me and asking about my last gig.
We have robust documentation and we've practiced engineers maintaining a "stash" repo for their notes, which may sync back up to the primary documentation. We also make an effort wipe our stack and redo it every 2-4 weeks, so that we understand the warts while potentially finding new ones.
We'll slowly move towards better developer experiences (and Makefiles are honestly great for most use cases), but a documentation culture is most important right now.
The last time I did this, I wrote a self documenting bash script project.sh similar to the last Nix example with a list of commands and a help text and menu options.
Another useful object is not just unix history but a tool like Rash in Python, advanced bash shell history stored in SQLite. There are many similar tools nowadays but then you can look for commands you run in this project directory structure in your cli history. Projects are not flat, so there may be specific commands needed in certain directories.
the first target is 'help', so when you enter the directory, you run make and it spits out a list of possible targets.. The help target is just a bunch of #comments.
Each target does some sort of useful thing, like regenerating swagger, cleaning up temporary crap, starting in dev mode, etc.
Coupled with a readme it's the best, simplest approach.
I never have to review (except occasional grep something ~/.zsh_history), but I find myself typing Ctrl-R to find commands in history all the time.
Even better, newer versions support predictions [0] - which, whenever you type any text, it immediately lists multiple commands where it finds a match.
Of course, that addresses only myself, but not whoever touches the project. As well, I may not know in what context that command was ran. So I appreciate some suggestions here that guide toward making scripts and providing useful info in README.
Then users of your project can type `ib ?` to get the list of available scripts and ib itself will setup context of their execution as needed.
Log in to our Postgres? that's `psql` something something. CTRL + ALT + V, type psql - there it is
PGPASSWORD=pass1234 psql -h our-database-dev.abcdefg.us-east-1.rds.amazonaws.com -U acme maindb
Press Enter to automatically enter it in currently active window
history | grep -i "whatever I want to remember"