Time to execute PHP
Hello, today we will talk how to measure executing time of PHP code.
First of all we need to understand what is this. Time to execute is End Seconds - Start seconds.
Lets catch start time:
<?php
function getTime() {
$a = explode (' ',microtime());
return(double) $a[0] + $a[1];
}
?>
now we gonna catch start, end time and calculate them.
function CalcTime($stime,$ftime){
echo "Time to execute: ".number_format(($ftime - $stime),2)." sec.";
}
$startTime = getTime();
//Do something here...
$endTime = getTime();
CalcTime($startTime,$endTime);
On base of this script you can test your script and choose the best way to program something.
Checking proxy list in bash
Hello again!
Now i will tell you how to check proxy list with bash script and curl.
First of all we need to make some page somewhere with content "proxyok" (you can use some free hosting for example), and you should have some proxy list file where every proxy is on a new row and format is host:port.
Now lets begin.
#!/bin/bash
x=0
while [ $x -lt $(cat proxylist.txt | wc -l) ]
do
let x=x+1
PROXY=`head -n $x proxylist.txt | tail -n 1`
echo "Checking proxy $PROXY, number $x"
CONTENT=`curl "http://www.testurl.com/page.html" --proxy "$PROXY" --silent --compressed --progress-bar`
if [ "$CONTENT" == "proxyok" ]
then
echo "proxy is ok!"
echo $PROXY >> activeproxy.txt
else
echo "proxy is DOWN!"
fi
done
Now change "http://www.testurl.com/page.html" with your URL and proxylist.txt to your proxy list.
Unix commands
Here we can found some explanations of Unix commands and some Bash examples: http://cb.vu/unixtoolbox.xhtml
Checking for Internet connection on Android
Here is simple example for internet connection check on Android devices:
private boolean checkInternetConnection() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
// test for connection
if (cm.getActiveNetworkInfo() != null
&& cm.getActiveNetworkInfo().isAvailable()
&& cm.getActiveNetworkInfo().isConnected()) {
return true;
} else {
return false;
}
}
Getting Manufacturer on Android Device
It was hard to investigate the problem with version 1.5 and Build Manufacturer, and here is the solution:
public String GetManufacturer(){
try {
return android.os.Build.class.getField("MANUFACTURER").get(null).toString();
} catch (Exception e) {
return "undefined";
}
}
Now we will catch Exception without Unexpected Error in Runtime.
Lua For IntelliJ IDEA
Here is very interesting API for IntelliJ IDEA which supports Lua.

You can found it on: https://bitbucket.org/sylvanaar2/lua-for-idea/wiki/Home
Special thanks to Sylvanaar.