~skin

Highland, UT

https://about.djhaskin.com

I mean

Trackers

~skin/git-receive-mail

Last active a month ago

~skin/jfon

Last active 9 months ago

#212 Split messages printed by `himalaya message read` in some way a month ago

Ticket created by ~skin on ~soywod/pimalaya

Please disregard #22 "mbox", it was written by mistake.

To make it easier to consume git patch emails via git am, I have written a script using himalaya.

Here is my current script:

email_ids=$(himalaya --output plain "${@}" | \
    tail -n +2 | \
    fzf --nth 3..5 \
        --preview="himalaya message read -p ${@} {1}" \
        --header-lines=1 \
        --multi | \
        awk -F' *| *' '/|/{print $1}')

(
    for email_id in $email_ids; do
        printf '\nFrom nobody Mon Sep 17 00:00:00 2001\n'
        himalaya --output plain message read -p --raw "${@}" $email_id
    done
) | git am -

This script fires up himalaya. It allows the user to select multiple git patch emails. It feeds the IDs of the emails to a for loop which prints <newline>From nobody Mon Sep 17 00:00:00 2001<newline> before each piece of mail is printed. Finally, it pipes all that output into git am -, so that the emails can be used to patch my git repo.

This script is slow since an IMAP connection is initiated for each retrieved email. I want a command that would enable me to retrieve all mails on the same connection, and which would print out the necessary From ... heading that makes it an "mbox file" suitable for git.

More generally, there is no way to tell the difference between one email and the next when printing out multiple emails in this way. Even if I specify --output json, the output is given as one single JSON string all run together.

I want the script I would like to write is this:

#!/bin/sh

himalaya --output plain "${@}" | \
    tail -n +2 | \
    fzf --nth 3..5 \
        --preview="himalaya message read -p ${@} {1}" \
        --header-lines=1 \
        --multi | \
        awk -F' *| *' '/|/{print $1}' | \
        xargs himalaya --output plain message read -p --raw "${@}" --mbox | \
        git am -

This script is much nicer since all the email patches are downloaded with a single imap connection, and thus runs faster.

I'd even be okay if we didn't support mbox format, but instead when I specified --output json that each email were in its own record, as in

#!/bin/sh

himalaya --output plain "${@}" | \
    tail -n +2 | \
    fzf --nth 3..5 \
        --preview="himalaya message read -p ${@} {1}" \
        --header-lines=1 \
        --multi | \
        awk -F' *| *' '/|/{print $1}' | \
        xargs himalaya --output json message read -p --raw "${@}" | \
        jq -r '.messages[] | '\nFrom nobody Mon Sep 17 00:00:00 2001\n\(.raw)'

In summary, I am asking for two distinct features:

  • When --output json is specified with himalaya message read, offer more than just a single string blob, but allow the messages to be consumed one by one.
  • Optionally (but preferably), implement an --mbox option allowing messages to be printed in git mbox format.

#91 Comodoro adds 60 seconds to timers over 60 seconds. 1 year, 1 month ago

Comment by ~skin on ~soywod/pimalaya

computation time is not taken into consideration :( I guess I need to rethink the algorithm.

I just wrote a similar timer to comodoro, it uses the date command to figure out what "actual" time it is and display that. This results in the timer correcting itself if it gets out of sync.

We could do something similar in comodoro, we sleep one second and then we check what time it is using the system clock, compute how many seconds the timer has been running and how much time it has left, and set our internal state to that number.

Here is the script:

#!/bin/sh

. "${HOME}/.profile"
while [ -n "${1}" ]
do
     name="${1}"
     shift
     duration="${1}"
     shift
     seconds=$(( ${duration} * 60 ))
     end=$(( $(date "+%s") + ${seconds} ))
     notify-send '⌚ Timer' "${name} (${duration} minutes)"
     play -q "${HOME}/Music/gong.wav" &
     while [ "${seconds}" -ge 0 ]
     do
         time_left="$(printf "%02d:%02d" "$(( ${seconds} / 60 ))" "$(( 
${seconds} % 60 ))")"
         w | awk '/tmux\([0-9]*\)/ { print $2 }' | while read trm
         do
             printf '\033]2;%s: %s\033\\' \
                 "${name}" \
                 "${time_left}" \
                 | tee "/dev/${trm}"
         done
         clear
         figlet -d "${HOME}/.local/share/figlet" -f timer -cWt 
"${time_left}"
         sleep 1
         seconds="$(( ${end} - $(date "+%s") ))"
     done
     play -q "${HOME}/Music/ding.wav" &
done

In particular, the amount of time we have left on the timer is re-computed against the system clock every second, as per this line:

         seconds="$(( ${end} - $(date "+%s") ))"

It can be found at this URL https://git.sr.ht/~skin/dotfiles/tree/main/item/dot-local/bin/timer

#91 Comodoro adds 60 seconds to timers over 60 seconds. 1 year, 1 month ago

Comment by ~skin on ~soywod/pimalaya

Could you share your config? I cannot reproduce. I tried to setup 60s+ timer and all works as expected.

Here it is:

[skin-pom]
tcp-host = "localhost"
tcp-port = 9999
on-blast-begin = "com-hook Blast"
on-blast-running = "com-run Blast"
on-pacer-begin = "com-hook Pacer"
on-pacer-running = "com-run Pacer"
on-rest-begin = "com-hook Rest"
on-rest-running = "com-run Rest"
on-rest-end = "com-hook Complete"

[[skin-pom.cycles]]
name = "Blast"
duration = 1440

[[skin-pom.cycles]]
name = "Pacer"
duration = 60

[[skin-pom.cycles]]
name = "Rest"
duration = 300

During the "Blast" cycle, it would run slow. This is what is happening: the clock is running slow, so that over 24 minutes I gained 6 seconds * 24 minutes = 144 seconds, or two minutes and 24 seconds.

Because of math reasons, I assumed it just added a minute to both the Pacer and the Blast cycles, but in reality what was happening was the clock was just running slow. I caught it in the act, it counts out 9 seconds about every 10 "real" seconds. Thus, after a 24 minute timer, 26 minutes have elapsed. So I got confused initially and thought it was just straight up adding time. I later realized it wasn't, it was just counting time too slow. :shrug:

-- Dan Haskin

#91 Comodoro adds 60 seconds to timers over 60 seconds. 1 year, 1 month ago

Comment by ~skin on ~soywod/pimalaya

Yeah, I caught it in the act. The thing adds a second about every 10 seconds or so. Thus, the clock runs 10% too slow. It does not keep acurate time :(

#91 Comodoro adds 60 seconds to timers over 60 seconds. 1 year, 1 month ago

Comment by ~skin on ~soywod/pimalaya

It's like the clock runs slower or something. Is that possible? I lose like 10 seconds over a minute.

#91 Comodoro adds 60 seconds to timers over 60 seconds. 1 year, 1 month ago

Ticket created by ~skin on ~soywod/pimalaya

For reasons I do not understand, when I set comodoro to any time over 60 seconds, it adds 60 seconds to the time. My 24 minute timer runs for 25 minutes. My 1 minute timer for 2. Etc.

#78 Configure wizard is broken (on Windows) 1 year, 2 months ago

Comment by ~skin on ~soywod/pimalaya

Tinkering some more, looks like I just caught ya mid-debug. I was able to figure out all the stuff commented out, no big deal. Maybe this ticket is just noise.

#78 Configure wizard is broken (on Windows) 1 year, 2 months ago

Comment by ~skin on ~soywod/pimalaya

It's trying to write to /home/soywod :P

#78 Configure wizard is broken (on Windows) 1 year, 2 months ago

Comment by ~skin on ~soywod/pimalaya

Configure wizard still broken:

11:06:36 ~/Code/thirdparty/himalaya $ himalaya 
Himalaya couldn't find an already existing configuration file.

First let's setup an account
✔ What is your email address? · djhaskin987@gmail.com
✔ Which name would you like to display with your email? · Daniel Jay Haskin
✔ Which backend would you like to configure your account for? · IMAP
✔ What is your IMAP host: · imap.gmail.com
✔ Which security protocol do you want to use? · SSL/TLS
✔ Which IMAP port would you like to use? · 993
✔ What is your IMAP login? · djhaskin987@gmail.com
✔ Which IMAP authentication mechanism would you like to use? · OAuth 2.0
✔ Which sender would you like use with your account? · SMTP
✔ Enter the SMTP host:  · smtp.gmail.com
✔ Which security protocol do you want to use? · SSL/TLS
✔ Enter the SMTP port: · 465
✔ Enter your SMTP login: · djhaskin987@gmail.com
✔ What would you like to name your account? · gmail

Writing the configuration to "/home/soywod/config.wizard.toml"...
Error: Permission denied (os error 13)

#82 `cargo install --path .` Does not work on Himalaya 1 year, 2 months ago

Comment by ~skin on ~soywod/pimalaya

Note, cargo install --all-features --path . DOES work, as long as I install the notmuch library first. This error is on linux.