Thursday, December 9, 2010

smashphoops.33 pt4

more dubstep!
http://goo.gl/I9x6e

19 - fine without you - Djmee remix
20 - blame ft. Camillia Marie - Star - Dr. P remix <- this tune is of the nuts hook.
21 - scary monsters and sprites - noisia
22 - kill everybody - bare noise remix
23 - piano Tune - bar 9
24 - shot me down - bare
25 - f double u - cookie monster
26 - power skism

Thursday, December 2, 2010

smashphoops.33 pt2.

Part 2 of 3 -> http://goo.gl/gLK2L

10. Ur dream - scream
11. all in - Dubba Jonny
12. afro jack ft. eva simmons - adam f. remix
13. i remember - deadmau5 caspa remix
14. chewie center - subscape ?
15. paranoid - dansette junior
16. follow - crystal fighters
17. delerium - silence - high rankin
18. haunt you - flux pavilion

Friday, November 26, 2010

smashphoops.33

Gotcha!
+ dubstep
the originals for smashpooped.33. part 1 : http://goo.gl/gV1qQ
+ kion and murda - number 1 sound
+ flux pavilion - excuse me
+ dubtek - western dub
+ sukh knight - jewel theif
+ jakwob remix (katie melua) - the flood
+ john legend & magnetic man - getting nowhere
+ true tiger remix (macy gray) - lately
+ caspa remix (miike snow) - black and blue
+ a1 bassline & tek one - arrakis 97

Tuesday, April 13, 2010

getIdInsert


$loadFile = "bxsc.trans.cards.dat";
$dbconn = array("user"=>"djmornyc","host"=>"localhost","dbname"=>"mor_db");

if(!$conn = getConn($dbconn))
echo "connection failed\n";

$fp = fopen($loadFile,"r");
$null = pg_query($conn,"BEGIN");

while($data = fgets($fp,4096))
{
$cardnum = trim($data);
$resInsert = pg_query($conn,getSqlInsertCard($cardnum));
var_dump(pg_fetch_all($resInsert))."\n";
}

$null = pg_query($conn,"COMMIT");
$null = fclose($fp);
$null = pg_close($conn);

function getSqlInsertCard($cardnum)
{
return "insert into bxsc_cards (cardnum)
select '{$cardnum}' where not exists (select cardnum from bxsc_cards where cardnum = '$cardnum') returning id";

}

function getConn($dbconn)
{
$connStr = "";

foreach($dbconn as $key => $value)
$connStr.=" {$key}={$value} ";

return pg_connect($connStr);
}

?>

Monday, November 16, 2009

plpgsql style



CREATE OR REPLACE function _getSchema(_table text) RETURNS integer AS $$

DECLARE

_record RECORD;
_column TEXT;
_type TEXT;

BEGIN
RAISE NOTICE 'select ';

FOR _record in
SELECT column_name,data_type from information_schema.columns where table_name = _table

LOOP

_column := _record.column_name;
_type := _record.data_type;

IF
_record.data_type = 'text'
THEN
RAISE NOTICE 'count(distinct(%)) as dist_%,', _column, _column;
ELSIF
_record.data_type = 'numeric' or _record.data_type = 'integer'
THEN
RAISE NOTICE 'sum (%) as sum_%,', _column, _column;
END IF;

END LOOP;

RAISE NOTICE 'count (*) as rows';
RAISE NOTICE 'from % ', _table;


RETURN 0;

END;
$$ LANGUAGE 'plpgsql';

Saturday, November 14, 2009

get basic stats from a table.


$arPgUser = array("user"=> "postgres","host"=>"localhost","dbname"=>"dev","password" => "i1m2a3p4o5o6p7e8r9");
$connStr = getConnStr($arPgUser);
$conn = pg_connect($connStr);
$table = "books";

$sqlGetSchema = "select column_name,data_type from information_schema.columns where table_name = '{$table}'";
$res = pg_fetch_all(pg_query($conn,$sqlGetSchema));
$columns = array_map("sqlFieldStats",($res));

$sqlBuildStats= sqlBuildStats($columns,$table);
$res = pg_fetch_all(pg_query($conn,$sqlBuildStats));
print_r($res);

pg_close($conn);

function sqlBuildStats($columns,$table){

$sqlColumns = implode(",\n",$columns);
$sql = "
select
$sqlColumns
from
$table
";
echo "{$sql}\n";

return trim($sql);
}

function sqlFieldStats($arSchema){

switch($arSchema['data_type']){

case "text":
return "count(distinct({$arSchema['column_name']})) as dist_{$arSchema['column_name']}";
break;

case "numeric":
return "sum({$arSchema['column_name']}) as sum_{$arSchema['column_name']}";
break;
}
}


function getConnStr($arPgUser){

$connStr = "";
foreach ($arPgUser as $key => $value)
$connStr.= "{$key} = {$value} ";

return $connStr;
}

Friday, October 2, 2009