FizzBuzz ladder approach performance test

The FizzBuzz task is quite popular specially on interviews for juniors or middle developers. I quite often hear that ladder approach is faster, but I do not think so. I made benchmark test to be absolutely sure, which is actually the main goal for this blog post.

Below you can see both implementation of FizzBuzz.

For testing purposes I executed this two functions 500 times with $startFrom value from 0 to 500 and the result shows that:
FizzBuzz finished for 8.325s
FizzBuzz2 finished for 7.773s
Read more

Function which return third side from two side of triangle and corner between them

For this function I used external function written by Enrique Gonzalez for converting degrees to radian (
// I am not proud with that long function name, but in this case it explaining exactly what it does.
function find_third_side_from_two_side_with_corner(a, b, y) {
    return Math.log((Math.pow(a,2) + Math.pow(b,2)) -2*a*b*Math.cos(deg2rad(y)));

// example how to use it.
Read more

Really small JavaScript function which return only integer from given string.

function get_only_int(string)
    string = string.replace(/[^0-9]/g,'');
    if (string.length > 0)
        return parseInt(string);
        return 0;

Command line parser written in PHP

Tiny, light and easy for using parser which give flags and arguments in same time.
class Cli_Parser
	 * @param string $argv - default is $_SERVER['argv']
	 * @return array(
	 * 		'flag' => array('flag1','flag2','flag3'), 
	 * 		'arg' => array('key2' => 'value2', 'key2' => 'value2', 'key3' => 'value3')
	 * )
	public static function get($argv = NULL) 
		if ($argv === NULL)
Read more

PHP function for checking for active process ID

This tiny function work on CentOS but I think it will work in all unix based OS.
function is_active_process($pid)
	$output = array();
	exec("ps -p ".$pid, $output);
	return (count($output) > 1);