Django Locale URL – 404 bug

by gNesher on 26/03/2012

Django Locale URL (django-localeurl) allows you to easily manage multiple languages in your site by adding the language code to the URL. Sadly there is a fairly significant bug when dealing with non-existing urls (404 errors) on live sites (DEBUG=False). Localeurl is unable to match a language (as the url is invalid) and breaks down – ignoring the 404 template (this seems to happen for 500 errors as well).

Since the bug only happens when debugging is turned off I was only able to catch this when I was setting a live site, and had to come up with the following quick fix (lines 79/80)

try:
url.startswith(urlresolvers.get_script_prefix())
except ValueError:
raise Http404

This will basically try to resolve the language prefix, and raise a 404 error if an error occurs. This is not a perfect fix (as there might be other errors preventing the script from fetching the url prefix) but it does provide an instant fix.

This still leaves me with no real alternatives for localeurl, so if you know of a better alternative do leave a comment.

No Comments

jCarousel Lite Reloaded

by gNesher on 31/01/2012

jCarousel Lite is a great little (2k) jQuery carousel script that was developed back in 2007 by Ganeshji Marwaha which I still use for most of my sites.

Sadly, the script is no longer being developed/supported.

Since I made quite a few modifications to the script over time, I decided to release an updated version called jCarousel Lite Reloaded which includes several useful bits of added functionality.

jCarousel Lite Reloaded (v0.91) changelist:

New additions

1. Added support for mouse swipe using jQuery Touchswipe (http://www.netcu.de/jquery-touchwipe-iphone-ipad-library) simply set the swipeSupport to True (only supports horizontal swipe at the moment).

2. Multiple Rows –  Based on tpb976 modification (as found on google groups) allows you to set the number of rows in your carousel by setting the rows variables.

3. Pagination - Will populate a predefined list (UL) with navigation buttons to each of the available pages. Simply set btnPagnation to the class of the empty list.

Bug Fixes

1. Two new variables called liheight and liwidth were introduced to tackle cases where the carousel is hidden when the page loads.

2. The circular option breaks down when multiple rows are introduced. Since I was not able to reproduce a solution that worked for multiple rows I changed the implementation. Setting the carousel to circular will now simply navigate to the start/end of the carousel.

3. Several small changes to improve code readability and some tiny performance increase.

4. IE bug now sorted. Also ran script through Jlint.

Known Issues

The Vertical carousel was not tested (never encountered a situation where it was needed). It should work, but test it before you use it (and report back if you find any bugs).

Download: jcarousellitereloaded0-91

In the next update I will mostly focus on implement additional community patches which are available in the comments section of the jCarousel Lite blog post (27 pages of them).

No Comments

Quick update

by gNesher on 27/01/2012

I’ve been away for a couple of weeks for a quick family visit in Israel, but I haven’t forgotten about the blog quite yet :)

As you can see I have a new, much cleaner design (a logo + a portfolio page is currently in the works).

Next week I’m planning to share an updated version of jCarousel lite an excellent jQuery Carousel plugin that is long due for an update (the last update was released in 2007). I’ve implemented many of the suggestions / snippets of codes that appeared in the comments (and implemented a couple of additions of my own design) – so stay tuned.

No Comments

Skyrim Great Game, Disappointing Ending

by gNesher on 8/01/2012

I’ve been playing Skyrim ever since it came out (about a month now) and finally decided its time to finish the main plot line.

To say the ending was disappointing is an understatement - I won’t go into too much details (as some of you might still be playing it) but the lack of significant cinematics or changes in the world (you can keep playing even after you finished the main plot line) makes it extremely confusing/disappointing.

I actually had to go online to verify I finished the game properly and wasn’t missing something. It turned out I’m not the only one feeling this way and Google is full of similar complaints.

No Comments

1x print sales isn’t working for me

by gNesher on 31/12/2011

Unlike many online galleries 1x implements a rather strict approval process to all photographs making it one of the best online galleries around.

About a year ago 1x started offering prints of its online collection, sharing the revenue with its photographers. The deal sounded sweet but came with a catch – you had to be a paying member (99$ a year).

While I was only able to publish a single photograph on the site it received a large number of views and I decided to give it a try.

6 months later I’m sad to report the experiment failed miserably. While the photo received about 600k unique views during that period, I was unable to sell a single print.

if your selling prints in 1x I would love to hear your experience – as something is clearly not working for me.

Edit

I’ve also started asking around in 1x forums - only a couple of replies so far, but it seems no one is selling any prints.

P.S
Heres a link to my photo

No Comments

Django Piston – ordered dictionary

by gNesher on 29/12/2011

Django Piston is a great tool for adding a Restful API to your Django project. Sadly development seems to have stopped quite some time ago.

One of the problems (which is currently marked as an open major bug) is that Piston uses a Python dictionary to store the data, which means you can not relay on the data being delivered in a consistent order – which can be a fairly big problem in some cases.

As the bug was reported well over a year ago, I doubt we will see an update anytime soon – however it is something that can be solved quite easily be editing emitters.py and switching the regular Python dictionary with Django SortedDict.

You can grab the edited file bellow (changes include comments) or just do it yourselves. This version seems to work perfectly in my initial testings.

emitters.py

No Comments

Sony NEX5N first run

by gNesher on 24/12/2011

I received my brand new Sony NEX5N several days ago, but today was the first time I got a chance to properly test it.

The camera is impressive, and while it does take time to learn how to handle it (controls are more in line with point and shoot cameras than DSLRs) you are certainly rewarded for your effort.

I’m attaching several examples bellow – all taken in RAW and went through some minor edits in Aperture.

Update:

While Sony claim the Nex5N can take 10 photos a second in burst mode, I haven’t only been able to get around 3-5 photos at which point the cache needs to be written to the memory card and capture speed is reduced to 1-2 photos a second. Slightly disappointing.

No Comments

Lolly for Lolly – Arduino fun

by gNesher on 23/12/2011

As a Christmas card, we decided to do something different.

We created a website called lollyforlolly where visitors were invited to tweet our hash tag (#lollyforlolly) to turn on a heat lamp and melt a lolly. The more lollies melt, the more money the company donates.

The entire process was being documented by two live streams (one for the lollies, and one for the collected water/money).

To control the heat lamp I created an Arduino controlled electrical socket (using a solid state relay) simply turning it on/off based on user tweets (retrieved using python and tweepy).

We ended up raising about 600£ with hundreds of unique visitors participating in the campaign.

No Comments

Less Framework + JS joy

by gNesher on 20/12/2011

While there are several CSS Frameworks that support responsive web design they all relay on Media Queries to load different css styles based on the screen width.

While loading custom CSS styles is often enough, my latest project involved some JS commands that I had to adapt to the different screen sizes.

Using the JS screen.width worked fine for 3 out of the 4 layouts, but Less Framework uses the minimum screen width to differentiate the mobile wide/narrow displays which presented a small challenge.

My solution was a fairly quick CSS + JS hack. I created a div with a certain width and set it to be invisible in all layout except for the wide mobile. I then added an event listener for screen resize + page load and check the width of the div. Since invisible elements get a 0 width, I’m able to detect the change and catch the wide mobile layout.

Its a somewhat messy hack, but it seems to work fine on all mobile devices/browsers I’ve tested so far – though if you find a better solution, do leave a comment.

No Comments

Winter Wanderland Photography Meetup

by gNesher on 18/12/2011
No Comments