mirror of
https://github.com/almet/notmyidea.git
synced 2025-04-28 19:42:37 +02:00
TILs
This commit is contained in:
parent
97c3d1ee40
commit
197aa18098
3 changed files with 136 additions and 1 deletions
121
content/code/2023-09-27-2.md
Normal file
121
content/code/2023-09-27-2.md
Normal file
|
@ -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
|
||||||
|
|
||||||
|
<Listener listener0>
|
||||||
|
AllowIRC = true
|
||||||
|
AllowWeb = true
|
||||||
|
IPv4 = true
|
||||||
|
IPv6 = true
|
||||||
|
Port = 6697
|
||||||
|
SSL = true
|
||||||
|
URIPrefix = /
|
||||||
|
</Listener>
|
||||||
|
|
||||||
|
<User alexis>
|
||||||
|
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]
|
||||||
|
|
||||||
|
<Network liberachat>
|
||||||
|
FloodBurst = 9
|
||||||
|
FloodRate = 2.00
|
||||||
|
IRCConnectEnabled = true
|
||||||
|
JoinDelay = 0
|
||||||
|
LoadModule = simple_away
|
||||||
|
RealName = N/A
|
||||||
|
Server = irc.libera.chat +6697
|
||||||
|
TrustAllCerts = false
|
||||||
|
TrustPKI = true
|
||||||
|
|
||||||
|
<Chan #peewee>
|
||||||
|
</Chan>
|
||||||
|
</Network>
|
||||||
|
|
||||||
|
<Pass password>
|
||||||
|
Hash = REDACTED
|
||||||
|
Method = SHA256
|
||||||
|
Salt = REDACTED
|
||||||
|
</Pass>
|
||||||
|
</User>
|
||||||
|
```
|
||||||
|
|
||||||
|
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=<username> -password=<yourpass> -autoconnect
|
||||||
|
/set irc.server.znc.tls_fingerprint <fingerprint-goes-here>
|
||||||
|
/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)
|
14
content/code/2023-09-27.md
Normal file
14
content/code/2023-09-27.md
Normal file
|
@ -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 :-)
|
|
@ -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é
|
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.
|
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
|
: 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
|
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,
|
moyen de rencontrer d'autres personnes animées par des valeurs collectivistes,
|
||||||
|
|
Loading…
Reference in a new issue