(English) Efficient algorithm for finding incorrect transactions in double-entry bookkeeping

Aquestra entrada només està disponible en English.

Posted in Uncategorized | Leave a comment

(English) Managing short-term lending with two-way YNAB

Aquestra entrada només està disponible en English.

Posted in Uncategorized | Leave a comment

(English) How to build PeaZip installer for Windows

Aquestra entrada només està disponible en English.

Posted in Uncategorized | Leave a comment

(English) git error: unable to create file (Invalid argument)

Aquestra entrada només està disponible en English.

Posted in Uncategorized | Leave a comment

(English) Moodle sending text files with incorrect text/html MIME type

Aquestra entrada només està disponible en English.

Posted in Uncategorized | Leave a comment

(English) Grub2: Boot Windows by default

Aquestra entrada només està disponible en English.

Posted in Uncategorized | Leave a comment

(English) Setting contact's group in Android 2.3 Gingerbread

Aquestra entrada només està disponible en English.

Posted in Uncategorized | 1 Comment

(English) Irrefutable proof: two spaces after a period on the web is evil

Aquestra entrada només està disponible en English.

Posted in Uncategorized | Leave a comment

(English) Windows-7–like window management with Ubuntu (and Compiz)

Aquestra entrada només està disponible en English.

Posted in Uncategorized | Leave a comment

(English) Check HTTP headers (specifically MIME type) for file downloads

A client called us up saying they had problems downloading files from our e-learning portal. After some back and forth on the phone I found out the problem was their browser and/or MIME types. Either the MIME type wasn't being set correctly or their browser was ignoring it. In any case the consequence was that the byte stream was being output to screen as garbled (Greek numbers, according to the client) text.

I wanted to check the HTTP headers the URL was returning, to make sure we were in fact setting the MIME type. Firebug shows the headers in the console and net tabs. In this case they weren't being displayed though, as the URL was initiating a download. Slightly stumped, I thought for a minute and remembered cURL.

I've never used cURL, but have read much of it. I guessed it could maybe do the trick, so I set about finding out. After a cursory search I found out that

 $ curl -I -H http://URL

Would return the headers for the requested URL. The URL I was trying requires cookie-based authentication, though. After reading the manual I managed to log in via cURL, save the cookies in a text file, then request the file using the cookies to authenticate:

First I POSTed to the login form's action URL with the necessary parameters, while saving the cookies generated by the POST to a text file. Then, using the text file I requested the file URL and, voilà, got what I needed.

$ curl -c cookies.txt -L -d "username=<USER>&pass=<PASS>" http://URL/login.php
$ curl -c cookies.txt -b cookies.txt -L -I http://URL/file.pdf
Posted in Uncategorized | Tagged | Leave a comment