Skip to content

Instantly share code, notes, and snippets.

Avatar

Sidney Liebrand SidOfc

View GitHub Profile
@SidOfc
SidOfc / woop-woop.js
Last active Mar 6, 2019
A small benchmark of for vs forEach
View woop-woop.js
// 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 Sep 27, 2018
Adds `:Rg` command to FZF.vim.
View vim-rg-outdated-command.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)
@SidOfc
SidOfc / bem.js
Last active Sep 21, 2018
BEM helper V2
View bem.js
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 / fullscreen-scratch-2.vim
Created Aug 26, 2018
Gist file containing code for medium post codi.vim fullscreen workflow
View fullscreen-scratch-2.vim
" 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 / fullscreen-scratch-1.vim
Last active Aug 26, 2018
Gist file containing code for medium post codi.vim fullscreen workflow
View fullscreen-scratch-1.vim
" 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
You can’t perform that action at this time.