Skip to content

Instantly share code, notes, and snippets.

View ychaouche's full-sized avatar

Yassine Chaouche ychaouche

View GitHub Profile
@ychaouche
ychaouche / _txt.column.select.awk
Created September 24, 2025 14:09
column selection with awk
BEGIN {
split(COLS,columns_array,",");
for (i in columns_array){
col=columns_array[i];
n=split(col,range,"-");
if (n>1) {
min=range[1];
max=range[2];
@ychaouche
ychaouche / awk cut
Created September 24, 2025 13:57
awk code doens't preserve formatting
14:55:46 ~ -1- $ ls | head | awk '{$2=$3=$4=""; print}'
total
-rw-r--r-- 20K Jun 4 2024 absences.ods
-rw-r--r-- 7.1K Jun 4 2024 absences.xlsx
-rw-r--r-- 11K Mar 14 2023 ahmed.pdf
-rw-r--r-- 66K Mar 14 2023 ahmed.png
-rw-r--r-- 7.0K Mar 14 2023 ahmed.txt
drwxr-xr-x 4.0K Nov 5 2024 APPS
drwxr-xr-x 4.0K Jul 17 19:46 AUDIO
-rw-r--r-- 19K Apr 9 2023 bash.ps
@ychaouche
ychaouche / smtp
Created September 17, 2025 09:57
[...] smtp[...] E5A5E1C00096: to=<...>, relay=127.0.0.1[127.0.0.1]:10024, [...] queued as D3D291C000A7)
[...] smtp[...] E5A5E1C00096: to=<...>, relay=127.0.0.1[127.0.0.1]:10024, [...] queued as D3D291C000A7)
[...] smtp[...] E5A5E1C00096: to=<...>, relay=127.0.0.1[127.0.0.1]:10024, [...] queued as D3D291C000A7)
[...] smtp[...] E5A5E1C00096: to=<...>, relay=127.0.0.1[127.0.0.1]:10024, [...] queued as D3D291C000A7)
[...] smtp[...] E5A5E1C00096: to=<...>, relay=127.0.0.1[127.0.0.1]:10024, [...] queued as D3D291C000A7)
[...] smtp[...] E5A5E1C00096: to=<...>, relay=127.0.0.1[127.0.0.1]:10024, [...] queued as D3D291C000A7)
@ychaouche
ychaouche / txt.replace
Created September 16, 2025 15:11
txt.replace
Usage:
txt.replace -f fieldnumber -c command
Example:
Change the formatting of numbers in the output of ls
16:09:24 ~/MUSIQUE/CONTENT/RAM -1- $ command ls -l
total 73576
-rw-r--r-- 1 ychaouche ychaouche 5443123 Mar 9 2025 10.mp3
-rw-r--r-- 1 ychaouche ychaouche 4434170 Mar 9 2025 11.mp3
#250824 13:50:36 server id 1 end_log_pos 52469755 CRC32 0x73d17664 Query thread_id=189646 exec_time=0 error_code=0
SET TIMESTAMP=1756039836/*!*/;
COMMIT
/*!*/;
# at 52469755
#250824 13:59:06 server id 1 end_log_pos 52469797 CRC32 0xfebe2cd6 GTID 0-1-287315
/*!100001 SET @@session.gtid_seq_no=287315*//*!*/;
BEGIN
/*!*/;
# at 52469797
@ychaouche
ychaouche / apt error
Created August 20, 2025 17:23
apt error
root@app-server[10.10.10.83] ~ # apt-get update
Hit:1 http://security.debian.org/debian-security bookworm-security InRelease
Hit:2 http://deb.debian.org/debian bookworm InRelease
Hit:3 http://deb.debian.org/debian bookworm-updates InRelease
Reading package lists... Done
W: Skipping acquire of configured file 'updates/source/Sources' as repository 'http://security.debian.org/debian-security bookworm-security InRelease' doesn't have the component 'updates' (component misspelt in sources.list?)
W: Skipping acquire of configured file 'updates/binary-amd64/Packages' as repository 'http://security.debian.org/debian-security bookworm-security InRelease' doesn't have the component 'updates' (component misspelt in sources.list?)
W: Skipping acquire of configured file 'updates/i18n/Translation-en_US.UTF-8' as repository 'http://security.debian.org/debian-security bookworm-security InRelease' doesn't have the component 'updates' (component misspelt in sources.list?)
W: Skipping acquire of configured file 'updates/i18n/T
@ychaouche
ychaouche / why remove mariadb?
Created August 19, 2025 09:26
why remove mariadb?
root@app-server[10.10.10.83] ~ # apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
default-mysql-server dh-python emacs24-nox g++-6 galera-3 libaio1 libbabeltrace-ctf1 libbind9-140 libblas-common libboost-filesystem1.62.0 libboost-iostreams1.62.0 libboost-system1.62.0 libconfig-inifiles-perl libdbd-mysql-perl
libdbi-perl libdbus-glib-1-2 libdns162 libevent-2.0-5 libgfortran3 libgmime-2.6-0 libisc160 libisccc140 libisccfg140 libjemalloc1 libjs-angularjs libjs-lodash liblwres141 libmagickcore-6.q16-3 libmagickwand-6.q16-3 libnotmuch4
libperl5.24 libpython3.5 libpython3.5-minimal libpython3.5-stdlib libreadline5 libsnappy1v5 libstdc++-6-dev libtalloc2 libterm-readkey-perl libunbound2 libwebpmux2 libxerces-c3.1 libxml-security-c17v5 mariadb-client-10.3
mariadb-client-core-10.3 mariadb-server-10.3 mariadb-server-core-10.3 php7.0-dev python-gpgme python-idna python-oauth python-pyasn1 python
@ychaouche
ychaouche / add-newline-after-punctuation.el
Last active July 24, 2025 15:02
add-newline-after-punctuation.el
(defun add-newline-after-punctuation9 (start end)
"Place a newline after each sequence of 4 or more words followed by a comma, semicolon, colon, or period in the region."
(interactive "r")
(save-excursion
(goto-char start)
(while (re-search-forward "\\(\\w+\s+\\)\\{3,\\}\\w+\s*[.,:;])" end t)
(replace-match "\\&\n"))))
@ychaouche
ychaouche / lsync tutorial
Last active July 21, 2025 09:10
Lsync tutorial
Using lsyncd to synchronize file changes across multiple hosts
Posted 07-18-22 at 06:00 PM by ychaouche
Updated 05-30-23 at 07:12 AM by ychaouche
Tags live synchronization, lsyncd, rsync
In my own machine,
I create a directory named SYNC.
I put all the files I need to synchronize with other machines in there,
and have their original locations be symlinks to their new location inside the SYNC directory.
12:07:35 ~/NOTES/TXT -1- $ type net.paste0x0
net.paste0x0 is a function
net.paste0x0 ()
{
local useragent="net.paste0x0 by https://github.com/ychaouche";
echo "net.paste0x0 $1";
if (($#)); then
filepath="$1";
filename="$(basename "$filepath")";
mkdir /tmp/net.paste0x0/ 2> /dev/null;