All posts filed under: Coding

It’s all about programming!

Create nice unicode PDF using Python

Leave a comment
Coding / Howtos / Python

Today I started one of the less motivating activities in Python 2.x: encoding. In Python 3 unicode will be everywhere, but as of the 2.6 version I’ve on one of the server I have to endure. Objective: get data from a UTF-8 encoded json and print a nice PDF. Tools: json, urllib2, fpdf, cgi What you need: pyfpdf: https://code.google.com/p/pyfpdf/downloads/list Download fpdf-1.7.hg.zip or more recent Unzip, enter the directory and python setup.py install locate fpdf cd /usr/lib/python2.6/site-packages/fpdf (or the directory […]

Django development on Virtualbox: step by step setup

Leave a comment
Coding / django / Howtos / Python

I had a bad morning trying to repair my Cygwin installation from a virtualenv mess. It’s time to get a Debian and install it on a Virtualbox for my new django project! Windows: host Debian: guest Choosing the distro: what I want Python 2.6 Django 1.4 Apache + Mysql I’m a Debian fan from years so I go to the Debian website and download Wheezy netinst iso (32 bit, since I’m on a 32 bit OS […]

Joomla Webform alternative: JForms

comment 1
Coding

I don’t use Joomla, but sometimes a friend or a colleague of mine ask me some tips. My answer could be: in Drupal it will take 5 minutes. Since I’m very open-minded, today instead of replying in that awkward way I try to found an alternative to a very useful module for Drupal called Webform. I’ve found a limited but working equivalent for Joomla called JForms. Tested on: Joomla 1.5 JForms version 0.7 RC1 Installation: […]

Disable autocomplete for keyup on jQuery

comment 1
Coding

There’s an event I cannot handle on jQuery: the Firefox autocomplete on textarea. If you have to use the keyup event for a string match on textarea content, you have to exclude autocompletion, that is out of keyup logic. To do this, simply add: $(‘#myelement’).attr(‘autocomplete’, ‘off’); to your jQuery. Autocomplete will be disabled and the unhandled event will not fire. See also: Javascript keyup doesn’t work as expected, it executes in instances where I have […]

Character substitution on Jquery

comments 3
Coding

Here an easy way to search and replace each occurrence a group of characters (in this case underscore and minus) with another (in this case a space) on a specified element (in this case each A), using Jquery javascript library. $("a").each(function() { $(this).html($(this).html().replace(/[_-]/g," ")); }); The first argument passed on replace is a regex, if you just pass a single character (like “_” or “-“) only first occurrence for each element. Real world usage: I […]

Display HTML on Lightbox v2

comments 5
Coding

I’m trying drupal 6.x from some weeks ago. On Drupal 5.x, I’ve used Greybox Redux module to display HTML content on a Javascript popup window. On 6.x, where Greybox isn’t available, I try successfully Lightbox v2. I use this module for images on many sites: syntax to display HTML on a popup IFRAME changes slightly: <a rel="lightframe" href="http://example.com" title="Lightframe label">Link Text</a> And this is the l() equivalent: l('Link text', 'http://example.com', array('attributes' => array('rel'=>'lightframe', 'title'=>'"Lightframe label'))) […]

i can patch this!

Leave a comment
Coding

*nix command of the day: diff -Naur old new > new.patch Where “old” and “new” are files or directories to patch. Example (a Drupal patch for IDs duplication): $ patch -p0<fapi-5.x-dupe-id_111719-151.patch patching file includes/form.inc $ Creating patch for Drupal: diff -up original.php new.php > filename.patch another example: diff -up path/to/file/example.module path/to/file/exampleNew.module > mypatchname.patch See also: How to create and use a patch in Linux Creating patches in Drupal