Archive for January, 2009

PHP Power Set

Thursday, January 22nd, 2009

Here is a snippet that shows how to get the power set of an array.

/**
* Takes the power set of a one dimensional array and returns a 2-D array.
* array(a,b,c) ->
* array(array(a),array(b),array(c),array(a,b),array(b,c),array(a,b,c))
*/
function powerSet($in,$minimumNumber = 1) {
   $count = count($in);
   $members = pow(2,$count);
   $return = array();
   for ($i = 0; $i < $members; $i++) {
      $b = sprintf("%0".$count."b",$i);
      $out = array();
      for ($j = 0; $j < $count; $j++) {
         if ($b{$j} == '1') $out[] = $in[$j];
      }
      if (count($out) >= $minimumNumber) {
         $return[] = $out;
      }
   }
   return $return;
}

Which browsers load images that have display:none or visibility:hidden?

Thursday, January 15th, 2009

Turns out all of them, with the sole exception of Opera 9, and only for display:none. It looks like Opera is the only browser that cares about the speed of the browsing experience.

browsers tested: IE 7, IE 6, FF 3.0, Safari, Chrome and Opera 9.

Test Page:  http://janitor61.com/test/test.html

openallbrowsers.bat

Wednesday, January 7th, 2009

Here’s a Windows Batch file that will let you open a specific web page in all browsers. Look through it and comment out the browsers you don’t have installed.

 @echo off
echo ---------------------------
echo -- Open in all browsers  --
echo ---------------------------
:enter
echo Enter the URL:
set /p answer=URL:
echo Use "%answer%"?
set /p use=[Y/N]:
if /i "%use:~,1%" EQU "N" goto enter
REM == Opera ==
start "" "%programfiles%\Opera\opera.exe" "%answer%"
REM == Firefox ==
start "" "%programfiles%\Mozilla Firefox\firefox.exe" "%answer%"
REM == Safari ==
start "" "%programfiles%\Safari\Safari.exe" "%answer%"
REM == Internet Explorer ==
start "" "%programfiles%\Internet Explorer\iexplore.exe" "%answer%"
REM == MultipleIE (only if you have this installed) ==
start "" "%programfiles%\MultipleIEs\IE6\iexplore.exe" "%answer%"
REM == Chrome ==
start "" "%USERPROFILE%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe" "%answer%"