From 197aa1809874315d26a4e67b2d0ed6bc9025b839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Wed, 27 Sep 2023 14:51:28 +0200 Subject: [PATCH] TILs --- content/code/2023-09-27-2.md | 121 +++++++++++++++++++++++++++++++++++ content/code/2023-09-27.md | 14 ++++ content/pages/projets.md | 2 +- 3 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 content/code/2023-09-27-2.md create mode 100644 content/code/2023-09-27.md diff --git a/content/code/2023-09-27-2.md b/content/code/2023-09-27-2.md new file mode 100644 index 0000000..fc9db42 --- /dev/null +++ b/content/code/2023-09-27-2.md @@ -0,0 +1,121 @@ +--- +title: Setting up a IRC Bouncer with ZNC +tag: ZNC, Weechat, IRC +--- + +It's been a while since I've used IRC, but I needed to connect to it today to discuss around [Peewee](https://docs.peewee-orm.com). + +The main issue with IRC is that you need to be connected to see the answer, and to get the context of the conversation. Unless... you set up a bouncer. + +The bouncer is named [ZNC](https://znc.in), and the IRC client I use is [Weechat](https://weechat.org). + +So, that's what I did: + +## Installation of ZNC + +```bash +apt install znc +sudo -u _znc /usr/bin/znc --datadir=/var/lib/znc --makeconf +sudo systemctl enable znc +``` + +You can answer the questions asked by `--makeconf`, it will generate you a configuration file like this (stored in `/var/lib/znc/configurations/znc.conf`): + +```conf +AnonIPLimit = 10 +AuthOnlyViaModule = false +ConfigWriteDelay = 0 +ConnectDelay = 5 +HideVersion = false +LoadModule = webadmin +MaxBufferSize = 500 +ProtectWebSessions = true +SSLCertFile = /var/lib/znc/znc.pem +SSLDHParamFile = /var/lib/znc/znc.pem +SSLKeyFile = /var/lib/znc/znc.pem +ServerThrottle = 30 +Version = 1.8.2 + + + AllowIRC = true + AllowWeb = true + IPv4 = true + IPv6 = true + Port = 6697 + SSL = true + URIPrefix = / + + + + Admin = true + Allow = * + AltNick = alexis_ + AppendTimestamp = false + AuthOnlyViaModule = false + AutoClearChanBuffer = true + AutoClearQueryBuffer = true + BindHost = skate.notmyidea.org + ChanBufferSize = 50 + DenyLoadMod = false + DenySetBindHost = false + Ident = alexis + JoinTries = 10 + LoadModule = chansaver + LoadModule = controlpanel + MaxJoins = 0 + MaxNetworks = 1 + MaxQueryBuffers = 50 + MultiClients = true + Nick = alexis + NoTrafficTimeout = 180 + PrependTimestamp = true + QueryBufferSize = 50 + QuitMsg = See you :) + RealName = N/A + StatusPrefix = * + TimestampFormat = [%H:%M:%S] + + + FloodBurst = 9 + FloodRate = 2.00 + IRCConnectEnabled = true + JoinDelay = 0 + LoadModule = simple_away + RealName = N/A + Server = irc.libera.chat +6697 + TrustAllCerts = false + TrustPKI = true + + + + + + + Hash = REDACTED + Method = SHA256 + Salt = REDACTED + + +``` + +You can access a web interface on the exposed port. I had to make a change in my Firefox configuration, in `about:config`, set `network.security.ports.banned.override` to `6697`, otherwise, Firefox prevents you from connecting to these ports (which might actually be a good idea). + +## Weechat configuration + +Now, to use this in weechat, here are some useful commands. First, get the fingerprint of the SSL certificate generated on your server: + +```bash +cat /var/log/znc/znc.pem | openssl x509 -sha512 -fingerprint -noout | tr -d ':' | tr 'A-Z' 'a-z' | cut -d = -f 2 +```` + +Then, in weechat : + +```weechat +/server add znc host/6697 -tls -username= -password= -autoconnect +/set irc.server.znc.tls_fingerprint +/connect znc +``` + +And you should be all set! + +Resources : [The ZNC Wiki on Weechat](https://wiki.znc.in/Weechat) and the [Debian page on ZNC](https://wiki.debian.org/ZNC) diff --git a/content/code/2023-09-27.md b/content/code/2023-09-27.md new file mode 100644 index 0000000..23cf9de --- /dev/null +++ b/content/code/2023-09-27.md @@ -0,0 +1,14 @@ +--- +title: llm command-line tips +tags: python, llm, bash, sqlite +--- + +I'm using [llm](https://llm.datasette.io) more and more, and today I had to find back prompts I used in the past. Here is a command I've been using, which allows me to filter the results based on what I want. It leverages [sql-utils](https://sqlutils.datasette.io), a cli tool which is able to talk to a SQLITE database and answer in json, and [jq](https://github.com/jqlang/jq) a command-line tool capable of doing requests for json. + +All in all, it's pretty satisfying to use. I finally got a simple way to query databases! I'm also using [glow](https://github.com/charmbracelet/glow), which is capable of transforming markdown into a better version on the terminal. + +```bash +sqlite-utils "$(llm logs path)" "SELECT * FROM responses WHERE prompt LIKE '%search%'" | jq '.[].response' -r | glow +```` + +Which got me a colored response :-) diff --git a/content/pages/projets.md b/content/pages/projets.md index 4d388ed..7dd0e1f 100644 --- a/content/pages/projets.md +++ b/content/pages/projets.md @@ -60,7 +60,7 @@ certaines sites comme addons.mozilla.com. valeurs de coopération, de partage et de gastronomie. J'en suis parti à l'été 2023 pour retourner vers le developpement. La Brasserie existe toujours. -[Le Grappe](https://reseaugrappe.org/) +[Le Grappe](https://www.reseaugrappe.org/) : Durant mes années étudiantes (2007-2012), j'ai participé à la création et à l'animation d'un réseau d'associations « porteuses de projets en environnement ». Un bon moyen de rencontrer d'autres personnes animées par des valeurs collectivistes,