Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Stian Lode slode

💭
I may be slow to respond.
  • boost.ai
  • Stavanger, Norway
View GitHub Profile
View uuid.vim
" Changes all uuids in a document
noremap <leader>cu :%s/[-[:xdigit:]]\{36}/\=substitute(system('uuidgen'), "\n", "", "")/<CR>
" Inserts a new uuid at cursor
noremap <leader>iu :let @u=substitute(system('uuidgen'), "\n", "", "")<CR>"up
@slode
slode / uuid.vim
Created Jun 24, 2019
Use vim to replace uuids in file with new uuids.
View uuid.vim
""" Will replace all 36 character uuids in a file.
noremap <leader>uu :%s/[-[:xdigit:]]\{36}/\=substitute(system('uuidgen'), "\n", "", "")/<CR>
@slode
slode / all_git.zsh
Last active May 15, 2019
zsh function for running a command in multiple git repositories
View all_git.zsh
autoload -U colors && colors
all-git() {
for i in */.git; do
gitdir=$(dirname $i);
echo $fg[green]">>> repos="$gitdir $reset_color
(cd $gitdir && git $@)
echo ""
done
}
View fast-binary-search.cpp
/*
MIT License
Copyright (c) 2017 Stian Lode,
stian.lode@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@slode
slode / numpy-fast-symmetric-pad.py
Last active Jun 11, 2020
A faster numpy pad algorithm where the padding mode is symmetric along the axes.
View numpy-fast-symmetric-pad.py
"""
MIT License
Copyright (c) 2017 Stian Lode,
stian.lode@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
View decorated_hr.css
body {
background: #fff;
}
hr.style-eight {
padding: 0;
border: none;
border-top: 3px solid #000;
text-align: center;
margin: 30px 0;
}
View pprint_cmd.py
def print_cmd(command, line_length=80, indent=" "):
import sys, textwrap
lines = textwrap.wrap(
command,
width=line_length,
subsequent_indent=" \\\n" + indent,
break_long_words=False,
break_on_hyphens=False)
for line in lines:
View fast_find.vim
let g:ffind_excl_files = ['*.swp', '*~', '*.pyc', '*.so', '*.gif', '*.png']
let g:ffind_incl_files = ['*.c', '*.hh', 'scons*', '*.py', '*.cpp', '*.h', '*.hpp', '*.php','*.js','*.css','*.html','*.scss']
let g:ffind_path = '.'
function! FFind(...)
" Timing the search
let l:start=reltime()
let l:expaths = exists('g:ffind_excl_path') ? " \\( -path " . join(g:ffind_excl_path, " -o -path ")." \\) -prune -o" : ''
let l:exfiles = exists('g:ffind_excl_files') ? " -not \\( -iname '".join(g:ffind_excl_files, "' -o -iname '")."' \\) " : ''