abidibo.net

Posted in "php"

Images, thumbnails, entropy and PHP

php programming

Years ago' I developed a php class to create image thumbnails on the fly, evaluating the interesting part of the image. I wrote about this in my company's blog, now I'd like to share these concepts here, in my poor english.

Why, what?

Generate thumbnails from images is a common task in modern web applications, because there is no reason to serve oversized images, when they are used as 800px wide (or less) images in a template. There is no reason to make a user download the whole image (many KB or MB), if then it is resized through css.

But how to deal with thumbnails?
There are two main approaches used by modern web applications:

  1. have the backend generate ...

read the full post


Singleton, the PHP way

patterns php programming singleton

I realized that even if the great part of my work consists in programming PHP stuff, I rarely write about PHP in my posts, maybe because I really don't like it?

But today I'll write about a way to implement the singleton pattern with PHP.

This is quite an easy job making use of PHP 5.3.0, thanks to the "Late Static Binding" feature. In particular we'll use the get_called_class method and the static keyword. Notice that ...

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


Vim for php programmers

php programming vim

Il succo è questo:
ho scritto due post sul blog della otto (la tanto cara azienda in cui lavoro), in cui illustro come si possa fare per rendere vim un editor perfetto per sviluppare codice php. Allora siccome sarebbe inutile ripetere qui le stesse cose e soprattutto non ne ho voglia, vi linko semplicemente i due post in questione, buona lettura.

Vim for php programmers parte 1

Vim for php programmers parte 2


jeff-flatpages, html page module for jeff framework

jeff php programming webmaster

jeff-flatpage is a jeff module that lets you store simple "flat" HTML content in a database and handles the management for you via jeff’s admin interface. It is the right module to use for the creation of "About" or "Privacy Policy" type pages, which don't need a specific module and implementation.

So it's ready! The first jeff module for the management of HTML contents is available for the download in the otto github account, release v1.0.

Let's see the main features:

  • Management of html pages (date, title, subtitle abstract, text, images, videos, visualization privileges)
  • Visualization through customizable templates
  • Translations availables for english and italian
  • Error pages 404 (not found) and 403 (forbidden)
  • Possibility to restrict the access to contents to a set of chosen system groups.

Please for complete instructions about the module installation refer to the README file of the github repository.

Please comment here for general considerations, use the proper github area for bug reporting.

Enjoy it ;)


Jeff Tutorial - Installazione

jeff php tutorial

In questo tutorial vediamo come installare Jeff e creare un ambiente vergine pronto per aiutarci nello sviluppo di una qualunque applicazione.
Qui suppongo che si lavori in ambiente LAMP, ma con altre configurazioni non è che le cose siano molto diverse.

Scarichiamo Jeff

Per scaricare Jeff possiamo visitare la pagina https://github.com/otto-torino/jeff e premere il pulsante download (sono disponibili 2 formati: tar.gz e zip), oppure utilizzare il comando git:

git clone git://github.com/otto-torino/jeff.git ./jeff

A questo punto ci ritroveremo con la cartella jeff che include tutto il codice necessario. Mettiamo la cartella all'interno della document root, tipo

/var/www/jeff

e passiamo alla creazione del database...

Creiamo un db

All'interno della cartella principale troviamo il file jeff.sql, il quale contiene le istruzioni SQL per creare le tabelle di cui Jeff ha bisogno nella sua configurazione base. Allora dobbiamo:

  • Creare un database, ad esempio db_jeff
  • Creare un utente che possa eseguire statements sul database creato, in fase di sviluppo ed in locale solitamente questo non si fa e si utilizza l'utente root senza password
  • Eseguire tutte le query contenute nel file jeff.sql per creare le tabelle, questo si ...

read the full post


The Jeff Wiki is out

jeff php webmaster programming

Mr ans Mrs, señores y señoras the first release of the Jeff Wiki is ready. It contains some sections that covers almost all the development stuffs:

  • Requirements
  • Installation
  • Structure
  • Core classes
  • Libraries
  • Modules
  • Default installed themes
This guide is written for development purposes. Contains the declaration and description of all Jeff classes, modules and libraries. After reading it a developer should be able to extend the framework at his like and to build new modules.

Requirements

Explains the system requirements

Installation

Explains how to install Jeff and get ready with it. jeff is a php framework but has also some CMS characteristics so that after installation it's possible to surf to a default index page and the default administrative area.

Structure

This is a tour in the process that led to the document page rendering. Starting from the entry point,index.php, and ending with the single method output ...

read the full post


  • 1

Your Smartwatch Loves Tasker!

Your Smartwatch Loves Tasker!

Now available for purchase!

Featured