Skip to content

Instantly share code, notes, and snippets.

View webarthur's full-sized avatar
✌️

Arthur Ronconi webarthur

✌️
View GitHub Profile
@webarthur
webarthur / setup.js
Last active January 5, 2017 17:48
Ajax subdomain CORS
// ajax
var xhr = new XMLHttpRequest();
xhr.open(method, url, true);
xhr.withCredentials = true;
[...]
// htaccess
SetEnvIf Origin "http(s)?://(www\.)?(example.org)$" AccessControlAllowOrigin=$0
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
@webarthur
webarthur / .htaccess
Created December 17, 2016 15:42
Redirect only root link in WordPress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^$ "http://example.org" [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
@webarthur
webarthur / is_cnpj.js
Last active November 30, 2020 13:20
Valida CNPJ - função em JavaScript
function is_cnpj(c) {
var b = [6,5,4,3,2,9,8,7,6,5,4,3,2];
if((c = c.replace(/[^\d]/g,"")).length != 14)
return false;
if(/0{14}/.test(c))
return false;
for (var i = 0, n = 0; i < 12; n += c[i] * b[++i]);
@webarthur
webarthur / docker-compose.yml
Last active October 30, 2016 23:07
Docker para WordPress com Compose
wp:
image: wordpress:latest
ports:
- 80:80
volumes:
- ./html:/var/www/html/
environment:
WORDPRESS_DB_NAME: wp
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: 123
@webarthur
webarthur / Dockerfile
Created October 30, 2016 23:01
Dockerfile para LAMP/WordPress
FROM php:5.6-apache
# instala modulos do Apache
RUN a2enmod headers \
&& a2enmod rewrite
# instala extensões do PHP5
RUN apt-get update && apt-get install -y libmcrypt-dev libpng12-dev libjpeg-dev libpq-dev imagemagick libxml2-dev libfreetype6-dev\
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr --with-php-config=/usr/local/bin/php-config --with-freetype-dir=/usr/ --enable-gd-native-ttf \
@webarthur
webarthur / disable-backspace.js
Last active October 13, 2016 13:52
Desativar tecla backspace de voltar página do navegador
// detecta todas as teclas que estão sendo pressionadas
$(document).unbind('keydown').bind('keydown', function (event) {
// filtra apenas a tecla <backspace>
if (event.keyCode === 8) {
// variável que decidirá se a tecla será bloqueada
var doPrevent = true;
// tipos de campos permitidos
@webarthur
webarthur / docker-compose.yml
Created October 8, 2016 13:41
Docker: php5.6 + Apache 2 + MongoDB
httpd:
image: php5.6
ports:
- 80:80
volumes:
- ./home:/home
- ./html:/var/www/html/app
- ./config/apache2:/etc/apache2
- ./config/php:/usr/local/etc/php
- ./log:/var/log/apache2
@webarthur
webarthur / Dockerfile
Created October 8, 2016 13:39
Dockerfile php 5.6 + Apache 2 + php mongo driver
FROM php:5.6-apache
# install apache modules
RUN a2enmod headers \
&& a2enmod rewrite
# install mongo php driver
RUN apt-get update && apt-get install -y libssl-dev
RUN pecl install mongo
@webarthur
webarthur / cumulative-alert.js
Created October 3, 2016 13:21
Acumulador de alertas javascript
/**
* Acumulador de alertas
* > use (alert.cumulative = true) para ativar a função acumuladora.
* > use alert.show() para mostrar todas as mensagens acumuladas em um único alert.
* > as mensagens acumuladas ficam armazenadas no array alert.messages.
*
* @author Arthur Araújo
* @date 03/10/2016
*/
var __alert = alert;
@webarthur
webarthur / docker.sh
Last active September 7, 2017 23:57
Comandos úteis para docker
# lista imagens instaladas
docker images
# remove imagem
docker rmi [ID]
# lista todos os containers criados
docker ps -a
# lista containers ativos