Skip to content

Instantly share code, notes, and snippets.

@Konfekt
Konfekt / tika.bat
Created Nov 14, 2021
run tika (= document text viewer) in cmd using UTF-8 encoding
View tika.bat
@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 Nov 14, 2021
run language-tool in cmd using UTF-8 encoding
View langtool.bat
@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 Nov 19, 2021
open %EDITOR% (or vim or notepad) using UTF-8 codepage in Microsoft Windows cmd shell
View e.bat
@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 Oct 18, 2021 — forked from PeterRincker/diff.md
:DiffOrig but smarter
View diff.md

: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 Sep 15, 2021
self-contained version of git-xlsx-textconv.pl for use in Git under Windows
View git-xlsx-textconv.pl
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).
@Konfekt
Konfekt / view-attachments-mutt-windows-wsl.md
Last active Sep 24, 2021
View mail from Mutt in GUI Browser or E-Mail client under Windows (Subsystem for Linux) WSL
View view-attachments-mutt-windows-wsl.md

To be able to view an E-Mail from Mutt under Linux or Windows (using the WSL Subsystem for Linux)

  • in your default GUI E-Mail client by selecting the e-mail and hitting E(mail),
  • in your default GUI browser by selecting the attached HTML file and hitting B(rowser),

add to ~/.muttrc the lines

macro pager  E        "<pipe-message>iconv -c --to-code=UTF8 > ~/.cache/mutt/mail.eml<enter><shell-escape>~/bin/wsl-open.sh $HOME/.cache/mutt/mail.eml<enter>"
macro attach B "iconv -c --to-code=UTF8 &gt; ~/.cache/mutt/mail.html~/bin/wsl-open.sh $HOME/.cache/mutt/mail.html"
@Konfekt
Konfekt / vim_mouse_2.ahk
Last active Feb 7, 2022
toggle vim_mouse_2.ahk (from https://github.com/4strid/vim_mouse_2.ahk) by Ctrl+; (similar to keynav on Linux)
View vim_mouse_2.ahk
#InstallKeybdHook
; vim_mouse_2.ahk
; vim (and now also WASD!) bindings to control the mouse with the keyboard
;
; Astrid Fesz-Nguyen
; 2019-04-14
;
; Last updated 2019-06-24
@Konfekt
Konfekt / add-vim-help.sh
Last active Aug 31, 2021
add missing Vim help to Vim plug-in repos
View add-vim-help.sh
#!/usr/bin/env bash
# description: add missing Vim help to Vim plug-in repos
# usage: add-vim-help.sh repos/*
# where repos/* are folders containing cloned repos without Vim help files
# needs:
# - md2vim from https://github.com/FooSoft/md2vim
# - hub from https://github.com/github/hub/ to open a Github pull request
@Konfekt
Konfekt / git-diff.md
Last active Jun 5, 2022
git diff common binary files
View git-diff.md
@Konfekt
Konfekt / scope.sh
Last active Apr 23, 2022
scope.sh for text preview of office documents in ranger file manager (similar to mailcap file)
View scope.sh
#!/bin/bash
# CUSTOM {{{
shopt -s nocasematch
# }}}
set -o noclobber -o noglob -o nounset -o pipefail
IFS=$'\n'
# If the option `use_preview_script` is set to `true`,