C++ – Print Out Objects From Set

In C++11, why use a for loop when you can use a foreach loop? In C++98/03, why use a for loop when you can use an algorithm instead? Note that this works with any pair of iterators, not only those from std::set<t>. std::copy will use your user-defined operator<< to print out every item inside the set using this single statement.

Using %PROGRAMFILES(x86)% on Windows OS 32bit

According to this the environment variable %PROGRAMFILES(x86)% is only available on 64-bit systems. However, if you are on a 64-bit system and use %PROGRAMFILES%, the result you get depend on whether the process requesting the environment variable is 32-bit or 64-bit. So from a 64-bit process on a 64-bit system you would get C:\Program Files, from a 32-bit process on a … Read more

How can I tail a log file in Python?

So, this is coming quite late, but I ran into the same problem again, and there’s a much better solution now. Just use pygtail: Pygtail reads log file lines that have not been read. It will even handle log files that have been rotated. Based on logcheck’s logtail2 (http://logcheck.org)

How to parse XML in Bash?

This is really just an explaination of Yuzem’s answer, but I didn’t feel like this much editing should be done to someone else, and comments don’t allow formatting, so… Let’s call that “read_dom” instead of “rdom”, space it out a bit and use longer variables: Okay so it defines a function called read_dom. The first line makes … Read more

How to remove old Docker containers

Since Docker 1.13.x you can use Docker container prune: This will remove all stopped containers and should work on all platforms the same way. There is also a Docker system prune: which will clean up all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes, in one command. For older Docker versions, you can string Docker commands … Read more

Blender vs. Unity 

Blender and Unity are not the same things. Unity is a game engine, which means that its purpose is to create games, and you can program in it using C# or JavaScript. But you cannot make 3d models in it. While Blender is a program for modelling mainly. You can create applications or games in it but it … Read more

First differences filter

First, you should read up on Matlab’s documentation of the filter function. If you just want to take a first difference, what you’re looking to generate is the series: Which corresponds to the vector a = 1, and b = [1, -1], so your Matlab code would look like:

KeyPressed event in java

Depending on where you want to trap the “enter” key, you could use an ActionListener (on such components such as text components or buttons) or attach a key binding to you component This will rely on the component being focused.