Skip to content

Instantly share code, notes, and snippets.

View lnoering's full-sized avatar

Leonardo Noering lnoering

View GitHub Profile
@lnoering
lnoering / estado.php
Created August 6, 2015 18:08
Verificar o Estado pelo Cep.
public function getEstado($cep)
{
$estados = array('ac'=>'69900,69999',
'al'=>'57000,57999',
'am'=>'69000,69299|69400,69899',
'ap'=>'68900,68999',
'ba'=>'40000,48999',
'ce'=>'60000,63999',
'df'=>'70000,72799|73000,73699',
'es'=>'29000,29999',
@lnoering
lnoering / vhost nginx
Last active August 29, 2015 14:26
Vhost para projetos locais com Nginx.
# versao do nginx 1.8.0
server {
listen 80;
server_name ~^(www\.)?(?<sname>.+).local.com.br$;
root /home/projetos/$sname;
error_log /var/logs/$sname.error.log;
access_log /var/logs/$sname.access.log;
@lnoering
lnoering / magento.conf
Created August 7, 2015 16:10
Configuração de vhost para Magento.
## colocar em /etc/nginx
#ini - http://www.magentocommerce.com/magento-connect/speedster-by-fooman.html
rewrite ^/minify/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
rewrite ^/skin/m/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
#fim - http://www.magentocommerce.com/magento-connect/speedster-by-fooman.html
location ~* \.(eot|ttf|woff)$ {
add_header Access-Control-Allow-Origin "*";
}
@lnoering
lnoering / php.conf
Created August 7, 2015 16:11
Configuração do php-fpm com nginx.
## colocar em /etc/nginx
## php-fpm parsing
location ~ .php$ {
## Catch 404s that try_files miss
if (!-e $request_filename) { rewrite / /index.php last; }
## Disable cache for php files
expires off;
@lnoering
lnoering / gzip.conf
Created August 7, 2015 16:12
Configuração de gzip no vhost.
# colocar em /etc/nginx
##turn on gzip compreesion
gzip on;
gzip_static on;
gzip_comp_level 9;
gzip_min_length 1100;
gzip_types text/plain image/png image/gif image/jpeg application/x-javascript text/css text/xml application/xml application/xml+rss text/javascript;
gzip_vary on;
gzip_http_version 1.1;
@lnoering
lnoering / fedora.txt
Last active August 29, 2015 14:26
Nginx + PHP-FPM no Fedora!
## http://www.if-not-true-then-false.com/2011/install-nginx-php-fpm-on-fedora-centos-red-hat-rhel/
## http://www.itzgeek.com/how-tos/linux/fedora-how-tos/nginx-php-fpm-mariadb-on-fedora-21.html
## Desabilitar o HTTPD ##
systemctl disable httpd.service
## Habilitar o Nginx ##
systemctl enable nginx.service
## Habilitar o FPM para não precisar ficar startando ##
@lnoering
lnoering / Criar SSL.txt
Last active October 20, 2015 11:47
Criar Certificado SSL para Desenvolvimento Local!
## Install OpenSSL ##
yum install openssl openssl-deve
## Criar a pasta para criar os arquivos ##
mkdir ~/domain.com.ssl/
cd ~/domain.com.ssl/
## Criando o .KEY ##
@lnoering
lnoering / tempo_execucao.sh
Last active October 31, 2015 01:43
Calcular tempo de execução de crons.
#!/bin/bash
# %s seconds since 1970-01-01 00:00:00 UTC
# %N nanoseconds (000000000..999999999)
# %m month (01..12)
# %d day of month (e.g., 01)
# %Y year
# %t a tab
# decrementar 1 da var( ${dias:+$(($dias-1))} ) caso tenha valor
# 10800 is timezone for brazil(gmt +3 hours)
@lnoering
lnoering / erros.md
Last active January 4, 2016 16:27
[Postgre] - Solutions

Problema ao iniciar o servidor do postgre

  • Comando utilizado para tentar inicializar.
su -c '/usr/pgsql-9.3/bin/pg_ctl start -D /var/lib/pgsql/9.3/data' postgres
  • Resultado

    < 2016-01-04 12:02:49.775 BRST >LOG: could not bind IPv4 socket: Cannot assign requested address
    < 2016-01-04 12:02:49.775 BRST >HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.

@lnoering
lnoering / apache.md
Last active January 12, 2016 17:55
[vhosts] Configurações de vhost.

<VirtualHost *:80> ServerAdmin suporte@empresa.com.br ServerName loja.com.br ServerAlias www.loja.com.br DirectoryIndex index.php index.html DocumentRoot (CAMINHO DA LOJA/) #Alias /blog (CAMINHO DA LOJA/)blog/

    <Directory (CAMINHO DA LOJA/)>

Order allow,deny