abidibo.net

Weblog

Convert select multiple widget to checkboxes in django admin form

django django-admin django-mptt jquery

I think this should be a nice post talking about the substitution of the default multiple select widget used in django admin interface to deal with m2m fields, with a multiple checkbox widget.

Yes I know, you may solve it this way, but I don't like such solution very much, and I think it is just not perfect for some reasons:

  • At the time of this writing the add related functionality (+) seems to be broken, throws an error, at least for me
  • It just can't be used with the django-mptt application, which is awesome to deal with data which have a tree like structure

So to graphically explain what we want to do here, say we want this ...

read the full post


Reverse selector engineering with mootools

css javascript mootools selectors

What if you need to get the css selector which targets a DOM element given the element itself?

This is the case for example when you want to store some added information over an element and show it after recharging the page. In this case you may store the information in the local storage object together with the path to the element, in other words you must be able to store the element position inside the DOM

In this scenario ...

read the full post


MySQL, bad preformance of INFORMATION_SCHEMA queries

cache mysql performance php

Recently I've discovered a quite big perfomance problem when running INFORMATION_SCHEMA queries on mysql.

In particular I found that on some systems (some mysql versions) a query like

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'db_name' AND TABLE_NAME = 'db_table'

can take up to 0.1s to run!

Clearly such time interval is not acceptable, and I think it happens only with some versions of mysql because I've run some tests on my local machine and on the server where this site is running obtaining a result of 0.0007 seconds, we are talking about a difference of two orders of magnitude!

I've not investigated more about which mysql versions are affected and if there are any patches, I ...

read the full post


Glen Hansard, Milano 2013

glen hansard life me music

Dunque oggi sono scassato come una merda, ma sono contento perché ieri sera sono andato in una disco tamarra di Milano a sentire Glen Hansard in concerto.

Inizio concerto ore 20:00, ore 20:00 meno qualcosa parcheggiamo a poca distanza dal locale, 3 bottiglie di vino alle spalle, ci incamminiamo verso l'ingresso e santo Carlo "Oh, ma è Glen!", scorge Glen camminare verso di noi diretto probabilmente ad una birra e paninazzo.

Molliamo di brutto filtri e armamentari e lo placchiamo. Flu rotto in culo si fa firmare l'ukulele ora vero e proprio cimelio. Poi è il momento della foto ed inizio a blaterargli qualcosa di incomprensibile riguardo al fatto che anch'io avrei voluto fargli ...

read the full post


Development of a preview functionality with canvas

canvas javascript mootools

Do you remember the last post about canvas dealing with undo and redo functionality?

Now we'll see how to add a preview functionality, that is I want to see my straight line, or my circle, while keeping pressed the left mouse button and moving the pointer to change the shape size.

The first, bad, idea

Initially I thought that the way was to store the portion of canvas interested by the modification and restore it in the next mousemove call, so that the mousemove function has to respect the following flow:

  • restore the previous saved state
  • save the state of the portion of the canvas that now will be drawed
  • draw the new state

Such flow works, but doesn ...

read the full post


Deploy django application, set up another machine

deploy django git pip programming virtualenv

This entry is related to the series "Deploy django applications with nginx, uwsgi, virtualenv, south, git and fabric", the first part here.

So what happens here? Really nothing special, I've changed my working machine and so I had to set up my django projects on the new notebook. This post is only a remainder of the followed steps.

Install all the required system packages

Clearly I had to install some packages in the new machine:

  • mysql-server
  • python
  • python-dev
  • python-setuptools
  • build-essentials
  • libmysqlclient-dev
  • git

And also I've installed pip and virtualenv

Create the folder structure and the virtualenv

First of all create a directory which will contain the project, I've created it under /var/www:

$ mkdir /var/www/myproject ...

read the full post


A mootools powered showcase with dot pagination

animation effect javascript mootools programming showcase webmaster css3

Today I was playing (really working) with a nice animation effect to use for the pagination of a showcase module (or stories).

The concept is quite simple here, we have some items which iterates with a nice effect (fade in this case) automatically or not (decided through options). Every item has a dot controller which shows the item when clicked.

Nothing exceptional here, the cool thing is the effect that I gave to such dot controllers, as it seems that when clicking a not selected dot, the selected one moves forward or backward to reach the clicked point.

Quite difficult ...

read the full post


Using django-mptt TreeNodeChoiceField in a TabularInline admin form

django django-admin django-mptt

I use to use the django-mptt package to deal with tree like models. I also use to have my backoffice autogenerated by django admin.

Now one of the problems I've encountered was to add an inline form of a model which contains a "tree" field in a way the user can deal with a select input well formatted (showing parents and children in a clear way).

This task is easily reached in a normal form by defining the form ...

read the full post


Two must-have apps for android sysadmins

android mobile tips

This is only a short post to speak about two free awesome applications which I considered essential (especially the keyboard one) to perform sysadmin task from remote.

android

The terminal

I've tried a lot of them, and finally I decided to stay with Android Terminal Emulator, is fast and clean, and works well on my SGS.

The keyboard

Well, for those like me who can't edit text without vim the first problem to face when editing from mobile is ...

read the full post


moogallery, release 0.2

moogallery mootools programming webmaster javascript

Ok, the release 0.2 of moogallery is out!, Check out the updated demo here.

The new release offers some new interesting features:

  • Youtube and vimeo videos support
  • Audio support, mpeg and ogg encoding to assure cross browser capability
  • Mobile detection and swipe event handler to navigate through media in the lightbox view (requires Christoph Pojer's mootools-mobile plugin)

Maybe in the future I'll integrate a listener for the changes in the device orientation so that the gallery reloads recalculating the available dimensions. Such thing may be already done manually.

Check out the new release and comment here to let me know which improvements you'd add to the plugin.


Your Smartwatch Loves Tasker!

Your Smartwatch Loves Tasker!

Now available for purchase!

Featured