Friday, May 31, 2013

File icon extensions (emblems) like of Dropbox

I have been wondering how Dropbox could put a icon on the file indicating it's synchronizing or synchronized. I digged its code and the files of gnome itself and found the way for that.

You can find some examples for these icons in /usr/share/icons/gnome/scalable/emblems/ which belongs to Gnome.

If you want to have a custom icon, then you can put your files in /usr/share/pixmaps

An example filename: emblem-my-synced-symbolic.svg

I had the impression that the file name should start with emblem but I'm not really sure.

After having your file in /usr/share/pixmaps, you can activate this icon for a file:

gvfs-set-attribute -t stringv /home/emre/sample.txt metadata::emblems 'my-synced-symbolic'



Now your file has the svg icon on it.

Friday, May 24, 2013

Fix for SuspiciousOperation: Invalid HTTP_HOST header

With Django 1.5, HTTP_HOST header filter is applied to the requests.  If the HTTP_HOST header is not among the ALLOWED_HOSTS list in the settings.py, an error is raised, saying this is a suspicious operation.

Let me give an example. Someone (who is not Google), is trying to reach my IP address with the HTTP_HOST www.google.com as if I'm hosting the google.com homepage.:

SuspiciousOperation: Invalid HTTP_HOST header (you may need to set ALLOWED_HOSTS): www.google.com


This happens frequently, leading to emails sent to the admins which is annoying. To overcome this, you can add the IP Address of the requester to /etc/hosts.deny file.

Indeed I thought I could put a hostname filter in nginx configuration, especially in the listen part but my configuration did not have an effect.

The attacker tries to exploit a vulnerability and performs a scan over the web. They seem to be from Vietnam.