Windows .bat file command line tool, wait for keypress when double-clicked

Windows .bat files can be a convenient and quick way to automate things, like, for example, a compilation command involving a lot of options. They can be executed from the command line or by double-clicking them from the explorer. In the latter case, one would want the script to wait for a keypress until they close the window. When started from the command line, the waiting from a keypress is rather annoying.

It is possible to make the script behave differently depending on the way it was executed:

IF /I %0 EQU "%~dpnx0" PAUSE

This executes the PAUSE command when the file was started by double-click.

Source: Detect if bat file is running via double click or from cmd window

Code Mocking

Did you just start on your job and had to take over an implementation from a previous colleague? Welcome to Code Mocking!

“Code Mocking is an engineering tradition, which happens whenever a software project is handed to a new engineer”

Of course, the old code is always written very badly compared to your standards 😉

From Dilbert by Scott Adams:
http://www.dilbert.com/2013-02-24/

How to test the thread limit on Linux

/* compile with: gcc -pthread -o thread-limit thread-limit.c */
/* originally from: http://www.volano.com/linuxnotes.html */

#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <stdlib.h>

#define MAX_THREADS 100000
int i;

void run(void) {
char c;
if (i < 10)
printf(“Address of c = %u KB\n”, (unsigned int) &c / 1024);
sleep(60 * 60);
}

int main(int argc, char *argv[]) {
int rc = 0;
pthread_t thread[MAX_THREADS];
printf(“Creating threads …\n”);
for (i = 0; i < MAX_THREADS && rc == 0; i++) {
rc = pthread_create(&(thread[i]), NULL, (void *) &run, NULL);
if (rc == 0) {
pthread_detach(thread[i]);
if ((i + 1) % 1000 == 0)
printf(“%i threads so far …\n”, i + 1);
}
else
printf(“Failed with return code %i creating thread %i.\n”,
rc, i + 1);
}
exit(0);
}

Additional information

If you are an administrator of a server, you can configure various limits in /etc/security/limits.conf

New simulation server: roadrunner

nes-servers

Computation speed for a parallizable numbercrunching problem: red:our new server, blue:two other servers, green:a fast laptop in comparison

The institute has a new number cruncher at your service!

roadrunner.nes.aau.at

It can run up to 24 parallel threads and is now our fastest server.

You can log in with your university LDAP account, the server is only available from NES network (or via VPN). It runs Ubuntu 12.04 LTS and provides the same software set up as feynman.

Codepad

codepad is an online collaboration tool for exchanging code which also integrates various compilers/interpreters. After entering code, codepad will run it and print the output.
New pads can be created without registration. For each pad you get a short URL for sharing the code.

Codepad provides syntax highlighting depending on the language. Supported languages are C, C++, D, Haskell, Lua, OCaml, PHP, Perl, Python, Ruby, Scheme, and Tcl. It can be also used to share plain text.

TeXlipse

Standard LateX editors are optimized for small screens. But we are in 2012 and have big screens and your next monitor or laptop screen will likely even have larger resolution. The eclipse-plugin Texlipse takes advantage of this and provides an IDE for editing LateX documents with a real-time preview.

TeXlipse: Eclipse IDE for LateX

So, unless you have netbook, get the plug-in at http://texlipse.sourceforge.net/.

Calling a batch file from another batch file

Unlike as it is in Linux, calling a batch file from another batch file causes the first process to be overload by the new one. So, as a C64 programmer would put it, it is rather a “GOTO” than a “GOSUB”. In order to avoid this problem, put a “call” command before calling the second batch file.

call sub.bat “Hallo”
call sub.bat “World”

Become a Programmer, Motherfucker

Interesting webpage promoting the ideal of a real programmer in contrast to a managing software development.

It features also a huge list of free books on Assembly Language, Bash, C / C++, C#, Clojure, ColdFusion, Delphi / Pascal, Erlang, F#, Forth, Haskell, HTML / CSS, Java, JavaScript, Latex, Lisp, Lua, Nemerle, Oberon, Objective-C, OCaml, Oracle PL/SQL, Parrot / Perl 6, Perl, PHP, PowerShell, Prolog, Python, R, Ruby, Scala, Scheme, Smalltalk, SQL, etc.

http://programming-motherfucker.com