Tuesday, January 24, 2012

Highcharts: Controlling and mastering axis interval properties


Interval properties for xAxis and yAxis:

tickPixelInterval
tickInterval
tickInterval
startOnTick
endOnTick

Example "fixed number of intervals":
tickInterval : xAxis_tickInterval
startOnTick : xAxis_min
endOnTick : xAxis_max

The secret to get the exact number of intervals desired is to have xAxis_min and xAxis_max multiples of xAxis_tickInterval.
To do this, assuming you want 10 intervals, the extra fix should look like:

var xAxis_min = value_min;
var xAxis_max = value_max;
var xAxis_tickInterval = Math.round((xAxis_max - xAxis_min) / 10);
while(xAxis_min % xAxis_tickInterval != 0) {
xAxis_min--;
}
while(xAxis_max % xAxis_tickInterval != 0) {
xAxis_max++;
}

And the xAxis properties:
xAxis: {
showLastLabel: true,
min : xAxis_min,
max : xAxis_max,
tickInterval : xAxis_tickInterval,
startOnTick : xAxis_min,
endOnTick : xAxis_max
}

Wednesday, January 18, 2012

Highcharts: hide highcharts.com branding

To hide hide highcharts.com link set: credits.enabled = false

chart = new Highcharts.Chart({
credits : {
  enabled : false
},
...
});

jquery add options to select

How to add option elements to a select element:

$('#selector-id').append('<option value="123">Text Option</option>');

jquery select first option from select

How to select first option element from a select.

Get the value of first option:
var val-to-select = $('#selector-id').find('option:first').val();

Select it:
$('#selector-id').val(val-to-select);

jquery remove select options

How to remove all option elements from a select element:

$('#selector-id').children().remove();

ies4linux Ubuntu 11.10

Install ies4linux Ubuntu 11.10

sudo apt-get install wine cabextract
cd ~/Desktop/
wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-latest.tar.gz
tar zxvf ies4linux-latest.tar.gz
cd ies4linux-*
./ies4linux

Tuesday, January 17, 2012

PHP: Simple files exporter

Export only certain files from a project directory to an external directory. Operating system: linux (can be addapted to Windows).
Define a short list of files which will be exported.
The PHP script also creates recursively the target directories. This will spare the user from waisting a lot of time creating complex folder/subfolder structures.

<?php

$files = '
folder1/folder2/folder3/folder4/file1.php
folder1/folder2/folder3/folder4/file2.php
folder1/folder2/folder5/folder6/folder7/file3.php
folder1/folder2/folder5/folder6/folder8/folder9/file4.php
';


$project_path = '/absolute-current-path-of-the-project';
$project_path_export = '/absolute-target-path-of-the-export-folder';


$files_array = explode("\n", trim($files));
foreach($files_array as $f) {
$f = trim($f);
if(is_file($project_path . '/' . $f)) {
// make target dir if necessary
$dirs = explode('/', $project_path_export . '/' . $f);
unset($dirs[count($dirs) - 1]);
$dir_target = implode('/', $dirs);
if(!is_dir($dir_target)) {
shell_exec("mkdir -p $dir_target");
}
// copy file
if(is_dir($dir_target)) {
shell_exec("cp {$project_path}/{$f} {$dir_target}/");
}
}
}


PHP: AJAX json encode french characters

How to display french or other charset characters using AJAX JSON calls.

Current behaviour: text replaced by null;

Solution: Apply PHP function utf8_encode to the string (for each element in the array).

$string_array_element = utf8_encode($string_array_element);

Friday, January 6, 2012

SVN command line resources

Eclipse - permanently store certificate password

Preferences -> Team -> SVN

Change SVN interface Client to SVNKit

Eclipse - Ignore local files for SVN commit

Examples of files to ignore:
.buildpath
.project
.settings

Eclipse -> Preferences -> Team -> Ignored Resources

Ubuntu: Install PHP, Apache, MySQL

$ sudo apt-get install apache2 libapache2-mod-php5 php5 php5-common php5-curl php5-mysql php5-json php5-gd php5-mcrypt php5-memcache php5-memcached php5-ming php5-cli

Ubuntu - Eclipse - Failed to load JavaHL Library

Eclipse SVN, subclipse: "Failed to load JavaHL Library"

Solution:
$ sudo apt-get install libsvn-java

Ubuntu 11.10 - Eclipse 3.7.1 - No Java virtual machine was found

Error: eclipse: "No Java virtual machine was found"
System: Ubuntu 11.10 fresh install

Solution:
$ aptitude search jdk
# install openjdk-7-jre openjdk-7-jdk if they are not installed
$ sudo apt-get install openjdk-7-jre openjdk-7-jdk

Mount SMB shares from the command line

Mount smbfs command with permissions for the current user:

$ sudo mount -t smbfs //network-resource/folder /local-path/local-folder -o username=user,password=pass,uid=`id -u`,gid=`id -g`

Ubuntu 11.10 add/remove/move panel elements

How to add/remove/move panel elements in Ubuntu 11.10

The problem is that when you right-click on the panel nothing happens!

The solution: hold ALT pressed and right-click the panel. :)

Ubuntu 11.10 restore classic menu/panel

How to restore classic menu/panel in Ubuntu 11.10

Open terminal: CTRL + ALT + T

$ sudo apt-get install gnome-session-fallback

Log out and select at Log-in screen: Gnome Classic.

Tuesday, January 3, 2012

wstats.net - new version

Some new features are now available. Feel free to check the new version: http://wstats.net.

Sunday, January 1, 2012

Ttransparent background CSS

CSS properties for transparency:
.transparent
{
opacity:0.4;
filter:alpha(opacity=40); /* For IE8 and earlier */
}