Skip to content

Instantly share code, notes, and snippets.

View wescleymatos's full-sized avatar
:octocat:
I'm ready!

Wescley Matos wescleymatos

:octocat:
I'm ready!
View GitHub Profile
@wescleymatos
wescleymatos / command_linux.sh
Created June 18, 2012 11:51
comandos linux importantes
#remover todos os arquivos .mp3 de um File Server, por exemplo:
find / -type f -iname *.mp3 -exec rm -rf {} \;
@wescleymatos
wescleymatos / money.php
Created June 25, 2012 14:05
convert mysql decimal(10,2) in money brazil(R$)
<?php
//Converte de R$ para decimal(10,2)
//$value = 150.000,00
$value = str_replace('.','',$value);
$value = str_replace(',','.',$value);
echo $value; //150000.00
//Converter de decimal(10,2) para R$
//$value = 150000.00
@wescleymatos
wescleymatos / generator_php.php
Created July 3, 2012 18:22
gerador de nomes
<?php
function filenameGenerator($file){
preg_match("/(\w{3,4})$/i", $file, $matchs);
return sha1($file.date('YmdHis', time())).".".$matchs[1];
}
?>
@wescleymatos
wescleymatos / ferramentas_php
Created August 7, 2012 17:20
Minhas Ferramentas para Trabalhar com PHP
#Inslatar Xdebug
sudo apt-get install xdebug
#Instalar o pear
sudo apt-get install php-pear
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover pear.cakephp.org
@wescleymatos
wescleymatos / virtualhost
Created August 10, 2012 12:55
Config Virtualhost apache2
#Em /etc/apache2/sites-avaliable crie o arquivo
NameVirtualHost *
<VirtualHost *>
ServerAdmin [email protected]
DocumentRoot /var/www/prime
ServerName www.prime.com.br
ServerAlias prime.com.br *.prime.com.br
@wescleymatos
wescleymatos / placeholder.js
Created September 11, 2012 14:41
Placeholder IE
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
if (input.val() == '' || input.val() == input.attr('placeholder')) {
input.addClass('placeholder');
<?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
@wescleymatos
wescleymatos / image_preview.html
Created May 9, 2013 20:15
Este código exibe o preview de uma imagem e recupera seu tamanho original.
<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;
(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);
@wescleymatos
wescleymatos / altura_div.js
Last active December 18, 2015 01:48
Pega a altura das divs e ordena o array de forma descendente.
$(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);
});