Skip to content

Instantly share code, notes, and snippets.

@Vftdan
Vftdan / gemini_protocol.vim
Last active February 9, 2021 22:50
Vim gemini:// protocol plugin
function! s:read_gemini(url)
call s:init_go_url()
function! s:init_go_url()
endfunction
let l:svpos = winsaveview()
setlocal bl ro noswapfile
if &ft == ''
setlocal ft=gmi
else
let &ft=&ft
@Vftdan
Vftdan / lambda.vim
Last active February 9, 2021 22:09
Lambda expression vim syntax
" Vim syntax file
if !exists("main_syntax")
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
let main_syntax = 'lambda'
endif
@Vftdan
Vftdan / aliases.vim
Created October 17, 2020 08:23
Aliases for vim command mode. (Function is not mine.)
" Command mode aliases
function! SetupCommandAlias(from, to)
exec 'cnoreabbrev <expr> ' . a:from
\ . ' ((getcmdtype() is# ":" && getcmdline() is# "' . a:from . '")'
\ . '? ("' . a:to . '") : ("' . a:from . '"))'
endfunction
command! -nargs=* Calias call SetupCommandAlias([<f-args>][0], join([<f-args>][1:]))
Calias calias Calias
Calias nvim visual
Calias W! w!
@Vftdan
Vftdan / wrap-lines.sh
Created July 17, 2020 14:52
Break each line that is longer than 80 characters with sed. One line can be broken more than once.
sed 's/.\{80\}/\0\n/g'
@Vftdan
Vftdan / bindump.sh
Created April 8, 2020 07:16
Like hexdump, but with base 2. Bit & byte order is little-endian.
#! /bin/sh
for i in $( (echo 'ibase=16;obase=2;'; hexdump -v -e '/1 "%02X\n"' $@) | bc); do \
printf '%08i\n' $i | rev
done
@Vftdan
Vftdan / bspwm-unminimize-event.sh
Last active March 1, 2020 18:19
Minimize windows while using bspwm
#! /bin/sh
xev -root | grep '(_NET_ACTIVE_WINDOW)' -B 1 --line-buffered | \
grep '^ClientMessage' --line-buffered | sed -u -e 's/^.*window //; s/,//' | \
while read w; do \
if [ -n "$(bspc query -N -n $w.hidden)" ]; then \
bspc node "$w" -g hidden=off
bspc node $w.fullscreen -t tiled
bspc node $w -l normal
bspc node -a $w
fi
@Vftdan
Vftdan / pal2gpl.py
Created August 9, 2019 19:47
Convert pal to gpl palette
#! /usr/bin/env python3
input() #header
input() #version
cnt = int(input()) #number of colors
print("GIMP Palette")
print("Columns: {0}".format(cnt))
print("#")
for i in range(cnt):
print("{0} {1} {2}\tUntitled".format(*(input().split())) + str(i + 1))
@Vftdan
Vftdan / toggleMicOneLiner.sh
Last active January 7, 2019 13:33 — forked from nikhilw/toggleMicOneLiner.sh
Toggle mic on-off on a Ubuntu / Linux Mint machine with a keyboard shortcut
#! /bin/sh
# static icon, easier to set as a bash alias or directly use as a single command instead of creating a script file.
amixer -D pulse set Capture toggle | gawk 'match($0, /(Front Left|Mono).*\[(.*)\]/, a) {print a[2]}' | xargs notify-send --hint=int:transient:1 -i "audio-input-microphone" "Mic switched: $1"
M107
M104 S200
G28
G1 Z5 F250.0
M109 S200
G21
@Vftdan
Vftdan / toggleSide
Created November 23, 2018 19:03
"javascript:" bookmarks for vk.com
javascript:void%28%28document.getElementById%28%22side_bar%22%29.style.display%3Ddocument.getElementById%28%22side_bar%22%29.style.display%3D%3D%22none%22%3F%22block%22%3A%22none%22%29%5E%28document.getElementById%28%22page_body%22%29.style.float%3Ddocument.getElementById%28%22side_bar%22%29.style.display%3D%3D%22none%22%3F%22none%22%3A%22right%22%29%29