Skip to content

Instantly share code, notes, and snippets.

View slode's full-sized avatar
💭
I may be slow to respond.

Stian Lode slode

💭
I may be slow to respond.
  • boost.ai
  • Stavanger, Norway
View GitHub Profile
" 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 June 24, 2019 13:29
Use vim to replace uuids in file with new uuids.
""" 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 09:47
zsh function for running a command in multiple git repositories
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
}
/*
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 June 11, 2020 03:39
A faster numpy pad algorithm where the padding mode is symmetric along the axes.
"""
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
body {
background: #fff;
}
hr.style-eight {
padding: 0;
border: none;
border-top: 3px solid #000;
text-align: center;
margin: 30px 0;
}
@slode
slode / pprint_cmd.py
Last active September 16, 2016 08:47
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:
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 '")."' \\) " : ''