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 run the following script… for i in *; do sed -i 's/foo/bar/g' $i; done …in a folder, which contains a file with the content: ...

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 also learned something new :). Suppose the function looks something like this: foo = function(arg1, arg2) { console.log('original function'); } now you want to wrap that function, you do this: ...

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 ending. This means that, for example the path ‘path/without/filending’ doesn’t get matched by the regex, but ‘path/with/file.ending’ does. Update: … ...

Apps you should have for rooted Android devices

After rooting my android device, I realized, that there are a variety of apps which are very powerful if you have a rooted device. In this post, I want to introduce you to my favorite apps which are only for rooted devices or are more useful on rooted devices. Voltage Control This simple app allows you to change the CPU govenours, IO shedulers and the CPU frequency. It does not have profiles and all this “if screen turned of then…” stuff which is, in my opinion, positive in any way. ...

Reverse Tether mit Cyanogenmod 7.2.0 und Kubuntu 12.04 LTS

Folgendes Tutorial beschreibt, wie man mit dem Smartphone per USB über den PC ins Internet zu verbindet: Zuerst richtet man bei Kubuntu neben der Verbindung für das Internet eine neue Verbindung ein, die als Methode “Gemeinsam” verwendet. Nun aktiviert man auf dem Smartphone USB-Tethering und verbindet, unter Kubuntu, über die eben erstellten Verbindung, mit dem Smartphone (sollte im Netzwerkmanager zu sehen sein). Jetzt tippt man im Terminal in Kubuntu “ifconfig” ein und schaut welche IP die … ...