12 July 2012

206. Chrome, cookies and incessant spying

With age and added responsibilities I'm becoming grumpier and grumpier.

I read lxer.com everyday since it provides a good aggregation of linux-related news. On clicking on this link to h-online I was shown a pop-up in the top left corner letting me know that h-online uses cookies, and by clicking close my consent to be tracked is assumed. A link was given to a page where I could opt out, and another link to etracker was provided on that page. Clicking on that and eventually getting past the captcha told me that etracker will no longer track my browser (so I have to do it for chrome, chromium, and iceweasel? And on every one of my six computers?)

I signed up for my first dial-up internet connection in 1996, and as far as I can remember cookies were heavily discussed already back then. However -- and again this is as far as I can remember -- accepting cookies wasn't necessary since not every website + their mum was using them to track you. 

As far as I can see there are a few reasons why websites want to set first or third party cookies:
* Ads. Targeted ads.
* Information. Which is then sold to companies tailoring ads.
* Automatic log-in and customisations
* Because everyone else is doing it


I've cleared my cache, but I saw cookies from the Swedish ministry of foreign affairs, among others. I find it difficult to imagine a legitimate reason for them to set a local cookie on my computer. I don't think there is any evil intent behind it -- instead it's probably a case of 'why not?'.


It's easy enough to set your browser to block all cookies or to automatically delete them on closing your browser. Some browsers allow you to accept cookies on a site/provider basis. This easily leads to you having to click pop-up after pop-up after pop-up...

The ideal case -- from the point of the user -- is one where you block all cookies and add exceptions for sites that YOU deem have legitimate reasons to set cookies and where YOU benefit from having cookies set.

A little experiment. Try disabling cookies completely, and then log-in to your blogger or gmail account. Try adding an exception for google servers only, then log in to blogger -- you get stuck in a nice little loop which only gets broken if you add an exception for blogger.

In fact, I can't even do much on the university network without allowing cookies -- the university wants to set cookies in order to allow me to do just about anything.

Anyway, after that rant, here's how you might want to manage your cookies in google chrome:
Got to settings in google chrome and type in cookies

Click on Content Settings.
Check:
* Block sites from settings any data
* Block third party cookies and site data
Then click on Manage Exceptions 

 Add sites YOU feel should have the right to add cookies.
With google and blogger you have little choice: in order to use those sites you need to enable cookies.
Note that wildcards are added using [*.]


You may also want to clear you cache to get rid of cookies which have already been set.
Continuously add exceptions for sites which you want to grant the ability to set cookies. 

You can also add sites by clicking on the cookie icon to the right of the URL field in your browser:

Take a look at what cookies are set every now and again.

If you find that you have plenty of cookies like these:

it's likely because you have the Google Opt Outs enabled:




10 July 2012

205. Debian, TeXLive and style files: making lecture slides

Because I keep forgetting...(my blog serves as a public notebook). I don't make any presumptions about this being terribly new or relevant to a lot of people.

This post expanded into something quite different from what was indicated by the title:

Here's the short version:
kpsewhich -var-value=TEXMFHOME
$HOME/texmf
ls $HOME/texmf
ls: cannot access /home/me/texmf: No such file or directory
mkdir ~/texmf/tex/latex -p

Copy your style files e.g.
cp lecturestyles/ -R ~/texmf/tex/latex

(sudo) texhash

And here goes the long version:

I hate powerpoint presentations --- even if they are made with latex (time to make it a generic trademark?) but the university I'm working at considers blackboards too old-fashioned. Apparently the maths and physics departments are still fighting the good fight, but my department has rolled over. Why do we let people who don't teach decide how we do things? Anyway...

For my lecturs, slides, seminar talks etc. I'm using a fairly heavily edited version of this
http://robjhyndman.com/researchtips/latex-templates-for-monash/
for making slides. It's served me well for giving seminar talks etc. I'm currently putting together a new course* and it's now becoming more important than ever to make sure I organise my material already from the outset.

So, a few things to do:
1. Organise everything neatly in folders:
main.tex

/lectures/silicon.tex
/lectures/aluminium.tex

images/aluminium/
images/algorithms/opa

etc.

Beware: when you include images in silicon.tex but call silicon.tex via main.tex, the paths are relative to main.tex, i.e. it's not ../images/aluminium/ore.eps but images/aluminium/ore.eps.

2. Finally move the style files from the local folder (i.e. where the tex file is) to the destination indicated by TEXMFHOME variable:


kpsewhich -var-value=TEXMFHOME
/home/me/texmf
ls $HOME/texmf
ls: cannot access /home/me/texmf: No such file or directory
mkdir ~/texmf/tex/latex -p

Copy your style files e.g.
cp lecturestyles/ -R ~/texmf/tex/latex/

(sudo) texhash 

3. Make liberal use of \include{} in latex
Basically -- you have a document with the preamble

\documentclass[14pt]{beamer}
\usepackage[version=3]{mhchem}
\usepackage{array}
\usepackage{color}
\usetheme{styles/Hytex}
 \def\biz{\begin{itemize}[<+-| alert@+>]}
 \def\eiz{\end{itemize}}
 \def\ben{\begin{enumerate}[<+-| alert@+>]}
 \def\een{\end{enumerate}}

\title{Chemistry 3456}
\author{Verahill}
\date{}

\begin{document}
\include{lectures/introduction}
\include{lectures/silicon}
\include{lectures/phosphorous}
\include{lectures/aluminium}
\end{document}

And then you create individual files for each lecture or topic e.g. silicon.tex:

\title{Silicon: spines, shells and minerals}
\begin{frame}
 \titlepage
 \centerline{Department of Chemistry}
 \centerline{\includegraphics[width=8cm]{styles/myunilogo}}
 \centerline{\small\color[rgb]{0.01,0.33,0.58}}
\end{frame}

\section{Silicon}
\begin{frame}
Today's lecture will cover:
biz
\item Bouncy balls
\item Froth reductors
eiz
\end{frame}

without preambles or anything of that sort.

It's still a bit annoying that you can't set the location of the aux, nav, log etc. files in each .tex document since the clutter offends my eyes. But hey, there's a limit even to my grumpiness.

4. \usepackage{}
Try looking for chemistry related packages which are installed on your system
find /usr/share/texlive/texmf-dist/tex/latex/ -name "*.sty"|grep [cC]hem

The ones which show up on my system are:
achemso, mychemistry, chemstyle, chemcompounds, mhchem, chemmacros, chemarrow and chemfig

mhchem is most likely the most useful one:
\usepackage[version=3]{mhchem}
You can either do
\ce{OH-}+\ce{[B(OH)3} $\rightarrow$ \ce{[B(OH)4-}or more elegantly:\begin{reaction}
OH- + B(OH)3 -> B(OH)4-
\end{reaction}
SIunits are good too:
\usepackage{SIunits}
The bond length is 1.1 \angstrom{} at 298\kelvin{} (25 \celsius{})
Chemfig looks very promising for a 2D chemistry drawing package and uses tikz, but it has a fairly steep learning curve (in the sense that you need to familiarise yourself with most use cases before you can do anything - it doesn't necessarily take very long):

\chemfig{C(-[2]H)(-[4]H)(-[6]H)-C(-[2]H)(-[6]H)-H}
draws ethane. The 2, 4, 6 are angles in multiples of 45 degrees. So, there are H at 90, 180 and 360  relative to the first carbon. 0 degrees is parallel to the horizontal, and angles increase as in a normal coordinate system (i.e. counter-clockwise).
In addition, you can do Lewis dot structures:
\chemfig{B(-[3]\lewis{420,Cl})(-[5]\lewis{460,Cl})-\lewis{260,Cl}
The 420 means bar to the left (0), top (2) and left (4). 260 means bar left, bottom and top. There's a lot to learn though...

Lastly, e.g.
\chemfig{*6(-=-=-=)}
draws benzene. The 6 indicates a hexagon and the -=-= the sequence of bonds.


5. Dia for flowcharts and cycles
I tried using tikz to make pretty, native flowcharts and cycling diagrammes, but it was too much work and too hard for lecture slides (I might revisit it for articles)
Instead, the dia package in debian make it easy to quickly make up .eps flowcharts

6. Use inkscape to turn png into eps
A lot of programmes can create eps files from raster formatted image files. However, most of them do a very poor job.

Instead I like using inkscape and have a .sh file for it:
inkscape --verb FileSave --verb FileClose --export-eps=$1.eps $1.png

7. BKChem for more difficult schemes
8. GDIS/povray for nice 3D structures.

9. MOdiagram for MO diagrams. Awesome BUT enabling labels leads to catastrophic failure:
"! Font LGR/cmss/m/n/12=gsmn1200 at 12.0pt not loadable: Metric (TFM) file not found."

You need to install cbfonts which is supposed to be included in texlive (I think). But it seems that some files are missing. Download cbfonts.zip from http://www.ctan.org/tex-archive/fonts/greek/cbfonts. Assuming you downloaded in ~/Downloads.
mv ~/Downloads/cbfonts.zip ~/tmp
cd ~/tmp
unzip cbfonts.zip
cd cbfonts/
sudo cp fonts/* -R /usr/share/texmf/fonts/ 

sudo update-updmap

sudo texhash && sudo updmap-sys
*to all my former lecturers: I am so, so, so truly sorry for not appreciating more how 1) much effort is involved in putting together a course (even a badly prepared one) and 2) as an undergraduate I didn't acknowledge that teaching isn't your main job.

204. GNOME 3: prevent shotwell from taking over storage devices with photos

I occasionally move pictures off my phone and the CF card of my camera. It annoys me a little bit that shotwell  gets to open and import my photos uninvited.

It also annoys me that a 5 seconds search through the preferences of nautilus and shotwell doesn't offer a solution, but I suppose when we really think about it is a GNOME issue.

Well, it's easy to sort it out: start the gnome system settings, go to details, and select Removable Media.

Post-script:
A lot of functionality is disabled, shifted around or removed completely in the core gnome apps because select devs consider it 'confusing', not obvious or difficult to locate (fixing the sentence to make it grammatically coherent would make it unreadable and clunky -- you know what I mean). Yet somehow the System Settings/Details as a dumping ground for some rather odd stuff has survived since Gnome 3.0.

Again, I like gnome. But gnome will probably do a whole lot better taking criticism from it's loyal users than catering to imaginary mobile device users, hypothetical ex-windows/osx users or basing design decisions on classroom-appropriated theory.