Skip to content

Instantly share code, notes, and snippets.

View wsdookadr's full-sized avatar
🎯
Focusing

Stefan Corneliu Petrea wsdookadr

🎯
Focusing
  • Nobody at Nowhere
  • Nowhere
View GitHub Profile
@wsdookadr
wsdookadr / Dockerfile
Created September 10, 2023 03:08
docker setup template based on slackware image
FROM vbatts/slackware:15.0
LABEL maintainer "Stefan Corneliu Petrea <stefan.petrea@gmail.com>"
RUN slackpkg update
COPY bashrc /root/.bashrc
RUN source ~/.bashrc && slackpkg_unatt install ca-certificates perl rsync lz4 cyrus-sasl curl zstd xxHash nghttp2 brotli gcc make binutils patch
RUN update-ca-certificates -f
RUN wget -O sbopkg.tgz https://github.com/sbopkg/sbopkg/releases/download/0.38.2/sbopkg-0.38.2-noarch-1_wsr.tgz
RUN upgradepkg --install-new sbopkg.tgz
RUN mkdir -p /var/lib/sbopkg/queues /var/lib/sbopkg/SBo/15.0
@wsdookadr
wsdookadr / fzf-find.sh
Last active August 28, 2023 05:27
i3 + fzf + recoll setup
#!/bin/bash
IFS=$'\n'
export FZF_DEFAULT_COMMAND='cd ~/books ; fd . -a -i -e "pdf" -e "djvu" -e "epub" --type f'
# files=($(fzf-tmux --query="$1" --multi --select-1 --exit-0))
FILE=$(fzf --print-query --bind 'tab:replace-query' | head -1)
nohup okular "$FILE" & sleep 1
@wsdookadr
wsdookadr / build.sh
Last active March 9, 2023 21:54
Fetch & build github repos for studying purposes (built to run on WSL on Windows)
#!/bin/bash
#
# Builds all the repos. Yes it assumes they're .NET projects.
# This can be adapted to other toolchains and makefiles (automake / cmake / npm / ninja / etc)
# of your choice.
#
for d in $(find -maxdepth 1 -mindepth 1 -type d); do
cd $d
echo "== $d =="
#find -name "build*cmd" | xargs -I{} powershell.exe -c './{}' ;
@wsdookadr
wsdookadr / drawio-decompress.sh
Last active January 15, 2023 11:59
decompress drawio diagrams
#!/bin/bash
#
# Example: ./drawio-decompress.sh https://raw.githubusercontent.com/TalalAlrawajfeh/mathematics-roadmap/master/mathematics-roadmap.drawio
#
# https://app.diagrams.net/
# https://drawio-app.com/extracting-the-xml-from-mxfiles/
#
curl "$1" | \
perl -pne 's{.*<diagram[^<>]+">}{}g; s{<\/d.*}{}g;' | \
base64 -d | \
@wsdookadr
wsdookadr / rasterize-multipage-pdf.sh
Created January 12, 2023 08:32
Rasterizing multipage PDFs
#!/bin/bash
#
# Rasterizing a multi-page PDF
# Summary: split to pages, convert each page to png, convert each png to pdf, re-assemble
# Use-case: https://en.wikipedia.org/wiki/Content_Disarm_%26_Reconstruction
#
# Requirements:
# 1. sudo apt-get install pdftk imagemagick
# 2. Edit /etc/ImageMagick-6/policy.xml and make sure you have the following two lines at the end
# <policy domain="coder" rights="read|write" pattern="PDF" />
@wsdookadr
wsdookadr / Makefile
Last active March 12, 2021 23:46
Looping over rows in an SQLite database using Bash
gen_data:
echo "1 2 3" > data.tsv
echo "4 5 6" >> data.tsv
echo "7 8 9" >> data.tsv
build_db:
sqlite3 data.db < schema.sql
query:
./query.sh

init

CREATE TABLE IF NOT EXISTS `OCCUPATIONS` (
  `Name` varchar(200) NOT NULL,
  `Occupation` varchar(200) NOT NULL
);
INSERT INTO `OCCUPATIONS` (Name, Occupation) VALUES
  ('Samantha','Doctor'),
  ('Julia','Actor'),
@wsdookadr
wsdookadr / .vimrc
Created October 28, 2018 11:49
.vimrc
" general settings
set nocompatible
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set nobackup " don't keep a backup file
set noswapfile " no swap file either
set history=800 " keep lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching