12 comments

[ 1.4 ms ] story [ 26.3 ms ] thread
I used Org Mode for all mandatory assignments [0] when I was a student, it worked super well and I could create well formatted LaTeX documents/PDFs from it as well. The supervisors were very impressed that I did my assignment in LaTeX, and I could never be bothered to correct them :-)

[0]: https://gist.github.com/sondr3/ae4eda2816cfeda7b8597ce1c48d0..., best viewed as the raw file for all the details

Kudos to you, my biggest regret nowadays was not learning how to use orgmode (and org-roam) in college. As long as you set up a proper environment and have an org-publish config you barely need to bother with verbose LaTeX documents.

https://www.orgroam.com/

I had an amusing incident that was related, quite some years back as a CS undergrad. One prof had quite poor eyesight, so had a no-pencil rule for assignments. Typed was OK, neat pen was fine also. (My writing has always been atrocious, typed it is.) As it happened, I used LaTeX (and I knew she did also.)

She also had a rule about promptness of assignment delivery, meaning the start of class when she arrived. Fair enough!

On this one assignment, I had done all but the last question at home, and printed it off, with the hope that I could finish it at the lab and send it to a laser printer in another building. At the time, labs used shared, dot-matrix printers that were usually jammed. I got the last question done, sent it to the printer, then checked the queue. Apparently someone was printing a book, not going to get done before class.

I emailed her my .tex file, with the explanation that I'd hand in my incomplete printout in class, but would appreciate if she could mark the last section so I knew how I did. This was sent well before class, as the timestamp would show. The prof ended up printing, marking, and returning this version, and I received full marks!

I used a similar setup a long while ago and wanted a way to connect to databases easily. So I wrote some code to parse the MySQL and Postres config files to extract database info in Emacs: https://stackoverflow.com/a/46114944
My “Poor Man’s SQL Workbench” trick is to…

    Use org-babel to execute the queries, from my “sql-queries.org” file.
    Overwrite results into a /tmp file, also an org-mode file, with latest query results (call it anything — “query-result.org”).
    Make psql spit out org-formatted tables for extra oomph.
    Keep that results file open in another buffer (or frame on a big screen, if the table is wide).
    Let Emacs auto-refresh the buffer, when it detects the file has changed.
Et voila! L’établi SQL du pauvre.

Screenshot + sample code in the gist below (a `.org` file, as befits this topic :)

https://gist.github.com/adityaathalye/a6004acd34c683bcc806b2...

Emacs with databases without org would be interessing. I now there is sql-mode which supposedly works to connect with an inferior process but a tuorial about that would be nice
You can also set a `.pgpass` in your `$HOME` or point another path to a `PGPASSFILE` envar, so postgresql credentials don't leak to main org file.

https://www.postgresql.org/docs/current/libpq-pgpass.html

I think even better to encrypt the password in ~/.authinfo.gpg, e.g.,

     machine my_db login my_usr password bla-bla-123
And then in the source block header, you can inject it into a variable

    :var pass=(auth-source-pick-first-password :host "my_db")
That's a built-in elisp function. Yes, you can call arbitrary functions to assign vars for org-mode source blocks. You can even assign shell command output, I often do things like:

    :var token=(shell-command-to-string "echo $MY_TOKEN")
What's crazy about this shit is that you can even pipe the content of the file back into itself:

     #+begin_src sh :pretty :var token=(shell-command-to-string (format "grep my_token %s" buffer-file-name))
        echo $token
     #+end_src
     
That's an absurd bananas degree of ingenious engineering that makes you question the sanity of programmers who deliberately abandon Emacs, even after experiencing such power.
You can also combine this with TRAMP to work on databases you can't directly access from your local machine. E.g.:

  #+header: :dir /ssh:user@remote-host:/
  #+begin_src sql
  ..
  #+end_src
Slight off-topic, but getting organized was a lifelong struggle for me (I was the person who had a five-foot high stack of unorganized papers and crap in their locker in middle and high school), and org-mode is the only system that broke me out of that cycle. It has genuinely changed my life. It's not for everyone, but if you've been unsatisfied with everything else and keep jumping from system to system, it's worth a try. (Especially now that you can get Claude to just explain the basics of Emacs configuration to you, which wasn't the case when I started.)