ambrevar.gitlab.io issueshttps://gitlab.com/ambrevar/ambrevar.gitlab.io/-/issues2021-09-07T09:03:06Zhttps://gitlab.com/ambrevar/ambrevar.gitlab.io/-/issues/23Re: sudo asking for password only once2021-09-07T09:03:06Zgoose121Re: sudo asking for password only onceI'm not exactly sure what "Have `sudo` ask for password only once until the timeout expires. (Does anyone know how to do this?)" refers to, in the article about using a Lisp REPL as a shell; by default, `sudo` when run from `sly` stores ...I'm not exactly sure what "Have `sudo` ask for password only once until the timeout expires. (Does anyone know how to do this?)" refers to, in the article about using a Lisp REPL as a shell; by default, `sudo` when run from `sly` stores its authentication timeout data based on the parent's process id, so from the same `sly` process it should only ask once. Adding `Defaults timestamp_type=global` to your `/etc/sudoers` makes it store the timeout for all processes, so it will only ask once within the timeout no matter which Lisp process you run it from, if that's the behaviour which that line refers to.https://gitlab.com/ambrevar/ambrevar.gitlab.io/-/issues/22Some idea for "lisp repl as main shell" from `nushell`.2021-09-07T09:06:56Zjcguu95Some idea for "lisp repl as main shell" from `nushell`.I'm often not a fan of the idea of "new shell". But recently two new ideas hit. The first one is "lisp repl as main shell" from the blog, and the second one is the table object structure in `nushell`. I wish to quickly introduce some of ...I'm often not a fan of the idea of "new shell". But recently two new ideas hit. The first one is "lisp repl as main shell" from the blog, and the second one is the table object structure in `nushell`. I wish to quickly introduce some of its strength, and perhaps motivates some incentives for the lisp community. I'm sure it wouldn't be hard to integrate such in the first (wonderful) idea "lisp repl as main shell".
======
https://www.nushell.sh/book/loading_data.html
Take a look at its table object. It is nicely printed, and it is
also very easy to write commands to handle the data. See for
example in the link above.
```
> open people.txt | lines | split column "|" | str trim | get Column1
```
Moreover, it's also easy to coordinate with plain-text input by
using `lines`, `split` and `each`, or
[more](https://www.nushell.sh/book/working_with_tables.html#selecting-the-data-you-want).
```
> ls | each { echo $"($it.name) is ($it.size)" }
───┬─────────────────────
0 │ genawait is 4.1 KB
1 │ learncpp is 4.1 KB
2 │ nuscripts is 4.1 KB
───┴─────────────────────
```
Some examples about [lists](https://www.nushell.sh/book/working_with_lists.html):
```
echo [[1 2] [3 [4 5 [6 7 8]]]] | flatten | flatten | flatten # [1 2 3 4 5 6 7 8]
let scores = [3 8 4]
echo "total =" (echo $scores | reduce { $acc + $it }) # 15
echo "total =" (echo $scores | math sum) # easier approach, same result
echo "product =" (echo $scores | reduce --fold 1 { $acc * $it }) # 96
```https://gitlab.com/ambrevar/ambrevar.gitlab.io/-/issues/21Alternative shell links2021-05-24T11:32:31ZFulvio Scapintrantorvega@gmail.comAlternative shell linksHey, @trantorvega from FOSDEM here ;)
Perhaps I forgot to mention a very interesting alternative project: oilshell
The author blogs about shells and the related technical topics, quite an interesting read indeed
http://www.oilshell.or...Hey, @trantorvega from FOSDEM here ;)
Perhaps I forgot to mention a very interesting alternative project: oilshell
The author blogs about shells and the related technical topics, quite an interesting read indeed
http://www.oilshell.org/
http://www.oilshell.org/blog/2021/01/philosophy-design.html
I suggest taking a look at past articles
http://www.oilshell.org/blog/
The wiki is pretty rich, especially the extensive collection (and comments) on existing alternatives and approaches
https://github.com/oilshell/oil/wiki
https://github.com/oilshell/oil/wiki/ExternalResources
https://github.com/oilshell/oil/wiki/Alternative-Shells
https://github.com/oilshell/oil/wiki/Internal-DSLs-for-Shell
https://github.com/oilshell/oil/wiki/The-Biggest-Shell-Programs-in-the-World
Regards and have a nice day :wave:https://gitlab.com/ambrevar/ambrevar.gitlab.io/-/issues/20Bash fibonacci version spawns a lot of processes2021-02-16T11:27:23ZPrzemek KitszelBash fibonacci version spawns a lot of processesFirst of all, I enjoyed reading the article.
("A Lisp REPL as my main shell", in case that "Comments" section is common for whole blog/site).
I made an observation, that it is unfair to compare pure math of lisp version to sub-shell spa...First of all, I enjoyed reading the article.
("A Lisp REPL as my main shell", in case that "Comments" section is common for whole blog/site).
I made an observation, that it is unfair to compare pure math of lisp version to sub-shell spawning version in bash (`if [` is also a new process).
All of the above just perfectly proves your point, that bash is cumbersome to use ;)
I'm attaching sane versions of recursive fibonacci, in bash (it pushes values on stack to stay in single shell), and also versions that call `gawk` or `bc`, which despite calling additional tool are a lot cleaner.
Pure bash version computes fib30 in under 3 minutes. Others compute fib33 in under 3 seconds.
```bash
#!/bin/bash
fibonacci () {
local ans prev1 prev2
# global: stack
if [[ $1 -lt 2 ]]; then
ans="$1"
else
fibonacci $(($1 - 1)) push
fibonacci $(($1 - 2)) push
prev1=${stack[$((${#stack[@]}-1))]}
unset stack[$((${#stack[@]}-1))]
prev2=${stack[$((${#stack[@]}-1))]}
unset stack[$((${#stack[@]}-1))]
ans=$((prev1+prev2))
fi
if [ -n "$2" ]; then
stack[${#stack[@]}]="$ans"
else
echo "$ans"
fi
}
fibo-awk() {
gawk -M -v q="$1" '
function fib(n) {
if (n < 2)
return n
return fib(n-1) + fib(n-2)
}
BEGIN {
print fib(q)
}
'
}
fibo-bc() {
bc <<<'
define fib(n) {
if (n < 2)
return n
return fib(n-1) + fib(n-2)
}
'"fib($1)"
}
#~ time fibonacci 30
time fibo-awk 33
time fibo-bc 33https://gitlab.com/ambrevar/ambrevar.gitlab.io/-/issues/18Deploy library2020-06-18T09:05:08ZGhost UserDeploy libraryI think it would be nice mention https://github.com/Shinmera/deploy in the Deploying section too. It works well for a project of mine. AFAIK, it also will take care of compressing the executable automatically if you are using SBCL, so th...I think it would be nice mention https://github.com/Shinmera/deploy in the Deploying section too. It works well for a project of mine. AFAIK, it also will take care of compressing the executable automatically if you are using SBCL, so there is no need to explicitly call the sb-* stuff.https://gitlab.com/ambrevar/ambrevar.gitlab.io/-/issues/17sxiv.el2020-05-08T14:33:08ZJohn Doesxiv.elThank you for your post.
When you mentioned sxiv and xsel, I wondered if my package sxiv.el might help you. It launches sxiv, and files marked in that sxiv process will be marked in a Dired buffer. Then you can do all the usual Dired st...Thank you for your post.
When you mentioned sxiv and xsel, I wondered if my package sxiv.el might help you. It launches sxiv, and files marked in that sxiv process will be marked in a Dired buffer. Then you can do all the usual Dired stuff - copy, move, delete, copy names/paths, etc.
https://melpa.org/#/sxiv
https://gitlab.com/contrapunctus/sxiv.elhttps://gitlab.com/ambrevar/ambrevar.gitlab.io/-/issues/16Duplicate code2020-02-26T12:35:17ZRommel MARTINEZDuplicate codeHi, I just discovered your blog via HN. In the [article](https://ambrevar.xyz/modern-common-lisp/index.html) about Lisp, I saw that there are two mentions of the following code snippet:
```
(declaim (optimize (speed 0) (space 0) (debug ...Hi, I just discovered your blog via HN. In the [article](https://ambrevar.xyz/modern-common-lisp/index.html) about Lisp, I saw that there are two mentions of the following code snippet:
```
(declaim (optimize (speed 0) (space 0) (debug 3)))
```
It may be a better idea to fuse them together in one section.https://gitlab.com/ambrevar/ambrevar.gitlab.io/-/issues/15It's easy to fuzzy search windows with dmenu and wmctrl2020-02-20T18:08:26ZI'm not going to share my nameIt's easy to fuzzy search windows with dmenu and wmctrl `wmctrl -a $(wmctrl -l | cut -d " " -f 5- | dmenu -i -p "Switch Window?" -l 5)`
I know you already fixed that with EXWM, but I just wanted you to know. `wmctrl -a $(wmctrl -l | cut -d " " -f 5- | dmenu -i -p "Switch Window?" -l 5)`
I know you already fixed that with EXWM, but I just wanted you to know.https://gitlab.com/ambrevar/ambrevar.gitlab.io/-/issues/7Emacs everywhere2018-11-27T23:16:09ZJean LouisEmacs everywhereOnce I found on News Ycombinator the[ Emacs Everywhere](https://github.com/zachcurry/emacs-anywhere " Emacs Everywhere") I understood I can use Emacs for editing web forms. Very handy, but I don't find the setup there good for me.
So wh...Once I found on News Ycombinator the[ Emacs Everywhere](https://github.com/zachcurry/emacs-anywhere " Emacs Everywhere") I understood I can use Emacs for editing web forms. Very handy, but I don't find the setup there good for me.
So what I made is my version of using GNU Emacs on web forms.
First I have placed settings for my [StumpWM](https://stumpwm.github.io/ "StumpWM") like following:
```
(define-key *root-map* (kbd "y") "exec emacs-everywhere.lisp")
```
Which would mean that on C-t y I am running that
small script "emacs-everywhere.lisp":
```
;; (load "/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/date-time.lisp")
;; I think that function timestamp-filename is working below
(defparameter *emacs* "emacs-client-x") ;; customize it yourself
(defparameter *tmp-dir* "/home/data1/protected/tmp/emacs-everywhere/")
(ensure-directories-exist *tmp-dir*)
(defun timestamp-filename ()
(multiple-value-bind
(second minute hour date month year day-of-week dst-p tz)
(get-decoded-time)
(declare (ignore dst-p day-of-week tz))
(format nil "~d-~2,'0d-~2,'0d-~2,'0d:~2,'0d:~2,'0d"
year
month
date
hour
minute
second
)))
(defun tmp-filename ()
(concatenate 'string *tmp-dir* (timestamp-filename) ".txt"))
(defun emacs-tmp-filename (tmp-filename)
(let ((command (format nil "~A ~A" *emacs* (tmp-filename))))
command))
(let ((tmp-filename (tmp-filename)))
(shell (emacs-tmp-filename tmp-filename))
(if (probe-file tmp-filename)
(progn
(shell (format nil "xclip -selection clipboard -in '~A'" tmp-filename))
(shell "xclip -out"))))
```
So what happens is that I get a file, something
like 2018-09-14-09:07:01.txt in the temporary
directory:
/home/data1/protected/tmp/emacs-everywhere/ and I
am editing the file, save and close it, and the
text of the file goes into my X selection.
Then I am simply pasting it into the form.
And the data remains for later reviews.
Now, previously we talked about using
encryption. So this could be good way to use
simply GNU Emacs to enter passwords into web
forms, remember them or store them, or search for
them by simple greping and adding them to simple
file.