Skip to content

Instantly share code, notes, and snippets.

@miles-d
miles-d / Blink_cyberpunk.js
Created December 30, 2020 10:18
Blink_cyberpunk
@miles-d
miles-d / autocommands.vim
Created December 13, 2020 10:45
All the autocommands in my vimrc.
augroup USER
autocmd!
autocmd BufReadPost fugitive://* set bufhidden=delete
autocmd FileType vimwiki setlocal textwidth=0
autocmd FileType vimwiki setlocal foldmethod=manual
autocmd FileType vimwiki,markdown setlocal keywordprg=dict
autocmd FileType coffee,javascript,python,vimwiki,css,ruby setlocal shiftwidth=2 tabstop=2
autocmd FileType python,php,javascript,java,ruby,c,typescript iabbrev <buffer> ret return
autocmd FileType php,java iabbrev <buffer> pv private
autocmd FileType php,java iabbrev <buffer> pub public
@miles-d
miles-d / counter3.py
Created November 8, 2020 20:40
Count occurences of all 3-character sequences of lowercase letters in a file.
import sys
import string
fname = sys.argv[1]
pairs = {}
char = None
next_char = None
next_next_char = None
@miles-d
miles-d / rare_sequences_of_3_characters.txt
Created November 8, 2020 20:12
List of sequences of lowercase letters that don't occur in English dictionary
aaa
aad
aaf
aah
aaj
aao
aap
aaq
aau
aav
@miles-d
miles-d / insert_external.vim
Last active July 30, 2020 11:07
Insert result of external command in vim while in insert mode
" Prompt for input, execute, and trim newlines from the result.
function! ExternalCommandResult()
return system(input('Command: '))[:-2]
endfunction
" Create a mapping in insert mode.
inoremap <C-R>! <C-R>=ExternalCommandResult()<cr>
" Try it out with e.g. `date`: (be in insert mode) CTRL-R ! date ENTER
" If you like it, copy it to your .vimrc.
@miles-d
miles-d / vimprovement_1_summary.txt
Last active July 28, 2020 11:14
Vimprovement Online 1 - summary
Vimprovement 1: Using external programs to process text inside vim
(Based on an event https://www.meetup.com/Berlin-vim-users/events/272044751 of Berlin vim users meetup)
Vim is well suited to interact with UNIX environment.
One of the examples of that is filtering lines with external commands without even having to leave vim.
UNIX has plenty programs to process text, and knowing them can make you more effective in working with text.
1. How to run external programs as filters inside vim
@font-face {
font-family: ProggySquare;
font-style: normal;
font-weight: normal;
src: url(data:font/ttf;charset-utf-8;base64,AAEAAAAMAIAAAwBAT1MvMohrdBAAAAFIAAAATmNtYXACEiN1AAADoAAAAVJjdnQgAAAAAAAABPwAAAACZ2x5ZnteBXoAAAcEAACT+GhlYWTXkWjKAAAAzAAAADZoaGVhB8ICQwAAAQQAAAAkaG10eH2AewAAAAGYAAACBmxvY2GiS8eIAAAFAAAAAgRtYXhwAaoAygAAASgAAAAgbmFtZd3Q5jIAAJr8AAABoXBvc3SmrIPvAACcoAAABdJwcmVwaQIBEgAABPQAAAAIAAEAAAABAADpYm24Xw889QADCAAAAAAAt2d3hAAAAAC9kqjOAAD/AAOABIAAAAADAAIAAAAAAAAAAQAABED+wAAAA4AAAAAAA4AAAQAAAAAAAAAAAAAAAAAAAAIAAQAAAQEAgAAgAAAAAAACAAgAQAAKAAAAdgAIAAAAAAAAA4ABkAAFAAACvAKKAAAAjwK8AooAAAHFADICAAAAAAAECQAAAAAAAAAAAAAAAAAAAAAAAAAAAABBbHRzAEAAACCsCAAAAAAABIABAAAAA4AAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAYABAAAAAIAAAACAAYABAAEAAIAAgACAAIABAACAAIAAgACAAIAAgACAAIAAgACAAIABgACAAAAAgACAAIAAAACAAIAAgACAAIAAgACAAIABAACAAIAAgAAAAIAAgACAAIAAgACAAAAAgAAAAAAAgAAAAIABAACAAQAAgAAAAQAAgACAAIAAgACAAIAAgACAAQAAgACAAQAAAACAAIAAgACAAIAAgAEAAIAAgAAAAIAAgACAAIABgACAAAA
@font-face {
font-family: Monogram;
font-style: normal;
font-weight: normal;
src: url(data:font/ttf;charset-utf-9;base64,AAEAAAAOAIAAAwBgRkZUTWdlp94AACgkAAAAHEdERUYAnQAkAAAn/AAAAChPUy8yhSVxUgAAAWgAAABWY21hcNRX7YMAAAKkAAABWmN2dCAAIgKIAAAEAAAAAARnYXNw//8AAQAAJ/QAAAAIZ2x5Zq/uhc8AAATkAAAgOGhlYWQOkNqhAAAA7AAAADZoaGVhBCwBBQAAASQAAAAkaG10eAfLA6IAAAHAAAAA5GxvY2G6A7H4AAAEBAAAAN5tYXhwALkAZQAAAUgAAAAgbmFtZW6O2q8AACUcAAABwnBvc3TXzlJDAAAm4AAAARMAAQAAAAEAADLOjtdfDzz1AB8EAAAAAADW7su9AAAAANbuy70AAP+AAYACqgAAAAgAAgAAAAAAAAABAAACqv+AAAABgAAAAAABgAABAAAAAAAAAAAAAAAAAAAABAABAAAAbgA0AAkAAAAAAAIAAAABAAEAAABAAC4AAAAAAAEBgAH0AAUACAKZAswAAACPApkCzAAAAesAMwEJAAACAAYJAAAAAAAAAAAAAwABAAIAAAAAAAAAADJ0dGYAQAAgMAADAP8AAAACqgCAAAAAAQAAAAAAAAF2ACIAAAAAAVUAAAGAAAAAgABAAAAAAAAAAAAAgACAAEAAQAAAAEAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQACAAEAAAAAAAIAAAAAAAAAAAACAAAAAQAA
@font-face {
font-family: "ProggyDotted";
font-style: normal;
font-weight: normal;
src: url(data:font/ttf;charset-utf-8;base64,AAEAAAAOAIAAAwBgR1BPU6/9vusAAADsAAAANkdTVUJEdkx1AAABJAAAACBPUy8yh2NOLwAAAUQAAABgY21hcPE6GYEAAAGkAAAKWmdhc3D//wADAAAMAAAAAAhnbHlmwRJYZwAADAgACGDQaGVhZBCuw5gACGzYAAAANmhoZWEFEQbwAAhtEAAAACRobXR4fpaWBwAIbTQAABg0a2VybgABAA8ACIVoAAAAEmxvY2Eb5QdcAAiFfAAAGDhtYXhwBiwBowAInbQAAAAgbmFtZa0akGsACJ3UAAAzjnBvc3RTGFDPAAjRZAAANKwAAQAAAAoAHgAsAAFERkxUAAgABAAAAAAAAAABAAAAAWtlcm4ACAAAAAEAAAABAAQACQAAAAAAAAABAAAACgAcAB4AAURGTFQACAAEAAAAAP//AAAAAAAAAAIC+AGQAAUAAAKKArwALwCMAooCvP9cAeAAMQECAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEJpcmQAQAAg/v8Dtv64AI8DtgFIID8A/9/9AAACDgO2AAAAIAACAAAAAwABAAAAAAAcAAMAAQAAASIAAwAKAAAE2gAAAQYAAAEAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVl
@font-face {
font-family: "ProggyVector";
font-style: normal;
font-weight: normal;
src: url(data:font/ttf;charset-utf-8;base64,AAEAAAAOAIAAAwBgR1BPU6/9vusAAADsAAAANkdTVUJEdkx1AAABJAAAACBPUy8yh2NOLwAAAUQAAABgY21hcPE6GYEAAAGkAAAKWmdhc3D//wADAAAMAAAAAAhnbHlmue5R6wAADAgACGBEaGVhZBCuxkQACGxMAAAANmhoZWEFEQbwAAhshAAAACRobXR4fpaWBwAIbKgAABg0a2VybgABAA8ACITcAAAAEmxvY2Eb4chYAAiE8AAAGDhtYXhwBiwBowAInSgAAAAgbmFtZeOhTZMACJ1IAAAzs3Bvc3RTGFDPAAjQ/AAANKwAAQAAAAoAHgAsAAFERkxUAAgABAAAAAAAAAABAAAAAWtlcm4ACAAAAAEAAAABAAQACQAAAAAAAAABAAAACgAcAB4AAURGTFQACAAEAAAAAP//AAAAAAAAAAIC+AGQAAUAAAKKArwALwCMAooCvP9cAeAAMQECAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEJpcmQAQAAg/v8Dtv64AI8DtgFIID8A/9/9AAACDgO2AAAAIAACAAAAAwABAAAAAAAcAAMAAQAAASIAAwAKAAAE2gAAAQYAAAEAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVl