Skip to content

Instantly share code, notes, and snippets.

@Konfekt
Konfekt / xdg-open
Last active May 5, 2024 11:23
drop-in replacement for xdg-open forwarding to more robust file open handlers of common desktop environments
#!/usr/bin/env bash
# exit on error or on use of undeclared variable or pipe error:
set -o errexit -o errtrace -o nounset -o pipefail
# optionally debug output by supplying TRACE=1
[[ "${TRACE:-0}" == "1" ]] && set -o xtrace
shopt -s inherit_errexit
PS4='+\t '
IFS=$'\n\t '
@Konfekt
Konfekt / persian-banan.vim
Created January 6, 2023 09:28
persian transliterate (finglish) keymap
scriptencoding utf-8
" Adapted from http://www.persoarabic.org/content/generated/doc.free/mohsen/PLPC/120036/current/accessPage/index.html#farsi-transliterate-bananPersianInputMethod
" Use this short name in the status line.
let b:keymap_name = "per"
loadkeymap
1 ١ " Arabic_1
@Konfekt
Konfekt / arabic-qwerty.vim
Last active December 6, 2022 08:15
arabic phonetic keymap
scriptencoding utf-8
" Arabic phonetic keyboard from http://arabic.omaralzabir.com/
" at https://github.com/suryaya/Arabic-Phonetic-Keyboard-Linux
" See also https://r.nf/r/learn_arabic/comments/etj8x4/i_made_an_arabic_phonetic_keyboard_for_linux/
" Use this short name in the status line.
let b:keymap_name = "ara"
loadkeymap
@Konfekt
Konfekt / persian-qwerty.vim
Last active January 5, 2023 13:15
persian phonetic keymap
scriptencoding utf-8
" Adapted from https://github.com/gpuminingir/Farsi-Phonetic-Keyboard-Linux/blob/main/ubuntu_ir_keyboardlaout_qwerty
" to fit https://www.jahanshiri.ir/keyboard/phonetic/en/ .
" See also https://www.facebook.com/PersianPhoneticKeyboardLayout/
" Use this short name in the status line.
let b:keymap_name = "per"
loadkeymap
@Konfekt
Konfekt / wacom2monitor.sh
Last active April 20, 2024 05:11
A shell script to map all Wacom devices to a given monitor, in particular to switch through all available monitors by repeatedly calling it with the parameter NEXT
#!/usr/bin/env bash
# exit on error or on use of undeclared variable or pipe error:
set -o errexit -o errtrace -o nounset -o pipefail
# optionally debug output by supplying TRACE=1
[[ "${TRACE:-0}" == "1" ]] && set -o xtrace
shopt -s inherit_errexit
PS4='+\t '
IFS=$'\n\t'
@Konfekt
Konfekt / tika.bat
Created November 14, 2021 05:11
run tika (= document text viewer) in cmd using UTF-8 encoding
@echo off
setlocal
rem From https://tika.apache.org/download.html
set tika_jar="%USERPROFILE%\bin\tika.jar"
rem From https://superuser.com/questions/1118106/can-the-utf-8-code-page-identifier-65001-be-different-on-other-computers/1121076#1121076
rem capture output of chcp after colon
for /F "tokens=2 delims=:" %%G in ('chcp') do set "_chcp=%%G"
rem strip trailing dots
@Konfekt
Konfekt / langtool.bat
Created November 14, 2021 04:57
run language-tool in cmd using UTF-8 encoding
@echo off
setlocal
rem From https://languagetool.org/download/LanguageTool-stable.zip
set langtool_jar=%USERPROFILE%\bin\languagetool-commandline.jar
rem From https://superuser.com/questions/1118106/can-the-utf-8-code-page-identifier-65001-be-different-on-other-computers/1121076#1121076
rem capture output of chcp after colon
for /F "tokens=2 delims=:" %%G in ('chcp') do set "_chcp=%%G"
rem strip trailing dots
@Konfekt
Konfekt / e.bat
Last active November 19, 2021 09:24
open %EDITOR% (or vim or notepad) using UTF-8 codepage in Microsoft Windows cmd shell
@echo off
SETLOCAL ENABLEEXTENSIONS
rem From https://superuser.com/questions/1118106/can-the-utf-8-code-page-identifier-65001-be-different-on-other-computers/1121076#1121076
rem capture output of chcp after colon
for /F "tokens=2 delims=:" %%G in ('chcp') do set "_chcp=%%G"
rem strip trailing dots
IF "%_chcp:~-1%"=="." set "_chcp=%_chcp:~0,-1%"
IF DEFINED EDITOR (
@Konfekt
Konfekt / diff.md
Last active October 18, 2021 08:21 — forked from PeterRincker/diff.md
:DiffOrig but smarter

:DiffOrig but smarter

This is an enhanced version of the snippet provided under :help diff-original-file.

Where the original :DiffOrig only shows differences between the buffer in memory and the file on disk, :Diff can be used in two ways:

  • against the file on disk, like the original, with:

    :Diff
    
@Konfekt
Konfekt / git-xlsx-textconv.pl
Last active September 15, 2021 06:25
self-contained version of git-xlsx-textconv.pl for use in Git under Windows
This file has been truncated, but you can view the full file.
#!/usr/bin/env perl
# Self-contained version of git-xlsx-textconv.pl from
# https://github.com/yappo/p5-git-xlsx-textconv.pl
# for use in Git under Windows.
# created by [fatpacker](https://www.perladvent.org/2012/2012-12-14.html).
# In contrast xls2csv from https://github.com/xevo/xls2csv cannot be made
# self-contained by fatpacker because of binary dependencies (such as Iconv).
# This chunk of stuff was generated by App::FatPacker. To find the original