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
/* CSS */ | |
.bubble { | |
font: 12px Arial; | |
display: block; | |
width: 200px; | |
position: relative; | |
margin-bottom: 18px; | |
color:#fff; | |
padding: 15px; | |
background: #000; |
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 | |
/** | |
* Get the size of a file in reader-friendly units (KB, MB, etc.) | |
* @param string $filename The name of the file to size | |
* @param int $precision The number of decimal places to show (default: 1) | |
* @return string|bool A string with the size of the file or false on error | |
* @author Sunny Walker <www.miraclesalad.com> | |
*/ | |
function getFileSize($filename, $precision=1) { | |
$return = false; |
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
/* use : $(selector).convertToList() | |
it's better to follow it with .remove() to remove the original container */ | |
(function ($) { | |
$.fn.convertToList = function () { | |
var that = this; | |
this.before( | |
$('<select><option>Please select</option></select>'). | |
change(function () { | |
window.location = $(this).val(); |
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
//calculate the time before calling the function in window.onload | |
var beforeload = (new Date()).getTime(); | |
function getPageLoadTime(){ | |
//calculate the current time in afterload | |
var afterload = (new Date()).getTime(); | |
// now use the beforeload and afterload to calculate the seconds | |
seconds = (afterload-beforeload) / 1000; | |
// Place the seconds in the innerHTML to show the results | |
$("#load_time").text('Page load time :: ' + seconds + ' sec(s).'); |
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
$.ajax({ | |
type: 'POST', | |
url: 'url.php', | |
data: 'nombre=' + $('#nombre').val() + '&' + 'edad=' + $('#edad').val(), | |
dataType: 'json', | |
success: function(data){ | |
var html = ''; | |
$.each(data,function(index,user){ | |
html+= '<div class="user"><p>' + index + '</p>'; | |
html+= '<p>' + user.user_edad + '</p></div>'; |
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 hideAddressBar(){ | |
if(!window.location.hash){ | |
if(document.height < window.outerHeight){ | |
document.body.style.height = (window.outerHeight + 50) + 'px'; | |
} | |
setTimeout( function(){ window.scrollTo(0, 1); }, 50 ); | |
} | |
} | |
window.addEventListener("load", function(){ if(!window.pageYOffset){ hideAddressBar(); } } ); |
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
// this object gets filled with params | |
var params = {}; | |
// split and map parameters | |
location.search.substr(1).split('&').forEach(function(p) { | |
p = p.split('='); | |
params[p[0]] = decodeURIComponent(p[1] || 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
<?php | |
$url = "http://api.twitter.com/1/users/show.json?screen_name=Aleks_Cudars&include_entities=true"; | |
$feed = file_get_contents($url); | |
$twitter_decoded = json_decode($feed); | |
echo $twitter_decoded->followers_count; |
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 | |
$child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = ".$post->ID." AND post_type = 'page' ORDER BY menu_order", 'OBJECT'); | |
?> | |
<?php if ( $child_pages ) : foreach ( $child_pages as $pageChild ) : setup_postdata( $pageChild ); ?> | |
<div class="child-thumb"> | |
<?php echo get_the_post_thumbnail($pageChild->ID, 'thumbnail'); ?> | |
<a href="<?php echo get_permalink($pageChild->ID); ?>" rel="bookmark" title="<?php echo $pageChild->post_title; ?>"><?php echo $pageChild->post_title; ?></a> | |
</div> |
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 getUrl() { | |
$url = @( $_SERVER["HTTPS"] != 'on' ) ? 'http://'.$_SERVER["SERVER_NAME"] : 'https://'.$_SERVER["SERVER_NAME"]; | |
$url .= ( $_SERVER["SERVER_PORT"] !== 80 ) ? ":".$_SERVER["SERVER_PORT"] : ""; | |
$url .= $_SERVER["REQUEST_URI"]; | |
return $url; | |
} |