Thursday, January 12, 2012

Suppressing BibTeX fields for specific biblatex entry types

I use LaTeX for writing academic papers and biblatex for handling the citations and references in them. One problem I ran into is that biblatex prints out the location, address, month, and publisher for a lot of entries, which I prefer not to have in my reference list. Rather than editing the BibTeX .bib file and losing that data forever, you can tell biblatex to ignore or suppress specific pieces of it.

Below is my code. It suppresses location, address, month, etc. for all entries, and suppresses the publisher and editor field unless the entry is a book. You may need to modify this for whatever style you're using.

% Loads biblatex with clickable links from citations and the reference list, 
% with back references if the style supports them.
\usepackage[hyperref,doi,url=false,backref,style=alphabetic,maxbibnames=99]{biblatex}
\bibliography{refs.bib}

\AtEveryBibitem{% Clean up the bibtex rather than editing it
 \clearlist{address}
 \clearfield{date}
 \clearfield{eprint}
 \clearfield{isbn}
 \clearfield{issn}
 \clearlist{location}
 \clearfield{month}
 \clearfield{series}
 
 \ifentrytype{book}{}{% Remove publisher and editor except for books
  \clearlist{publisher}
  \clearname{editor}
 }
}

Edit on 2/9/2012: As @siretart helpfully points out in the comments, biblatex makes distinctions between fields, name lists, and literal lists in the source file. To see whether to use \clearfield, \clearname, or \clearlist check the biblatex manual for the data type. For example, date and series are fields, location is a literal list, and editor is a name list. I've updated the code above to reflect this.

Monday, August 8, 2011

Microsoft Security Essentials Automatic Updates

I love Microsoft Security Essentials, but I'm annoyed by having to do the virus signature updates manually with each Windows Update. This could be because I have Windows Update set to download but let me choose which ones to install. However, you can use the Task Scheduler to automatically run the signature update every day.

AddictiveTips provides instructions, but on my 64-bit Win7 machine the file location was different.

Instead of
C:\Program Files\Microsoft Security Essentials\MpCmdRun.exe SignatureUpdate
I used
"C:\Program Files\Microsoft Security Client\Antimalware\MpCmdRun.exe" SignatureUpdate
So far, so good!

Tuesday, May 31, 2011

Make Firefox 4 to save passwords for ALL websites

Some websites ask web browsers to disable their password auto-complete features. This allows developers to increase the password security for important sites like banking, but can also be used for less important sites.

You can force Firefox to ignore the website settings and save all passwords, but you must then be extra vigilant about which passwords you save. Banking sites and the like will now prompt you to save the password, which you probably shouldn't do for them.

There was an easy fix for Firefox before version 4 (see this post), but there are a few hoops to jump through for the latest version. Firefox 4 packages all the necessary files into omni.jar in the program folder, which is a non-standard archive format that needs to be specially altered. Below are the directions from this comment:

0. Make a backup copy of omni.jar
1. Unzip the omni.jar (using either 7zip, Winrar)
2. Edit accordingly
3. Pack again using ZIP format + SFX option (Self-Extract)
4. Rename back to omni.jar
5. Launch Firefox!

Friday, March 25, 2011

Better APA-style: working around hyperref and apacite problems

I'm writing an article in LaTeX using APA style, so I'm using the popular
apa.cls style. It defaults to using apacite for citations and references, which works well enough.

But if I have a URL field in the BibTeX, like I always do in JabRef to remember where I found things, it prints it for each reference wasting a lot of space and not breaking lines properly. I also like the URLs I do show to be clickable hyperlinks, and my citations and cross-references as well. You can usually do this using hyperref, but a lot of things break when using apacite and hyperref together. Here's the top of the file:
\documentclass[jou]{apa}
\usepackage{hyperref}
And here is the output of pdflatex:
! Undefined control sequence.
\hyper@@link ->\let \Hy@reserved@a
\relax \@ifnextchar [{\hyper@link@ }{\hyp...
l.83 \cite{Aris09Visual}
...
! Argument of \@@cite has an extra }.

\par
l.83 \cite{Aris09Visual}
...
Runaway argument?
>{\hyper@link@ }\def \reserved@b {\hyper@link@ [link]}\futurelet \@let@token \E
TC.
! Paragraph ended before \@@cite was complete.

\par
l.83 \cite{Aris09Visual}
Other people have had this problem before, but there aren't any great solutions. See the end for a good solution using biblatex-apa instead of apacite. If you insist on using apacite, there are instructions here for how to make things mostly work:
The simplest way to fix the problem is to put a single
instance of \protect into hyperref.sty.

Turn this:
   \def\bibcite#1#2{%
\@newl at bel{b}{#1\@extra at binfo}{%
\hyper@@link[cite]{}{cite.#1\@extra at b@citeb}{#2}%
into this:
   \def\bibcite#1#2{%
\@newl at bel{b}{#1\@extra at binfo}{%
\protect\hyper@@link[cite]{}{cite.#1\@extra at b@citeb}{#2}%
This occurs at
line 3972 in hyperref.sty [2007/02/07 v6.75r
and at
line 4939 in hyperref.sty [2008/04/05 v6.77l
(line 8328 of the corresponding hyperref.dtx ).
but this breaks the citations. Later they added additional code to the tex file:
It's really just a matter of executing APA's version of \bibcite
before doing the extra stuff that hyperref needs to create the hyper-linking (which seems to work just fine).

For example, the following coding seems to work OK.
\usepackage{apacite}
\let\APAbibcite\bibcite %%%% add this line

\usepackage{color}
\definecolor{darkblue}{rgb}{0.0,0.0,0.3}
\usepackage[bookmarks=true]{hyperref}
\hypersetup{
pdfauthor={Salvatore Enrico Indiogine},
pdftitle={},
pdfsubject={TAMU EDCI},
pdfkeywords={},
pdfcreator={LaTeX with hyperref package},
pdfproducer={dvips + ps2pdf},
colorlinks,breaklinks,
linkcolor={darkblue},
urlcolor={darkblue},
anchorcolor={darkblue},
citecolor={darkblue}}

%%%% add the following 2 lines
\let\HYPERbibcite\bibcite
\def\bibcite#1#2{\APAbibcite{#1}{#2}\HYPERbibcite{#1}{#2}}
This fixes most problems, but there are still warnings and ampersands missing in the references.

A better solution for me was to use biblatex-apa with biblatex instead of apacite.

First replace \bibliography{...} at the end of your tex file with \printbibliography. Then modify the the top to look like this (note the noapacite option for apa.cls).
\documentclass[jou,noapacite]{apa} %%%% apacite is buggy with hyperref

\usepackage{color}

\usepackage[]{hyperref}
\hypersetup{
pdfauthor={AUTHORS},
pdftitle={TITLE},
pdfkeywords={KEYWORDS},
colorlinks,breaklinks,
linkcolor={blue},
urlcolor={blue},
anchorcolor={blue},
citecolor={blue}}

%%%% bilatex-apa
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=apa,hyperref,doi,url]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
\bibliography{}

Thursday, March 24, 2011

CrashPlan local backup phones home way too much

I recently tried using CrashPlan, an online backup program that also provides a free client for local or local network backups. I was not happy when I discovered how much it phoned home for these supposedly local backups.

After watching the EFF's presentation The Law of Laptop Search and Seizure from DEFCON 18, I discovered that only a subpoena is required to get your data from an online provider while a court-approved warrant is needed to search your personal machines. CrashPlan claim to use file and network encryption to protect your data on their servers, but I'd much rather roll my own backup servers for the added security.

After installing the CrashPlan proprietary Java client I fired up Wireshark to see how much CrashPlan was phoning home for local backups. When you open the program, you're forced to create an account with their online service, so naturally it sends that info. I was surprised though when I started configuring local backup settings and that information was sent to their servers too. Why do they need all your configuration? To populate their web interface.

This web interface could be useful for users wanting to change their settings remotely, but I'm not pleased with all my backup selections, destination folders, exclude lists, and the like forwarded on to their service and configurable there. It would be easy for them to store a lot more information about the files on the machine without the end user knowing.

CrashPlan seems to provide a good service for users wanting to do online backup, but one of their main selling points is the free local backup system. I'd be much happier with it if they gave an option to switch the web interface and all phoning home off. As it is, I'll stick with my harder to set up but open source and private BackupPC system.

Wednesday, February 9, 2011

LaTeX Error: Undefined Color when using apa.cls

I was writing a journal article in LaTeX using the apa.cls style and was having trouble with my little command for leaving notes to myself:
\documentclass[jou]{apa}
\usepackage{color}
...
\definecolor{Orange}{rgb}{1,0.5,0}
\newcommand{\todo}[1]{\textsf{\textcolor{Orange}{[#1]}}}
On building, I'd get an error message: LaTeX Error: Undefined Color `ORANGE'. It only happened when using the jou option, not with man or doc. I couldn't for the life of me figure it out, and on a whim changed the color from Orange to ORANGE. Viola! It works perfectly! Apparently something in there automatically upper-cases the color.
\definecolor{ORANGE}{rgb}{1,0.5,0}%Lowercase breaks on \documentclass[jou]{apa}!
\newcommand{\todo}[1]{\textsf{\textcolor{ORANGE}{[#1]}}}

Friday, October 29, 2010

Full/Incremental Backup Cutoff in Windows 7 Backup

I couldn't understand why the Windows 7 Backup would sometimes do incremental backups and other times full ones. After much searching, here's what I found on the TechNet Forums:
We have introduced automatic full backup feature in Windows7 to help customers who run into a situation where they never create full backups. When their backup target eventually gets filled, they are left with only one backup set to delete. They need to delete the entire backup set to resume backups and so end up in a situation where they do not have any backup.

The rules that determine when to take automatic full backup are:
1. If previous full backup was taken 1 year back
2. Ratio of size of deleted files + older versions of files in current backup set is 50% or more of the size of the current backup if it were full.

We deliberately did not allow forcibly starting new backup set or configuring these rules through our UI because we did not want to confuse users about full backups, incremental backups, automatic full backups.

If you find that these settings do not match your requirements, we allow the defaults to be tweaked using registry keys.

Registry key to control enable/disable automatic switching to full backup:
Path: SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsBackup\AutomaticFullBackup
Name: Enabled
Type: DWORD
Value: 0 indicates automatic full backup is disabled, non-zero indicates it is enabled
Default if not specified: 1
Registry key to control the time period when backup should automatically switch to full:
Path: SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsBackup\AutomaticFullBackup
Name: TimePeriodInDays
Type: DWORD
Value: Count of days
Default if not specified: 365
Registry key to control the % of deleted/missing + older versions of files that determines whether to switch to full backup:
Path: SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsBackup\AutomaticFullBackup
Name: OlderFilesSizePercentage
Type: DWORD
Value: Percentage value from 0 to 100
Default if not specified: 50
...
A lower value for OlderFilesSizePercentage would mean the automatic full backup would trigger earlier than when it would trigger if this key was not set. Hope that is clear.

To clarify on your question on incremental backups to network storage location:
Windows Backup supports incremental backup to network storage locations. This is true for file backup as well as system image backup.

However in case of system image backup, Windows Backup supports only preserving the latest version of the system image backup. This is because system image backup versions currently are maintained as shadow copy versions of the backup target volume containing the backups. Since shadow copy cannot be created on network shares, it is not possible to support multiple versions of system image when taken to network share.
Example command line usage:
wbadmin start backup -vssfull -backuptarget:y: -include:c:,d:
This would only support taking a block-level backup of the entire volumes included in backup in client SKUs. (That is why if you have noticed, you can only include full volumes as part of "wbadmin start backup"). So this does not end up creating a new backup 'period' for the file backups.