Feb 07, 2012

Code Snippets

pimteam created a Page  -  May 14, 2014

Sometimes you need to do preg_replace on user input. Don't forget to escape all special characters or you'll get funny results. Here is how:

  1 Thread   PHP  
pimteam created a Page  -  Mar 13, 2013
1 235 

A class to convert km/h to mph and knots and vice-versa. It can also parse speeds in a text and return the text with corrected and converted speeds. See the live demo at http://ultralight-airplanes.info/yspeed.html for better idea what can it do.

pimteam created a Page  -  Nov 27, 2012
4 144 

This is a javascript class that converts the HTML 5 Canvas element into interactive drawing board with tools etc. The code below contains the full class, but I recommend downloading the zip from http://re.trotoys.com/article/rocanvas/ because it contains CSS, images and samples. The code is Apache licensed so you can use it on your sites without any issues.

pimteam created a Page  -  Oct 08, 2012

This is rather simple stuff yet I see it so rarely used. In any dating sites, health calculators, DIY stuff calculators etc they ask you to enter weight and height of something (or your own weight and height) only in their preferred measurement system (metric or Imperial). Boring! This simple javascript will convert the units and instantly fill the appropriate fields in the form.

pimteam created a Page  -  Aug 16, 2012

I have struggled with creating calendars in PHP and HTML several times so far. There are different approaches, but I believe the class below is one of the best possible in terms of code readability.

  3 Threads   PHP  
pimteam created a Page  -  Feb 07, 2012
1 582 

This class calculates compounded interest on investment, saving or loan. It allows variable compounding (reinvesting) percentage. Here's a page where you can see the class used: http://sharkinvestor.com/investment-calculator/

  5 Threads   PHP  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.