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.
28 03, 2009

array_change_key_case

By | 2009-10-15T22:42:53+00:00 March 28th, 2009|Categories: PHP, Ruby|Tags: , , , , |1 Comment

This function changes all keys in an array by returning an array with all keys from argument lowercased or uppercased. Numbered indices are left as is.

PHP

$input_array = array('FirSt' => 1, 'SecOnd' => 4);
print_r( array_change_key_case($input_array, CASE_UPPER) );
// => array('FIRST' => 1, 'SECOND' => 4);

To replicate this functionality in Ruby, we need to use a Hash object, since arrays in Ruby don’t use associative key/value pairs.

Ruby

hash = {'FirSt' => 1, 'SecOnd' => 4}
 
result = hash.inject({}) do |hash, keys|
  hash[keys[0].upcase] = keys[1]
  hash
end
p result
# => { 'FIRST' => 1, 'SECOND' => 4 }
25 03, 2009

addslashes

By | 2009-03-27T14:28:04+00:00 March 25th, 2009|Categories: PHP, Ruby|Tags: , , , |Comments Off on addslashes

Addslashes takes a string as an argument, and returns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote [ ‘ ], double quote [ ” ], backslash [ \ ] and NULL (the NULL byte).

PHP

echo addslashes("Here's some money for your lunch");
// => Here\'s some money for your lunch

Ruby

puts "Here's some money for your lunch".gsub(/['"\\\x0]/,'\\\\\0');
# => Here\'s some money for your lunch

As you can see above, the easiest way to emulate the PHP function addslashes() in Ruby is to use regular expressions.

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