bahmanm

joined 1 year ago
 

Shameless plug: I am the author.

 

Just wanted to share some (exciting) news about my Common Lisp project, euler-cl. I finally got the time to sit down and integrate it with Codecov! This means a couple of cool things:

  • πŸ“ˆ Test Coverage Tracking: I can now see how well my code is tested over time, giving valuable insights into code quality.
  • πŸ… Codecov Badge: euler-cl now sports a snazzy Codecov badge to show off!
  • πŸ“¦ Reusable Setup: The code and setup process should be simple enough to be used as a reference to integrate Codecov (and potentially other services) into your own Common Lisp projects!

If you're interested this commit is almost all you need: https://github.com/bahmanm/euler-cl/commit/855b014

Let me know in the comments if you have any questions or want to chat about integrating Codecov into your own projects!

[–] bahmanm@lemmy.ml 10 points 11 months ago

"Announcment"

It used to be quite common on mailing lists to categorise/tag threads by using subject prefixes such as "ANN", "HELP", "BUG" and "RESOLVED".

It's just an old habit but I feel my messages/posts lack some clarity if I don't do it πŸ˜…

 

lemmy-synapse is a light-weight observability and monitoring stack for Lemmy servers.


Using Prometheus and Grafana, it allows the admins to visualise and query the stats of their instance. v1.0.0 comes out of the box with 3 detailed dashboards:

  • Host stats (CPU, RAM, disk, network, ...)
  • PostgreSQL stats (connections, locks, transations, queries, ...)
  • Docker stats (container CPU, RAM, disk, network, OOM signals, ...)

It runs as Docker compose cluster alongside the Lemmy cluster and does not require any changes to it in most cases. Uninstalling lemmy-synapse is as easy as tearing down its cluster and deleting its installation directory.


Got questions/feedback? Pray drop a line:

[–] bahmanm@lemmy.ml 1 points 1 year ago

I didn't like the capitalised names so configured xdg to use all lowercase letters. That's why ~/opt fits in pretty nicely.

You've got a point re ~/.local/opt but I personally like the idea of having the important bits right in my home dir. Here's my layout (which I'm quite used to now after all these years):

$ ls ~
bin  
desktop  
doc  
downloads  
mnt  
music  
opt 
pictures  
public  
src  
templates  
tmp  
videos  
workspace

where

  • bin is just a bunch of symlinks to frequently used apps from opt
  • src is where i keep clones of repos (but I don't do work in src)
  • workspace is a where I do my work on git worktrees (based off src)
[–] bahmanm@lemmy.ml 14 points 1 year ago

Thanks! So much for my reading skills/attention span πŸ˜‚

[–] bahmanm@lemmy.ml 0 points 1 year ago (3 children)

Which Debian version is it based on?

 

Follow up on a previous post: [DISCUSS] Recent momentary outages


I've been working on a simple opt-in solution, primarily for Lemmy end users like me (but also helpful for admins), to easily check the status/health of their favourite instance.

🌎 lemmy-meter.info

You can find the details of the implementation in lemmy-meter github repo.


❓ @admins: would you be interested in adding your instance to lemmy-meter?

You don't need to do anything except confirming - I'll handle the rest. It should only take a few minutes for your instance to show up in lemmy-meter.

Out of the box it will send only 4 HTTP GET requests per minute to your instance. However that is totally configurable if it sounds too much or too little.


PS: I wasn't sure how to reach out to the admins short of messaging them individually.

 

cross-posted from: https://lemmy.ml/post/5719058

Follow up on a previous post: [DISCUSS] Recent momentary outages


I've been working on a simple opt-in solution, primarily for Lemmy end users like me (but also helpful for admins), to easily check the status/health of their favourite instance.

🌎 lemmy-meter.info

You can find the details of the implementation in lemmy-meter github repo.


❓ @admins: would you be interested in adding your instance to lemmy-meter?

You don't need to do anything except confirming - I'll handle the rest. It should only take a few minutes for your instance to show up in lemmy-meter.

Out of the box it will send only 4 HTTP GET requests per minute to your instance. However that is totally configurable if it sounds too much or too little.


PS: I wasn't sure how to reach out to the admins short of messaging them individually.

[–] bahmanm@lemmy.ml 4 points 1 year ago (2 children)

RE Go: Others have already mentioned the right way, thought I'd personally prefer ~/opt/go over what was suggested.


RE Perl: To instruct Perl to install to another directory, for example to ~/opt/perl5, put the following lines somewhere in your bash init files.

export PERL5LIB="$HOME/opt/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"
export PERL_LOCAL_LIB_ROOT="$HOME/opt/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"
export PERL_MB_OPT="--install_base \"$HOME/opt/perl5\""
export PERL_MM_OPT="INSTALL_BASE=$HOME/opt/perl5"
export PATH="$HOME/opt/perl5/bin${PATH:+:${PATH}}"

Though you need to re-install the Perl packages you had previously installed.

[–] bahmanm@lemmy.ml 3 points 1 year ago

NB: I have never had the fortune to write Lisp in a professional setup.

For years, I used to use SBCL snippets for a whole set of automation tasks in my daily workflow, like updating git repos in batch, checking failing CI/CD pipelines per repo, organising my music collection, etc.

But gradually I switched to more specialised tools and, yes, Emacs Lisp to do what I needed to do. It just felt more ergonomic in my case.

The last time I seriously used SBCL was to solve some of Project Euler's challenges back in 2018: https://github.com/bahmanm/euler-cl

Nowadays, I've got no non-elisp code left πŸ™‚ πŸ€·β€β™‚οΈ

[–] bahmanm@lemmy.ml 4 points 1 year ago (1 children)

This is fantastic! πŸ‘

I use Perl one-liners for record and text processing a lot and this will be definitely something I will keep coming back to - I've already learned a trick from "Context Matching" (9) πŸ™‚

[–] bahmanm@lemmy.ml 1 points 1 year ago

That sounds a great starting point!

πŸ—£Thinking out loud here...

Say, if a crate implements the AutomatedContentFlagger interface it would show up on the admin page as an "Automated Filter" and the admin could dis/enable it on demand. That way we can have more filters than CSAM using the same interface.

[–] bahmanm@lemmy.ml 10 points 1 year ago

That was my case until I discovered that GNU tar has got a pretty decent online manual - it's way better written than the manpage. I rarely forget the options nowadays even though I dont' use tar that frequently.

[–] bahmanm@lemmy.ml 1 points 1 year ago

I cross-posted the same questions on Matrix and got the answer there.


The hook I'm using is invoked before the minor modes are setup - that's why it's being overridden. The suggestion was to have a hook function for each minor mode that I want to control. It's not clean but gets the job done.


Here's the working snippet:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun bahman/helm-major-mode.hook ()
 (display-line-numbers-mode -1)
 (puni-mode -1))

(add-hook 'helm-major-mode-hook
         #'bahman/helm-major-mode.hook)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defvar bahman/display-line-numbers-mode.disabled-modes
 '(vterm-mode erlang-shell-mode)
 "Disable `display-line-numbers' for the specified modes.")

(defun bahman/display-line-numbers-mode.hook ()
 (when (seq-contains-p bahman/display-line-numbers-mode.disabled-modes
                       major-mode)
     (display-line-numbers-mode -1)))

(add-hook 'display-line-numbers-mode-hook
         #'bahman/display-line-numbers-mode.hook)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defvar bahman/puni-mode.disabled-modes
 '(vterm-mode)
 "Disable `puni-mode' for the specificied modes.")

(defun bahman/puni-mode.hook ()
 (when (seq-contains-p bahman/puni-mode.disabled-modes
                       major-mode)
   (puni-mode -1)))

(add-hook 'puni-mode-hook
         #'bahman/puni-mode.hook)
 

See my reply below (https://lemmy.ml/comment/3972018) for a working solution.


I've got quite a few useful minor modes enabled globally, namely puni-mode and display-line-numbers-mode.

However, I'd like to be able to disable (one or more of) them for certain major modes. For example, I don't want puni or display-line-number to be activated when using vterm.

I've been trying to make the following snippet do the job for me to no avail. What am I missing?

I'd appreciate any hints/help πŸ™


(defvar bahman/display-line-numbers-mode.disabled-modes
  '(vterm-mode erlang-shell-mode)
  "Disable `display-line-numbers' for the specified modes.")

(defvar bahman/puni-mode.disabled-modes
  '(vterm-mode)
  "Disable `puni-mode' for the specificied modes.")

(defun bahman/after-change-major-mode-hook.disable-minor-modes ()
  "Disable certain minor modes for certain major modes 🀷.
See
  `bahman/display-line-numbers-mode.disabled-modes'
  `bahman/puni-mode.disabled-modes'"
  (with-current-buffer (current-buffer)
    (when (seq-contains-p bahman/display-line-numbers-mode.disabled-modes
                          major-mode
                          #'eq)
      (display-line-numbers-mode -1))
    (when (seq-contains-p bahman/puni-mode.disabled-modes
                          major-mode
                          #'eq)
      (puni-mode -1))))

(add-hook 'after-change-major-mode-hook
          #'bahman/after-change-major-mode-hook.disable-minor-modes)
[–] bahmanm@lemmy.ml 1 points 1 year ago

Thanks all for your feedback πŸ™

I'm going to stick to "version 2" which, to my mind, reads more naturally. I'll definitely consider the iterative suggestions for the sake of performance if I ever decide to submit a patch upstream. But for now, what I've got does the job for me dealing w/ sequences w/ less than 50 elements.

[–] bahmanm@lemmy.ml 4 points 1 year ago

TBH I use whatever build tool is the better fit for the job, be it Gradle, SBT or Rebar.

But for some (presumably subjective) reason, I like GNU Make quite a lot. And whenever I get the chance I use it - esp since it's somehow ubiquitous nowadays w/ all the Linux containers/VMs everywhere and Homebrew on Mac machines.

 

cross-posted from: https://lemmy.ml/post/4908824

There are two major flavours of variables in GNU Make: "simple" and "recursive".

While simple variables are quite simple and easy to understand, they can be limiting at times. On the other hand, recursive variables are powerful yet tricky.

...

There is exactly one rule to recall when using recursive variables...

🧠 The value of a recursive variable is computed every time it is expanded.

 

cross-posted from: https://lemmy.ml/post/4692376

From GNU lists earlier today:

We have learned with deep sadness that Thien-Thi Nguyen (ttn) died in October 2022. Thien-Thi was a hacker, artist, writer, and long-time maintainer and contributor to many GNU programs as well as other free software packages. He was the GNU maintainer of the rcs, guile-sdl, alive, and superopt packages, and he was working on GNU Go as well.

Thien-Thi especially loved GNU Emacs, GNU Taler, and GNU Go: he was the author and maintainer of the xpm, gnugo, ascii-art-to-unicode, and hideshow GNU Emacs packages and made substantial contributions to many others such as vc, as well as to GNU Taler and its documentation.

We greatly miss Thien-Thi in the free software community - his death is a great loss to the Free World.

 

cross-posted from: https://lemmy.ml/post/4591838

Suppose I need to find out if the intersection of an arbitrary number of lists or sequences is empty.

Instead of the obvious O(n^2^) approach I used a hash table to achieve an O(n) implementation.

Now, loop mini-language aside, is this idiomatic elisp code? Could it be improved w/o adding a lot of complexity?

You can view the same snippet w/ syntax highlighting on pastebin.

(defun seq-intersect-p (seq1 seq2 &rest sequences)
 "Determine if the intersection of SEQ1, SEQ2 and SEQUENCES is non-nil."
 (cl-do* ((sequences `(,seq1 ,seq2 ,@sequences) (cdr sequences))
          (seq (car sequences) (car sequences))
          (elements (make-hash-table :test #'equal))
          (intersect-p nil))
     ((or (seq-empty-p sequences)) intersect-p)
   (cl-do* ((seq seq (cdr seq))
            (element (car seq) (car seq)))
       ((or intersect-p (seq-empty-p seq)) intersect-p)
     (if (ht-get elements element)
         (setf intersect-p t)
       (ht-set elements element t)))))

(defun test-seq-intersect-p ()
 "Test cases."
 (cl-assert (null (seq-intersect-p '()
                                   '())))
 (cl-assert (null (seq-intersect-p '(1)
                                   '())))
 (cl-assert (null (seq-intersect-p '(1 2)
                                   '(3 4)
                                   '(5 6))))
 (cl-assert (seq-intersect-p '(1 2)
                             '(3 4)
                             '(5 6)
                             '(1)))
 t)

(test-seq-intersect-p)

Version 2

(defun seq-intersect-p (first second & sequences)
  "Determine if FIRST, SECOND and any of the sequences in SEQUENCES have
an intersection."
  (if (seq-empty-p sequences)
      (seq-intersection first second)
    (or (seq-intersection first second)
        (apply #'seq-intersect-p
               first
               (seq-first sequences)
               `,@(seq-rest sequences))
        (apply #'seq-intersect-p
               second
               (seq-first sequences)
               `,@(seq-rest sequences))
        (apply #'seq-intersect-p
               (seq-first sequences)
               (seq-elt sequences 2)
               `,@(seq-rest (seq-rest sequences))))))
 

Suppose I need to find out if the intersection of an arbitrary number of lists or sequences is empty.

Instead of the obvious O(n^2^) approach I used a hash table to achieve an O(n) implementation.

Now, loop mini-language aside, is this idiomatic elisp code? Could it be improved w/o adding a lot of complexity?

You can view the same snippet w/ syntax highlighting on pastebin.

(defun seq-intersect-p (seq1 seq2 &rest sequences)
  "Determine if the intersection of SEQ1, SEQ2 and SEQUENCES is non-nil."
  (cl-do* ((sequences `(,seq1 ,seq2 ,@sequences) (cdr sequences))
           (seq (car sequences) (car sequences))
           (elements (make-hash-table :test #'equal))
           (intersect-p nil))
      ((or (seq-empty-p sequences)) intersect-p)
    (cl-do* ((seq seq (cdr seq))
             (element (car seq) (car seq)))
        ((or intersect-p (seq-empty-p seq)) intersect-p)
      (if (ht-get elements element)
          (setf intersect-p t)
        (ht-set elements element t)))))

(defun test-seq-intersect-p ()
  "Test cases."
  (cl-assert (null (seq-intersect-p '()
                                    '())))
  (cl-assert (null (seq-intersect-p '(1)
                                    '())))
  (cl-assert (null (seq-intersect-p '(1 2)
                                    '(3 4)
                                    '(5 6))))
  (cl-assert (seq-intersect-p '(1 2)
                              '(3 4)
                              '(5 6)
                              '(1)))
  t)

(test-seq-intersect-p)
 

cross-posted from: https://lemmy.ml/post/4560181

A follow up on [DISCUSS] Website to monitor Lemmy servers' performance/availability


I wanted to experiment w/ Lemmy's APIs to, eventually, build a public-facing performance monitoring solution for Lemmy.

It started w/ a couple of shell commands which I found myself repeating. Then I recalled the saying "Don't repeat yourself - make Make make things happen for you!" and, well, stopped typing commands in bash.

Instead I, incrementally, wrote a makefile to do the crud work for me (esp thanks to its declarative style): https://github.com/bahmanm/lemmy-clerk/blob/v0.0.1/run-clerk


TBH there's nothing special about the file. But I thought I'd share this primarily b/c it is a demonstration of the patterns I usually use in my makefiles and I'd love some feedback on those.

Additionally, it's a real world use-case for bmakelib (a library that I maintain 😎 )

102
submitted 1 year ago* (last edited 1 year ago) by bahmanm@lemmy.ml to c/linux@lemmy.ml
 

I thought I'd share how happy I've been w/ my Gnome experience these past few years despite the occasionally controversial UI/UX decisions the Gnome folks tend to make.

I use Gnome Online Accounts integration w/ Google (drive, e-mail, calendar & contacts) and it "just works"β„’ & it does so quite reliably.

It's so polished & well-integrated in the desktop that I often don't even notice that I'm using in on a daily basis ❀️

PS: I'm using Gnome 44.3 on openSUSE Tumbleweed running on an old ThinkPad T530 w/ an nVidia GPU.

view more: next β€Ί