django-admin-bootstrapped compatibility list

To ease you in the choice of what admin theme to use

You may already know that django-admin-bootstrapped is a Bootstrap theme for the default Django admin application.

Maybe you even know that with it you can also translate an application name, add custom html (eg. an help section) to the change_list/change_form views, and sort inlines with - almost - no code.

But whay you may not know is how compatible the project is with the django apps ecosystem.

Well it's good! This is a list of known complex apps that just works with django-admin-bootstrapped.

Known compatible django applications

django-cms

The pony powered CMS with Frontend-Editing. More...

Satchmo

The webshop for professionist with deadlines. ...

Continue reading…

Use GoAccess to analyze your Amazon S3 logs

Just provide the correct format!

GoAccess is a neat tool to analyze any kind of web log fastly and even real-time. It supports out-of-the-box logs written in the following log format:

  • Common Log Format (CLF) Apache
  • Combined Log Format (XLF/ELF) Apache
  • W3C format (IIS).
  • Apache virtual hosts

Unluckly Amazon S3 uses a different log format, but with GoAccess it's not a problem since it can be configured to any custom format. How?

The manpage lists the available parameters to define a custom log format, but I found nowhere a string compatible with Amazon S3 logs. With a little trial and error, here is a format ...

Continue reading…

08 January
Posted under tool

LESS is more

My css file was quite messy, so I decided for a fresh start with LESS.
Was it worthy?

In short: yes!

Writing css with LESS will actually save you a lot of keystroke, even with the zen-coding/emmet plugin. The variable thing is something insanely useful. The other gem is the & operator: with it you can write very self-explanatory class dependencies.

Using LESS with Flask

To integrate LESS with this website, I hade to change the code to integrate Flask-Assets. Flask-Assets is a great tool that will add support for merging, minifying and compiling CSS and Javascript files.

To use it, in the application script add this code after the application declaration:

from flask_assets import Environment
assets = Environment(application) ...

Continue reading…

Click event not fired on Android 2.3.x

Handle 'click' events in jQuery with support for the default browser shipped with Android Gingerbread (2.3.x)

This is something I discovered some time ago, but keeps popping out. Looks like the default browser shipped with Android Gingerbread (2.3.x) doesn't fire neither the click nor the tap event. Instead of them, it will fire the touchstart one.

The solution is handling the correct event based on the browser capability. An example solution is the following:

var touch = ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch;
var touchEvent = touch ? 'touchstart' : 'click';

$('#anItem').bind(touchEvent, function() {
  console.log("Touchclicked:", this);
});

I made a Gist of it, so if you have a better way to handle it please fork and let me know!

Plus I ...

Continue reading…

Monitor your website with New Relic

And get a supercool t-shirt for free!

New Relic is one of those things you keep seeing while browsing the net for nerd stuff.

Basically, it's a 'plugin' for your website that will monitor any kind of information you can think about: application speed, code errors, cpu and memory usage and a huge amount of data that will satisfy everybody.

It's data porn!

New Relic screen

As a nice plus, just for trying the service you'll get a free t-shirt! Yes, simple things make me happy.

New Relic t-shirt New Relic t-shirt detail

Continue reading…

Bootstrap your Django admin in 3 minutes

And do it without changing your existing codebase!

Do you want Bootstrap on your Django admin app? You do not want to mess with the templates? That's why I did it for you!

Updates

2013-01-17: Version bump to 0.3. Some UI cleaning and documentation. See the CHANGELOG for more details
2012-12-19: Version bump to 0.2. Sortable inlines. See the CHANGELOG for more details
2012-11-20: Version bump to 0.1.1. Couple of bugfixing, Bootstrap upgraded to version 2.2.1, etc. See the CHANGELOG for more details
2012-11-16: Package addded to Pypi. You should now be able to pip install django-admin-bootstrapped. Thank Cyril for the help!

What you'll get

  • a responsive interface ...

Continue reading…

My Sublime Text Editor configuration

Because sharing is caring.

So I must share mine. Here's the complete list of what I really use, in alphanumeric order. Plus a screenshot that's always nice.

My ST

Djaneiro

Django syntax and goodies.

emmet-sublime

AKA Zen-coding. I'm still in the getting known fase, sometime I like it, sometime I have to write more than what's needed. But that's just because me.

Generate Password

Need to generate a password on the fly? super+shift+p: password and you're done.

Git

I use this just to have a fast access to the changelog for the current file. But for the real work there is no way other than the ...

Continue reading…

Why I'll never trust G-WAN

A webserver that's 4 time faster than nginx? Monkey likes! But...

Today a link on Hacker News got my attention: Node.js is just all hype. Since I'm inclined to think the same, I started reading it. Imagine my disappointment when the article rapidly changed argument and started talking about G-WAN as the Cinderella of the "Next big things Club". Anyhow, the idea of having an application server that's not bound to the technology you want to use was interesting.

So I did what I always do when somebody is trying to sell me a new tecnology: I googled it for feedbacks and documentation.

Well, I found a couple of nice blog ...

Continue reading…

The server is not in your timezone

Scheduled a cron job that didn't start when expected? The problem is you!

99% of the time the problem is not in the scheduling, but in you not caring about how the server was configured in first place. Noah Sussman summarized a lot of falsehoods programmers believe about time on his own website. Don't miss the updates!

As a quick hint, I can suggest sticking with UTC datetimes and always normalize dates to it. If you're using Django, be sure to check the time zones (new in Django 1.4) support, it helps a lot.

Continue reading…

httpcode: what the hell is code 418? What, a teapot???

Httpcode is a simple tool to explain the meaning of HTTP status codes

This is a neat tool that comes handy when you get exotic HTTP statut codes like the 418 one (teapots are bad guys, beware!).

It's opensource (fork it on GitHub) and you can install it easily with pip:

$ pip install httpcode

And this is the list of codes known to the tool.

Status code 100
Message: Continue
Code explanation: Request received, please continue
Status code 101
Message: Switching Protocols
Code explanation: Switching to new protocol; obey Upgrade header
Status code 200
Message: OK
Code explanation: Request fulfilled, document follows
Status code 201
Message: Created
Code explanation: Document created, URL follows ...

Continue reading…

05 September
Posted under tool

Must read: James Socol's Best Basic Security Practices (Especially with Django)

James Socol, the Community Platforms Manager at Mozilla, is writing a great summary about best security pratices web developers must be aware of. Even if mainly focused on Django ironing, it's a must read for every web developer.

Point your browser on James Socol's website, Cofffe on the keyboard and bookmark it. James - the Community Platforms Manager at Mozilla - is writing a great summary about web security focused on Django applications, but valid nonetheless for every framework.

These are the arguments he's covering:

  • Basics: locking your car doors.
    • Password Storage
    • XSS: Cross-Site Scripting
    • CSRF: Cross-Site Request Forgeries
    • Injections, SQL and Otherwise
    • Access Control
    • Session Fixation and Hijacking
    • Server Configuration
    • Click-jacking and a little Phishing
    • Stay Up to Date
  • Advanced: Some gotchas from my experience and some things you may well see.
    • Mass Assignment
    • Cache Poisoning
    • Bots: Spam, Brute-force, ...

Continue reading…

Bootstrap upgrade to version 2.1

The guys working on Twitter Bootstrap just released the new version 2.1. Codingnot.es has been upgraded to it and got a small restyling. Let's see what's changed!

Codingnot.es is mainly my own playground, so when I got the news that Twitter released a new version of Bootstrap I was eager to test it on it!

The greatest news of all is the new documentation. Frankly, the old website wasn't that clear on how to use the library, but now is way better. Not perfect, but better :)

Looks like the typeahead plugin got some async love. If you don't know it, I'm talking about this plugin. Since the previous version, typeahead could work only on static json data. Now the source option accepts a function so ajax retrieval ...

Continue reading…

Check your website for broken links with jQuery

Broken links happens, but it's something you can check easily without any server side requirement. Just Javascript!

Writing my notes I make mistakes. I know, my English has room for improvement, but I do other mistakes like broken links, duplicate titles, empty meta descriptions...

A wise person would tell me: "hey dumbass, just download Xenu's Link Sleuth and let it handle the dirty job!". You are completely right. But I'm a OSX user, as you can see by my notes, so Xenu is out of question. And I want something easier, maybe integrated in my website.

So I wrote Status.js!


Updates

2012-08-17: Graph plotting and sitemap.xml generator

A table is useful, but sometimes something more graphic is ...

Continue reading…

Spatialite for Python does not work on OSX

The default Python shipped with OSX is not compatible with Spatialite. Lucky, there is a solution for that. Find more inside!

Is your OSX ready to work with the GIS extension for SQLite? Try doing this on a Python shell:

>>> import sqlite3
>>> conn = sqlite3.connect(':memory:')
>>> conn.enable_load_extension(True)
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'sqlite3.Connection' object has no attribute 'enable_load_extension'

If you get the same error, welcome aboard!

The problem is that the Python interpreter shipped with OSX is not build with loadable extension support.

I'll quote the official documentation (I have had some troubles finding it):

[1] (1, 2) The sqlite3 module is not built with loadable extension support by default, because some platforms (notably Mac OS X) have ...

Continue reading…

How to setup correctly OSX for Python development

Let's setup OSX for Python development using homebrew and virtualenv.

OSX is great for Python development, because it ships with the interpreter preinstalled. But sometimes you'll waste hours trying to make it work with your code.

So it's actually better to do not rely on what OSX gives you out of the box and install Python from scratch, but the easy way!

Prerequisites

  • a clean OSX installation (10.7 Lion or 10.8 Mountain Lion)
  • no /usr/local folder
  • Xcode installed
  • XQuartz for formulae that require X11 libraries. Thanks Rust to point it out on Hacker News.
  • an internet connection

The procedure is quite easy, but please consider that I will not be ...

Continue reading…

Beware the jQuery.noConflict() monster!

The intentions behind jQuery.noConflict() are good, but you will have problems if you are not careful.

jQuery.noConflict() is the suggested way to use jQuery with other libraries.

Basically, it prevents jQuery to replace the $ variable with a reference to itself, so that you can still use some other $ based javascript library together with jQuery.

How does it work?

Try including Prototype and jQuery and print the $ variable.

<script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
console.log($);
>>> function() <- this is jQuery, any code that expects Prototype to be on the $ variabile will fail
</script>

But if you call the jQuery.noConflict() method, things will change.

<script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
jQuery.noConflict();
console.log($);
>>> $(element) <- this is Prototype, not jQuery!
console.log(jQuery);
>>> function() <- this is jQuery, as expected
</script>

So everything is cool and happy

Unlucky, it's not. If you rely on noConflict, you must be careful when including jQuery code from external ...

Continue reading…

03 August
Posted under jquery

Recycling! (part 2): build your new website with Flask (and Twitter Bootstrap) and run it on Openshift

Let's put Flask, Twitter Bootstrap and OpenShift together to build our new super cool website in 30 minutes.

Previously we discussed about what technologies we will use to build our new website. The winners are Flask, OpenShift and Twitter Bootstrap.

Now we will see how to put all together to obtain something like in the following screenshot.

The final result

TL,DR

If you want to see the results before digging in the how-to, point your browser at http://mysite-riccardoforina.rhcloud.com

If you are not confortable with the topics, I suggest you to follow this how-to step by step. I have tested it copy-pasting every line of code, so you'll end with something working for sure.

Anyway, you can find the latest version of ...

Continue reading…

Reading suggestion: Ready Player One

The year is 2044 and the world is in near-ruins. The Great Recession has taken its toll on the world's economy, and resources are scarce. The Internet and gaming culture have evolved into a creation known as OASIS, a massive multiplayer online simulation game...

The year is 2044 and the world is in near-ruins. The Great Recession has taken its toll on the world's economy, and resources are scarce. The Internet and gaming culture have evolved into a creation known as OASIS, a massive multiplayer online simulation game created by James Halliday and Ogden Morrow of Gregarious Simulation Systems (GSS), formerly known as Gregarious Games. Halliday, with no heirs or other living family, dies suddenly and leaves a video will to those in OASIS and a book that was dubbed Anorak's Almanac, which purports to be a volume written by James Halliday's avatar Anorak ...

Continue reading…

01 August
Posted under books

Recycling! (part 1): build your new website with Flask (and Twitter Bootstrap) and run it on Openshift

Are you a lazy developer but still want a website? And without spending a cent too? Me too! Let's see how after the jump.

So you want a website. Something yours, were you can mess around and experiment with something seen on Hacker News. That's fine, we share the same need.

What do we need?

  • A web framework (something to handle urls, contents, templating, etc.)
  • An hosting solution. That's important, we want it compatible with our framework, easy to work with, and cheap.
  • Do you really want to reinvent the html/css wheel again? Well, I don't, so we need some html framework. Mobile support is a plus.

Web framework

A Google search for 'web framework' will give us about 246,000,000 results. Not bad.

Since ...

Continue reading…