Skip to content

Instantly share code, notes, and snippets.

@lkuty
lkuty / sync_loop_unix.rb
Created August 3, 2023 13:08
Ruby version of sync_loop_unix.sh from imapsync to handle double quotes in $extra
#!/home/xxx/.rbenv/versions/3.2.0/bin/ruby
require 'open3'
def ms2str(ms)
return nil if ms.nil?
x, ms = ms.divmod(1000)
x, s = x.divmod(60)
x, m = x.divmod(60)
d, h = x.divmod(24)
(defun |#"-reader| (stream sub-char numarg)
(declare (ignore sub-char numarg))
(let (chars)
(do ((prev (read-char stream) curr)
(curr (read-char stream) (read-char stream)))
((and (char= prev #\") (char= curr #\#)))
(push prev chars))
(coerce (nreverse chars) 'string)))
(set-dispatch-macro-character #\# #\" #'|#"-reader|)