Flex Friendly URLs and Tracking in Google Analytics

June 17th, 2009

Hey,

I recently posted a tutorial to Transylvania Flex Group on adobe.com

http://groups.adobe.com/posts/6bca8cb2e9

You can learn how to create permanent links with Flex Applications and Track dynamic clicks with Google Analytics.

HTML Entities for Romanian Special Characters

March 12th, 2009

There is a list of special romanian characters equivalent HTML Entities:

Upper case Lower Case Upper case Entity Lower case Entity
Ă ă Ă ă
 â  â
Î î Î î
Ș ș &amp#x218; &amp#x219;
Ş ş Ş ş
Ț ț &amp#x21A; &amp#x21B;
Ţ ţ Ţ ţ

Image over javascript

January 11th, 2009

Hello!

I am using quite often this script, it’s a very simple on but helpful becouse I designed it to be standard.

Well the images used should be in the folowing format: <name>.<extension> and <name>_over.<extension>

And the script is the folowing:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<script type="text/javascript">
function over(obj)
{
	var length=obj.src.length;
	var index_ext=0;
	while (obj.src.indexOf('.',index_ext+1)!=-1)
	 {
		index_ext=obj.src.indexOf('.',index_ext+1)
	 }
	var extension=obj.src.substring( index_ext , length);
	obj.src=(obj.src.substring(0,index_ext)+"_over"+extension);
}
function out(obj)
{
	var length=obj.src.length;
	var index_ext=0;
	while (obj.src.indexOf('.',index_ext+1)!=-1)
	 {
	 index_ext=obj.src.indexOf('.',index_ext+1)
	 }
	var extension=obj.src.substring( index_ext , length);
	var idx_ov=0;
	obj.src=(obj.src.substring(0,index_ext-5)+extension);
}
</script>

And the usage is as folows:

<img onmouseover="over(this)" onmouseout="out(this)" src="buton.jpg" alt="" />

And here is an example:

Un simplu script JavaScript pentru input-uri

December 16th, 2008


E o chestie des utilizata, dar am facut un mititiel standard pe care il voi folosi si eu in continuare; pentru ca de fiecare data faceam tot cate o alta varianta a acestui script. Cateva secunde, dar e bine sa le economisesti :P

Uite aici despre ce e vorba:

       function toggle_content(event, obj, default_val) {
	if (event.type=="focus") {
		if (obj.value==default_val) {
			obj.value="";
		}
	} else
	if (event.type=="blur") {
		if (obj.value=="") {
			obj.value=default_val;
		}
	}
}

Ok. si cum se apeleaza:

<input name="field" type="text" onfocus="toggle_content(event, this, 'cauta...')" onblur="toggle_content(event, this, 'cauta...')" value="cauta..." />

puteti vedea si un exemplu:

Stiati ca? Nu poti defini constante array in PHP!

December 12th, 2008

Ciudat, interesant totusi ca in PHP se folosesc foarte des array-urile.

Oricum ideea e ca nu poti defini constante in PHP, adica asa:

1
2
3
// it will not work like this
define('MY_ARRAY', array ('one', 'two', 'three'));
echo MY_ARRAY[0]; // undefined index 0

Dar sunt vreo doua variante prin care poti face asta. Una ar fi sa salvezi de exemplu un string in constanta:

1
2
3
4
define ('MY_ARRAY', 'one,two,three');
$my_local_array = explode(',',MY_ARRAY);
echo $my_local_array[0]; // it will work
// result: one

sau poti sa serializezi obiectul (cea mai recomandata), astfel poti sa salvezi array-uri sau orice alte obiecte complexe:

1
2
3
4
5
6
7
8
9
// va recomand aceasta varianta, e cea mai simpla si are cea mai larga aplicabilitate
 
$arr = array ("one" => 1, "two" => 2, "three" => 3); // variabila de definit
 
define ('MY_ARRAY',serialize($arr)); // salvam obiectul serializat
$my_local_array = unserialize(MY_ARRAY); // il deserializam pentru a-l putea folosi
 
echo $my_local_array['one']; // and there you go :)
// result: 1

PHP header() and then die()

December 9th, 2008

Usualy, header() function can be used to change page headers, linke header(“Content-type: jpg’);

But, a most use case is, for example when you want to check user login:

1
2
3
4
5
6
7
8
9
<?php
 
if (!$user->isLogged()) {
 
header("Location: login.php");
 
}
 
?>

The problem is, there are some cases when the script continues to run after header(“Location: “), and you should allways die() after the header(“Location: “).
Like this:

1
2
3
4
5
6
7
8
9
<?php
 
if (!$user->isLogged()) {
 
header("Location: login.php");
die();
}
 
?>

Cum sa apara manuta deasupra link-ului fara campul href definit

December 8th, 2008

Deseori am intalnit aceasta problema, si chiar recent mi-a dat mari batai de cap un designer de layout.

Prima varianta, care am folosit-o si eu un timp, e sa definesti un tag href null:

<a onclick="alert('Hello World!');">click me</a>

ok, nu pare nimic gresit pana aici.
Mai nou, s-a inventat CSSul de cativa ani.
Asa ca e mult mai simplu sa definesti:

a {
cursor: pointer;
}

Mai ales ca daca vrei ca un link sa faca submit la un formular, atunci IT’s A MUST. Pentru ca pur si simplu ar urma link-ul din href si functionalitatile nu vor mai fi cele scontate.

PHP short_open_tags cannot set to on in WAMPSERVER

December 6th, 2008

Recently, I encountered that problem. I was working with a PHP engine wich was using php short_open_tags:

1
2
3
<?
// open PHP tag using <?  instead of <?php
?>

So very simple, I wanted to change the property by the simple way, tray icon -> PHP -> PHP Settings -> short open tag.

Ok the option is ticked, but the engine still doesn’t start. The issue. Looks like my version of PHP: 5.2.6, applies this setting only if set last on config file. So after many minutes of mistery, just adding line:

short_open_tags = On

at the end of my php.ini file, solved the proble.