Skip to content

Instantly share code, notes, and snippets.

@SidOfc
SidOfc / fullscreen-scratch-1.vim
Last active August 26, 2018 20:34
Gist file containing code for medium post codi.vim fullscreen workflow
" since it is fullscreen, I'd like a 50/50 split
let g:codi#width = 50.0
fun! s:FullscreenScratch()
" store filetype and bufnr of current buffer
" for later reference
let current_buf_ft = &ft
let current_buf_num = bufnr('%')
" create a new empty tab and set it up
@SidOfc
SidOfc / fullscreen-scratch-2.vim
Created August 26, 2018 20:35
Gist file containing code for medium post codi.vim fullscreen workflow
" since it is fullscreen, I'd like a 50/50 split
let g:codi#width = 50.0
" instead of destroying buffers, hide them and
" index them by filetype into this dictionary
let s:codi_filetype_tabs = {}
fun! s:FullscreenScratch()
" store filetype and bufnr of current buffer
" for later reference
@SidOfc
SidOfc / bem.js
Last active September 21, 2018 23:52
BEM helper V2
const isObject = subject => subject !== null && typeof subject === 'object';
const b = block => {
return {
// store values in underscored variable names since
// normal names will be used for functions
__block: block,
__element: null,
__modifiers: [],
// clear element and modifier cache
@SidOfc
SidOfc / woop-woop.js
Last active March 6, 2019 20:24
A small benchmark of for vs forEach
// run in terminal with: node woop-woop.js [arraySize = 1000000] [runs = 1]
// e.g. `node woop-woop.js 1000 2` runs the benchmark twice with thousand users.
const runs = parseInt(process.argv[3] || 1);
const arraySize = parseInt(process.argv[2] || 1000000);
let usersToGiveCoins = Array(arraySize).fill({username: 'Koala', coins: 0});
// simple benchmark function to wrap time + timeEnd and
// allows running benchmark an arbitrary number of times.
function bench(label, fn, times = 1) {
for (let i = 0; i < times; i++) {
@SidOfc
SidOfc / vim-rg-outdated-command.vim
Created September 27, 2018 20:40
Adds `:Rg` command to FZF.vim.
" FZF.vim now supports this command out of the box
" so this code is no longer needed.
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --hidden --ignore-case --no-heading --color=always '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'up:60%')
\ : fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'right:50%:hidden', '?'),
\ <bang>0)