Blog - Free stuff)
Typeface has a bug with word boundaries and special caracters(Unicode) - IE
We use regularly Typeface to apply a particular font to text on websites.
A bug happened: the regex engine splits the word "français" in "franç" and "ais". The split happened when the engine meet an accented caracter, UTF8 or Unicode.
The effect was invisible in many browsers, but in Internet Explorer, a space was inserted because the script created two distinct markups.
There is a solution! You just have to change line #289 of typeface.js to this:
var words = text.split(/\b(?=\X)/);
Et l'affaire est ketchup !
Credits: http://twitter.com/tousdan
Files and folders versionning software
Very often, we edit or replace (or delete!) a file while working. More often when the file is located on an external drive, shared by multiple users and when, sadly, two or more decide to work on the same file simultaneously.
So I've been looking around and trying a few solutions to this problem.
Subversion (SVN) is a good and reliable versionning software, but it requires a specific architecture to work, and http://sparko.ca is at a too early stage to use this solution. Everyone would have to work locally and then update/checkout/commit their work when done.
We decided to use AutoVer, a freeware Windows application developped by an australian guy. (http://beanland.net.au/AutoVer/)
The program is easy to install, we can set up as many folders as we want, filter what will be backuped, and decide what to do with older versions. We can also compare different versions together.
In our case, I set up the program to backup all our projects files (located on a network drive) and save the versions on an external drive.
Every single time a user presses "save" from any program (Notepad++, Photoshop, Office...), a before-save version of the file is created with the same path on the other drive. Thus, the file
E:\projects\project1\html\hello.php
is saved under
F:\projects\project1\html\hello.php.JJMMAAAAHHMMSS.php
So then, each time an individual (i.e. Joel) deletes by mistake a file, we can restore it immediately!
Image Email script, the spam solution!
Heres a useful trick if you dont want to receive spam in your email inbox when you display your email on a highly popular website.
Create an email.php page containing this script:
// Variables configuration
$emails[1] = "info@domain.com";
$emails[2] = "test@domain.com";
//$emails[n] = "anything@domain.com";
$pathToFont = "fonts/arial.ttf"; //System Font File
// Default variables
$maxWidth = 150;
$maxHeight = 16;
$paddding = 12;
$size = 10;
$background = "ffffff";
$color = "000000";
$emailAddress = "email@domain.com";
// Get variables
$maxWidth = (isset($_GET['width'])) ? (integer)$_GET['width']:$maxWidth;
$maxHeight = (isset($_GET['height'])) ? (integer)$_GET['height']:$maxHeight;
$paddding = (isset($_GET['padding'])) ? (integer)$_GET['padding']:$paddding;
$size = (isset($_GET['size'])) ? (integer)$_GET['size']:$size;
$background = (isset($_GET['background'])) ? ($_GET['background']):($background);
$color = (isset($_GET['color'])) ? ($_GET['color']):($color);
$emailAddress = (isset($emails[$_GET['email']])) ? ($emails[$_GET['email']]):$emailAddress;
// Color converter function
function hexToRGB($hex) {
$hex = str_replace("#", "", $hex);
$color = array();
if(strlen($hex) == 3) {
$color['r'] = hexdec(substr($hex, 0, 1) . $r);
$color['g'] = hexdec(substr($hex, 1, 1) . $g);
$color['b'] = hexdec(substr($hex, 2, 1) . $b);
}
else if(strlen($hex) == 6) {
$color['r'] = hexdec(substr($hex, 0, 2));
$color['g'] = hexdec(substr($hex, 2, 2));
$color['b'] = hexdec(substr($hex, 4, 2));
}
return $color;
}
// Create the image
$im = imagecreatetruecolor($maxWidth, $maxHeight);
$rgb = hexToRGB($background);
$backgroundColor = imagecolorallocate($im, $rgb["r"], $rgb["g"], $rgb["b"]);
$rgb = hexToRGB($color);
$fontColor = imagecolorallocate($im, $rgb["r"], $rgb["g"], $rgb["b"]);
// Add the background color
imagefilledrectangle($im, 0, 0, $maxWidth-1, $maxHeight-1, $backgroundColor);
imagecolortransparent($im, $backgroundColor);
// Size configuration
$coord = imagettfbbox ( $size ,0 , $pathToFont , "($emailAddress)" );
if($coord[2] > $maxWidth) $size = 9;
// Image Email creation
imagettftext ( $im, $size , 0 , 0 , $paddding , $fontColor, $pathToFont , $emailAddress );
// Display the image in the browser
header('Content-type: image/gif');
imagegif($im);
imagedestroy($im);
We use it like this:
email.php?email=1&color=F0F0F0&background=000000&width=220&height=16&padding=12
The variables are:
email: The email we want to display (declared in the script)
color: Font color
background: Background color
width: Image width
height: Image height
padding: Padding inside the image
Here's the final result of what it looks like:
NOTE: The GD2 library must be "enabled" in your PHP config.
Apache Error HTTPD: NoCase option for non-regex pattern is not supported and will be ignored.
An Apache error came to fill all our Apache error_logs. We (programmers) tend to use the [NC] flag in the .htaccess files that we create so that Apache doesn't consider the case when using RewriteCond.
The error is:
[warn] RewriteCond: NoCase option for non-regex pattern '-f' is not supported and will be ignored. [warn] RewriteCond: NoCase option for non-regex pattern '-d' is not supported and will be ignored.
So instead of using in .htaccess:
RewriteCond %{REQUEST_FILENAME} !-f [NC,OR]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
prefer to use:
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
Another (yet better!) solution is to use:
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule "." - [skip=100]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule "." - [skip=100]
Categories
All articles, Design, E-Commerce, Free stuff, Internal, Kitch website of the day, Mobile, Web, Web Marketing,
Tags
quétaine, Sparko, Montréal, htaccess, java, la presse, marketing, rewriteCond, site quétaine, accents, accesnotaire.com, affaires, Agence de développement web, amazon, apache, apple, archambault, autoVer, back-up, backup,

0