Sunday, October 23, 2016

wxwidgets example

% sudo apt-get install libwxgtk3.0-dev libwxbase3.0-dev wx3.0-headers (check if one of them depends on the others to reduce this list)

% g++ `wx-config --cxxflags --libs` hello.c

@i c++lib.w
@ @c
#include <wx/wx.h>

class MyApp: public wxApp
{
  virtual bool OnInit();
}@+@t\hskip -.1cm@>;

IMPLEMENT_APP(MyApp)@;

bool MyApp::OnInit()
{
  wxMessageBox( L"Это пример программы на библиотеке wxWidgets",
                L"О программе", wxOK | wxICON_INFORMATION );
  return true;
}

Wednesday, October 5, 2016

wide character resources

1) Text from Amendment 1 to C90 (see first paragraph on page 191):
     http://www.open-std.org/jtc1/sc22/wg14/www/docs/C99RationaleV5.10.pdf

2) Brief description of Amendment 1 to C90:
     http://www.lysator.liu.se/c/na1.html

3) ISO C Amendment 1 (MSE - Multibyte Support Extensions):
     http://www.unix.org/version2/whatsnew/login_mse.html

3) Page with a lot of links, which includes link 1) above:
     http://www.cse.psu.edu/~deh25/cmpsc311/Lectures/Standards/CStandard.html

4) Links to C standard:
     http://stackoverflow.com/questions/81656/where-do-i-find-the-current-c-or-c-standard-documents
     http://stackoverflow.com/questions/17014835/where-can-i-find-the-c89-c90-standards-in-pdf-format

-----------

Functions that convert between multibyte and wide characters (from C90):

mblen
mbtowc
wctomb
mbstowcs
wcstombs

Saturday, September 17, 2016

Fitball

Notes on GL-iNet 6416A

check if it will get IP from dhcp if it is plugged into wan and if it will get IP if it is plugged into lan, and understand the reason for it (BTW, dir320 does get ip both from wan and from lan)
sm. knizhechku po gl-inet - tam pro 2 usb porta skazano?
first configure network as necessary from web interface (connecting wan port to the main router for internet access) (check via "uci show ..."), because you may reset to factory defaults
only then install asterisk and the rest
set ip address on d-link to 192.168.8.2 and open 192.168.8.1 in browser
ask question why bootloader gives garbage on openwrt forum and on aliexpress
vypisat GL-AR150

Sunday, July 3, 2016

minicom config for openwrt

cat << EOF > /home/user/.minirc.openwrt
pu port      /dev/ttyUSB0
pu baudrate  115200
pu bits      8
pu parity    N
pu stopbits  1
pu minit
pu mreset
pu rtscts    No
pu logfname
EOF

Wednesday, June 22, 2016

how to connect via modem

sudo systemctl enable serial-getty@ttyS0.service
shutdown now -r
ps -ef|grep getty
if no serial, "sudo systemctl start dev-ttyS0.device" and reboot again
search which command must be entered not to reboot

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

Tuesday, March 22, 2016

VIDEOS

1. http://www.youtube.com/watch?v=JPpk-1btGZk
2. http://www.webofstories.com/ (knuth,Freeman Dyson, Benoit Mandelbrot, Carl Djerassi, Stan Lee,...)
3. http://archive.computerhistory.org/resources/access/text/2013/05/102658053-05-01-acc.pdf
4. http://scpd.stanford.edu/free-stuff/engineering-archives/donald-e-knuth-lectures (also check that the following video is in the list for one of the four channels that are there - https://www.youtube.com/watch?v=axUgEAgrSB8)
5. videos with knuth on numberphile
6. http://www.koszek.com/blog/2015/11/16/computer-history-from-giants-themselves/

Monday, March 21, 2016

CMap

\immediate\pdfobj stream file {t2a.cmap}
\font\aaa=larm1000
\pdffontattr\aaa{/ToUnicode \the\pdflastobj\space 0 R}
\font\bbb=labx1000
\pdffontattr\bbb{/ToUnicode \the\pdflastobj\space 0 R}
%\immediate\pdfobj stream file {t1.cmap}
%\font\ccc=ecrm1000
%\pdffontattr\ccc{/ToUnicode \the\pdflastobj\space 0 R}
%...

\aaa ....
при этом кодировки шрифтов должны соответствовать кодировкам CMap файлов.

Saturday, March 19, 2016

fstab

you need to run "systemctl daemon-reload" after changes to /etc/fstab
but it _should_ be possible to create a file monitoring service which uses D-Bus to do this automatically

Thursday, March 17, 2016

Chronology for cwebmac.tex

texhax fith: Mon Feb 1 09:35:34 CET 2016
first letter to Scherer: 31 January 2016 at 19:45
first letter to texhax: Wed Jan 27 23:52:52 CET 2016
first reply from ascherer: 1 February 2016 at 00:46
letter to Karl about second bug in cwebmac.tex: 25 January 2016 at 09:45
date of release of fix to first bug: 2016-01-20
first post of Scherer to tex-k: Mon Feb 1 11:51:41 CET 2016

Wednesday, February 3, 2016

How to use gettext

#include<libintl.h>
#include<locale.h>
#include<stdio.h>

#define _(String) gettext (String)

int main()
{
    setlocale(LC_MESSAGES, "ru_RU.UTF-8");
    setlocale(LC_CTYPE, "ru_RU.UTF-8");
    bindtextdomain("helloworld","dir");
    textdomain("helloworld");
    printf(_("Hello World\n"));
    return 0;
}

$ xgettext -d helloworld -o helloworld.po -k_ -s helloworld.c

Now edit .po file (set UTF-8 and translation):

-"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
 #: /tex_tmp/test.w:14
 msgid "Hello World\n"
-msgstr ""
+msgstr "привет\n"

$ msgfmt helloworld.po -o helloworld.mo

In the end you must get the following picture:

$ ls -l
total 24
-rwxr-xr-x 1 user user 7184 Feb  3 15:45 helloworld
-rw-r--r-- 1 user user  277 Feb  3 16:14 helloworld.c
-rw-r--r-- 1 user user  439 Feb  3 15:44 helloworld.mo
-rw-r--r-- 1 user user  668 Feb  3 15:43 helloworld.po
lrwxrwxrwx 1 user user    1 Feb  3 16:16 LC_MESSAGES -> .
lrwxrwxrwx 1 user user    1 Feb  3 16:17 ru -> .

now type `pwd' and put the result to "bindtextdomain" in program source.

now compile the program and run with `./helloworld'