“the j stands for Jilt”
about me | research blog | wordpress plugins | jQuery plugins

21 November, 2015

Fixing Apache, PHP, Pear and Haskell Platform after upgrading to OSX El Capitan

Another OSX upgrade, another long list of things that need to be manually fixed afterwards. This time it was even worse than the Mavericks upgrade.

Enable mod_rewrite and PHP in Apache

Uncomment the following lines in /etc/apache2/httpd.conf:

LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so

Also set AllowOverride All for <Directory "/Library/WebServer/Documents">.
Restart apache with:

sudo apachectl restart


I started with a fresh config file:

sudo cp -a /etc/php.ini.default /etc/php.ini

Then added timezone information:

date.timezone = "Europe/Stockholm"

Turn off SIP

  1. Reboot into recovery mode by pressing Command + R before the apple logo appears.
  2. Open up a terminal
  3. csrutil disable; reboot

Install PEAR & PECL Mongo driver

Install PEAR:

cd /usr/lib/php
sudo php install-pear-nozlib.phar

Then add this to php.ini:

include_path = ".:/usr/lib/php/pear"

Install XCode Command Line tools with:

xcode-select --install

Next I needed to install openssl through Homebrew. This took a few steps:

sudo chown -R $(whoami):admin /usr/local
sudo chown -R _mysql:wheel /usr/local/mysql/data
brew update
brew install openssl
brew link --force openssl

Before I could build the extension I also needed this (source):

cd /usr/local/lib
sudo ln -s ../../lib/libSystem.B.dylib libgcc_s.10.5.dylib

Finally I installed the PECL Mongo driver (legacy) with:

sudo pecl install mongo

Then enable in php.ini by adding:


And of course restart Apache again.

Haskell platform

I needed to recreate symlinks to Haskell platform programs inside /usr/local/bin.
This Stack Overflow answer explains how I did that.

Edit: After doing the above, GHC worked but whenever I tried to install anything in cabal I would get the error /usr/bin/ar: permission denied. After a lot of messing about, I had to clear everything Haskell-related and start over:

rm -rf ~/.cabal
rm -rf ~/Library/Haskell
sudo /Library/Haskell/bin/uninstall-hs all --remove
brew uninstall ghc cabal-install

And remove /Users/john/.cabal/bin from my path.
Then I installed GHC 7.10.2 and cabal from Homebrew and that seemed to work:

brew install ghc cabal-install

And add /Users/john/.cabal/bin back to my path.

Turn on SIP

Finally I turned SIP back on:

  1. Reboot into recovery mode again
  2. Run the following in a terminal: csrutil enable; reboot

21 October, 2014

Fix Apache & PHP after upgrading to OSX Yosemite

After waiting all night for OSX Yosemite to install, I finally booted into the new version of the OS… to find that Apache and PHP were no longer configured. Great. I remember a similar thing from the Mavericks update, so here is a list of the steps I followed to get things working again. Your results may very, but this may at least help.

  1. First you need to sort out the Apache config file /etc/apache2/httpd.conf, which has been reset to some default. Your old config file will be in the same directory, with some suffi like ~previous or .pre-update. In my case, I re-un-commented these lines:
    LoadModule rewrite_module libexec/apache2/mod_rewrite.so
    LoadModule php5_module libexec/apache2/libphp5.so

    I also needed to change AllowOverride None to AllowOverride Any in the <Directory "/Library/WebServer/Documents"> section.

  2. Then turn on Apache:
    sudo apachectl restart
  3. PHP’s config file has also disappeared, but again your old ones will be in /etc/ with some suffixes as above. In my case I started fresh with:
    sudo cp -a /etc/php.ini.default /etc/php.ini

    The only thing I added was:

    date.timezone = "Europe/Stockholm"

    Restart Apache again.

  4. Now I need to install PEAR. Clear anything named pear in your home directory, then:
    cd /usr/lib/php
    sudo php install-pear-nozlib.phar

    Then add the path where PEAR installed to php.ini:

    include_path = ".:/usr/lib/php/pear"
  5. I wanted to install the Mongo PECL package, which apparently requires the Command Line Tools, so:
    xcode-select --install

    And then finally I can install it:

    sudo pecl install mongo

    Add the following line to /etc/php.ini:


    Then restart Apache one more time.

5 September, 2014

De Gruyter fonts and LaTeX – the elusive DGMetaSerifScience.sty

I’m currently writing a paper which needs to conform to the De Gruyter format. The editor of the collection I’m submitting to asked us to use the Microsoft Word templates. Of course once you’ve used LaTeX there’s no going back to Word. De Gruyter themselves have on their website a LaTeX template which is freely downloadable and well documented.

The only issue is the fonts. De Gruyter have their own typeface family called De Gruyter Meta Science which looks very good and has great glyph coverage, but it is not free. Their guide explains that these fonts should be provided to you as an author by your editor. I asked, and I did in fact obtain these fonts in OTF format. Great. Except that to use them in the LaTeX template, you also apparently need some .sty files too. Quoting from the DeGruyter LaTeX template manual:

As already mentioned, dgruyter.sty checks whether the specific De Gruyter fonts are installed. More precisely, it checks whether a file DGMetaSerifScience.sty exists. If it exists, it presumes that the fonts DG Meta Science, DG MetaSerif Science, and the math font MinionMath are installed through the respective packages from De Gruyter. Otherwise errors will result.

The problem is, where do I get this .sty file from? I asked my editor, who sent me the fonts, but she had no idea about how to obtain them. After a lot of Googling and coming up with nothing, I decided to look into the details of the template file and try to figure out what this file should look like, so that I could create it myself. Turns out you actually need two .sty files which are almost identical, except in name. This is what I came up with for DGMetaScience.sty:


And an identical file called DGMetaSerifScience.sty where the package name is changed to reflect the file name. By having these files in the same directory as the rest of the LaTeX template I was able to successfully compile everything, and the result looks good. But who knows what else is contained in these elusive official .sty files, which I’ve omitted?


The De Gruyter fonts themselves are clearly protected and I’m not making any attempt on infringing that. All I’m doing is posting my guess of what I think the associated .sty files should look like, in the hopes that someone else can find this useful. Or perhaps someone who has a better idea of this stuff can tell me what’s missing from my versions.

5 April, 2013

The sad unreliability of Ubuntu One

I started using Ubuntu One more or less when it was first released. Admittedly it was pretty slow in the beginning, but they seemed to improve their speeds a lot and eventually I began to pay for extra space and use Ubuntu One exclusively for all my cloud syncing – some 3000 files from my entire Documents folder, and around 1,500 pictures. I used two Ubuntu machines and I thought U1 worked pretty well in making sure that I always had the most recent versions of everything on both machines.

I first noticed a problem with the syncing when by accident I noticed a that a folder which showed up on the U1 web interface was not on my computer. I tried various things to get this to work, trying all the command line options to u1sdtool, restarting, stopping/starting syncing etc. Eventually I wrote about it on Ask Ubuntu, and ended up getting in touch with U1 support. Their solution was to essentially clear all the cached syncing info on my machine and start again. Admittedly, this worked (although it did require that U1 scan and compare every single file again). I got the missing folder to sync, and everything seemed OK.

Things seemed OK for a few months. The a few weeks ago I got a new machine, a MacBook Pro. I still use Ubuntu at work, and since there is a U1 client for OSX I thought there should be no problem in continuing to use Ubuntu one for my syncing. This is when things really started going downhill. The initial sync on my Mac worked fine – I mean essentially it’s just downloading everything, pretty straightforward. But then I began to notice that some changes made would not get noticed by U1. Say I would delete a file from my Mac, but it would still appear in the web interface even though the U1 client would tell me that everything was up-to-date. This is really when I began to stop trusting it. Again I would try all the command line options for refreshing the sync folders, nothing. When I contacted U1 support again, they just had exactly the same solution – delete the caching data and re-sync. I did, it took it’s time to re-check every single file, and again things seemed OK again. But then I would add/delete some other file and notice that again that Ubuntu One would fail to notice them. There are things you can do to force it to notice the changes, like restarting the computer or un-checking and re-checking the “Sync locally” checkbox inside the client. But that defeats the whole purpose.

To make things worse, I’m also starting to notice this same erratic syncing behaviour from my Ubuntu machine too. And now I have absolutely no idea if there even exists a single complete version of all my files, anywhere. It feels like every computer I used U1 has some copy of my files, but is never 100% complete/updated. It’s a mess. There’s just too many files to check manually. I have backups, and I hope that when I look for a file and find that Ubuntu One has lost it, I can find it by digging into these backups. But that’s hardly a solution.  I absolutely cannot trust Ubuntu One anymore.

But I still want a cross-platform syncing solution. iCloud doesn’t have an Ubuntu client (and I haven’t heard good things about it anyway). Neither does Google Drive, although they keep promising one “soon”. Dropbox has clients for both and is starting to look like a real viable alternative now. I guess it’s popularity compared to U1 will mean it’s more reliable. But it’s going to take some work to move everything over, and I really want to avoid switching.

15 February, 2013

Determinate and indeterminate noun plural forms

Maltese nouns have two potential plural forms, determinate and indeterminate. The distinction is exhibited in examples such as:

English Singulative Determinate plural Indeterminate plural
road triq triqat toroq
tooth sinna sinniet snien

However it seems that in reality there are very few nouns which actually have both forms. An analysis of the 184 nouns in the GF Resource Grammar Library mini-lexicon shows that:

  • 14 (~7%) have both forms, though I would argue that many of these sound kind of arcane, e.g. ġbiel (ġebliet), xgħur (xagħariet), għejun (għajnejn).
  • 158 (~86%) have just a determinate plural
  • 3 (~1%) have just an indeterminate plural
  • 9 (~5%) have neither plural form. This is usually compensated by a collective form (e.g. baqar), a dual (e.g. riġlejn) or simply a singulative (e.g. plastik).

While this distinction can have some linguistic importance, for the purposes of the GF implementation will be simplified slightly, by storing only one plural form. This change will be made internally in the noun representation, so that the paradigm constructors are not affected and as such we still have this information available (although it is just being ignored for our purposes).

Another solution is to have indeterminate plural forms stored simply as variants of the determinate plural. I think that in most cases one could get away with this, though for now I am steering clear of all variant just to keep testing simple.

20 January, 2013

Removing inferred roots from verb smart paradigms

In the Maltese resource grammar implementation I had some code which tried to extract the radicals from a so-called mamma verb form. So for example:

classifyVerb "ħareġ"

would give (amongst other information) the radicals Ħ-R-Ġ in record form. This works well most of the time, except for cases where it is completely impossible to guess the missing radicals from weak-root verbs. For example, dar is actually the mamma of two distinct verbs, one with root D-W-R and another with D-J-R.

The usual way of dealing with this is to have a less-smart fallback in your paradigm, which takes an explicit root in such ambiguous cases. But the reality is that in this case we don’t even need the smarter version of the paradigm. The set of root-and-pattern verbs in Maltese is a closed set, so there are no new such verbs being added to the language (all new verbs are today added as loan verbs). Furthermore, this list has already been compiled by Michael Spagnol is his PhD thesis, and we even now have it in database form here. I am using this to directly build a monolingual Maltese verb database in GF, and since I already have the radicals for all these verbs, there really is no need at all to try and determine it automatically in a smart paradigm. As my professor Aarne Ranta likes to say, “don’t guess what you know.”

Changing the verb implementation

Perhaps I saw the signs earlier than I would like to admit, but it has become clear now that my current implementation of Maltese verb morphology in GF has taken the wrong direction and needs to be significantly re-written. Having an inflection table with close to 1000 forms is not just a headache implementationally, but also arguably not linguistically accurate either.

So the new plan, which is what is done in the implementations for Italian and Finnish, so to remove pronominal suffixes from the verb’s inflection table, and instead use binding on the syntax level to produce these forms. Reducing the inflection table is the easy part, but getting the rest to produce correct results might be tricky since the stem sometimes changes depending on the pronoun being suffixed.

So anyway I have created a new branch to work on this, so that at any point I can switch back to the original implementation if I want to compare something or if I end up wanting to use that approach again.

11 January, 2013

Markdown, Pandoc and GitHub

I love writing in Markdown, and in general I try to always write in Markdown and then convert into HTML/TeX. Pandoc is a fantastic tool for converting from Markdown to other formats, and since it is so versatile I would like to use it for everything. I also use GitHub a lot, which has an automatic renderer for Markdown documents.

Unfortunately, Pandoc’s Markdown (PM) and GitHub Flavored Markdown (GFM) are not identical, and I find myself constantly torn between the two, trying to satisfy both. I typically have some code repository hosted on GitHub, with at least one main readme file written in Markdown format. When browsing the repository through the GitHub website, this readme file is automatically converted to HTML. Since this is often the first and only documentation for my code, it is important to me that it renders correctly.

I often want to also convert my Markdown document locally into a self-contained HTML file, and sometimes TeX too, and for this Pandoc is just the best. But herein begin the differences in syntax support:


GFM likes “pipe-tables”, as defined in Markdown Extra:

| Item      | Value |
| --------- | -----:|
| Computer  | $1600 |
| Phone     |   $12 |
| Pipe      |    $1 |

However the latest releases of Pandoc (1.9.x) support a bunch of other table types, but not pipe-tables. The latest Pandoc (1.10.x) does thankfully support them, so my current solution is to use the development version of Pandoc and compile from source. This means my Makefile might not be portable, but at least I know it works me (though arguably maybe I shouldn’t depend on Pandoc in the first place).

Definition lists

Quite simply, GFM does not support definition lists. However they are defined in Markdown Extra like so, and Pandoc handles them like champ. At least GFM tends to degrade gracefully in this case, so definition lists don’t bother me too much.

Pre/post code

When building a standalone HTML or TeX file, you will definitely need to include some before and after code around your actual content. You could have completely separate files for this, and then glue them together in a Makefile. But sometimes this seems like overkill for a simple </body></html>, and I just want to stick them at the bottom of my Markdown file and be done with it. In fact GFM will happily ignore HTML tags, but will still display the content of something like <title>Hello!</title>. And if you try to include some TeX code it only gets worse.


Maybe it’s my fault for trying to expect too many different things from a simple language. But with a Master’s thesis looming, I’m currently thinking out my writing options. While I love the idea of writing in Markdown and using Pandoc to convert to TeX, this lack of standard really bothers me and I can’t help wondering if I might be safer with something like txt2tags, which my professor swears by.

23 October, 2012

Pronominal suffixes and transitivity

The verb morphology I am currently working on for Maltese definitely suffers from over-generation, in particular when it comes to derived verbs and pronominal suffixes. Derived verbs are often intransitive and interpreted as reflexive or passive, which makes the addition of direct object suffixes to them very awkward.

For example, take the root W-Ż-N in the first (underived) form: wiżen “he weighed”.
Adding some pronominal suffixes we get wiżnek “he weighed you”, wiżinlek … “he weighed … for you”, and wizinhomlok “he weighed them for you”.

So far so good, but let’s now look at the seventh derived form of this root: ntiżen “he was weighed”.
Appending an indirect object pronoun is fine: ntiżinlek “he was weighed for you”. But when we try with a direct object it ceases to make sense, e.g. ntiżnek and ntizinhomlok. The reflexive meaning taken on by this derived verbs means direct object pronouns no longer make any sense when attached to the verb (even when in combination with an indirect object pronoun).

The problem is that I currently don’t know if these cases are detectable on a morphological level. In other words, if seventh form verbs never have any direct object pronouns attached then it is very simple to fix the over-generation, but it’s still a little early for me to tell whether such a general exclusion can be made.

18 September, 2012

A MySQL Unicode collation for Maltese

If you’ve tried to store and retrieve Maltese text in a MySQL database before, you may have noticed that there is no way to sort it correctly according to the Maltese alphabet.

The  utf8_unicode_ci collation treats g and ġ etc. as interchangeable but that is of course not right. You can try utf8_bin, but since this sorts according to Unicode codepoints, ċ, ġ, ħ, ż get sorted after the letter z — which is even worse (although it does at least mean you can search for ħ without getting h back too).

What you really need is a custom collation for the Maltese alphabet. There isn’t one built-in, but luckily MySQL makes adding custom collations relatively painless. So I went ahead and implemented such a collation for Maltese, and called it utf8_maltese_ci. You can find the code, along with detailed installation and usage instructions at the GitHub repository for the Maltese MySQL collation.

Newer Posts »