Sunday, April 24, 2016

git branch

create new branch and push it to upstream:
git checkout -b <branch>
git push -u origin <branch>
and set <branch> to be cloned by default (<branch> may be "master" or another required branch):
git remote set-head origin <branch>

pull branch from upstream (see all branches with "git branch -a"):
git checkout <branch>

----------------------

To be able to "git diff" to branches, you need to set up necessary branches to track corresponding remote branch from origin:
  1) add information about the branch to .git/config
      git checkout <branch_name>
  2) previous command also automatically switches to the branch, so if it is necessary to return to master branch, do this
      git checkout master

Friday, April 22, 2016

krop

cut off extra margins in pdf file with "krop" and then print it with "fit" option in atril

Wednesday, April 20, 2016

BOOT

You can use the kernel parameter
'boot_delay=1000' to slow down the boot messages.

EDID

create /etc/initramfs-tools/hooks/cpedid with the following content:
    #!/bin/sh
    cp /lib/firmware/edid.bin "${DESTDIR}/lib/firmware"
    exit 0
and make it executable
copy edid.bin to /lib/firmware/
run "sudo update-initramfs -u"
check with "lsinitramfs /boot/initrd.img*"

Monday, April 11, 2016

How to increase day by one in C

  int year, month, day;
  sscanf(namelist[2]->d_name, "%2d%2d%2d", &year, &month, &day);
struct tm tmp;
tmp.tm_mday = day;
tmp.tm_mon = month;
tmp.tm_year = year + 2000 - 1900;
time_t epoch = mktime(&tmp);
epoch += 24*60*60;
struct tm *tmp2 = localtime(&epoch);
tmp=*tmp2;
strftime(buffer, SIZE, "%y%m%d", &tmp);

  if (strcmp(buffer, namelist[3]->d_name) != 0) {

Monday, April 4, 2016

CWEB examples

Run './downloadable-programs.sh --get' to curl tons of CWEB example
programmes. For the 'sat' programmes, there's also an archive
'http://www-cs-faculty.stanford.edu/~uno/programs/SATexamples.tgz', but
that's simply _huge_ (around 60 MiB), so the script does _not_ pull this
every time (nor do I push this on Github). The same applies to 24 MiB
'http://www-cs-faculty.stanford.edu/~uno/programs/boolchains.tgz'.

How to debug GTK applications

use g_message + tail .xsession-errors to debug graphical applications

Saturday, April 2, 2016

Forward Sync

#!/usr/bin/python
import dbus, sys
bus = dbus.SessionBus()
daemon = bus.get_object("org.mate.atril.Daemon", "/org/mate/atril/Daemon")
reply = daemon.FindDocument('file://' + sys.argv[1], True, dbus_interface = "org.mate.atril.Daemon")
window_obj = bus.get_object(reply, "/org/mate/atril/Window/0")
window_obj.SyncView(sys.argv[2], (int(sys.argv[3]), int(sys.argv[4])), 0, dbus_interface="org.mate.atril.Window")
call as "synctex-atril /tex_tmp/file.pdf /home/user/file.tex 77 1"
#define APPLICATION_DBUS_OBJECT_PATH "/org/mate/atril/Atril"
#define APPLICATION_DBUS_INTERFACE   "org.mate.atril.Application"

#define ATRIL_DAEMON_SERVICE        "org.mate.atril.Daemon"
#define ATRIL_DAEMON_OBJECT_PATH    "/org/mate/atril/Daemon"
#define ATRIL_DAEMON_INTERFACE      "org.mate.atril.Daemon"

#define EV_WINDOW_DBUS_OBJECT_PATH "/org/mate/atril/Window/%d"
#define EV_WINDOW_DBUS_INTERFACE   "org.mate.atril.Window"

in order to be able to use a certain service, a client must indicate not only the object path providing the desired service, but also the bus name under which the service process is connected to the bus



bus name    = org.mate.atril.Daemon  # qdbus
object path = /org/mate/atril/Daemon # qdbus org.mate.atril.Daemon
qdbus org.mate.atril.Daemon /org/mate/atril/Daemon org.mate.atril.Daemon.FindDocument "file:///tex_tmp/setup_tarif.pdf" true # qdbus org.mate.atril.Daemon /org/mate/atril/Daemon
qdbus --literal `qdbus org.mate.atril.Daemon /org/mate/atril/Daemon org.mate.atril.Daemon.FindDocument "file:///tex_tmp/setup_tarif.pdf" true` /org/mate/atril/Atril org.mate.atril.Application.GetWindowList