This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.

This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.
5 04, 2009

array_sum

By | 2009-10-15T22:42:43+00:00 April 5th, 2009|Categories: PHP, Ruby|Tags: , , , |2 Comments

Returns the sum of values in an array.

PHP

$a = array(2, 4, 6, 8);
echo array_sum($a);
// => 20

Ruby

a_var = [2, 4, 6, 8];
puts a_var.inject {|sum,x| sum ? sum + x : x };
# => 20

In the code above, the return value from the ruby code will be nil if the array used is empty. This is not exactly the same behaviour as PHP, since the array_sum() function will always return a number. We can force ruby to always return a float (or an int) too, even if the array is empty, by adding a bit of type casting to the final result:

Ruby

a_var = [];
puts a_var.inject {|sum,x| sum ? sum + x : x }.to_f;
# => 0.0
2 04, 2009

pi

By | 2009-04-01T16:04:36+00:00 April 2nd, 2009|Categories: PHP, Ruby|Tags: , , |Comments Off on pi

Returns the value of PI to 14 (default) decimal places. This precision can be altered in the php.ini file.

PHP

echo pi();
// => 3.1415926535898

Ruby

puts Math::PI;
# => 3.14159265358979

In the code above, PI is actually a constant of the Module Math. PHP also has a constant which stores the approximate value of PI – M_PI.

PHP

echo M_PI();
// => 3.1415926535898
20 03, 2009

abs

By | 2009-03-27T14:29:25+00:00 March 20th, 2009|Categories: PHP, Ruby|Tags: , , , |Comments Off on abs

Returns the absolute value for a number.

PHP

echo abs(-4.2);
// => 4.2;

Ruby

puts -4.2.abs;
# => 4.2;
17 03, 2009

acos

By | 2009-03-27T14:29:49+00:00 March 17th, 2009|Categories: PHP, Ruby|Tags: , , , , |Comments Off on acos

Returns the arc cosine of the argument provided in radians.

PHP

echo acos(0.7);
// => 0.79539883018414;

Ruby

puts Math.acos(0.7);
# => 0.79539883018414;
14 03, 2009

cos

By | 2009-03-27T14:30:20+00:00 March 14th, 2009|Categories: PHP, Ruby|Tags: , , |Comments Off on cos

Returns the cosine of the argument provided in radians.

PHP

echo cos(0.5);
// => 0.87758256189037;

Ruby

puts Math.cos(0.5);
# => 0.877582561890373;
11 03, 2009

ceil

By | 2009-03-27T14:30:38+00:00 March 11th, 2009|Categories: PHP, Ruby|Tags: , , , , |Comments Off on ceil

Returns the next highest integer value by rounding up the argument provided.

PHP

echo ceil(4.1);
// => 5

Ruby

puts 4.1.ceil;
# => 5