Height of an anchor with image

When I was coding a portfolio with images inside links I have found this interesting issue when height of an anchor is bigger than its image. You can fix it with css: "a {font-size: 0}" (font-size: 0; does not work in Opera 12). "a img { display: block }" should work in all browsers including Opera and IE.
Live example is here: http://hromnik.com/web/anchor-image/


Using Fuelux spinner with form

If you want to use Fuelux spinner with <form> tag, you have to do two things:

  1. Add type="button" attribute to ‘up’ and ‘down’ buttons. Form will not send when you click the buttons.
  2. Add following script to your javascript file:

    $('.spinner').each(function(i, item) {
       var val = parseInt($(this).find('.spinner-input').val());
       $(this).spinner('value', val);

    It will set values to Fuelux spinner and won’t count it from 1 but from input value.

PHP WTF foreach loop

I have worked with PHP for a few years but recently i found a big WTF factor for me as a former Java developer. Foreach loop in PHP has not its own scope! It means this:


$name = 'Peter';
echo '$name = "'. $name . '"; before foreach.<hr>';

$names = array('Mark', 'Peter', 'John');

foreach($names as $name) {
   echo '$name = "'. $name .'"; in foreach.<br>';

echo '<hr>$name = "'. $name .'"; after foreach<br>';

will result in:

$name = "Peter"; before foreach.
$name = "Mark"; in foreach.
$name = "Peter"; in foreach.
$name = "John"; in foreach.
$name = "John"; after foreach

It means the $name variable is rewritten by foreach and it’s BAD!!!
What if i want to say “Hi Peter” after this foreach and instead of it, it will say “Hi John”.
Any suggestions how to avoid this?

Select2 placeholder does not work (solution)

I was frustrated by select2 plugin. I did not understand why on plugin’s homepage placeholder works and on my site doesn’t. I tried to google it and i found that you must add <option></option> for your select. I tried to add multiple options with value but placeholder did not work. The first option must be empty in order to get placeholder working!
Like this:

<select id="sel" placeholder="Hello">
  <option>Option value</option>

<script type="text/javascript">

Here is working example: http://hromnik.com/web/select2/
Check source code for details.