Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View veirus's full-sized avatar

Alex veirus

View GitHub Profile
@veirus
veirus / packages-vivid.vim
Last active October 8, 2018 13:32
Installing Vim plugins using `axvr/Vivid.vim`. Pros: less boilerplate than `minpac`; Cons: you need to enable plugins *manually* - may brake some of them.
" quick add plugins for a plugin manager to load {{{1
function! AddPacFromCb() abort
if v:version >= 801 || (v:version == 800 && has("patch1630"))
let l:cb = trim(@+)
else
" do oldschool way to trim all spaces and whatnot
let l:cb = substitute(@+,'\v^\s*(.{-})\s*\n$','\1','')
endif
let l:cb = substitute(l:cb, '\v^https://github.com/','','')
put = 'Plugin ''' . l:cb . ''''
@veirus
veirus / md2org_URLS.vim
Last active July 30, 2018 14:04
Convert markdown style links to emacs orgmode format
" even easier with `.\{-}`:
%s/\[\(.\{-}\)](\(.\{-}\))/[[\2][\1]]/g
var names = document.body.getElementsByClassName('gameListRowItemName');
var namesString = '';
for (var i = 0; i < names.length; i++) namesString += (names[i].innerText + '\n');
@veirus
veirus / better_jk.vim
Last active June 27, 2018 15:44
Mappings for easier line navigation with <j> and <k> when `wrap` is on
" screen line scroll - very useful with wrap on
" https://bluz71.github.io/2017/05/15/vim-tips-tricks.html
nnoremap <expr> j v:count ? (v:count > 5 ? "m'" . v:count : '') . 'j' : 'gj'
nnoremap <expr> k v:count ? (v:count > 5 ? "m'" . v:count : '') . 'k' : 'gk'
@veirus
veirus / dror_pathlib.py
Created June 7, 2018 01:15
My *favourite* sorting script now with **Pathlib**
#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
# dror - pathlib edition
# Based on https://gist.github.com/dansku/9040240#file-dropboxorganize-py
__lastchanged__ = '2018-06-07 06:07'
__verstion__ = '0.6.2'
from datetime import date
from pathlib import Path
@veirus
veirus / autobrackets.vim
Created May 28, 2018 18:47
Simple function and mappings to close brackets automagically. In practice this shit is more irritating than helpful.
" Auto-insert closing parenthesis/brace {{{2
" TODO: make bracket insertion a little smarter
" right now it gets in the way more than it helps
inoremap ( ()<Left>
inoremap { {}<Left>
inoremap [ []<Left>
" Auto-delete closing parenthesis/brace
function! BetterBackSpace() abort
let cur_line = getline('.')
@veirus
veirus / packit.py
Last active May 20, 2018 08:42
Pack current project folder into zip excluding node_modules
#!/usr/bin/env python3
import os
import zipfile
def printProgressBar (iteration, total, prefix = '', suffix = '', decimals = 0,
length = 100, fill = '█', span = ' '):
"""
Call in a loop to create terminal progress bar
@params:
iteration - Required : current iteration (Int)
total - Required : total iterations (Int)
@veirus
veirus / dror5.py
Last active May 14, 2018 06:43
DROR updated for Python 3.6
#!/usr/bin/env python3.6
# dror - datetime format edition
# Based on https://gist.github.com/dansku/9040240#file-dropboxorganize-py
# 2018-05-14: convert to Pathlib; remove .encode('utf-8'); add alt output template
__verstion__ = '0.5.2'
import os.path
import glob
from datetime import date
from pathlib import Path
@veirus
veirus / switchvim.bat
Created May 14, 2018 06:36
Switch between two different .vim dirs on the fly - Windows version
@echo off
if exist "%USERPROFILE%\vimfiles" ( if not exist "%USERPROFILE%\vimfiles_" (move "%USERPROFILE%\vimfiles" "%USERPROFILE%\vimfiles_") else (echo "0 -> _ failed, _ exists"))
if exist "%USERPROFILE%\vimfiles1" ( if not exist "%USERPROFILE%\vimfiles" (move "%USERPROFILE%\vimfiles1" "%USERPROFILE%\vimfiles") else (echo "1 -> 0 failed, 0 exists"))
if exist "%USERPROFILE%\vimfiles_" ( if not exist "%USERPROFILE%\vimfiles1" (move "%USERPROFILE%\vimfiles_" "%USERPROFILE%\vimfiles1") else (echo "_ -> 1 failed, 1 exists"))
@veirus
veirus / foldmarker_map.vim
Created May 13, 2018 22:30
Simple mapping to quickly insert default fold marker
nnoremap <expr> <leader><Tab> getline('.') =~ "\"" ? "m1A {{{1<Esc>`1" : "m1A \" {{{1<Esc>`1"
nnoremap <expr> <leader>1<Tab> getline('.') =~ "\"" ? "m2A }}}1<Esc>`2" : "m1A \" }}}1<Esc>`2"
inoremap <expr> <localleader><Tab> getline('.') =~ "\"" ? "<Esc>m1A {{{1<C-o>`1" : "<Esc>m1A\" {{{1<C-o>`1"
inoremap <expr> <localleader>1<Tab> getline('.') =~ "\"" ? "<Esc>m2A }}}1<C-o>`2" : "<Esc>m2A\" }}}1<C-o>`2"