15 February 2012

67. Neat trick using reverse proxy -- several http hosts behind a firewall with only one port open

The situation: I was running two wireless webcams (Airlink101 AIC 250W) in order to monitor my laboratory. Both of these were connected to a linksys router. Only port 22 and 80 were opened by the university. We were forwarding port 80 to a Debian box running apache.

The goal: We wanted to have a page, e.g.www.externalhostname.com/image.html, serve up images from both the webcams. Using apache.

The solution:
A friend came up with this neat solution.

The following is assumed:
  • The external dns name is www.externalhostname.com
  • The cameras have the LAN ips 192.168.1.121 and 192.168.1.122


First the html file -- image.html:

<html>
<head>
<title>Lab Webcams</title>
<META HTTP-EQUIV="REFRESH" CONTENT="5">
</head>
<body bgcolor="rgb(0,0,122)" text="white">
<table border="1">
<tr>
<td>
Cam 1480
</td>
<td>
Cam 1485
</td>
<tr>
<td>
<img src="http://www.externalhostname.com/cam1/image.jpg" width="320" height="240"/>
</td>
<td>
<img src="http://www.externalhostname.com/cam2/image.jpg" width="320" height="240"/>
</td>
</table>
</body>
</htm>
Next, configure apache using /etc/apache2/httpd.conf:
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
LoadModule proxy_connect_module /usr/lib/apache2/modules/mod_proxy_connect.so
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /cam1 http://192.168.1.121
ProxyPassReverse /cam1 http://192.168.1.121
ProxyPass /cam2 http://192.168.1.122
ProxyPassReverse /cam2 http://192.168.1.122

Finally, copy the following from /etc/apache2/mods-available to /etc/apache2/mods-enabled:
proxy.conf
<IfModule mod_proxy.c>
</IfModule>
proxy_http.load

# Depends: proxy
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
proxy.load


LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so


That's it.

66. Minor bug: evolution 3.2.2 crashes, google chrome sync going crazy on debian testing

Symptom:

  • Evolution 3.2.2 crashes every few minutes -- presumably on retrieving new mail every ten minutes
  • Evolution uses 150% of your resources and becomes unresponsive if you try to recover messages lost in the crash
  • If you sync your Chrome/Chromium browser with google, you get a warning triangle saying that sync failed. On trying to log in again the log-in window keeps disappearing

Logging evolution using CAMEL_DEBUG=all evolution >&evo.log gives
(evolution:8112): evolution-mail-CRITICAL **: e_mail_folder_uri_from_folder: assertion `CAMEL_IS_FOLDER (folder)' failed
**
GLib-GIO:ERROR:/tmp/buildd/glib2.0-2.30.2/./gio/gdbusmessage.c:1986:append_value_to_blob: assertion failed: (g_utf8_validate (v, -1, &end) && (end == v + len))
[imapx:F] adding command, fmt = 'IDLE'
[imapx:F] completing command buffer is [4] 'IDLE'
[imapx:F] Starting command (active=1, literal) F00104 IDLE
[imapx:F] camel_imapx_write: 'F00104 IDLE
'
[imapx:F] camel_imapx_read: buffer is '+ idling
'
[imapx:F] token '+'
[imapx:F] token TOKEN 'idling'
[imapx:F] token '
'
[imapx:F] Got continuation response for IDLE
[imapx:F] ** Starting next command
[imapx:F] * no, no jobs
Here's the log from another crash:

(evolution:19158): evolution-mail-CRITICAL **: e_mail_folder_uri_from_folder: assertion `CAMEL_IS_FOLDER (folder)' failed
(evolution:19158): GLib-CRITICAL **: g_hash_table_lookup: assertion `hash_table != NULL' failed
(evolution:19158): evolution-mail-CRITICAL **: e_mail_folder_uri_from_folder: assertion `CAMEL_IS_FOLDER (folder)' failed
**

GLib-GIO:ERROR:/tmp/buildd/glib2.0-2.30.2/./gio/gdbusmessage.c:1986:append_value_to_blob: assertion failed: (g_utf8_validate (v, -1, &end) && (end == v + len))
Followed by instant Evolution disappearance

If I start evolution and disable all gmail related accounts, it stays stable. If I enable our university gmail-hosted account it crashes --

Icedove/thunderbird is not crashing.

The whole thing seems to be a combination of weird Google stuff and Evolution behaviour.


Solution - sort of:  
I solved the google chrome issue by signing out/disabling sync, then re-enabling again. I also removed my Online Accounts in gnome, then added them again.
I also installed libnss3-tools due to some errors chrome was throwing up, but it's probably unrelated.
Evolution was still unhappy though. I did the 'windows' thing and rebooted -- evolution crashed after about twenty minutes. After starting evolution again it ran without a hickup for 8 hours before I shut my system down.

65. LaTeX for 2013 ARC proposals

If you're in the limbo where you're not quite expert enough with LaTeX, but have happily said goodbye to MS Office, and you're an Australia scientist who annually has to fight the endless bureaucracy of the Australian Research Council (seriously -- 10 page limit about the science, followed by 70 pages about personal qualities?) you may find that you're in for a lot of grief.

If you collaborate with other people you will have to settle for a file format everyone can deal with ('everyone' except linux users), which is likely to be Word run in a virtual environment. If you're writing by yourself or together with more computer-savvy colleagues you will get away with using LaTeX for a fair number of the sections, while using gEdit for others.

I'm presuming that you will create a separate .tex file for each section.

The rules (http://www.arc.gov.au/ncgp/dp/dp_instructions.htm) says that you need

  • Black type
  • Single column
  • A4
  • 0.5 cm margin on all sides (top, bottom, right, left)
  • A 'highly legible font', preferably 12 pt Times New Roman


Also, reading between the lines, you shouldn't/needn't include page numbers since this will be generated by the RMS.

\usepackage{nopageno}

with \pagestyle{plain} just after \begin{document} may do the trick.


Black type and single column are defaults in LaTeX, so need no action. Everything below goes into the preamble.

For A4 and 12 point font, set that in the documentclass

\documentclass[12pt,a4paper]{article}\usepackage[latin1]{inputenc}\usepackage{amsmath}\usepackage{amsfonts}\usepackage{amssymb}\usepackage{mhchem}


For 0.5 cm margins on all sides 

\usepackage[margin=0.5cm]{geometry}
Additional for all sections:

\setlength\parindent{0pt} %no indent on first paragraph \usepackage{fullpage} % an alternative if you don't need 0.5 cm margins \author{} %we don't want author\date{} %we don't want date\begin{document}

Part C, section C1 Here you have several sections, such as AIMS AND BACKGROUND, RESEARCH PROJECT etc. To make sure that these DO NOT get numbered, use
\seccounter{secnumbdepth}{0}

Since the references are a separate document, set
\documentclass[10pt,a4paper]{article}
Part D is filled out online.

Part E, while a pain to write, uses regular 12 pt Times New Roman. If you don't want section numbering, use {secnumbdepth}{0}. If you want your sections to look like this
E1. Justification....
E2. Details of non-ARC contributions

Use
\seccounter{secnumbdepth}{1}\def\thesection{E\arabic{section}.}
As usual, this goes into the preamble, not the body. You should -- ideally -- never have to change the way you write. All changes should go into the documentclass style file or preamble.


Part F. Oh how we curse you.

F13.1 should be easy enough -- you can even skip sections and just use \title{F13.1. Justification} together with a \maketitle right after \begin{document}. Or you can use
\def\thesection{F13.\arabic{section.}


F14.2 offers potential for fun:
\setcounter{secnumdepth}{4}
\def\thesection{F14.2.\arabic{section}.}
\def\thesubsection{\alph{subsection})}
\title{F14.2 Recent significant publications (since 2007)}


This way if you put the following in the body:
\maketitle
\section{Research publications}
\subsection{Scholarly books}
\subsection{Scholarly book chapters}

you get
F14.2 Recent significant publications (since 2007) F14.2.1. Research publications a) Scholarly books b) Scholarly book chapters

For your reference list you may use 
25.* Blow, Joe; Doe, John; \textbf{Hill, Vera}. \emph{One page derivation of the GUT}, Phys. Rev., \textbf{2012}, \emph{108(3)}, 234-235 \\
For F14.3 use
\def\thesection{F\arabic{section}.} \def\thesubsection{14.\arabic{subsection}}
without \maketitle but with 
\subsection{Ten career-best publications}
in the body
G1 is difficult in latex if you want to do it properly. I gave up and used libreoffice for this one since I couldn't figure out how 
Put this in the preamble
\usepackage{rotating} %rotate text in narrow tables...\usepackage{array} % for vertical centering in tables...hacky...
and this in the body:
\section{Research support for Vera Hill}
\begin{table}[h]
 \begin{tabular}{b{4cm} p{0.5cm} p{0.5cm} l c  c c c c}
\textbf{ Description} & \begin{sideways}Same Research area \end{sideways}  &  \begin{sideways}Support type \end{sideways}& ARC Project ID & 2010 (k\$) & 2011 (k\$) & 2012 (k\$) & 2013 (k\$) & 2014 (k\$) \\
 \hline
 "Unifying general relativity with quantum mechanics" & N & C  & DP100202921 & 120 & 190 & 180 & 170 & 120 \\
 \hline
 \end{tabular}
\end{table}

It doesn't look quite right. You may also want to try e.g. m{0.5cm} for the rotated header captions The remaining sections should be fairly straightforward, formatting-wise. Ultimately, the ARC application process is one of the most ridiculous one I've had the misfortune to be subjected to.