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
Object.defineProperty(Date.prototype,"diff",{ | |
writable: false, configurable: false, enumerable: true, | |
/** | |
* Returns the difference between two Date objects. | |
* @param {Date} The date to compare to. | |
* @return {Object} | |
* @throws {TypeError} | |
*/ | |
value: function(date) { |
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
/** | |
* Implementação do algorítimo SoundEx em Javascript. | |
* @author João Batista Neto | |
* | |
* SoundEX é um algorítimo fonético para indexação de nomes pelo som segundo | |
* sua pronúncia. O algorítimo foi desenvolvido por Robert C. Russell e | |
* Margaret K. Odell e patenteado em 1918 e 1922. | |
* {@link http://en.wikipedia.org/wiki/Soundex} | |
* | |
* @return {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
SET @startDate=DATE("2012-07-01"); | |
SET @endDate:=DATE("2012-07-31"); | |
SET @diff:=@diff:=DATEDIFF(@startDate, @endDate); | |
SET @previousStartDate:=ADDDATE(@startDate, @diff); | |
SET @previousEndDate:=ADDDATE(@endDate, @diff); | |
SELECT | |
@startDate AS `currentStartDate`, | |
@endDate AS `currentEndDate`, | |
@previousStartDate AS `previousStartDate`, |
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
#!/bin/bash | |
prog=php | |
#função para iniciar o serviço | |
start() { | |
echo -n $"iniciando $prog..." | |
# aqui o código para iniciar alguma coisa, por exemplo: | |
php -S localhost:8080 >php_log & | |
} |
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
#!/bin/sh | |
curl -s "http://news.php.net/group.php?group=php.doc&format=rss" |xsltproc rss2json.xsl /dev/stdin |json_reformat |
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
#!/bin/bash | |
ICONV="iconv -f UTF-8 -t ISO-8859-1" | |
find $1 -type f -iname "*.html" | while read fn; do | |
cp ${fn} ${fn}.utf8 | |
$ICONV < ${fn}.utf8 > ${fn} | |
rm ${fn}.utf8 | |
done |
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
Number.prototype.$toFixed = Number.prototype.toFixed; | |
Number.prototype.toFixed = function(x) { | |
return (Math.floor(this * Math.pow(10, x)) / Math.pow(10, x)).$toFixed(x); | |
}; | |
print((22.315).toFixed(2)); //22.31 | |
print((49.995).toFixed(2)); //49.99 |
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
git config --global alias.cowsay '!git commit -m "`fortune | cowsay -f tux`"' |
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 | |
/** | |
* Verifica se uma string é UTF-8 | |
* @param string $string A string que será verificada | |
* @return boolean | |
*/ | |
function is_utf8($string) { | |
return (bool) preg_match('%^(?:'. | |
'[\x09\x0A\x0D\x20-\x7E]|'. | |
'[\xC2-\xDF][\x80-\xBF]|'. |
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
#!/bin/bash | |
if [ $EUID != 0 ]; then | |
echo 'Você precisa ser root para instalar certificados.' | |
exit $? | |
fi | |
# Diretório onde os certificados serão instalados | |
cert_path=`openssl version -d|sed 's/.*\"\(.*\)\"/\1/g'`/certs | |
# Path para o certificado da Cielo |
NewerOlder