Easy way to turn off ads on Gawker.

I was looking through the ad display code in Gawker’s leak. Turns out the methodology to serve ads in their Smarty “upgrade” GanjaPHP is pretty simple really. (You can find this in the Ganjasmarty.php file FYI)


static function smarty_function_adDisplay( $params, &$smarty ) {
// load page without ads - for debug
if( $_COOKIE['noad'] == 'true' ) return '';
...

I couldn’t believe it could really be that simple, but I had a simple way of trying. Just opened up the console and put in the following:


javascript:document.cookie='noad=1; expires=Thu, 2 Aug 2021 20:47:11 UTC; path=/';

Works like a charm. Except for the first flash ad, the others all vanished. You can do the same by going to the site and running this bookmarklet: NoAds Gawker.

It doesn’t seem to work on Lifehacker. Feel free to try it elsewhere (you might have to refresh the page once though)

(For a clean conscience, I deleted the cookie after; besides, I don’t see the benefit of having no ads on a site I never read anyway).

Django, Apache Uploading Japanese Files, and os.path.exists

If you are having a problem getting unicode files uploaded to Apache and are getting os.path.exist exceptions in Django, you should take a look at this link:

http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-you-get-a-unicodeencodeerror

It is not only for mod python; I had this problem with mod_wsgi.


One of my projects at work is maintaining a Japanese language ticketing system in Django. Recently, we added additional file uploading systems and everything working, I put it live.

Unfortunately: no one could upload files with Japanese characters in the name.

My first break came from copy/pasting the error code; it was the same as the one at this Stack Overflow. It was failing on some kind of python internal operation. However, this solution did not work for me (setting the language variable) as the language variable was already us.utf-8. Furthermore, I wasn’t going to hack around in the django internals without reason.

I realized that there was probably something going on in Apache and was busy trying to find out how to switch to the Apache user in Ubuntu when the next clue came up: a Japanese message board conversation.

The important conversation is reproduced below:

:909[sage]:2010/10/14(木) 04:18:32 ID:???
解決しました。
(I solved it)
原因はapache2ctl gracefulじゃなく/etc/init.d/apache2 restartとしないとenvvarsを変更しても意味がないのを知らない事でした。
(I had to reboot directly using /etc/init.d as opposed to using apache2ctl in order to reset envars.)
webで集めた情報をまとめておきます。
(Enclosed is the information I found on the web)
1. envvars変える。
(Switch Envvars)

http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-you-get-a-unicodeencodeerror

2. それでも駄目ならaptで入るlangage-pack的な物が入っていてUTF-8が使えるか調べる
あと、間違った情報だと思うんですが

3. sitecustomize.pyを用意、もしくはsite.pyを直接書き換えて、sys.getdefaultencoding() => ‘utf-8′が得られる様にする。
等の情報を見つけました。

3に関しては、sys.getdefaultencoding() => ‘ascii’のままでも僕は大丈夫でした。
返信くれた方、ありがとうございました。

The first line solved my problem. If you need a translation of the rest, let me know and I’ll be happy to do it.