Skip to content

Instantly share code, notes, and snippets.

View veirus's full-sized avatar

Alex veirus

View GitHub Profile
var names = document.body.getElementsByClassName('gameListRowItemName');
var namesString = '';
for (var i = 0; i < names.length; i++) namesString += (names[i].innerText + '\n');
@veirus
veirus / InsertFoldmarker.vim
Last active October 8, 2018 14:38
Quick and "smart" (not really...) insertion of current foldmarker + mostly accurate (not really...) foldlevel
function! InsertFoldMarker(...) abort
let l:cur_line = getline('.')
let l:markers = split(&l:fmr, ',')
let l:marker = (a:0) && len(l:markers)>1 ? l:markers[1] : l:markers[0]
let l:level = foldlevel('.')
let l:level = l:level == 0 ? '1' : l:level
let l:cms = split(&l:cms, '%s')
" TODO: handle paired comment markers
let l:cms = (a:0) && len(l:cms)>1 ? l:cms[1] : l:cms[0]
let l:marker_cnt = count(l:cur_line, l:cms)
@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 / 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 / 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"
@veirus
veirus / findmedia8.py
Created March 12, 2018 09:39
Findmedia.py - generate a (play)list of specified filetypes
#!/usr/bin/env python3
'''Findmedia - generate a (play)list of specified filetypes'''
import os
__revision__ = '8'
vidia = ('3gp', 'AVI', 'VOB', 'WMV', 'wmv', 'avi', 'flv', 'mka', 'mkv',
'mov', 'mp4', 'mpeg', 'mpg', 'vob', 'ogm')
newformats = ('webm')
@veirus
veirus / com.bat
Created January 16, 2018 09:11
Moving pictures into corresponding dirs: batch file edition.
@echo off
if exist "*.jpg" (md ".\jpg\") && (move *.jpg ".\jpg\") && (move *.jpeg ".\jpg\") ELSE (echo no jpg)
if exist "*.tga" (md ".\tga\") && (move *.tga ".\tga\") ELSE (echo no tga)
if exist "*.bmp" (md ".\bmp\") && (move *.bmp ".\bmp\") ELSE (echo no bmp)
if exist "*.gif" (md ".\gif\") && (move *.gif ".\gif\") ELSE (echo no gif)
if exist "*.psd" (md ".\psd\") && (move *.psd ".\psd\") ELSE (echo no psd)
if exist "*.png" (md ".\png\") && (move *.png ".\png\") ELSE (echo no png)