Pizza recipe

August 16, 2008 | Filed Under Uncategorized | Leave a Comment 

My pizza dough recipe is based on a recipe that I found on foodtv.ca called “Backyard Pizza Dough”. I can’t find a link to the original page. The original recipe called for 1 tbsp of salt which I believe to be far too much, I only use 1 tsp.

The ingredients:


In a large bowl mix together the water, yeast, sugar, and milk. Leave it for 5-10 minutes until the yeast starts to make things foamy.

Slowly mix in the flour using a wooden spoon. Don’t try to get the whole 2.5 cups in! Keep going until you have a fairly wet dough, then transfer to a lightly dusted surface and knead for a few minutes. The dough will be rather tricky to work with.

Cover with gladwrap and let rise until double in size. Punch down, cover, and leave to rise again.

Preheat oven to 200C.

Prepare toppings. Lightly oil a baking tray and dust with flour.

Pop the pizza in and immediately turn the oven down to 180C.

Cook until the base is just slightly golden.


An example:

[photo]


[photo]


[photo]




Foreign Police registration in Prague

March 24, 2008 | Filed Under Prague | Leave a Comment 

I have dual citizenship (Finnish and Australian). I recently registered with the Foreign Police here in Prague, and also applied for a temporary residence permit for my partner (an Australian citizen). I found it difficult to get an accurate list of which documents were necessary for the application, so I wrote up my experience here in the hope that it will help other people in the same situation.

Disclaimer: this is only my personal experience. Your situation may be different!

Required documents

We entered the Czech Republic on 90 day tourist visas in January 2008. In March 2008 we went to the office of the Foreign Police in Prague and submitted our application for temporary residency. Here is a list of what I assembled:

My wife, as an Australian citizen provided:

Notes

Once we had the right forms and documents together, the actual application process was straightforward. Total time spent in the office (waiting and submitting the application) was under an hour (but make sure you pick the right ticket from the machine at the door!). Some companies here play on the fear that all expats have regarding Czech bureaucracy, and I’ve heard of people paying hundreds of dollars to have an agency submit the paperwork for you. If you are an EU citizen or the family member of an EU citizen then these agencies are not necessary.

Useful links

Information about Residency for Citizens of the European Union and Their Family Members in the Czech Republic.

Advice for living in the Czech Republic.

Application forms. Scroll down to Cizinci (foreigners). An EU citizen applying for temporary residence of his/her family needs two forms:

Addendum 1

Be warned that picking up your residence permit can take a long time. We picked up ours and the process took a bit over 5 (five) hours. Around 4 hours was spent in a queue, simply waiting, and the last hour or so was spent waiting for the actual permit to be printed. Bizarrely they don’t actually print your residence permit until you turn up to collect it. This wastes everyone’s time.

The Foreign Police here in Prague could solve the problem of huge waiting times using some fairly basic techniques (book appointments for people, accept online applications, use temp staff to deal with busier periods, provide basic and correct information in English). In the mean time, take a good book.

Addendum 2

I accidentally deleted a reader’s question on how long it took for the Foreign Police to prepare our permits. The answer: the Foreign Police never sent anything saying that our permits were ready to be picked up, we were just told to come back two weeks after making the initial application.

Addendum 3

I’ve recently heard that people have had to wait anything up to 3 months to pick up their residence permits, so take my advice here with a grain of salt.



Cython vs C++

March 4, 2008 | Filed Under sage | 3 Comments 

In a comment on a recent post, Robert Šámal asked how Cython compares to C++. The graph below shows a comparison of a greedy critical set solver written in Cython and C++ (both use a brute force, naive, non-randomised implementation of a depth first search):

So things look good until n = 10. In defence of Cython, I must point out that my implementation was a first attempt and I am by no means an expert on writing good Cython code. Also, the Cython code is probably fast enough - in my experience, solving problems (computationally) for latin squares of order 10 is futile, so the code is more convenient for testing out small ideas.

edit: the code is here



An exact cover solver for Sage

March 1, 2008 | Filed Under sage | Leave a Comment 

For a while now I’ve been using my own C++ implementation of Knuth’s Dancing Links algorithm. The algorithm is quite fast for solving the 0-1 matrix exact cover problem. More importantly, a number of other combinatorial problems can be converted into an exact cover framework, such as finding latin square completions, enumerating latin bitrades, and computing the chromatic number and chromatic polynomial of graphs (those last two are from comments by Tom Boothby on the sage-devel mailing list).

The thread started by Tom inspired me to make my code public, license it with GPL, write a few doctests, and learn the necessary Cython to write a wrapper for my C++ code so that it would be usable from Sage. The code is available here, in particular dancing_links.sage (top level Sage wrapper), dancing_links.spyx (Cython code that calls my C++ code), and finally dancing_links.cpp (the actual solver).

Not surprisingly, the C++ version is a fair bit faster than the Python implementation adapted by Tom when used as a latin square solver for finding “greedy” critical sets:

x-axis: n, y-axis: number of seconds to compute the greedy critical set of B_n (addition table for Z_n), blue is Python, red is C++.



ssh socks proxy

February 20, 2008 | Filed Under computing | Leave a Comment 

I recently discovered that OpenSSH has a built in SOCKS proxy. This is really handy for browsing the net from another computer. In my situation I need access to sites like MathSciNet and JSTOR. My university has a subscription so I need to appear to be browsing the net from a certain IP address.

From my home computer I can do:

$ ssh -ND 9999 carlo@my-uni-computer

(after logging in no shell is given due to the -N option)

Then in Firefox I set the proxy to use SOCKS host localhost at port 9999. That’s it. Firefox plugins like FoxyProxy or SwitchProxy make switching the proxy setting quick and easy.

You can also use this to browse securely from a public wifi access point, avoid stupid web proxies, etc.



pyx-0.10 experimental package

February 17, 2008 | Filed Under sage | Leave a Comment 

PyX is a Python package for the creation of PostScript and PDF files. It seems like a more modern alternative to MetaPost so I was keen to try it out. I found that the experimental pyx-0.8.1 package in Sage 2.10 did not work (errors about a DVI file not finishing) so I created a Sage source package of the latest version: pyx-0.10.spkg.

Download that package and then do sage -i pyx-0.10.skpg to install it.

Here is the standard Hello World example (look for hello.pdf in your working directory):

import pyx x = y = int(0) c = pyx.canvas.canvas() c.text(x, y, “Hello, world!”) c.stroke(pyx.path.line(x, y, x+5, y+0)) c.writePDFfile(”hello”)

The previous pyx spkg tried to put the pyxrc file into /etc but I prefer to run Sage as a normal user, and sudo-ing to install a package isn’t completely straightforward (you have to set some environment variables, so it’s not newbie-friendly). I made my spkg-install file put pyxrc into $SAGE_LOCAL/etc but I’m not sure if this is a suitable location. Any suggestions?

edit: On the sage-devel mailing list I was told to use ~/.sage so I have ammended the pyx-0.10 package to do this.



Speeding up code using Cython

December 18, 2007 | Filed Under Uncategorized | 2 Comments 

The graph below compares a brute-force depth first search in Sage/Python (red line) to an implementation of the same algorithm in Cython (blue line). Vertical axis is run time in seconds, horizontal axis is number of latin square completions generated:

Cython does pretty well, and the code is far more readable than the earlier C++ version that I wrote.

For more about writing Cython code in Sage, see Chapter 5 of the documentation.



Using ‘yield’ to simulate a Markov chain

December 16, 2007 | Filed Under sage | Leave a Comment 

One thing that I really like about Sage is that it uses Python as its underlying language. This means that we get “for free” many nice features of Python. One of these features that I particularly like is the yield keyword. Here is a small example:

def foo():
    i = 0
    while True:
        yield i
        i = i + 1

We can use the foo function as a generator:

sage: g = foo()
sage: print g.next()
0
sage: print g.next()
1
sage: print g.next()
2

In other words, the yield keyword acts as a way to a Python function into a generator. The execution of foo is paused until the next call to g.next(). If we reach the end of the function, the StopIteration exception is raised.

The yield keyword makes it pretty easy to write the skeleton for a Markov chain simulator, using the following basic form:

def markov_chain():
    state = initial_state()
    while True:
        yield state

        state = new_state(state)

        if some_condition: return

For a real example, see the latin_square_generator function in latin.sage which is part of a small library for latin square manipulations in Sage. The Markov chain itself was given by Jacobson and Matthews in “Generating uniformly distributed random Latin squares,” Journal of Combinatorial Designs, vol 4, 1996, no 6, pp 405–437.



MetaPost Examples

December 11, 2007 | Filed Under LaTeX | Leave a Comment 

Introduction

My favourite package for drawing diagrams is MetaPost. Here’s an example, taken from my PhD thesis:

Metapost diagram

The best page for examples is the one by (La)TeX Navigator.

Compiling with LaTeX fonts

Normally MetaPost uses TeX to compile but it is nicer to have access to LaTeX fonts/symbols/etc. To do this put the following at the top of your MetaPost file:

verbatimtex
\documentclass[12pt]{article}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}

\begin{document}
etex

Then set the TEX environment variable and compile. For example, in Bash, you could do:

$ export TEX=latex && mpost case1.mp

My examples

Here are all the MetaPost diagrams from my PhD thesis. There are a few duplicates and some dodgy code, I make no claim of being an expert in MetaPost.

metapostexamples.pdf

Browse files

All files in a compressed tar archive

Metapost to PDF

A few of my Metapost files use the following TEX function (copied from here):

vardef TEX primary s =
   write "verbatimtex"                    to "mptextmp.mp";
   write "\documentclass[12pt]{article}"  to "mptextmp.mp";
   write "\usepackage[T1]{fontenc}"       to "mptextmp.mp";
   write "\usepackage{amsmath,amssymb}"   to "mptextmp.mp";
   write "\begin{document}"               to "mptextmp.mp";
   write "etex"                           to "mptextmp.mp";
   write "btex "&s&" etex"                to "mptextmp.mp";
   write EOF                              to "mptextmp.mp";
   scantokens "input mptextmp"
enddef;

The command mptopdf seems to have trouble with the temporary file mptextmp.mp. In particular I got this error when doing mptopdf bug.mp:

This is MetaPost, Version 0.901 (Web2C 7.5.5)
(/usr/share/texmf-texlive/web2c/natural.tcx)
(bug.mp (mptextmp.mp
>> mptextmp.mp
>> mptextmp.mpx
! Unable to make mpx file.
l.5 btex
         1 etex
Transcript written on bug.log.
 error in metapost run : bug.mp:5

        total run time : 0 seconds

MPtoPDF 1.3 : error while processing mp file

On the other hand, this seems to work:

mpost bug.mp
mptopdf bug.1

I’m not sure why this is the case - is this a bug or just undocumented behaviour?

Other stuff

MetaFun looks good. It’s also worth checking out what other peope have tagged as metapost on del.icio.us.



Installing Minion Pro fonts

December 11, 2007 | Filed Under LaTeX | Leave a Comment 

Introduction

This post describes how to install Minion Pro fonts on Ubuntu 7.04/7.10. It should work for any modern Linux distribution with TexLive.

We will install to /usr/local/share/texmf. Check that this matches the definition of TEXMFLOCAL in your installation:

$ kpsexpand '$TEXMFLOCAL'
/usr/local/share/texmf

It is vital that you install to the right path in /usr/local.

Install mnsymbol

Click on mnsymbol and download the entire directory as mnsymbol.zip.

unzip mnsymbol.zip
cd mnsymbol/tex
latex MnSymbol.ins
mkdir -p /usr/local/share/texmf/tex/latex/MnSymbol/
mkdir -p /usr/local/share/texmf/fonts/source/public/MnSymbol/
mkdir -p /usr/local/share/texmf/doc/latex/MnSymbol/
cp MnSymbol.sty /usr/local/share/texmf/tex/latex/MnSymbol/MnSymbol.sty
cd ..
cp source/* /usr/local/share/texmf/fonts/source/public/MnSymbol/
cp MnSymbol.pdf README /usr/local/share/texmf/doc/latex/MnSymbol/
mkdir -p /usr/local/share/texmf/fonts/map/dvips/MnSymbol
mkdir -p /usr/local/share/texmf/fonts/enc/dvips/MnSymbol
mkdir -p /usr/local/share/texmf/fonts/type1/public/MnSymbol
mkdir -p /usr/local/share/texmf/fonts/tfm/public/MnSymbol
cp enc/MnSymbol.map /usr/local/share/texmf/fonts/map/dvips/MnSymbol/
cp enc/*.enc /usr/local/share/texmf/fonts/enc/dvips/MnSymbol/
cp pfb/*.pfb /usr/local/share/texmf/fonts/type1/public/MnSymbol/
cp tfm/* /usr/local/share/texmf/fonts/tfm/public/MnSymbol/

Regenerate the indexes and enable MnSymbol:

mktexlsr
updmap-sys --enable MixedMap MnSymbol.map

You should be able to compile mnsymbol-test.tex with no errors.

Install the MinionPro package

We will need a few files from here: http://www.ctan.org/tex-archive/fonts/minionpro/.

Download scripts.zip and unpack it:

mkdir minionpro-scripts
cd minionpro-scripts
unzip ../scripts.zip

Copy your OTF fonts into the local directory.

find /youradobefonts/ -iname '*minion*pro*otf' -exec cp -v '{}' otf/ ';'

Hint: Adobe Reader ships with some Minion Pro fonts.

Make sure you have the latest version of lcdf-typetools and then convert the fonts:

sudo apt-get install lcdf-typetools
./convert.sh 

Install the fonts:

mkdir -p /usr/local/share/texmf/fonts/type1/adobe/MinionPro/
cp pfb/*.pfb /usr/local/share/texmf/fonts/type1/adobe/MinionPro/

Determine which version of the Adobe fonts you have. For example, I have the “002.000″ family:

$ otfinfo -v ~/Desktop/minionpro-scripts/otf/MinionPro-Regular.otf 
Version 2.015;PS 002.000;Core 1.0.38;makeotf.lib1.7.9032

You need to download one of the following encoding files:

Version | Encoding file
------------------------
001.000 | enc-v1.000.zip
001.001 | enc-v1.001.zip
002.000 | env-v2.000.zip

The last few steps:

cd /usr/local/share/texmf
unzip ~/Desktop/metrics-base.zip
unzip ~/Desktop/metrics-full.zip
unzip ~/Desktop/enc-X.XXX.zip        (pick your version)

Edit /etc/texmf/updmap.d/10local.cfg and add the following line:

Map MinionPro.map

Regenerate all indexes:

mktexlsr
update-updmap
updmap-sys 

You should see a line like this:

updmap-sys: using map file `/usr/local/share/texmf/fonts/map/dvips/MnSymbol/MnSymbol.map'

You should now be able to compile minionpro-test.tex with no errors.

You might see this error on large documents:

Font OMS/MnSymbolS/m/n/17.28=MnSymbolS12 at 17.28pt not loaded: Not enough room left.

Edit /etc/texmf/texmf.d/95NonPath.cnf and change

font_mem_size = 500000

to

font_mem_size = 5000000

or some other large value. Then run

update-texmf


Next Page →