recently got 'memory too low'. after removing my pictures, messages, reducing logs, changed to memory card, still nothing.
phone memory used 44Mb, free a few Kb.
eventually had to *#7370#
Monday, May 3, 2010
tail console output with ajax
I finally worked out how to have ajax tail the output from a server side command/script.
First capture the output of the console/command into a database:
#!/usr/local/bin/perl
use DBI;
use FileHandle;
use IPC::Open2;
$pid = open2(*Reader, *Writer, "tail -f /usr/local/logs/access_log" );
#print Writer "stuff\n";
my $dbh = DBI->connect('dbi:mysql:jpscc:localhost:3306','root','password') or die "Connection Error: $DBI::errstr\n";
while ($got = <Reader>)
{
print $got;
$hdl=$dbh->prepare_cached('INSERT INTO test_t (`line`) VALUES (?)');
$hdl->execute($got);
}
Then the server side cgi-script, in this case I used perl. You can use whatever language you want to achieve the same output. The output is a simple XML output:
#!/usr/bin/env perl
print "Content-type:text/xml\r\n\r\n";
use DBI;
my $dbh = DBI->connect('dbi:mysql:jpscc:localhost:3306','root','password') or die "Connection Error: $DBI::errstr\n";
print <<END;
<?xml version="1.0" encoding="ISO-8859-1"?>
END
$query_string = $ENV{'QUERY_STRING'};
print STDERR "query_string=[$query_string]\n";
my %FORM;
@pairs = split(/&/, $query_string);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
#Converting Hex to English.
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$FORM{$name} = $value;
print STDERR "input $name => $value\n";
}
print "<CATALOG>\n";
$hdl=$dbh->prepare_cached('SELECT * from test_t where (idx>'.$FORM{"id"}.')' );
print STDERR 'SELECT * from test_t where (idx>'.$FORM{"id"}.')' ;
$hdl->execute();
my $first=0;
my $last =0;
@age = $hdl->fetchrow_array();
$a = $age[2];
$first = $age[1];
chomp($a);
print "<ID>".$first."</ID>\n";
print "<ARTIST>".$a."</ARTIST>\n";
if ($hdl->rows > 0)
{
while (@age = $hdl->fetchrow_array())
{
#print "$age[0] $age[1] $age[2]\n";
$a = $age[2];
$last=$age[1];
chomp($a);
chomp($last);
print "<ID>".$last."</ID>\n";
print "<ARTIST>".$a."</ARTIST>\n";
}
print "</CATALOG>\n";
# delete if single use, otherwise create a cron cleanup
$hdl=$dbh->prepare_cached('DELETE from test_t where (idx >= '.$first.' and idx <= '.$last.')');
$hdl->execute();
#$dbh->commit;
}
Finally the client script request the lines based on the last line number it got.
Finally the client side. The client requests each line based on the line number:
#!/usr/bin/env perl
print "Content-type:text/html\r\n\r\n";
print <<END;
<html>
<head>
<script type="text/javascript">
var last_idx=0;
var timer_id=0;
b2.disabled = true;
function pause_page()
{
clearTimeout(timer_id);
b1.disabled = false;
b2.disabled = true;
}
function loadXMLDoc()
{
b1.disabled = true;
b2.disabled = false;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
xmlDoc=xmlhttp.responseXML;
var txt="";
x=xmlDoc.getElementsByTagName("ARTIST");
y1=xmlDoc.getElementsByTagName("ID");
for (i=0;i<x.length;i++)
{
last_idx = y1[i].childNodes[0].nodeValue;
txt=txt + last_idx + " "+ i+" ";
txt=txt + x[i].childNodes[0].nodeValue + " "+ i+"<br />";
//txt=txt + x[i].childNodes[0].nodeValue + "\\n";
}
var x = document.getElementById("myDiv").innerHTML;
x = x + txt;
document.getElementById("myDiv").innerHTML=x;
//document.getElementById("myDiv").innerHTML+=txt;
var objDiv = document.getElementById("myDiv");
objDiv.scrollTop = objDiv.scrollHeight;
}
}
xmlhttp.open("GET","get_lines_5.pl?id="+last_idx+"",true);
xmlhttp.send();
timer_id=setTimeout('loadXMLDoc();',5000) ;
}
</script>
</head>
<body>
<div id="myDiv" style="width: 95%; height: 50%; overflow: auto"><h2>Let AJAX change this text</h2></div>
<button type="button" id="b1" onclick="loadXMLDoc()">Change Content</button>
<button type="button" id="b2" onclick="pause_page()">Pause Content</button>
</body>
</html>
END
First capture the output of the console/command into a database:
#!/usr/local/bin/perl
use DBI;
use FileHandle;
use IPC::Open2;
$pid = open2(*Reader, *Writer, "tail -f /usr/local/logs/access_log" );
#print Writer "stuff\n";
my $dbh = DBI->connect('dbi:mysql:jpscc:localhost:3306','root','password') or die "Connection Error: $DBI::errstr\n";
while ($got = <Reader>)
{
print $got;
$hdl=$dbh->prepare_cached('INSERT INTO test_t (`line`) VALUES (?)');
$hdl->execute($got);
}
Then the server side cgi-script, in this case I used perl. You can use whatever language you want to achieve the same output. The output is a simple XML output:
#!/usr/bin/env perl
print "Content-type:text/xml\r\n\r\n";
use DBI;
my $dbh = DBI->connect('dbi:mysql:jpscc:localhost:3306','root','password') or die "Connection Error: $DBI::errstr\n";
print <<END;
<?xml version="1.0" encoding="ISO-8859-1"?>
END
$query_string = $ENV{'QUERY_STRING'};
print STDERR "query_string=[$query_string]\n";
my %FORM;
@pairs = split(/&/, $query_string);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
#Converting Hex to English.
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$FORM{$name} = $value;
print STDERR "input $name => $value\n";
}
print "<CATALOG>\n";
$hdl=$dbh->prepare_cached('SELECT * from test_t where (idx>'.$FORM{"id"}.')' );
print STDERR 'SELECT * from test_t where (idx>'.$FORM{"id"}.')' ;
$hdl->execute();
my $first=0;
my $last =0;
@age = $hdl->fetchrow_array();
$a = $age[2];
$first = $age[1];
chomp($a);
print "<ID>".$first."</ID>\n";
print "<ARTIST>".$a."</ARTIST>\n";
if ($hdl->rows > 0)
{
while (@age = $hdl->fetchrow_array())
{
#print "$age[0] $age[1] $age[2]\n";
$a = $age[2];
$last=$age[1];
chomp($a);
chomp($last);
print "<ID>".$last."</ID>\n";
print "<ARTIST>".$a."</ARTIST>\n";
}
print "</CATALOG>\n";
# delete if single use, otherwise create a cron cleanup
$hdl=$dbh->prepare_cached('DELETE from test_t where (idx >= '.$first.' and idx <= '.$last.')');
$hdl->execute();
#$dbh->commit;
}
Finally the client script request the lines based on the last line number it got.
Finally the client side. The client requests each line based on the line number:
#!/usr/bin/env perl
print "Content-type:text/html\r\n\r\n";
print <<END;
<html>
<head>
<script type="text/javascript">
var last_idx=0;
var timer_id=0;
b2.disabled = true;
function pause_page()
{
clearTimeout(timer_id);
b1.disabled = false;
b2.disabled = true;
}
function loadXMLDoc()
{
b1.disabled = true;
b2.disabled = false;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
xmlDoc=xmlhttp.responseXML;
var txt="";
x=xmlDoc.getElementsByTagName("ARTIST");
y1=xmlDoc.getElementsByTagName("ID");
for (i=0;i<x.length;i++)
{
last_idx = y1[i].childNodes[0].nodeValue;
txt=txt + last_idx + " "+ i+" ";
txt=txt + x[i].childNodes[0].nodeValue + " "+ i+"<br />";
//txt=txt + x[i].childNodes[0].nodeValue + "\\n";
}
var x = document.getElementById("myDiv").innerHTML;
x = x + txt;
document.getElementById("myDiv").innerHTML=x;
//document.getElementById("myDiv").innerHTML+=txt;
var objDiv = document.getElementById("myDiv");
objDiv.scrollTop = objDiv.scrollHeight;
}
}
xmlhttp.open("GET","get_lines_5.pl?id="+last_idx+"",true);
xmlhttp.send();
timer_id=setTimeout('loadXMLDoc();',5000) ;
}
</script>
</head>
<body>
<div id="myDiv" style="width: 95%; height: 50%; overflow: auto"><h2>Let AJAX change this text</h2></div>
<button type="button" id="b1" onclick="loadXMLDoc()">Change Content</button>
<button type="button" id="b2" onclick="pause_page()">Pause Content</button>
</body>
</html>
END
Thursday, April 22, 2010
lost in arcgis
yes arcgis is a huge package. For the beginner its just overwhelming. Fortunately the tutorial from PASDA helps.
Try to publish a GIS resource on the other hand. Sucks. When you edit a map from ArcMap then save it, the location of the shape data (.shp) is stored in the .mxd file. Thus you have to make sure that same location exists and has the file otherwise a "The database was not found" error will appear in the logs and no layers.
The only way is to recreate the same directory structure as the server ie the default c:\arcgisserver directory and subdirs.
Try to publish a GIS resource on the other hand. Sucks. When you edit a map from ArcMap then save it, the location of the shape data (.shp) is stored in the .mxd file. Thus you have to make sure that same location exists and has the file otherwise a "The database was not found" error will appear in the logs and no layers.
The only way is to recreate the same directory structure as the server ie the default c:\arcgisserver directory and subdirs.
Thursday, April 15, 2010
psp component av connections
I recently managed to try my component av cable on an lcd 32 inch tv. Nice. My 2 year old son then grabbed the PSP from his sister. I knew he was rough and I could see him pulling at the cables. Until I found that it broke. Cheap shite. The connector broke away from the cable!
So I cut the stub to see how the cables were connected to the connecter. There 8 cables within the main cable, red, green, white, blue, brown, yellow, orange and black.
They are connected so:

Sorry but I didn't buzzer the colours to the av connectors. [Remind myself to do this.]
So I cut the stub to see how the cables were connected to the connecter. There 8 cables within the main cable, red, green, white, blue, brown, yellow, orange and black.
They are connected so:

Sorry but I didn't buzzer the colours to the av connectors. [Remind myself to do this.]
Tuesday, March 23, 2010
tiger woods rubbish
just saw the interview, what rubbish. He looks as fake as his smile.
Can't help but remember what one of the mistress had said that he was a sex animal.
Once a womaniser, always a womaniser.
Can't help but remember what one of the mistress had said that he was a sex animal.
Once a womaniser, always a womaniser.
Friday, March 5, 2010
israel gets away with murder ... again
In an all too familiar story Israel gets away with murder (again and again and again). No one gives a damn. Such is the value of Palestinian life. Hate runs deep and societies have long memories, the atrocities of today becomes the excuse of tomorrow. It is seen today and yet no one wants to face it, thanks to the US (protection).
Rest in peace Mabhouh, may god forgive your soul.
Rest in peace Mabhouh, may god forgive your soul.
Monday, February 8, 2010
CEO the new dream job
They say win or lose you still have to pay the lawyer but the CEO is now the new dream job. You don't need to be educated or be in a 'bar council' you just have to be a good 'bullshit artist'.
When the company does well the CEO gets a (proportional) bonus. When the company goes bust, the CEO gets a golden handshake. When the company does not do well they still get a bonus.
Go figure.
I personally think they deserve a golden shower.
Now, where's a vacant CEO job.
When the company does well the CEO gets a (proportional) bonus. When the company goes bust, the CEO gets a golden handshake. When the company does not do well they still get a bonus.
Go figure.
I personally think they deserve a golden shower.
Now, where's a vacant CEO job.
Subscribe to:
Posts (Atom)
