Python: talk to bash via Popen

Use Popen to start bash. Then pipe stdout,stderr,stdin to be able to read and write to these handles. Write ‘ls’ to stdin followed by an enter. Calling flush is important, without it nothing happens.

#!/usr/bin/env python3
import subprocess
def main():
cmd = 'bash'
process = subprocess.Popen(cmd,
for line in iter(process.stdout.readline, b''):
print(line, end='')
if __name__ == '__main__':

Golang: why packages matter when testing

When creating a piece of software in Golang you are not obligated to separate your code into logical packages. You can go ahead and have everything in a single package called main and it will work fine. Until you start to write tests and the most simple unit test will take seconds to complete when running `go test`. Why is this? Because go test compiles that needs to be compiled in order to run the tests. So if you have defined only one package then EVERYTHING is going to be compiled. Even third party libraries…

So creating logical packages benefits your program’s structure and maintainability, but also speeds up your test times, or gives you back the time lost when testing with one package name. Depends on the angle you look at it…

Convert SVN repository to a GIT repository

Steps I followed to convert my SVN repository to a GIT repository.


svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt

then I editted the authors-transform.txt to have my name fully spelled out and my e-mail address filled in.


git svn clone [SVN repo URL] --no-metadata -A authors-transform.txt --stdlayout ~/temp --prefix=origin/

the important part for me was adding the –prefix=origin/. Without this, it all becomes a big mess because?the remote branches will have an empty prefix which makes things harder for you in the future.


To create a .gitignore file based on your svn:ignore properties use the following command:

cd ~/temp
git svn show-ignore -i origin/trunk > .gitignore
git add .gitignore
git commit -m 'Add .gitignore from svn:ignore properties'

Again the critical part for my situation was to add the -i origin/trunk (or –id). Without it it doesn’t know what SVN branch you want the properties off.

All of this was shamelessly copied from with some modifications to really make it work, because that post is a little outdated. Credits to John Albin.