Skip to content

Instantly share code, notes, and snippets.

View novasky-zz's full-sized avatar

William Novasky novasky-zz

View GitHub Profile
@novasky-zz
novasky-zz / gist:5730900
Last active July 5, 2016 18:58
Paginação com Doctrine 2?
<?php
$page = 1; // Página Atual
$numByPage = 5; // Número de registros por Página
$Empresa = $em->createQuery("SELECT e FROM Empresa e ")
->setFirstResult( ( $numByPage * ($page-1) ) )
->setMaxResults( $numByPage );
$Empresa = new \Doctrine\ORM\Tools\Pagination\Paginator($Empresa);
@novasky-zz
novasky-zz / gist:6010529
Created July 16, 2013 16:58
Loop For, Condição IF e Operador Ternário no Twig
{# Laço de repetição de array #}
{% for fruta in listFrutas %}
- {{fruta.nome}} <br>
{% endfor %}
or
{% for i in 0..10 %}
{# Laço de repetição #}
{% for i in 1..10 %}
@novasky-zz
novasky-zz / gist:6885187
Created October 8, 2013 14:03
Habilitar Rewrite Mode no linux.
sudo a2enmod rewrite
sudo service apache2 restart
@novasky-zz
novasky-zz / gist:6933419
Created October 11, 2013 11:51
Para corrigir o problema com espaço em branco no FckEditor
//Arquivo shared/libs/fckconfig.js
FCKConfig.FillEmptyBlocks = false
@novasky-zz
novasky-zz / gist:7213002
Created October 29, 2013 11:30
Dynamic subdomains with cPanel and PHP
# Put * in Subdomains in cPanel to setup Wildcard
# Put this in .htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([aA-zZ])$ subslug.php?username=$1
RewriteCond %{HTTP_HOST} ^(^.*)\.yourdomain.com
RewriteRule (.*) subslug.php?username=%1
@novasky-zz
novasky-zz / gist:b8d78f3af0e3ea614879
Created June 9, 2014 14:38
Aplicação Laravel 4 em Hospedagem Compartilhada
SetEnv APPLICATION_ENV production
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !-f
RewriteRule (.*) public/$1 [L]
RewriteCond %{REQUEST_URI} !-d
RewriteRule (.*) public/$1 [L]
</IfModule>
@novasky-zz
novasky-zz / gist:72ebf55130bbca62fc96
Created June 13, 2014 19:06
Buscando o Thumb de Vídeo do Youtube
Se o vídeo for em HD, a thumbnail de máxima resolução é esta:
http://img.youtube.com/vi/[ID do vídeo]/maxresdefault.jpg
Se não for, você pode resgatar a melhor thumbnail possível por aqui:
http://img.youtube.com/vi/[ID do vídeo]/mqdefault.jpg
Veja exemplos funcionando:
http://img.youtube.com/vi/UJtB55MaoD0/maxresdefault.jpg
http://img.youtube.com/vi/UJtB55MaoD0/mqdefault.jpg
@novasky-zz
novasky-zz / gist:772e09e2329be73f9c8d
Last active August 29, 2015 14:05
Fixed: Rollback transactions in PHP ADODB
<?php
/*
* Problem: RollbackTrans() command doesn't work
*
* FIX:
* The problem happens whenever I use the "mysql" driver to connect in the database
* To fix it, I used the "mysqli" driver in ADODB Connection
*
* The next example is the correct use of Transactions in ADODB
*/
@novasky-zz
novasky-zz / gist:6a1a7f415f26e178cac8
Created September 1, 2014 13:36
Rewrite Rule - Regra de reescrita com suporte a querystrings
RewriteRule ^pagina/([a-z0-9-]+)/([0-9]+)/?$ /pagina.php?lang=pt-br&id=$2&%{QUERY_STRING} [NC]
@novasky-zz
novasky-zz / gist:c7694a7e9a95625a84ef
Created September 24, 2014 18:21
Git: removendo arquivos deletados do versionamento
Para remover os arquivos deletados que antes haviam sido versionados, executar:
git ls-files --deleted | xargs git rm
git add .
git commit
Ou:
git add -u