]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
bba-ms-to-h
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Tue, 26 Apr 2022 10:36:34 +0000 (12:36 +0200)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Tue, 26 Apr 2022 10:36:34 +0000 (12:36 +0200)
search backwards for last "ms" miliseconds and convert them to hour at point.

If you output sql query timings you want to have this.

Signed-off-by: Andreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
bba.org

diff --git a/bba.org b/bba.org
index 772fbd80d49bc1220a1613219d118a49ef19beea..8278cb5b6457b7aa4bee6eecb1364a9b89827d40 100644 (file)
--- a/bba.org
+++ b/bba.org
@@ -1386,6 +1386,29 @@ Your notes are more useful if you can easily search them!
 
 #+END_SRC
 
+** search last miliseconds and convert to hours at point
+[2022-04-21 Thu 13:17]
+
+#+begin_src emacs-lisp :eval never
+  (defun bba-ms-to-h ()
+    "search for last miliseconds and conver tto hours at point.
+    Useful for Vertica timing output."
+    (interactive)
+    (save-mark-and-excursion
+      (let (bounds pos1 pos2 mything oldpos)
+        (setq oldpos (point))
+        (search-backward " ms")
+        (search-backward " ")
+        (right-char)
+      (setq bounds (bounds-of-thing-at-point 'symbol))
+      (setq pos1 (car bounds))
+      (setq pos2 (cdr bounds))
+      (setq mything (buffer-substring-no-properties pos1 pos2))
+      (setq mything (/ (round (/ (string-to-number mything) 10 60 60.0)) 100.0))
+      (goto-char oldpos)
+      (insert-before-markers (format "%s hours." mything)))))
+#+end_src
+
 ** Some initial languages we want org-babel to support
 
 #+BEGIN_SRC emacs-lisp