function mail_utf8($to, $subject = '(No subject)', $message = '', $header = '') {
$header_ = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n";
mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header_ . $header);
}
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
// Released under MIT license: http://www.opensource.org/licenses/mit-license.php | |
$('[placeholder]').focus(function() { | |
var input = $(this); | |
if (input.val() == input.attr('placeholder')) { | |
input.val(''); | |
input.removeClass('placeholder'); | |
} | |
}).blur(function() { | |
var input = $(this); |
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
//element - elemento que ao clicar, sobe ao topo automaticamente e suavamente ex: $('#subir') | |
function subirSuavemente(element){ | |
"use strict"; | |
element.click(function(event){ | |
$('html, body').animate({scrollTop:0}, 'slow'); | |
event.preventDefault(); | |
}); | |
} |
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
<!--# link: http://learn.iis.net/page.aspx/470/importing-apache-modrewrite-rules/ --> | |
<configuration> | |
<system.webServer> | |
<rewrite> | |
<rules> | |
<!--# Turn on URL rewriting--> | |
<!--# Protect hidden files from being viewed--> | |
<!--# Protect application and system files from being viewed--> | |
<rule name="Imported Rule 9" stopProcessing="true"> | |
<match url="^(?:application|modules|system)\b.*" ignoreCase="false" /> |
You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';
This is quite common and very helpful. Another option is to do:
name || (name = 'joe');
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 | |
mysql_connect("$hostname_config", "$username_config", "$password_config") or die(mysql_error()); | |
$db = mysql_select_db("$database_config") or die(mysql_error()); | |
mysql_query("SET NAMES 'utf8'"); | |
mysql_query('SET character_set_connection=utf8'); | |
mysql_query('SET character_set_client=utf8'); | |
mysql_query('SET character_set_results=utf8'); |
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 toCamelCase(str) { | |
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(letter, index) { | |
return index == 0 ? letter.toUpperCase() : letter.toLowerCase(); | |
}).replace(/\s+/g, ' '); | |
} |
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
-- | |
-- Estrutura da tabela `estados` | |
-- | |
CREATE TABLE IF NOT EXISTS `estados` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`nome` varchar(60) DEFAULT NULL, | |
`sigla` varchar(5) DEFAULT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='<double-click to overwrite multiple objects>' AUTO_INCREMENT=28 ; |
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
select floor(20/100*(count(*))) as min, floor(80/100*(count(*))) as max | |
from produto | |
order by valor | |
limit min, max; | |
select min, max | |
from (SELECT valor, floor(20/100*(count(*))) as min, floor(80/100*(count(*))) as max FROM produto group by fornecedor_id) produto | |
order by valor | |
limit 0, 4; |
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
SET @_mediaGlobal := (SELECT AVG(valor) FROM produto ORDER BY valor); | |
SET @dp := (SELECT (STDDEV(valor)/2) as dp FROM produto ORDER BY valor); | |
select (@_mediaGlobal - @dp) as min, (@_mediaGlobal + @dp) as max, @dp, @_mediaGlobal, AVG(valor) as mediaReal from produto where valor >= (@_mediaGlobal - @dp) and valor <= (@_mediaGlobal + @dp) order by valor; |