Friday, May 27, 2011

Synctex

I recently became aware of Synctex the successor of pdfsync.
pdfsync is a technology that allows synchronization between a (la)tex file and the corresponding pdf output. It wasn't the first of its kind but certainly the best i've tried. In practice you need support by both your viewer and editor but then it's down to pressing a command or (shift/ctrl/whatever)+clicking somewhere and you are magically teleported into the other app to the spot corresponding to the one you were at on the other side. Anyone who has texed and needed to proof a doc of more than 5 pages length before will understand that this is invaluable.


For all the goodness, this had some drawbacks unfortunately: pdfsync was based on some tex primitives as opposed to being embedded into the engine, so the output under some circumstances wasn't perfect, it could change the generated rendering and it was incompatible with some popular packages (e.g. colortbl). I have never been bitten by any of these in the last 3 years but it always was a good excuse for viewers not supporting it (they are usually the end that carries the burden).
It unfortunately still has it's place as we will see shortly, so here are links to set up  forward  and backward search underMacOS + vim + skim, evince doesn't have it and never will which leaves you with xpdf and okular on linux, both of which aren't my favourites.

In comes synctex: It is the natural evolution of pdfsync done by the original author and has all the goodies without the down sides. Setting it up under Mac was even easier now that skim supports macvim as a preset :). Just choose MacVim under preferences>sync and put the following in your .vim/ftplugin/tex.vim (assuming you use the vim-latex suite)

let g:Tex_DefaultTargetFormat = 'pdf'
let g:Tex_CompileRule_pdf = 'pdflatex -synctex=1 --interaction=nonstopmode $*'
let g:Tex_ViewRule_pdf = 'Skim'
 
Look at this for all other MacOS related progs, mupdf, and evince. Okular just needs to be called with
okular --unique 'file.pdf#src:linenumber file.tex'
(That's what i think the evince people should have done instead of using dbus. Oh, well...)

Now for the bad part, lua(la)tex + evince/okular isn't working with synctex. I filed bugs with luatex, evince and okular but i don't expect a solution for this anytime soon. :( That means i am back to pdfsync for now, since i really, really like my luatex. So have fun with that!

Edit: you need to tell vim to call okular/evince with the exact same filename that lualatex produces which is ./file
In order to do that goto compiler.vim which if you installed vim-latex in your .vim is under .vim/ftplugin/latex-suite/compiler.vim otherwise probably somewhere in /usr.
Apply this patch for okular. For evince it really depends which script you use, but read the patch and do it analogously.

Tuesday, May 3, 2011

Impurity Test endlich online!

Du hörst immer du wärst verdorben, glaubst es aber nicht? Du hast schon vor langem von ihm gehört, aber nie getraut ihn zu machen? Verzweifle nicht, er ist endlich hier! In der Tradition der besten Varianten, die wir kennen, raffiniert durch endloses Durchtesten, perfektioniert durch das verderbte Wesen Vieler. Der Impurity Test ist endlich hier!

Wednesday, April 13, 2011

Interesting article and some of the comments are even more insightful than the article itself. I think i agree with Anonymous (22. August 2010), who explains the futility of the whole attempt, s/he laconically summarized it like so:
That to make the internet useless for bad people, it must also be made useless for good people. You could literally firewall the entire damned thing to where the internet passed only ICMP echo requests, and do you know what would happen then? Spammers would resort to hawking viagra via ping packets fired in morse code, hoping to reach ham radio operators looking in the general vicinities of their DSL modems' RX LEDs. (I'm *not* kidding.)
And sadly enough s/he's right.

libao and the mac

Anyone who hasn't updated libao on the mac to 1.1. yet do so now! It fixes those two really annoying bugs concerning playback stopping when hibernating,suspending or (un-)plugging an audio connector.
By the way if you don't know why open source is useful, i think i have yet to find a text that expresses my views on this better than http://www.xiph.org/about/

Tuesday, March 29, 2011

HIbernate mac from cli

I forgot to turn off my mac and left the house, so what's a guy to do? Right log in via ssh (having dyndns working is a real plus here) and hibernate it. To do this use the following snippet in a script.
#!/bin/bash
osascript << EOT
tell application "System Events"
     sleep
end
EOT

Control apple network profile from the command line

I have to change between a network with a fixed address setup and some others with dhcp quite often, so i was really glad i found out about networksetup. The following snippet switches from the static to the dhcp profile, both of which i defined earlier in the network settings.
networksetup -setnetworkserviceenabled static off
networksetup -setnetworkserviceenabled DHCP on
This is a real time and sanity saver!

Thursday, March 3, 2011

New zsh Prompt

Spring's coming and it's time for a change. I have always liked the idea of colours in the prompt to make you aware of what kind of platform you are working on.  Stumbling upon this post inspired me and now here is my version for the zsh:

function cnprompt {
  set -A colours red green yellow blue magenta cyan #black white
  local col=${colours[$(hostname | cksum | cut -c2-6) % 6]}
  [[ -n "$SSH_CLIENT" ]] && local sig="%#%#" || local sig="%#"
  # i am thick at times; i need more warnings :P
  PS1="%B%(!.%F{red}root@.)%F{$col}%m%f%(?.. %??)%(1j. %j&.):%b %2~%B%(!.%F{red}.%F{yellow})$sig%f%b"
} 
Quick rundown:
  • first line sets up an array with the colours that make sense
  • second line computes an index into the colours array and sets col accordingly 
  • I check for whether I am on a local machine or logged in via ssh and double up the last sign
  • The main line sets a bold, coloured hostname preceded by a red root@. Then i print the exit code of the last command followed by number of backgrounded processes if any, both of which are a lot more helpful than i first thought. The whole thing ends with the last two dirs in pwd and the var set up in line 3
As for the formula, i ran

for host in list; do $((1+$(echo $host | cksum| cut -c1-2) % 6)); done 
to find the number combination that would cause the least overlap and gave the colours I preferred to the hosts I use most. I also tried using md5 instead or in addition to cksum but the spectrum it created seemed narrower.