Wednesday, April 24, 2019

chapterwise references with LaTEX and biblatex

I needed chapterwise references for my thesis. The suggestions at
https://tex.stackexchange.com/questions/345163/references-at-the-end-of-each-chapter
did not work with the "Cambridge" template on Overleaf.

or use TU Delft template which has per chapter references.


used that, and found:

The chapterbib package and biblatex are incompatible

Then got this - 

That seemed to work - \begin refsection etc 

% Chapter 1
\begin{refsection}
\chapter{Introduction} % Main chapter title

---snip----

% and at the end, where we want the references

\renewcommand{\bibname}{References}
% 20190501 - HN
% added this renewcommand to change  the title Bibliography to References
\printbibliography
\end{refsection}

Tuesday, April 16, 2019

mailstore for achiving emails

Here is part of an email to a colleague regarding Google Apps email reaching storage limits:

Regarding email - currently, our domain does not allow expansion of the existing amount of space. So, the only way is to delete large attachments. In many cases, the attachments are required and cannot be deleted. This can be handled in many ways.

1. Forward them themewise to specially created gmail ids and then delete
2. archive them locally by storing on a local hard disk and then delete
3. automate the local archiving using some tool like
https://www.google.com/search?q=imap+archive+tool+open+source

I guess you would want to work on Windows? I have not tried any of these tools, but this free Windows tool comes near the top in search results -
https://www.mailstore.com/en/products/mailstore-home/

And later, when he tried out mailstore, found that it had a specific option to get authorized for GMail - using that option, downloading emails was quite painless, though a long process for many GB of emails.

Thursday, April 11, 2019

voting in India

Today is polling day for us. Both State and National elections being held simultaneously here. Though the printed slips with our electoral roll serial number and polling booth location were given to us from our workplace, it is also available for all as an app,
https://play.google.com/store/apps/details?id=com.eci.citizen&hl=en_IN

Lots of information is available online as well as on the app, for example, the eligibility criteria and how to register,
https://eci.gov.in/faqs/

My experience was relatively seamless. Waited for around 20 minutes in line - around 20 people in line in front of me, including elderly ladies who had to be prompted on how to use the machine etc. All done in a harmonious manner. Very civilized. A demo video is at
https://eci.gov.in/video-gallery/evm-awareness/know-your-evm-r61/

Friday, April 05, 2019

Raspberry Pi shutdown using IR remote

Initially followed this instructable -

Had to make changes because of new version of Raspbian and lirc.

1. Added sensor as per this,
changing pinout as required by googling
2. Installation by
sudo apt-get update
sudo apt-get install lirc



3. Configuring kernel module was different from
The only thing we need to do is to uncomment out
dtoverlay=lirc-rpi
in /boot/config.txt

4. Configuration was slightly different from
(a) create /etc/lirc/hardware.conf and put in it
LOAD_MODULES=true
DRIVER="devinput"
DEVICE="/dev/lirc0"
(b) Placing the remote's configuration file was inside the directory /etc/lirc/lircd.conf.d
(c) starting the service was by /etc/init.d/lircd start

5. irexec configuration was different from
We needed to edit /etc/lirc/irexec.lircrc instead, since we want to shutdown and reboot, editing it to:
begin
    prog   = irexec
    button = KEY_1
    config = sudo shutdown -r now
end
begin
    prog   = irexec
    button = KEY_0
    config = sudo shutdown -h now
end


6. irrecord was a little tricky -
(Here also, instead of service lircd stop, we need to do /etc/init.d/lircd stop)

irrecord first wants you to press random keys. Then, you have to give the name of a key, press and hold it, then enter the next key's name when prompted, and so on for all the keys, and then only press ENTER to stop the process. And some keys are not recognized - maybe those should have been pressed during the first phase of random pressing.

7.  sudo /etc/init.d/lircd status reports error with duplicate remotes. We need to rename /etc/lircd/lircd.conf.d/devinput.lircd.conf to devinput.lircd.conf.dist
sudo mv devinput.lircd.conf devinput.lircd.conf.dist

8. sudo /etc/init.d/lircd status reports errors like
lircd-0.9.4c[364]: Error: Cannot glob /sys/class/rc/rc0/input[0-9]*/event[0-9]*
Then we need to edit /etc/lirc/lirc_options.conf, changing
device = devinput
to
device = default

9. sudo /etc/init.d/lircd status reports errors like
Error: could not get file information for /dev/lirc0
After a lot of searching, found on this page that this could be because the driver lirc-rpi has been replaced with a newer version called gpio-ir, so that the /boot/config.txt line has to be changed from
dtoverlay=lirc-rpi
to
dtoverlay=gpio-ir
Did that, and it worked.
This is on Raspberry Pi 2 running Raspbian 9 (Stretch) with kernel 4.19.23+, running lirc version 0.9.4c-9 while the other Pi, which worked with dtoverlay=lirc-rpi was running Raspbian 9 (Stretch) with kernel 4.14.98-v7+ and the same lirc version  0.9.4c-9.

testing AppImages on various distros - dd iso to USB

As mentioned in my previous post, I had created an AppImage for distribution a Linux binary. Testing on 3 distros one generation earlier is recommended using chroot. For example,
https://www.pcsuggest.com/setup-a-32-bit-chroot-with-ubuntu-live-cd/

But I found the procedure for creating chroots to be more cumbersome than just dumping the Live distro iso into a USB pen drive, booting another machine from USB, and checking the AppImage on the distro.

1. Since I was on an Ubuntu-based Mint Linux 18.1, it had a "Startup Disk Creator" GUI app for dumping Ubuntu-like Live CD/DVD to USB devices.

2. For Fedora and OpenSuse, I used the following commandline, taking care to note the correct device id like /dev/sdc1 or /dev/sdd1 or whatever using mount,
sudo umount /dev/sdd*
sudo dd if=Fedora-Workstation-Live-x86_64-24-1.2.iso of=/dev/sdd bs=8M status=progress oflag=direct

3. This commandline pattern worked fine for Fedora and OpenSuse, since these isos were meant to work as Live CD/DVDs. So, I did not need to use unetbootin or anything like that for these. Approximately 3 MB per second to my USB drives, which were not very fast. 7-8 minutes to write 1.5 GB. 

creating an AppImage to distribute Linux binaries

Some notes of my AppImage creation process.


  1. First tried creating manually, using
    https://github.com/AppImage/docs.appimage.org/blob/master/source/packaging-guide/manual.rst and the AppRunx86-64 from https://github.com/AppImage/AppImageKit/releases
  2. Found and copied the libs it uses by doing the following to copy all shared libraries -https://www.commandlinefu.com/commands/view/10238/copy-all-shared-libraries-for-a-binary-to-directory
    ldd file | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' /destination
  3. Need to use the environment variable $OWD (Original Working Directory) to get files from the OWD, like our ini file. This code snippet was a good template, https://stackoverflow.com/questions/40306012/c-using-environment-variables-for-paths
        char* pPath;
        pPath = getenv("PATH");
        if (pPath)
          std::cout << "Path =" << pPath << std::endl;
        return 0;
  4. Many libs copied with the manual method had to be excluded using the excludelist at
    https://github.com/AppImage/pkg2appimage/blob/master/excludelist
  5. Still did not work on newer distros. In this thread, probono recommended using trusty on TravisCI for building, and linuxdeployqt instead of manual creation of AppDir. Did that, and it worked. Far fewer libs are bundled by linuxdeployqt. Lists of the two bundles are available at this issue thread.
  6. The download link from transfer.sh can be seen if the entire log is downloaded from TravisCI.
  7. The travis yml file gives the outline of the build and bundling process.

Thursday, April 04, 2019

USB drive reported as read only - solution

Found my USB drive reported as read-only on Linux Mint 18.1.

Corruption could cause this, so tried
sudo dosfsck -a /dev/sdc1

That did not help. Though the CLI is able to write to it, Nemo still complains it is read-only.

Apaprently the fix is at https://forums.linuxmint.com/viewtopic.php?t=176546

So everything needed to fix the issue is to execute:
sudo chmod 777 /media/USERNAME

And/or maybe a reboot?

When I faced this issue today, I rebooted the system, and then the USB drive was mounted read/write.

Wednesday, April 03, 2019

transparent proxy over ssh - sshuttle

Sometimes the network to which I am connected fails, while the LAN over fiber to Studio is active, and Studio's backup network is functional. Then, an elegant way to use the Studio network, without having to install any proxy server software, is using sshuttle.

sshuttle --dns -r username@ip.address.of.machine 0.0.0.0/0

will transparently proxy all dns requests as well as all traffic through the remote machine. Only python needs to be installed on the remote machine.