Removing URLs from Zotero bibtex exports

When you export bibtex from zotero, it includes the URLs in the bibtex records. Some LaTeX bibliography styles include this information, and sometimes this is not what you want, for example because the URLs take up unnecessary space and are hard to wrap.

It’s quite easy to get zotero to export bibtex without the URLs.

  1. Go to Preferences | Advanced and click on the “Show Data Directory” button.
  2. Edit translators/BibTeX.js with your favourite text editor.
  3. In function doExport(), at around line 2040 in Zotero 3.0.7, change the “for (var field in fieldMap)” loop by adding a single line of code like this:
for(var field in fieldMap) {
    # only add the following line:
    if (field == "url") continue;
    if(item[fieldMap[field]]) {
        writeField(field, item[fieldMap[field]]);
    }
}

If your changes don’t seem to take, make sure that your text editor did not make a backup of the old BibTeX.js (vim does this, with an ~ appended), as Zotero could possible pick up the backed up version instead of your edited version.

Let me know in the comments if this helped!

Look! References without URLs!

Update on 2013-02-17: Added tip concerning editor backups of BibTeX.js (I ran into this problem myself).

Review of Ubuntu Linux 12.04 on the Samsung NP300V3A Core i5 NVIDIA Optimus laptop

An important warning: During installation, do NOT activate home folder encryption. Due to bugs 957843 and 509180, you will most probably suffer data loss, and you won’t even know about it until it’s too late. This happened on two of my laptops during normal use, both of which I have since completely reinstalled with LUKS whole disk encryption. It’s a shame that this bug has been known for years, but that Ubuntu still ships with this as its default home folder encryption configuration.

The Review

With the release of Ubuntu 12.04 Precise Pangolin on April 26, 2012, I decided that it was finally time to test this on my almost-a-year-old Samsung NP300V3A laptop. I had been procrastinating up to now, due to all the horror stories about the lack of Linux support for the NVIDIA Optimus graphics, a hardware-software combination that auto-switches in this case between the discrete NVIDIA GeForce GT520m and the CPU-integrated Intel HD3000.

I was quite pleasantly surprised. Read on if you’re curious as to why.

The obligatory Ubuntu 12.04 Unity desktop screenshot. My gnome-terminal is using the lovely Solarized colours. Extra indicators include Dropbox, and indicator-multiload for showing the CPU, network, load and disk activity gaphs.

Installation

With the Linux Startup Disk Utility (actually called the usb-creator-gtk) on my Ubuntu desktop I installed the 12.04 x86_64 image on an old 1GB USB flash drive. A point of criticism is that the final “installing bootloader” part takes some minutes, without much feedback other than a progress bar bouncing horizontally. Booting the live disk went perfectly, and I could test basic functionality. Joining my TP-LINK TL-WR1043ND access point went without a hitch. Even suspend and resume worked out of the box. Resuming is fast, almost MacBook speed! During the installation, I used the partition tool to resize an existing NTFS partition to create space for the Linux installation. It still amazes me how smooth this process has become. From start to final boot, the whole installation took 18 minutes.

NVIDIA Optimus Support

After bootup, the first two issues I ran into were the miserable (estimated) battery life, and the fact that Super-W did not activate Window-Scale, as I was used to on other Ubuntu installations. A “ps uaxw | grep -i unity” revealed that I was running unity-2d, and sniffing through /var/log/Xorg.0.log yielded the tell-tale “(EE) Failed to initialize GLX extension (Compatible NVIDIA X driver not found)” (also that X was getting confused with the seeming presence of both Intel and NVIDIA graphics). It was clear that Ubuntu 12.04 doesn’t support Optimus out of the box.

On AskUbuntu I found this fabulous answer by one of the developers of the new Bumblebee. In short:

sudo add-apt-repository ppa:ubuntu-x-swat/x-updates
sudo add-apt-repository ppa:bumblebee/stable
sudo apt-get update
sudo apt-get install bumblebee bumblebee-nvidia
sudo usermod -a -G bumblebee $USER

After this log out and log back in, and you’re in Optimus heaven! My battery estimate was soon 3.5h+ on 80% charge (it was just under 2h at 80% before installing bumblebee), unity 3D was running, and I could start applications, using the optirun prefix, running on the NVIDIA graphics. With glxspheres, I get 1.9 frames/sec and 1.9 Mpixels/sec without and 115 frames/sec and 113 Mpixels/sec with NVIDIA graphics. Importantly, bumblebee automatically switches off the NVIDIA graphics when nothing is using it, resulting in the much longer battery life. All hail the four main developers of Bumblebee: Thulinma, Lekensteyn, Samsagax and ArchangeGabriel.

Unity

Unity, Ubuntu’s unique GUI, has improved muchly since 11.10. I gave Unity on 11.04 a serious go, and also on 11.10, but I gave up in each instance after a week or two due to glaring bugs. The 12.04 Unity has made great progress in fixing a number of small but irritating bugs, I think it might be a keeper. The heads-up display (HUD) is indeed awesome: Press “alt” (the default keybinding) and then type away to search through the menus of the currently foreground application. I’ve come to appreciate the screen space savings due to the global menubar, although it doesn’t work for all apps yet, vim-gnome being an example of note. At this moment, my only wish would be to have a window-overview like you get in the gnome3-shell when you press the super key.

There has been much bitching and moaning about the direction Ubuntu has taken with Unity, some of it valid arguments. Especially the fact that much effort is being diverted from the gnome-shell is concerning. However, although I’ve dirtied many a word using previous versions of Unity, I think it’s good that it’s exploring directions that create a new UI experience that represents a counter-pole to the Windows and OS-X approaches.

Fixing Chrome icon grouping in Unity Launcher

At the time of this update (2012-05-04) I did run into one old annoyance again. If  you start up Chrome (or Chromium) and then one of its application shortcuts, for example GMail, it groups both under the same icon on the Unity Launcher:

Chrome and Chrome Application shortcuts are grouped together under the first launcher icon, whichever that is.

If you start up the application shortcut first, for example GMail, subsequent Chrome windows will be grouped under the GMail icon. Durn.

Fortunately, the devs have been working on this bug, and the fix should soon appear as a stable release update (SRU). Until that time, you can download and install the bamfdaemon, libbamf and libbamf3-0 deb packages from here. Anything with version 0.2.116 and newer has the fix. Note that this only fixes it for the case where you’ve started up Chrome first (scenario 1 above), and not an application shortcut. See my comment on the bug report.

Multi-monitor support

I had low(ish) expectations when I connected my 40″ Sony Bravia TV to the HDMI port of the laptop, so I was more or less speechless for a while when, without me having to touch any part of the interface, Ubuntu simply extended its desktop onto the TV panel. BOOM. Just like that.

What I also like very much, is that Ubuntu by default puts the Launcher and its main menu bar on both displays (this is configurable though) and, even more gratifying, that the Dash appears automatically on the display currently containing the mouse cursor when I press the Super key. In the photo below, you can see the laptop below, on battery, outputting to the Sony TV via HDMI, and glxspheres humming along at just over 90 FPS using the discrete NVIDIA graphics. What you don’t see is me, smiling maniacally behind the camera phone.

Ubuntu 12.04 multi-monitor support FTW!

The Displays configuration window seems to think the 40″ panel is 72″, but the resolution has been correctly deduced.

Miscellaneous hardware support

Power saving looks pretty good. With the brightness set to 40% (brightness setting is not persisent unfortunately), my power usage at idle is just under 9W:

PowerTop says my idle power consumpting at 40% brightness is under 9W.

Actually with normal browsing over wlan, I was not able to push it that far over 10W. This is after having toggled 10 or so powertop tunables from “bad” to “good”. After having installed laptop-mode-tools, the tunables are all automatically and persistently “good”, except for a VM timeout. However, this seems to be a misunderstanding between laptop-mode-tools and powertop, and it is in fact quite OK.

The hardware config panel key (Fn-F1) does nothing, the touchpad disable key (Fn-F5) just works, the volume keys (Fn-F6 to Fn-F8) just work, but the hardware fan (Fn-F11) and wireless (Fn-F12) keys do nothing.

Initially the brightness keys (Fn-F2 and Fn-F3) didn’t really work, only allowing me to switch between two brightness levels (100% and 90%). Adding “acpi_osi=Linux acpi_backlight=vendor” to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub, running sudo update-grub and then rebooting gives you 100% working hardware brightness control. Based on the information on this page, this configures brightness setting to happen through vendor-specific driver modules instead of through the ACPI default driver. Also see my askubuntu answer regarding this issue. Things have unfortunately changed to and fro with subsequent Ubuntu kernel releases, this page is up to date with linux kernel 3.2.0-31.

In the working cases, you get the gorgeous notifier display (and in the case of volume even a mac-like audio feedback as you change levels):

Pretty notifications with Unity

As mentioned before, suspend to and resume from RAM works like a charm, out of the box, and the resume is really fast. Hibernate does NOT work. I tested this with “sudo pm-hibernate”, but when I switched the laptop back on, it acted like it was being cold-started.

I tested the webcam and sound setup (speakers and built-in microphone) with the gmail talk plugin and with the cheese application. These both work fine. However, with Skype 2.2.0.35 for Linux, you get the dreaded too-dark webcam image. The often-posted solution of using luvcview to adjust brightness does NOT work. Here’s a better solution: Install v4l2ucp, the video4linux2 universal control panel. Keep this running when you start Skype. If the video is dark, switch the “Exposure, Auto Priority” off and then back on again. This solves the problem on my setup (built-in WebCam SCB-1100N). Whenever you startup Skype’s video capturing again, it manages to screw up the setting, so you have to retoggle it with v4l2ucp unfortunately.

The touchpad can be easily configured for two-finger scrolling, but not for three-finger gestures like it can be on Windows.

The touchpad configuration dialogue.

USB tethering with my Android-powered (CyanogenMod 7.1) HTC Desire Z works like a charm. I connect the USB cable, activate USB tethering on the telephone, and my laptop is online. This definitely qualifies as a Just Works(tm), and it seems to connect a whole lot faster than Windows 7 does.

Conclusions

When I bought this laptop, I had resigned myself to not being able to use it for Linux, for the largest part due to NVIDIA Optimus. However, due to the efforts of the Bumblebee people, and also due Ubuntu 12.04 as a whole with the multi-monitor support being a highlight, my verdict is that this laptop is a great buy also when you’re planning to go exclusively Linux.

More resources

  • My gnome-terminal uses the Solarized colour scheme from here, and my vim (both console and gnome) are using the setup from the main Solarized repository.

Updates

  • August 27, 2012: Updated fix for brightness controls.
  • June 14, 2012: Added warning about the default home encryption being completely broken.
  • May 6, 2012: Added USB tethering.
  • May 4, 2012: Added the Unity Launcher icon grouping bug fix.
  • May 3, 2012: Added the multi-monitor section after testing with my HDMI Sony TV. Added solution for dark webcam capture in Skype. Also, thanks to Ladislav Bodnar, host of DistroWatch.com, this review is now linked from the Ubuntu page.

Fix for blurry photos on HTC Desire Z

As you know, we here at VXLabs are of the educated opinion that the HTC Desire Z is an absolutely brilliant telephone. However, recently we noticed that some of our phones (at least two) started producing very blurry photos. See this test picture of my microwave for example:

Blurry-appearing microwave, in reality quite sharp!

This is of course quite irritating, especially in a phone that is otherwise sheer brilliance. No amount of moist-cloth lens cleaning could improve the results. Fortunately I came across this forum thread, where it was suggested either to replace the whole phone back plate including lens, or to have the phone repaired by the service centre, or to clean the lens with a q-tip and some toothpaste. The first two options either costing money or requiring a telephone still within its guarantee were quickly eliminated. Although the third option, suggested by forum user allanl-o, sounds strange, we wanted to explore it, for science’s sake of course. As an aside, the lenses of our two test telephones as well as that of the thread started looked like this (picture courtesy of xudsa II USERT, the thread started):

What your lens probably looks like if you’re taking really blurry pictures.

It seems that there’s some kind of coating that has started to flake off. In any case, it turns out that the mild abrasive in the tooth paste and a minute of two’s rubbing with a q-tip is just enough to clean up the glass in front of the lens completely, resulting in mega sharp photos again. Look at my microwave, now as sharp in the photo as it is in reality:

Microwave, sharp in reality and in the photo!

We’ve performed this procedure on two different HTC Desire Z phones, in both cases with great results. Let us know in the comments if this worked for you!

How to get Zotero IEEE style NOT to abbreviate with et al. in the bibliography

In my view, Zotero is currently the best reference manager available, and it’s also completely open source!

I had one niggling problem though with version 2.1.10 (latest stable at the time of this writing): When I would export (or Quick Copy) references in IEEE style, it would abbreviate the author list with “First Author, et al.” if there were seven (7) or more authors. When I’m building a bibliography list, this is of course never the right thing to do.

Here’s the simple workaround for this problem:

  • Go to Preferences | Advanced and click on the “Show Data Directory” button.
  • Edit styles/ieee.csl with your favourite text editor.
  • Look for the line starting with <bibliography et-al-min=”7″ … and change the 7 to a higher number, 100 for example.
Let me know in the comments if this helped!

A Windows console that does not suck

We’ve all been there: You’re used to the terminal on Linux or OSX, and then for some or other reason you need to work on Windows and you’re confronted with the half-baked monstrosity that is cmd.exe:

It’s 2011 and this is Windows 7: Why does the console still make me want to gnaw off my fingers?

To summarise: You can only resize the window vertically (so you’re always restricted to 80 characters width which is just idiotic on modern widescreen displays), copy and paste is so painful that you’ll wish that they’d rather just not bothered with it in the first place and the cmd.exe interpreter itself is primitive when compared with any modern unix shell.

Enter the two-pronged solution of Console2 and Git bash! Console2 is a console that solves the UI problems (resizing! copy and paste! terminal transparency! tabs!) and you can use it together with any combination of command line interpreters, such as for example the existing cmd.exe, bash or anything else.

Here’s my setup, configured with Git bash (you get this for free with the Windows git installer, for this purpose it’s better than Cygwin as it’s a touch closer to Windows) as well as plain old cmd.exe. To configure a Git bash tab, set Shell to “C:\Windows\SysWOW64\cmd.exe /c “”C:\Program Files (x86)\Git\bin\sh.exe” –login -i” (including all quotes) and Startup dir to %HOMEDRIVE%%HOMEPATH%. I’ve also configured Ctrl-Alt-T to invoke Console2. With shift-mouse-drag I can select text (nice editor select, not cmd.exe block select, ptooey!), and I’ve set Ctrl-Shift-C and Ctrl-Shift-V to copy and paste so it’s like the Gnome terminal on Linux. Behold:

Console2 makes the pain go away.

My Windows experience is a lot more bearable now, perhaps even slightly pleasant! Did I just say that?!

Alternatives

  • PowerShell replaces cmd.exe, but by default still runs inside the Windows console. Still much suckage in other words, plus that I don’t feel compelled to learn PS yes.
  • Cygwin mintty is also often cited as a console replacement, but seems to cause problems (for example with git) as it’s not a full Windows console.
  • Cygwin itself is really fantastic, but due to that POSIX compatibility layer which is otherwise a useful thing, differs too much from the native Windows goodies so that sometimes native Windows behaviour is interfered with.