Thursday, March 30, 2017

РКН головного мозга

Провайдер: ТТК (ТрансТелеКом)
     Цель: ... FAILED!
 Проверка: ... FAILED!


  -- begin --
$ telnet 443
telnet: Unable to connect to remote host: No route to host

$ sudo tcpdump -n -i eth1 icmp or host
... > ICMP host unreachable

$ nslookup
... name =
  -- end --

      Диагноз: РКН головного мозга

Friday, October 2, 2015

Auto-generated headers in qmake project files

qmake is quite handy for simple source code layout but supporting non-standard use-cases within qmake boundaries is not trivial.

One such example is adding auto-generated header to your project. There are three items qmake must be made aware of before you get the expected and consistent results:

  • arbitrary custom command for creating the header;
  • dependencies;
  • reverse dependencies from other files in the project.

The following snippet shows how to properly convert these items into the actual qmake syntax for "python > auto-gen.h" command which depends on a couple of extra files:

# This is a workaround to qmake bug (at least in 2.01a version) which
# results in invalid expansion of ${QMAKE_FILE_IN_PATH} variable within
# .commands definition in the presence of 'combine' .CONFIG option.
defineReplace(autoheadercmd) {
    LIST = $${1}
    return(python $$first(LIST) > $${2})

autohdr.CONFIG += combine
autohdr.input = AUTOHEADER
autohdr.output = auto-gen.h
autohdr.commands = ${QMAKE_FUNC_autoheadercmd}
autohdr.variable_out = HEADERS

This results in the following Makefile snippet:

compiler_autohdr_make_all: auto-gen.h
    -$(DEL_FILE) auto-gen.h
auto-gen.h: \ \
    python > auto-gen.h

or the following, in case of separate build directory:

compiler_autohdr_make_all: auto-gen.h
 -$(DEL_FILE) auto-gen.h
auto-gen.h: ../ \
  ../ \
 python ../ > auto-gen.h

Reverse dependencies are built automatically, and auto-gen.h will be properly listed where necessary in the Makefile, like this:

user.o: ../user.c ../user.h auto-gen.h
    $(CC) -c $(CFLAGS) $(INCPATH) -o user.o ../user.c

Correct reverse dependencies are especially important when using "make -j" for parallel compilation.


See qmake: генерация файлов с помощью QMAKE_EXTRA_COMPILERS by Sergey Skoblikov for extra details, and its parent page - for various other qmake-related topics. (Both are in Russian.)

Thursday, January 19, 2012

No Trust to X

Ctrl+Alt+<Keypad *>  - this is all you need nowadays to bypass screen lockers in X Server. Although, I believe, this flaw will be fixed pretty soon, the trust is lost for ever, and I'm going back to roots by switching to X-independent "vlock".

"sudo vlock -na" works even when called from X, and seems to be the most secure way to lock your machine, since virtual consoles are handled as well. 
 (Make sure you remember root password before executing the above command.)

Thursday, March 17, 2011

Shell Poetry

If in you want to
echo err >/dev/stderr
then you should
echo err >>/dev/stderr
unless you plan to catch
only the last message
when running 2>err.log

Forget all the above,
despite it works in many cases.
In fact, the only correct form is
echo err 1>&2

Sunday, July 22, 2007

Beyond Brightness and Contrast

[Digital Dog printer test image]When you occasionally open advanced display properties on your PC you might notice there is a tab for controlling gamma parameters. I was always curious why gamma controls might be required and more importantly how to use them properly. Despite this fact I never had enough courage to get my teeth into the topic until today...

Leaving aside a boring story of what finally pushed me beyond brightness and contrast monitor controls I just want to promote an excellent tutorial by Norman Koren on monitor calibration and gamma.

Linux users might want to start with Monitor calibration under X article at which originally led me to the Norman's site.