This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error_reporting(E_ALL); | |
ini_set('display_errors', '1'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/etc/php5/apache2/php.ini |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo /etc/init.d/apache2 restart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sql = "SELECT COUNT(*) FROM table WHERE 1"; | |
$records_count = Yii::app()->db->createCommand( $sql )->queryScalar(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The function checks if xml is valid | |
function is_valid_xml ( $xml ) { | |
if( empty( $xml ) ){ | |
return null; | |
} | |
libxml_clear_errors(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Encoding { | |
protected static $win1252ToUtf8 = array( | |
128 => "\xe2\x82\xac", | |
130 => "\xe2\x80\x9a", | |
131 => "\xc6\x92", | |
132 => "\xe2\x80\x9e", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// function extract a domain url from the link | |
// !Note: the domain name case is transformed to lowercase | |
function get_domain( $url ){ | |
$url = strtolower( $url ); | |
$base = str_ireplace( 'http://', '', $url ); | |
$base = str_ireplace( 'https://', '', $base ); | |
if( preg_match( '/^www\./i', $base ) ){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$mysqli = new mysqli('localhost', 'my_user', 'my_password', 'world'); | |
/* check connection */ | |
if (mysqli_connect_errno()) { | |
printf("Connect failed: %s\n", mysqli_connect_error()); | |
exit(); | |
} | |
$stmt = $mysqli->prepare("INSERT INTO CountryLanguage VALUES (?, ?, ?, ?)"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Yii::log('Log test',CLogger::LEVEL_ERROR); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using the Job Control of bash to send the process into the background: | |
ctrl+z to stop (pause) the program and get back to the shell | |
bg to run it in the background | |
disown -h so that the process isn't killed when the terminal closes | |
Suppose for some reason Ctrl+Z is also not working, go to another terminal, find the process id (using ps) and run | |
kill -20 PID | |
kill -18 PID |
OlderNewer