Tuesday, January 31, 2012

Layout Jumps Left If Vertical Scrollbar Appears - HOW TO FIX IN CSS

Looks good in IE (5.5 <= 8 beta), FF (2,3), Chrome and Opera.
html {
  overflow-y: scroll;
}

Thursday, January 19, 2012

Moodle: Upload Big Files

  1. Set post_max_size to (ex.) 1000M in php.ini.
  2. Set upload_max_filesize to (ex.) 1000M in php.ini.
  3. Check the upload_tmp_dir value on the phpinfo page. If it's empty, php use the default tmp folder. On linux, it is /tmp. Sometimes it's a mapped partition/device and it has a size. If the size is lower than 1000MB, the upload won't work. Change the size of the tmp dir!
  4. If there is a LimitRequestBody row in httpd.conf (apache) or in a virtual host file, change the value to 0, it means unlimited.

Monday, January 16, 2012

Remove Yellow Border Hover from Input Boxes in Chrome

input[type="text"], input[type="password"], textarea, select { 
  outline: none;
}

Tuesday, January 10, 2012

Allow Only Numbers (0-9) in Input Fields with jQuery

  $(".numbersOnly").keydown(function(e){
    var key = e.charCode || e.keyCode || 0;
    // allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
    return (
        key == 8 || 
        key == 9 ||
        key == 46 ||
        (key >= 37 && key <= 40) ||
        (key >= 48 && key <= 57) ||
        (key >= 96 && key <= 105));
  });

Get Data from an URL using cURL

$url = 'http://www.domain.hu/user/getUsers';
 
/* gets the data from a URL */
 
function get_data($url)
{
  $ch = curl_init();
  $timeout = 60;
  curl_setopt($ch,CURLOPT_URL,$url);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
  $data = curl_exec($ch);
  curl_close($ch);
  return $data;
}