jump to navigation

Travel, and how it hurts sometimes 2016 May 7 10:00

Posted by diamond in : Random , add a comment

I’m currently in Turkey for a week, on holidays with Saskia. As Saskia was flying in from germany, I was travelling solo yesterday. Here’s a list of things that went well:

Here’s a more free-form description of things that didn’t go so well:

The flight had been rescheduled to be 90mins later, so instead of landing at 22:15, i was now meant to land at 23:45, and be at the hotel well after midnight.

The flight turned out to be full of families with young kids. The kid behind me was probably about 3, and threw a tantrum (full volume screaming and seat kicking) when the flight attendant insisted that his parents switch off his ipad. This sort of thing made the 3h flight seem even longer.

We landed at 23:30, slightly ahead of (the updated) schedule. I walked quickly to passport control, eager to get to the hotel. After queuing for 10 minutes, the officer informed me that as i was irish, i needed a visa. I hadn’t figured this, as i knew that sassi didn’t have a visa, but it turns out that .ie is in a different category than .de. With a sinking feeling, i head over to the visa office he waved at.

Arriving at the visa counter, i can see a guy sitting on a couch in a back room. I can’t tell what he’s doing, and after trying a timid ‘hello’ through the window, i conclude that he’s ignoring me due to being on a break or something. After standing around for 5 minutes, a cleaning lady comes by, notices my predicament, and proceeds to bang on the window and shout at the guy until he wakes up. Turns out he was having a nice nap.

The visa price is relatively low, 25EUR, payable in USD/EUR/GBP, cash only. Oh dear. All i had was swiss francs, and credit cards. Nope. There’s no bank on this side of immigration, the currency exchange shop next door is shut as it’s now midnight. Welp.

Visa guy looks at my ticket stub, and goes to call someone. He comes back to report that “personnelle is coming”. Waiting, waiting, no-one shows up.

Eventually another passenger comes up to buy a visa. He also tries to pay with credit-card, but is able to go get 50EUR from his family to pay. As he has 25EUR change (exactly what i desperately need), i nervously step in to ask if he can help. His first response is “Hey, i have a family to take care of”. I offer him 50CHF (~45EUR) for his 25EUR, and that i’ll give him EUR once i can get to an atm on the far side. He’s clearly very unsure, and eventually relents, saying “I really hope i’m not being ripped off”. We agree to meet on the far side of passport control.

This time it takes 15 minutes to get through the queue. The guy who lent me the EUR is gone, presumably needing to get his family somewhere as it’s well after midnight.

I arrive at the baggage claim area, and discover that as it’s been about 50mins since we landed, that my flight is no longer listed. I go to the lost & found, only to be redirected to another office at the other end that deals with my airline.

The guy there is confused for a minute, asks me did i check the belt. When i explain i can’t even tell which belt to look at, he understands and comes out with me. Fortunately my suitcase was still on the belt.

I take my suitcase and hurry out the door, desperately hoping that customs don’t decide to add to this trainwreck of an evening. Fortunately they didn’t (but i don’t know why, as i would have looked nervous and shady as hell by this point).

I scurry over to the travel operator to catch the bus. Except the bus is long gone. It’s now over an hour since the plan landed. They held the bus up for ages, waiting for me, but eventually people (understandably) got upset at the delays, and insisted on going.

I apologise a lot, and ask when the next bus will be. 2am, another 90 minutes of waiting around. Oh hell no. Turns out a taxi will cost 15EUR, oh fuck yes please.

I still need cash to pay for the taxi, so i withdraw 100EUR from an atm (2x 50EUR notes), and get put into a taxi after waiting around a few minutes.

On the way to the hotel, i see at least 5 police cars stopped along the way, with flashing lights. Some of them have clearly pulled cars over. Please please please not me.

We pull up to the entrance to the hotel, and the security guard comes out. He asks for my passport, i had it over, he says no. He asks for my luggage tag, i hand it over, he says no. He asks for the name of the hotel, while we’re sitting in front of a 4m sign with the hotel name on it. I’m bewildered at this point, and say the hotel name. No. He then asks for my voucher. I frantically search my bag, and hand over a bunch of docs i’d gotten. “Welcome to the hotel!”. Thank fuck.

The taxi pulls up at the front door and unloads my luggage. I hand the driver a 50EUR note, and he says that he can’t give change. I don’t have change. I have squat. So i say fuck it, keep the change. He looks confused, but accepts it after a minute.

I had some turkish lira and EUR in my suitcase, but i thought it was only about 12EUR in total. Turns out, i had 25 in euro notes alone (which i couldn’t use for the visa, as i couldn’t get to my baggage). I could have paid him the correct amount, i was just so damn exhausted and stressed i never though to check. So i effectively paid 45EUR for a 25EUR visa, and 50EUR for a 15EUR taxi ride. But at least i was finally there.

***Edit***
Oh yeah, forgot a thing – when i went to the atm, my withdrawl was refused by my bank. Fortunately my credit card worked :/

flock vs fcntl 2014 November 18 12:46

Posted by diamond in : Tech , add a comment

Both flock(2) and fcntl(2) can create advisory locks on unix. What i hadn’t realised, until it bit me this morning, is that the semantics are subtly different. flock() creates a lock at the open file table level. fcntl() creates a lock at the file region level. This means that if you open a file twice, flock() will treat both FDs independently, whereas fcntl() treats them as being the same thing. Here’s a demonstration using python.

First, fcntl() (note that fcntl.lockf uses fcntl() underneath):


Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import fcntl
>>> a=open("/tmp/testy", "w")
>>> b=open("/tmp/testy", "w")
>>> fcntl.lockf(a, fcntl.LOCK_EX | fcntl.LOCK_NB)
>>> fcntl.lockf(b, fcntl.LOCK_EX | fcntl.LOCK_NB)
>>>

Second, flock():

Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import fcntl
>>> a=open("/tmp/testy", "w")
>>> b=open("/tmp/testy", "w")
>>> fcntl.flock(a, fcntl.LOCK_EX | fcntl.LOCK_NB)
>>> fcntl.flock(b, fcntl.LOCK_EX | fcntl.LOCK_NB)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 11] Resource temporarily unavailable
>>>

The reason i came across this was i was trying to write unittests around some locking code, and couldn’t figure out why opening the same file twice and locking both FDs never failed. Eventually i spotted that flock() was working while fcntl() was not, and careful reading of the manpages indicated why :)

Mark irssi window as unread 2013 September 24 16:00

Posted by diamond in : Tech , add a comment

Someone messages me on irc/im, i change to the irssi window, see that it’s something i want to leave for later, then promptly forget about it. This has been happening for many years. Today, it finally ends. I present unread.pl, a tiny irssi script that allows me to mark windows as unread:


$ cat unread.pl
#!/usr/bin/perl -w
 
sub cmd_unread {
my ($data, $server, $witem) = @_;
my $base = Irssi::window_find_refnum(1);
my $target;
 
if ($data eq "") {
$target = Irssi::active_win();
$base->set_active();
} else {
$target = Irssi::window_find_refnum($data);
}
 
$target->activity(4);
}
 
Irssi::command_bind("unread", "cmd_unread");

If given no argument, it marks the current window as unread and switches to window 1. Otherwise it just marks the specified window as unread.

Google chrome per-workspace profiles

Posted by diamond in : Tech , add a comment

Do you use chrome and find it irritating that when you click on a link outside of the browser, it’ll just use whatever chrome window you last had active? I sure do. Here’s my fix for gnome classic:

1) A custom launcher script that detects which workspace i’m on, and decides which browser profile to send the request to:

$ cat bin/google-chrome-launcher
#!/bin/bash
workspace=$(xprop -root -notype _NET_CURRENT_DESKTOP | sed 's/^.* = //')
profiledir=""
 
case "$workspace" in
0) profiledir="Default";;
1) profiledir="Profile 1";;
esac
 
if [ -n "$profiledir" ]; then
exec google-chrome --profile-directory="$profiledir" "$@"
else
exec google-chrome "$@"
fi

2) A custom .desktop to invoke my custom script:

$ cat .local/share/applications/google-chrome-custom.desktop
[Desktop Entry]
Version=1.0
Name=Google Chrome Custom
Exec=google-chrome-launcher %U
Terminal=false
Icon=google-chrome
Type=Application
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml_xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;

3) Make this the default. Gnome Classic/Fallback being the horrible hybrid broken beast that it is, i could find no gui way of doing this, so i simply edited ~/.local/share/applications/mimeapps.list and changed every occurrence of google-chrome.desktop to google-chrome-custom.desktop, and that seemed to do the trick.

I’ve found a new bio one-liner 2011 May 9 18:41

Posted by diamond in : Random , add a comment

A friend of mine, Tobias, when asked to describe me in one line came out up with this gem:

“He’s the reason babies cry when they’re born.”

This is hands-down the best thing that’s ever been said about me.