This file contains 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
dig +short myip.opendns.com @resolver1.opendns.com |
This file contains 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 is_hash($var){ | |
if (!is_array($var)) | |
return false; | |
return array_keys($var) !== range(0,sizeof($var)-1); | |
} | |
function is_foreachable($var) { | |
return (is_array($var) && count($var)) || ($var instanceof Traversable); | |
} |
This file contains 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
to turn it on: | |
set global general_log = 'off'; set global general_log_file = '/var/log/mysql/mysql.log'; set global general_log = 'on'; | |
to turn it off: | |
set global general_log = 'off'; |
This file contains 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
http://www.slideshare.net/avalanche123/introduction-toimagine |
This file contains 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
$query=db_select('node','n'); | |
$query->distinct(true); | |
# ( 6371 * acos( cos( radians($lat) ) * cos( radians( DATABASENAME.scheda.lat ) ) * cos( radians( DATABASENAME.scheda.lng ) - radians($lon) ) + sin( radians($lat) ) * sin( radians( DATABASENAME.scheda.lat ) ) ) ) AS distance | |
$query= db_select('node','n'); | |
$query->join('location_instance','li','li.nid=n.nid'); | |
$query->join('location','l','li.lid=l.lid'); | |
$query->leftJoin('location_phone','lp','lp.lid=l.lid'); |
This file contains 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
public static double distance(double lat1,double lon1,double lat2,double lon2){ | |
return ( 6371 * Math.acos( Math.cos( Math.toRadians(lat1) ) * Math.cos( Math.toRadians( lat2 ) ) * Math.cos( Math.toRadians( lon2 ) - Math.toRadians(lon1) ) + Math.sin( Math.toRadians(lat1) ) * Math.sin( Math.toRadians( lat2 ) ) ) ) ; | |
} | |
public static double distance(GeoPoint point1,GeoPoint point2){ | |
return distance(point1.getLatitudeE6()/1000000,point1.getLongitudeE6()/1000000,point2.getLatitudeE6()/1000000,point2.getLongitudeE6()/1000000); | |
} |
This file contains 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
if($node->field_video[LANGUAGE_NONE][0]['file']->uri){ | |
$variables = array( | |
'uri' => $node->field_video[LANGUAGE_NONE][0]['file']->uri, | |
'video_id' => $node->nid, // just working because there's only one video per nid | |
'options' => array( | |
'width'=>media_youtube_variable_get('width'), | |
'height'=>media_youtube_variable_get('height'), | |
'autoplay' => media_youtube_variable_get('autoplay'), | |
), |
This file contains 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
sviluppo@dev:~$ cat /usr/local/bin/update_svn_proj.sh | |
#/bin/bash | |
VHOSTSDIR="/var/www/vhosts/"; | |
if [ "$(id -u)" != "0" ]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi |
This file contains 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
$options['target'] = 'default'; | |
$args=$query->getArguments(); | |
$stmt = Database::getConnection($options['target'])->prepareQuery($query); | |
print interpolateQuery($stmt->queryString,$args); | |
$result[]=serialize((string)interpolateQuery($stmt->queryString,$args)); | |
function interpolateQuery($query, $params) { | |
$keys = array(); | |
$values = array(); |
This file contains 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 _get_query_string(SelectQueryInterface $query) { | |
$string = (string) $query; | |
$arguments = $query->arguments(); | |
if (!empty($arguments) && is_array($arguments)) { | |
foreach ($arguments as $placeholder => &$value) { | |
if (is_string($value)) { | |
$value = "'$value'"; | |
} | |
} |
NewerOlder