.htaccess, document root and Zend Framework

2008-10-29

It’s funny but I couldn’t find anyone having this issue. It certainly isn’t limited to Zend Framework, it affects everyone who doesn’t have access to apache configuration and wants to have document root in a deeper directory. Maybe I just can’t google very well.

Imagine a shared host. You can’t choose your document root, it’s firmly set to one particular directory. Now you want to install Zend Framework. Imagine you’d like to follow the standard directory structure (that means you more or less have these directories in your project: application (the application), library (zend and other libraries) and public (stuff accessible from the outside, images, css etc.)). Normally, you’d want to point your document root to the public directory, but when you can’t do that you can use .htaccess in the project directory to redirect everything to public.

RewriteEngine On
RewriteRule !.(js|gif|jpg|png|css|txt)$ public/index.php [L]
RewriteRule ^(.)$ public/$1 [L]</code></p> <p>This was the first thing I wrote, and it works on <strong>certain</strong> servers. Other servers will kindly remind you that <em>"Request exceeded the limit of 10 internal redirects due to probable configuration error."</em> Which kind of makes sense when you think about it. Makes me wonder how comes the above code actually worked on two different configurations.</p> <p>Now here's the code that works (and in my humble opinion it also <strong>should</strong> work, as opposed to the one above):</p> <p><code lang="apache">RewriteEngine On<br /> RewriteRule !\.(js|gif|jpg|png|css|txt)$ public/index.php [L]
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.
)$ public/$1 [L]

And finally a disclaimer: I am not sure about the security implications. If someone knows more about possible security issues with this, please do leave a comment.

How I Met Your Mother

2008-10-21

I’ve never really watched any television series. Sure, I saw an episode or two of many various series, but it never quite felt worth spending more time on them. This summer I was shown 4 episodes of HIMYM.

I tried to resist for a while, because I consider television series to be a waste of time (and time is the most precious for me). But after few weeks I just gave up and started watching the series from the start. And even though I “wasted” about 24 hours of my life, I don’t regret it.

Also, my opinion of Tuesdays has increased dramatically since I started watching HIMYM. Today’s episode (S04E05 as they say, or “Shelter Island”, if you prefer the full name) was simply perfect. There was a little bit of everything, silly jokes, profound jokes, back references, sad moments, life lessons, you name it.

Happy Tuesday!

Whatever

2008-10-02

Such an amazing word! It can be used to express a myriad of different meanings, but they all have something in common – indifference. “Whatever” is possibly the most indifferent word in the world.

I’ve been searching for a Czech equivalent, but there simply isn’t anything similar. When you are asked whether you want chocolate or vanilla ice cream, you can say “I don’t care”, but saying “whatever” is way cooler. Unfortunately, in Czech language, we are stuck with “I don’t care”.

Whatever…

How to read my blog

2008-09-22

First, I’m fully aware of the fact that my blog is public. I don’t mind people reading it, I even want people to read my blog – actually that’s mostly why I write it.

Why, then, is it so uncomfortable when people who sit right next to me are reading it? It’s not like I’d mind them reading it somewhere else, but them reading it when I’m nearby makes me feel really awkward.

I was thinking about this a lot, but couldn’t really come up with any reason. Maybe I’m scared of the possibility of immediate, real time confrontation? But there wasn’t anything much controversial on the front page at the time. Plus I’m generally not afraid of real time confrontation, as long as it’s either written or in person (I hate telephones).

So, to answer the question of how to read my blog: Please, don’t read my blog when I’m nearby. Go to the other room. Thank you.

Sans public transport for one year

2008-09-11

Yay, I made it – one year without using Brno public transport. I walked, walked, walked and walked. Sometimes I used my bike when it was too far and when the weather was suitable. I only used car when it was because of someone else (such as driving my grandaunt to her home or similar occasions).

I had used public transport at Brno tournament one year ago, and now I had to do the same because the tournament site is too far to walk to and I couldn’t go by bike as I was going with my Polisz friends. The tournament was a minor disaster for me, but I enjoyed it nevertheless. Especially the moments not spent playing go.

While I’m not planning to break any more records as far as public transport is concerned, I still plan on trying to actively avoid using it. Walking is good.

And yes, j’aime français, why are you asking?

Subtitles evolution

2008-09-02

It shouldn’t be much of a surprise to anyone that I used to watch (English) movies with Czech subtitles.

About two years ago I found out that it was a really bad idea. Apart from the subtitles stealing my time because I had to read them, they also stole my brain cycles as I couldn’t avoid comparing what I heard in the English original to the Czech translation, looking for what I missed and what I’d translate better. While this might have been a good exercise as far as translation skills are concerned, it made me tired rather quickly. Plus I usually had no idea what the movie was about.

So I switched to English subtitles. That was a great improvement. No more time spent translating everything both ways three times. I could finally enjoy movies again. But still, I couldn’t help but read the subtitles anyway, just because they were there.

And so it happened that I almost stopped using subtitles for English movies alltogether. I still occasionally use subtitles for special things such as Monty Python, where there are a lot of jokes and puns which would be difficult for me to catch otherwise.

Overworked?

2008-08-04

Do I spend too much time at work?

Let’s see:

First, I work eight hours a day and I sleep eight hours. That means I work half of my waking time.

Second, I only work two out of three days (counting weekends, public vacations and paid holidays adds up pretty close to one third). This means that I spend one third of my waking time at work. Not too bad.

Third, I’ll probably work around half of my life (I didn’t work during my first 20 years here and I won’t work when I’m old either).

That means I am going to spend about one sixth of my life at work (awake life, that is). That definitely doesn’t feel like “too much”, does it?

Oh, plus I got some tesuji up my sleeve… but more on that next time. 8-)

LSG 2008

2008-07-26

“What took you so long?”

Yes, I’ve returned from LSG a week ago. But I spent all my time either at work or creating the photogallery (I made over 800 pictures but my memory card got full so I had to delete the bad ones, I returned with over 650 pictures and the gallery is 187, so – as you can see – it was a lot of work).

LSG was great (you can see mroe photogalleries), and I really regret having to wait almost 350 days for the next one again. Last year when I came home from LSG I just sat there for several days doing nothing and waiting for the next LSG. Luckily, this year work takes care of that, it’s really good to have something concrete to do.

Sorry for a boring post, hopefully it was at least short enough. :-) (and hey – it included links to photos… by the way, my favourite pictures from my own gallery are 4, 32, 94, 100, 109, 149, 152, 176, 178 and 181)

Louise Attaque

2008-07-01

I haven’t written a post about music for a long long time. I wanted to write about Nightwish’s “new” album Dark Passion Play, but since it can be summed up with “pretty good album, too bad the new singer’s voice is nowhere near Tarja’s” and since everyone and their dog already knows Nightwish, it wouldn’t be too enlightening.

In January I was searching for some good French music (since I like listening to French language) and so I asked scurge (I’d really like to link him, since he’s starting a go school, but sadly he has no webpage yet – anyway, if you are looking for a go teacher, check out “scurge” on KGS (he’s way stronger than the kgs 4d he has)) for suggestions. He told me to try Louise Attaque and remarked that they are “a bit weird”.

So, yes, Louise Attaque are a bit weird, but they are also absolutely awesome. Their music is pretty original, I’ve never heard anything similar before. And I can listen to their songs over and over and over and over and over and…

They have released three albums so far:

Louise Attaque
This self-titled album is their first and in my opinion also the best. J’t’emmene au vent is my favourite Louise Attaque song (it also has a cool video). Other extremely good songs are Ton invitation, Les nuits parisiennes and Fatigante (funny changes in rhythm and speed all the time).

Comme on a dit
Also the best album. I haven’t listened to this one as many times as the other two, but I’m trying to catch up. The best song here is La plume, people say it has a clever text – I think it’s about time for me to start learning French. Other notable songs include (but are not limited to) Tu dis rien, Sans filet, Tout Passe, Comme on a dit and Du nord au sud.

A Plus Tard Crocodile
Their last album is not as fantastic as the previous two… nevertheless, there are several pretty good songs: Revolver, Oui non, Nos Sourires (except the last minute, which is horrible) and Depuis Toujours (the best song from the album, imho).

Oh well, at least I managed not to list all the songs from each album. :-)

Tone Mapping with GIMP

2008-06-14

“Tone mapping reduces global contrast in images while increasing local contrast and shadow/highlight detail.” or so Gimp Addict’s Tone Mapper tutorial says. Go and read his tutorial, I will add few comments to it:
4) “radius of 100-500 is good” – yes, it usually is, but since we don’t know the size of the image, I’d rather say that 10% of image size (that is (width+height)/2) is a good starting point.
5) 75% is again a good starting point, but you might want to play around with the value.
7) It depends… if you want to increase the tonemapping effect, duplicating the “soft light” layer is the way to go (I’ve tried changing the layer mode and nothing else really worked at all).

So I wanted to create a script that would do this. After searching the GIMP Plugin Registry, I found Tone mapping script, which basically follows Gimp Addict’s guide. However, it only has two options – the amount of blur and the amount of layer transparency. That certainly isn’t enough for me. Luckily, the plugin is GPL…

(((GIMP’s Script-Fu) uses Scheme) (which is (a dialect) (of the (Lisp (programming language)))) ((Lisp is a (programming language)) (for people) (who (really (really (like parentheses))))))

And because I like parentheses almost half as much as an average Lisp programmer, I rewrote the Tone mapping script and created Advanced Tone Mapping script. Feel free to put it in your GIMP’s script directory (~/.gimp-2.4/scripts/ in my case).

There are four parameters for Advanced Tone Mapping script:

  • Gauss. Blur (% of img size) – is the amount saying how much the blurring should be used for the tone mapping. It is in percents of image size (where image size = (width+height)/2). Ten is a good default, but different values might be interesting too.
  • Opacity of blurred layer – this is the 75 default, which can be changed if you want stronger or weaker effect.
  • Opacity of merged layer – the default is 90. If 100 is not enough, consider increasing number of “copies of merged layer”.
  • Copies of merged layer – when one, it’s barely noticeable, you can deny any accusations of postprocessing easily. :) Three has a lot of “halo effect” and anything above five will completely mess all colours up.

The first set of pictures is simply a preview. The image on the left is the original image, and the image on the right is processed by Advanced Tone Mapping with Gaussian-blur set to 10, opacity of blurred layer equal 75, opacity of merged layer full 100, and finally three copies of the merged layer (note the way I use to show those values – it is also used for naming the layers, which can be handy if you later forget which layer is which or what you have done). The image on the right might be a bit over the top, but it shows nicely what can be done with Advanced Tone Mapping script:

Tone mapping

The next example shows some pretty conservative tone mapping. The one on the left was created with almost none blur, while the one on the right has 10% blur. Note the difference: the one on the left has no halo but appears a bit flat, while the one on the right has a slight halo but also has higher level of detail.

careful Tone mapping

Oh my… the following example shows what can go wrong with tone mapping (I’m sorry for all the people who already gouged their eyes out). The reason why image on the left appears so flat and awful is that almost no blur was applied. The image on the right is a comparison with healthy blur applied. Five copies is still a bit too much, but hey, at least it has kind of action-like look.

Tone mapping gone wrong

The last image shows the difference between the default blur and maximum blur available. As you can see in the right side picture, the halo is so huge it’s almost impossible to see. The bad news is that with maximum blur we lose a lot of detail near the borders of light/dark areas.

Tone mapping different halo

Ok, that’s it – now go and experiment with my script on your own photos. 8-)

PS: Underexpose your images – the dark areas can still be lightened, while the burned out areas are usually completely white and can’t be darkened.

PPS: The more contrast there is, the more layers you apply, the more blur you will usually need.

PPPS: Any kind of noise in your picture will be greatly amplified.

PPPPS: No, this is not HDR, this is just tone mapping of a single image (just jpeg, in my case). Tone mapping is a part of HDR, but HDR is not a part of tone mapping. ;)