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
var Binet = function( X ) { | |
var sqrt5 = Math.sqrt( 5 ); | |
return ( 1 / sqrt5 ) * ( Math.pow( ( 1 + sqrt5 ) / 2 , X ) - Math.pow( ( 1 - sqrt5 ) / 2 , X ) ); | |
} |
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 | |
/* | |
This function saved my life. | |
found on: http://www.sitepoint.com/forums//showthread.php?t=438748 | |
by: crvandyke | |
It takes an object, and when all else if/else/recursive functions fail to convert the object into an associative array, this one goes for the kill. Who would'a thunk it?! | |
*/ | |
$array = json_decode(json_encode($object), true); |
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 | |
header('Content-Type: text/html; charset=utf-8'); | |
//conexão com o servidor | |
$conect = mysql_connect("host", "user", "password"); | |
// Caso a conexão seja reprovada, exibe na tela uma mensagem de erro | |
if (!$conect) die ("<h1>Falha na coneco com o Banco de Dados!</h1>"); | |
// Caso a conexão seja aprovada, então conecta o Banco de Dados. |
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 str_pad (input, pad_length, pad_string, pad_type) { | |
// Returns input string padded on the left or right to specified length with pad_string | |
// | |
// version: 1009.2513 | |
// discuss at: http://phpjs.org/functions/str_pad | |
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) | |
// + namespaced by: Michael White (http://getsprink.com) | |
// + input by: Marco van Oort | |
// + bugfixed by: Brett Zamir (http://brett-zamir.me) | |
// * example 1: str_pad('Kevin van Zonneveld', 30, '-=', 'STR_PAD_LEFT'); |
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
<html> | |
<head> | |
<title>DEMONSTRAÇÃO: Marcar todas as Check Boxes de uma lista</title> | |
</head> | |
<body> | |
<script> | |
function checkAll(o){ | |
console.log(o); | |
var boxes = document.getElementsByTagName("input"); | |
for (var x=0;x<boxes.length;x++){ |
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
$(document).ready(function() { | |
var alturaMenu = $("#menu_vertical").height(), | |
alturaUltimasNoticias2 = $("#ultimas_noticias_2").height(), | |
alturaNoticiasDetalhe = $("#noticias_detalhe").height(); | |
var alturas = new Array(alturaMenu, alturaNoticiasDetalhe, alturaUltimasNoticias2); | |
alturas = alturas.sort(function(a,b){return b-a}); | |
console.log(alturas); | |
}); |
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() { | |
var script, | |
scripts = document.getElementsByTagName('script')[0]; | |
function load(url) { | |
script = document.createElement('script'); | |
script.async = true; | |
script.src = url; | |
scripts.parentNode.insertBefore(script, scripts); |
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
<html> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> | |
<script src="http://fancyapps.com/fancybox/source/jquery.fancybox.pack.js?v=2.1.4"></script> | |
<link rel="stylesheet" type="text/css" href="http://fancyapps.com/fancybox/source/jquery.fancybox.css?v=2.1.4" media="screen" /> | |
<style type="text/css"> | |
#imgPreview {width: 100px;} | |
</style> | |
<script> | |
var reader = new FileReader(); | |
reader.onload = onLoadFile; |
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 | |
function xml2array($contents, $get_attributes=1, $priority = 'tag') { | |
if(!$contents) return array(); | |
if(!function_exists('xml_parser_create')) { | |
//print "'xml_parser_create()' function not found!"; | |
return array(); | |
} | |
//Get the XML parser of PHP - PHP must have this module for the parser to work |