emacs 28.1 'parse-time-weekdays' - weekdays configuration doesn't working - emacs

Before Emacs 28.1 (Linux) I used:
(eval-after-load 'parse-time
'(progn
(setq parse-time-weekdays (nconc parse-time-weekdays
'(("so" . 0) ("mo" . 1) ("di" . 2) ("mi" . 3) ("do" . 4) ("fr" . 5) ("sa" . 6)))))
which gives german weekdays when entering org-mode dates, like <2022-08-21 So>, now I'am getting <2022-08-21 Sun> (Org mode version 9.5.4).
Why?

Related

How to change different org-roam-capture-dailies-template by working days or weekend?

I have a template, and it works fine. Now I just wonder if there is a way to use A template in working days and use B template in weekend.
(setq org-roam-dailies-capture-templates
`(("d" "default" entry "* %<%H:%M:%S> \n %? \n\n"
:if-new (file+head "%<%Y-%m-%d>.org"
,(concat "#+title: %<%Y-%m-%d>\n"
"\n"
"%<%Y-%m-%d %A %W weeks %j days>\n"
"\n"
"*Don't ignore your dreams; don't work too much; say what you think; cultivate friendships; be happy*\n"
"\n"
))
:unnarrowed t)))

How to loop through dates in Racket?

I want to loop through dates from the current date to some stop date, like the following example in Python:
import datetime
def count_dates(stop_date):
step = datetime.date.today()
while step >= stop_date:
yield step
step = step - datetime.timedelta(days=1)
def main():
for step in count_dates(datetime.date(2018, 1, 1)):
print(step.isoformat())
I don't see any date calculation functions in Racket, however. How can this be done?
If you want to use racket/date, you can accomplish your goal with find-seconds, seconds->date, current-seconds, and a simple arithmetic:
#lang racket
(require racket/date
racket/generator)
(define 1day (* 60 60 24))
(define (count-dates year month day)
(define target (find-seconds 0 0 0 day month year))
(in-generator
(let loop ([current (current-seconds)])
(when (>= current target)
(yield (seconds->date current))
(loop (- current 1day))))))
(date-display-format 'iso-8601)
(for ([dt (count-dates 2019 2 1)])
(displayln (date->string dt)))
This outputs:
2019-02-11
2019-02-10
2019-02-09
2019-02-08
2019-02-07
2019-02-06
2019-02-05
2019-02-04
2019-02-03
2019-02-02
2019-02-01
That is, from today (Feb 11, 2019) to Feb 1, 2019.
You can also use gregor or srfi-19 which are alternative date libraries that have a notion of time duration/difference.
Here is how you can do it using the date arithmetic provided by gregor. Specifically the +days and -days functions are helpful here:
#lang racket
(require gregor
racket/generator)
;; Date -> [Sequenceof Date]
(define (count-dates stop-date)
(in-generator
(let loop ([step (today)])
(when (date>=? step stop-date)
(yield step)
(loop (-days step 1))))))
(for ([step (count-dates (date 2018 1 1))])
(displayln (date->iso8601 step)))
And if you need something more general than "some number of days", there's also functions like +date-period and -date-period.

emacs: slime-repl hang if using read() or read-line() function

I am using Emacs 24.3.1 on Ubuntu 14.04, slime-20160402.549, GNU CLISP 2.4. Whenever i use read() or read-line() function in slime-repl, it will freeze after one or two input characters (e.g. "wa"),
; SLIME 2016-04-02
CL-USER> (read)
wa
Trying C-g it shows the error below:
Debugger entered--Lisp error: (quit)
accept-process-output(nil 0.01)
#[0 "\306\307!\306\310!\211\302L\266\211\211\300L\266\311\312J\301#\313\314\315\316\317D\316\nD\316\fD\320\257E\257!\266\321\322\323 \322\262\322\262\324!\325=\204J
slime-eval((swank:simple-completions "wa" (quote "COMMON-LISP-USER")))
slime-simple-completions("wa")
ac-source-slime-simple-candidates()
ac-candidates-1(((init . ac-slime-init) (candidates . ac-source-slime-simple-candidates) (candidate-face . ac-slime-menu-face) (selection-face . ac-slime-selection-face) (prefix . slime-symbol-start-pos) (symbol . "l") (document . ac-slime-documentation) (match . ac-source-slime-case-correcting-completions)))
ac-candidates()
ac-update(t)
ac-show-menu()
apply(ac-show-menu nil)
...
This problem does not happen in clisp REPL on command line.
Any helps?

Determine the date format by locale with clj-time

I have been searching for this for quite a while now through Google and I couldn't find an ultimate solution with clj-time. I want to format a date automatically by the locale, like in this example or here. How would I do this using clj-time?
Thanks & Cheers
Use with-locale (http://clj-time.github.io/clj-time/doc/clj-time.format.html#var-with-locale)
(require '[clj-time.core :as time] '[clj-time.format :as fmt])
(import '[java.util Locale])
(def custom-formatter (fmt/formatters :rfc822))
(def ja-formatter (fmt/with-locale custom-formatter (Locale. "ja")))
(fmt/unparse ja-formatter (time/date-time 2010 10 3))
> "日, 03 10 2010 00:00:00 +0000"
-UPDATE-
Example of usage of joda-time DateTimeFormat:
(require '[clj-time.core :as time] '[clj-time.format :as fmt])
(import '[java.util Locale])
(import '[org.joda.time.format DateTimeFormat])
(def custom-formatter (DateTimeFormat/longDate))
(def ja-formatter (fmt/with-locale custom-formatter (Locale. "ja")))
(fmt/unparse ja-formatter (time/date-time 2010 10 3))
"2010/10/03"
(def us-formatter (fmt/with-locale custom-formatter (Locale. "us")))
(fmt/unparse us-formatter (time/date-time 2010 10 3))
"October 3, 2010"

Racket Server & PostgreSQL - BLOB upload/download without saving to memory or disk

I am trying to make a servlet for the Racket Web Server that would allow a user to upload pictures to the site and display the already uploaded files as images on the same page. I would like to stream the pictures directly in and out of a PostgreSQL database, rather than saving them to a temporary file on disk or in memory. Is it possible? If so, what is the best way to do it? Can it be done with a stateless servlet? Any help is greatly appreciated!
Should be. I recommend the db package from PLaneT (because I wrote it). You can read the docs online.
The PostgreSQL table should have a bytea field for the image contents; on the Racket side it will be represented as a byte string.
In your servlet, you should probably return a response/full structure with the image contents. You'll have to deal with the return code, MIME type, etc yourself. (See the example in the documentation.)
In the name of science, I am posting one half of the answer to my own question. This page will show images that are already in the database. The upload page is still an open question.
Ryan Culpepper helped me in private correspondence beyond of what is posted here. I thank him for his help. All things that may look like black magic come from him, and all clumsy goofs are mine. I will be grateful for all suggestions on how to improve the code.
#lang racket
#|
================================================================================================================
We are assuming that the PostgreSQL database we are connecting to
has a table "person" with columns
"id", "firstname", "lastname" and "portrait".
The "portrait" column contains the OID of a BLOB
that stores the image file we want to display.
Suppose further that the table "person" has a legitimate entry with
id=22, firstname="John", lastname="Doe"
Then the page
http://127.0.0.1/page/22
should display greetings "Hello, John Doe!"
and show the portrait of the person below the greeting.
The portrait itself should be at
http://127.0.0.1/portrait/22.jpg
The program should be run via Racket -t "<filename>"
after defining the environment variables
"DB_USER", "DB_NAME", "DB_PORT", "DB_PASSWORD".
================================================================================================================
|#
(require
web-server/servlet
web-server/servlet-env
web-server/dispatch
web-server/stuffers/hmac-sha1
web-server/http
web-server/http/response-structs
(planet ryanc/db:1:4)
(planet ryanc/db:1:4/util/connect)
net/base64)
;---------------------------------------------------------------------------------------------------------------
; response
;---------------------------------------------------------------------------------------------------------------
(define (start given-request)
(site-dispatch given-request))
(define-values (site-dispatch given-request)
(dispatch-rules
[("page" (integer-arg)) show-page]
[("portrait" (string-arg)) show-portrait]))
(define (show-page given-request given-person-id)
(let* ( [db-person_firstname_lastname
(query-maybe-row my-connection
"SELECT firstname, lastname FROM person WHERE id = $1"
given-person-id)]
[my-firstname (vector-ref db-person_firstname_lastname 0)]
[my-lastname (vector-ref db-person_firstname_lastname 1)])
(response/xexpr
`(html ([xmlns "http://www.w3.org/1999/xhtml"])
(head
(title "Page with a portrait"))
(body
(div ([id "greetings"])
,(string-append
"Hello, " my-firstname " " my-lastname "! "))
(img ( [src ,(string-append "/portrait/"
(number->string given-person-id) ".jpg")])))))))
(define (show-portrait given-request given-portrait-file)
(let* ( [my-user-id (car (regexp-match #rx"^([0-9]+)"
given-portrait-file))]
[my-portrait-oid (query-value my-connection
"SELECT portrait FROM person WHERE id = $1"
(string->number my-user-id))]
[STREAMOUT_CHUNK_SIZE 1000]
[INV_READ #x00040000])
(response
200 ; code
#"Okay" ; message
(current-seconds) ; seconds
#"image/jpeg" ; mime type
empty ; headers
(lambda (given-output-stream) ; body generator
(start-transaction my-connection)
(define object-descriptor
(query-value my-connection
"SELECT LO_OPEN( $1, $2 )" my-portrait-oid INV_READ))
(define (stream-next-chunk)
(begin
(define my-next-chunk
(query-value my-connection
"SELECT LOREAD( $1, $2 )"
object-descriptor STREAMOUT_CHUNK_SIZE))
(if (> (bytes-length my-next-chunk) 0)
(begin
(write-bytes my-next-chunk given-output-stream)
(stream-next-chunk)
#t)
#f)))
(stream-next-chunk)
(commit-transaction my-connection)))))
;---------------------------------------------------------------------------------------------------------------
; database connection
;---------------------------------------------------------------------------------------------------------------
(define my-connection
(virtual-connection
(connection-pool
(lambda ()
(eprintf "(Re)establishing database connection...\n")
(postgresql-connect
#:user (getenv "DB_USER")
#:database (getenv "DB_NAME")
#:port (string->number (getenv "DB_PORT"))
#:socket #f
#:password (getenv "DB_PASSWORD")
#:allow-cleartext-password? #f
#:ssl 'optional ; other choices: 'yes 'no
)))))
;---------------------------------------------------------------------------------------------------------------
; servlet parameters
;---------------------------------------------------------------------------------------------------------------
(serve/servlet start
#:command-line? #t ; #t to use serve/servlet in a start up script for a Web application, and don't want a browser opened or the DrRacket banner printed
#:connection-close? #f ; #t to close every connection after one request. (Otherwise, the client decides based on what HTTP version it uses.)
#:launch-browser? #f
#:quit? #f ; #t makes the URL "/quit" end the server
#:banner? #t ; #t to print an informative banner
#:listen-ip #f ; give an IP to accept connections from external machines
#:port 80 ; 443 is the default for SSL, 80 - for open connections
#:servlet-regexp #rx"" ; #rx"" captures top-level requests
#:stateless? #t
#:server-root-path ; where the server files are rooted, default=(the distribution root)
(build-path ".")
#:ssl? #f
#:log-file (build-path "server.log"))