Categories: geek

RSS - Atom - Subscribe via email

Marginalia and hiding the value of password-ish variables

Posted: - Modified: | emacs

I like the way Marginalia adds annotations to minibuffer completion. I’m experimenting with streaming, so I’m trying to not leak passwords while playing around with marginalia. (I’ll probably mess up at some point. Please be nice! =) )

This is the annotator function:

(defun my/marginalia-annotate-variable (cand)
  "Annotate variable CAND with its documentation string."
  (when-let (sym (intern-soft cand))
    (marginalia--fields
     ((marginalia--symbol-class sym) :face 'marginalia-modified)
     ((let ((print-escape-newlines t)
            (print-escape-control-characters t)
            (print-escape-multibyte t))
        (prin1-to-string
         (cond
          ((string-match "pass" cand) "*******")
          ((boundp sym) (symbol-value sym))
          (t 'unbound))))
      :truncate (/ marginalia-truncate-width 3) :face 'marginalia-variable)
     ((documentation-property sym 'variable-documentation)
      :truncate marginalia-truncate-width :face 'marginalia-documentation))))

Something like the following code adds it to my annotator functions. The actual code I evaluate is in my use-package marginalia declaration in my Emacs config.

(setq marginalia-annotators
      '(marginalia-annotators-heavy
        marginalia-annotators-light))
(add-to-list 'marginalia-annotators-heavy
             '(symbol . my/marginalia-annotate-function-with-args))
View or add comments

2021-02-01 Emacs news

Posted: - Modified: | emacs, emacs-news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, planet.emacslife.com, YouTube, the Emacs NEWS file and emacs-devel.

View or add comments

A list of sharks that are obligate ram ventilators

Posted: - Modified: | geek

(Edited 2021-02-04 to explain what obligate ram ventilators do.)

A- and I have been curious about which shark species are obligate ram ventilators and need to keep swimming with their mouths open in order to get oxygen from the water flowing through their gills. Here is an incomplete list. (Disclaimer: We’re not marine biologists and have no idea what we’re doing.)


20210128_121612 Obligate ram ventilators #nature #sketch.jpg

  1. Great white shark (Carcharodon carcharias) Source
  2. Bull shark (Carcharhinus leucas) Source
  3. Sandbar shark (Carcharhinus plumbeus) Source
  4. Porbeagle (Lamna nasus) Source
  5. Salmon shark (Lamna ditropis) Source
  6. Thresher shark (Alopiidae) Source
    • Pelagic thresher (Alopias pelagicus)
    • Bigeye thresher (Alopias superciliosus)
    • Alopias vulpinus
  7. Mako shark (Isurus oxyrinchus, Isurus paucus) Source
  8. Hammerhead (Sphyrnidae) Source
    • Winghead shark (Eusphyra blochii)
    • Scalloped bonnethead (Sphyrna corona)
    • Carolina hammerhead (Sphyrna gilberti)
    • Scalloped hammerhead (Sphyrna lewini)
    • Scoophead (Sphyrna media)
    • Great hammerhead (Sphyrna mokarran)
    • Bonnethead (Sphyrna tiburo)
    • Smalleye hammerhead (Sphyrna tudes)
    • Smooth hammerhead (Sphyrna zygaena)
  9. Whale shark (Rhincodon typus) Source

Some fishes are also obligate ram ventilators. Here is an incomplete list:

  • Tuna Source
  • Billfish Source – Structural Adaptations for Ram Ventilation: Gill Fusions in Scombrids and Billfishes
  • Paddlefish (Polyodon) Source
  • Swordfish Source
  • Bonito Source – Structural Adaptations for Ram Ventilation: Gill Fusions in Scombrids and Billfishes
  • Bluefish Source

So… how do they keep swimming? What about sleep?

Apparently, part of their brain stays active and keeps them swimming. Also, sometimes they rest in currents with their mouth open. Source

View or add comments

2021-01-25 Emacs news

| emacs, emacs-news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, planet.emacslife.com, YouTube, the Emacs NEWS file and emacs-devel.

View or add comments

2021-01-18 Emacs news

| emacs, emacs-news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, planet.emacslife.com, YouTube, the Emacs NEWS file and emacs-devel.

View or add comments

2021-01-11 Emacs news

| emacs, emacs-news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, planet.emacslife.com, YouTube, the Emacs NEWS file and emacs-devel.

View or add comments

Using Emacs to fix automatically generated subtitle timestamps

Posted: - Modified: | emacs

I like how people are making more and more Emacs-related videos. I think subtitles, transcripts, and show notes would go a long way to helping people quickly search, skim, and squeeze these videos into their day.

Youtube’s automatically-generated subtitles overlap. I think some players scroll the subtitles, but the ones I use just display them in alternating positions. I like to have non-overlapping subtitles, so here’s some code that works with subed.el to fix the timestamps.

(defun my/subed-fix-timestamps ()
  "Change all ending timestamps to the start of the next subtitle."
  (goto-char (point-max))
  (let ((timestamp (subed-subtitle-msecs-start)))
    (while (subed-backward-subtitle-time-start)
      (subed-set-subtitle-time-stop timestamp)
      (setq timestamp (subed-subtitle-msecs-start)))))

Then it’s easy to edit the subtitles (punctuation, capitalization, special terms), especially with the shortcuts for splitting and merging subtitles.

For transcripts with starting and ending timestamps per paragraph, I like using the merge shortcut to merge all the subtitles for a paragraph together. Here’s a sample: https://emacsconf.org/2020/talks/05/

Tonight I edited automatically-generated subtitles for a screencast that was about 40 minutes long. The resulting file had 1157 captions, so about 2 seconds each. I finished it in about 80 minutes, pretty much the 2x speed that I’ve been seeing. I can probably get a little faster if I figure out good workflows for:

  • jumping: avy muscle memory, maybe?
  • splitting things into sentences and phrases
  • fixing common speech recognition errors (ex: emax -> Emacs, which I handle with regex replaces; maybe a list of them?)

I experimented with making a hydra for this before, but thinking about the keys to use slowed me down a bit and it didn’t flow very well. Might be worth tinkering with.

Transcribing from scratch takes me about 4-5x playtime. I haven’t tweaked my workflow for that one yet because I’ve only transcribed one talk with subed.el , and there’s a backlog of talks that already have automatically generated subtitles to edit. Low-hanging fruit! =)

So that’s another thing I (or other people) can occasionally do to help out even if I don’t have enough focused time to think about a programming challenge or do a podcast myself. And I get to learn more in the process, too. Fun!

View or add comments