snippets

Loop over files - bash one line

It’s simple: for i in *; do echo $i; done If you want to replace a certain text in all files with something new, use this: for i in *; do sed -i 's/original/new/g' $i; done where original is the original text and new is the new text. If you...

How to wrap a javascript function

Recently I wanted to modify a project, to wrap a javascript function, so that I could extend the functionality of that function without breaking the project it was assigned to. After searching the web for a bit, I found this stackoverflow-post, which exactly fits my needs. Works perfectly and I...

Regex for relative file paths

Regular expressions can come in handy when you need to find strings. This Regual expression simply matches relative paths. It’s not perfect, but it gets the job done :) (([^\./\\:*?<>|"]*)(/[^\./\\:*?<>|"]*)*/([^\./\\:*?<>|"]*\.[^\./\\:*?<>|"]+)) I should mention, that this regex is meant for python and also the relative path has to have a file...