Version Française
( Blog - Free stuff)

Calculateur de versements hypothécaires canadien

Written by David Grégoire | 16 November 2010 | 0

Voilà:

function paiements(AnnualIntRate, Period, Amount, PPay){
PrValue = Amount;
IntRate = (Math.pow((1+AnnualIntRate/2),(2/PPay)) - 1)

Pa = (PrValue * IntRate) / (1 - Math.pow (1 + IntRate, - (Period * PPay)))
return Pa;
}

aux deux semaines
console.log(paiements(0.045, 25, 325000, 24));

au mois
console.log(paiements(0.045, 25, 325000, 12));

accéléré deux semaines
console.log(paiements(0.045, 25, 325000, 26));

par semaine
console.log(paiements(0.045, 25, 325000, 52));

Tags: calculatrice hypothécaire, hypothèque, java, versements hypothécaires,

Category: Free stuff

Share:

Typeface has a bug with word boundaries and special caracters(Unicode) - IE

Written by David Grégoire | 23 March 2010 | 3

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

Tags: accents, caracteres spéciaux, java, regex, typeface, unicode,

Category: Free stuff

Share:

Files and folders versionning software

Written by David Grégoire | 8 January 2010 | 3

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!

Tags: autoVer, back-up, backup, fichiers, files, freeware, programme, sauvegarde, software, versionning,

Category: Free stuff

Share:

Image Email script, the spam solution!

Written by Joel Landry | 4 January 2010 | 0

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.

Tags: email, image email, spam,

Category: Free stuff

Share:

  • Pages :
  • 1
  • 2