Skip to content

Instantly share code, notes, and snippets.

View dublado's full-sized avatar
📭
Send me a Telegram

Thiago Machado dublado

📭
Send me a Telegram
View GitHub Profile
@dublado
dublado / gist:1478451
Created December 14, 2011 20:50
limpa string - Retirando acentos, caracteres especiais e espaços do nome de um arquivo durante uma operação de upload
function limpastring($palavra)
{
//$palavra = "açúcar união";
$palavra = strtolower(ereg_replace("[^a-zA-Z0-9_.]",
"", strtr($nome_antigo, "áàãâéêíóôõúüçÁÀÃÂÉÊÍÓÔÕÚÜÇ ",
"aaaaeeiooouucAAAAEEIOOOUUC_")));
return $palavra; // imprime "acucar_uniao"
}
@dublado
dublado / gist:1478465
Created December 14, 2011 20:52
utf8 converter fixer
<pre><?php
$var = "Not%c3%adcias";
echo $var;
echo "\n";
echo htmlentities($var);
echo "\n";
echo urlencode($var);
echo "\n";
@dublado
dublado / gist:1478494
Last active March 10, 2016 13:54
ffmpeg converter mp4 em mp3
ffmpeg -i input.m4downgrade svn -acodec libmp3lame -ab 128k output.mp3
#!/bin/bash
for i in *.mp4
do
ffmpeg -i "$i" -ab 128k "${i%mp4}mp3"
done
@dublado
dublado / gist:1488257
Created December 16, 2011 22:14
block enter and backspace
if (typeof window.event != 'undefined') // IE
document.onkeydown = function() // IE
{
var t=event.srcElement.type;
var kc=event.keyCode;
return ((kc != 8 && kc != 13) || ( t == 'text' && kc != 13 ) ||
(t == 'textarea') || ( t == 'submit' && kc == 13))
}
else
document.onkeypress = function(e) // FireFox/Others
@dublado
dublado / gist:1894920
Created February 23, 2012 20:36
svn diff zip revision to deploy
Para apenas uma release
svn diff -c 442 | cut -c 9- | xargs zip -9 patch_hoje.zip
Para um range de releases
svn diff -r 419:442 --summarize | cut -c 9- | xargs zip -9 patch.zip
@dublado
dublado / gist:2044534
Created March 15, 2012 14:41
svn ignore
svn propset svn:ignore "*" var/log/
Pode ser usado a opção --recursive
@dublado
dublado / gist:2230381
Created March 28, 2012 20:47
Getting static block
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('identifier')->toHtml() ?>
@dublado
dublado / gist:2286973
Created April 2, 2012 20:24
get utm source, name and all
function getUtm(){
$utm = array();
if(!empty($_COOKIE['__utmz'])){
$pattern = "/(utmcsr=([^\|]*)[\|]?)|(utmccn=([^\|]*)[\|]?)|(utmcmd=([^\|]*)[\|]?)|(utmctr=([^\|]*)[\|]?)|(utmcct=([^\|]*)[\|]?)/i";
preg_match_all($pattern, $_COOKIE['__utmz'], $matches);
if(!empty($matches[0])){
foreach($matches[0] as $match){
$pair = null;
$match = trim($match, "|");
list($k, $v) = explode("=", $match);
@dublado
dublado / gist:2560365
Created April 30, 2012 17:40
get zip code magento
$postcode = new Mage_Checkout_Block_Cart_Shipping;
$zip_code = $postcode->getEstimatePostcode();
@dublado
dublado / gist:2829709
Last active September 26, 2016 16:50
diff 2 folders
diff -qrbB default_sacred_core_folder clients_core_folder
# q = report only differ
# r = recursive
# ignore change in the amount of white space
# ignore changes whose lines are all blank