Skip to content

Instantly share code, notes, and snippets.

@abidibo
abidibo / recreate_session.php
Created November 7, 2011 15:59
Recreate a php session
<?php
define('SESSION_TIMEOUT', '1800'); // 30 minutes
session_name('fuckIE');
session_start();
// ...bla bla
if (isset($_SESSION['last_activity']) && (time() - $_SESSION['last_activity'] > SESSION_TIMEOUT)) {
@abidibo
abidibo / fck_editor_chr_counter.js
Created November 9, 2011 14:42
A proof of character counter for fck editor 2.x
// requires mootools-core bind function
function FCKeditor_OnComplete(editorInstance){
editorInstance.EditorDocument.addEventListener('keypress', checkCharacters.bind(editorInstance));
}
function checkCharacters(e) {
@abidibo
abidibo / get_tree_from_table.php
Created November 10, 2011 16:03
Recursion to get a tree from a id-parent sql table
<?php
// I use here Jeff's db methods
public function getTree($registry, $parent=0) {
$child_rows = $registry->db->autoSelect("id", TABLE, "parent='$parent'", "name");
$children = array();
@abidibo
abidibo / fp_ipad_fix.js
Created March 19, 2012 16:13
Bug fix for flowplayer ipad
video.fp_setPlaylist = function(playlist) {
log("Setting playlist");
activeIndex = 0;
for ( var i = 0; i < playlist.length; i++ ) {
if(typeof playlist[i].url != 'undefined') playlist[i] = fixClip(playlist[i]);
}
activePlaylist = playlist;
// keep flowplayer.js in sync
@abidibo
abidibo / accessibilità
Created December 5, 2012 09:07
Accessibilità Gino solo testo/altocontrasto/grafica
**in topBar phpModuleView**
=================================
$encode = true;
if($_SERVER['REQUEST_URI'] == '/index.php') {
$ubase = $_SERVER['REQUEST_URI']."?textview=";
$encode = false;
}
elseif(substr($_SERVER['SCRIPT_URL'], -1) == '/') {
$ubase = $_SERVER['REQUEST_URI']."?";
}
@abidibo
abidibo / APE SERVER configuration
Last active December 11, 2015 07:18
Configuration of APE SERVER, 2 machines, 1 serevr and 1 client
GENERAL
=================
Two machines, 1 server and 1 client
The backoffice and frontend applications resides on the server
SERVER
=================
Suppose the server ip on the local netw is 192.168.0.74
ls -la /var/ape
@abidibo
abidibo / mootab.css
Last active December 11, 2015 22:58
A mootools class to create a tab structure. js and css included.
.mootab .tab_contents {
border: 1px solid #eee;
padding: 10px;
}
.mootab .tab_titles .link {
cursor: pointer;
display: inline-block;
border:1px solid #eee;
border-bottom-width: 0;
padding: 2px 5px;
@abidibo
abidibo / time_graph_canvas.js
Last active December 12, 2015 04:38
This is a mootools class which permits to draw a temporal graph over a canvas. Features: - grid system (different steps on tx and y axis) - scale factor different for both axis - x axis (time) discrete - y axis continuous - can't draw in the past, always growing x - maybe more...
// new namespace
var tcg = {};
// main graph controller
tcg.graph = new Class({
options: {
x_grid_step: 20, // grid step in px on x axis
y_grid_step: 40, // grid step in px on y axis
x_factor: 1, // multiplier factor of each grid step on x axis (value = m * grid-steps)
@abidibo
abidibo / cache.php
Last active December 15, 2015 00:18
A class to manage the caching of html outputs and data structures
<?php
/**
* @file cache.php
* @brief Contains the \ref cache, outputCache and dataCache classes.
*
* @author abidibo [email protected]
* @version 0.99
* @date 2011-2012
* @copyright Otto srl [MIT License](http://www.opensource.org/licenses/mit-license.php)
*/
@abidibo
abidibo / path.js
Created March 28, 2013 11:09
Reverse selector engineering. Get css selector from element. Works with browsers implementing the :nth-of-type selector. Requires mootools selectors.
// requires mootools selectors
var path = function path(element) {
if(element.get('id')) {
return '#' + element.get('id');
}
if(element == document.body) {
return 'body';