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
wp_embed_register_handler( 'gist', '/https:\/\/gist\.github\.com\/(\d+)(\?file=.*)?/i', 'wp_embed_handler_gist' ); | |
function wp_embed_handler_gist( $matches, $attr, $url, $rawattr ) { | |
$embed = sprintf( | |
'<script src="https://gist.github.com/%1$s.js%2$s"></script>', | |
esc_attr($matches[1]), | |
esc_attr($matches[2]) | |
); |
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
<?php | |
$address = 'avenida+gustavo+paiva,maceio,alagoas,brasil'; | |
$geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$address.'&sensor=false'); | |
$output= json_decode($geocode); | |
$lat = $output->results[0]->geometry->location->lat; | |
$long = $output->results[0]->geometry->location->lng; |
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
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.ahead(180); | |
robot.rotateCannon(360); |
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_settings() { | |
var doc_location = document.location.href; | |
var url_strip = new RegExp("http:\/\/.*\/"); | |
var base_url = url_strip.exec(doc_location); | |
var settings = { "base_url" : base_url } | |
return settings; | |
} | |
settings = get_settings(); | |
alert(settings.base_url); |
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
<?php | |
//PHP - Get Gmail new messages (unread) from Atom Feed | |
$username = urlencode('my-gmail-account'); | |
$password = 'my-password'; | |
$tag = ''; | |
$handle = curl_init(); | |
$options = 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
<?php | |
$text = "Hi, please visit (http://www.google.com)"; | |
$text = preg_replace("#http://([A-z0-9./-]+)#", '<a href="$1">$0</a>', $text); | |
echo $text; | |
?> |
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
<?php | |
$date_a = strtotime('2010-11-25'); | |
$date_b = strtotime('2012-11-25'); | |
if($date_a >= $date_ab{ | |
echo 'date_a >= date_b'; | |
}else{ | |
echo 'date_a < date_b'; | |
} |
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
<?php | |
function distance($lat1, $lon1, $lat2, $lon2, $unit) { | |
$theta = $lon1 - $lon2; | |
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta)); | |
$dist = acos($dist); | |
$dist = rad2deg($dist); | |
$miles = $dist * 60 * 1.1515; | |
$unit = strtoupper($unit); |
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
<?php | |
$string = 'Hi, visit my website: http://beto.euqueroserummacaco.com'; | |
$string = preg_replace('/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', '', $string); | |
echo $string; | |
?> |
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
<?php | |
function slug($str){ | |
$str = strtolower(trim($str)); | |
$str = preg_replace('/[^a-z0-9-]/', '-', $str); | |
$str = preg_replace('/-+/', "-", $str); | |
return $str; | |
} | |
echo slug('This is my string ;) '); |
OlderNewer