Skip to content

Instantly share code, notes, and snippets.

View guilhermevini's full-sized avatar
🏠
Working from home

Guilherme Vinicius guilhermevini

🏠
Working from home
View GitHub Profile
@guilhermevini
guilhermevini / bitbucket-pipelines.yml
Created January 30, 2017 13:56
Test Laravel application on bitbucket pipelines
image: smartapps/bitbucket-pipelines-php-mysql:stretch
pipelines:
default:
- step:
script:
- service mysql start
- mysql -h localhost --user=root --password=root -e "CREATE DATABASE tests;"
- composer install
- php -r "file_exists('.env') || copy('.env.tests', '.env');"
@guilhermevini
guilhermevini / subscribe.php
Created June 17, 2017 01:46
incrementa arquivo txt com e-mail vindo de um input
<?php
if(isset($_POST['email'])) {
$myfile = fopen("base.txt", "a") or die("Unable to open file!");
$txt = $_POST['email'] . "\n";
fwrite($myfile, $txt);
fclose($myfile);
}
?>
@guilhermevini
guilhermevini / mysql-change-password.txt
Created June 19, 2017 16:43
Muda senha do banco de dados
mysql -u root -h localhost -p
USE banco;
SET PASSWORD FOR 'user'@'localhost' = PASSWORD('senha');
FLUSH PRIVILEGES;
quit;
@guilhermevini
guilhermevini / fail2ban.txt
Created August 15, 2017 19:53
block flooded wp
# cat /etc/fail2ban/action.d/ufw.conf
[Definition]
actionstart =
actionstop =
actioncheck =
actionban = ufw insert 1 deny from <ip>
actionunban = ufw delete deny from <ip>
# cat /etc/fail2ban/filter.d/xmlrpc.conf
[Definition]
if [ ! -a ~/.inputrc ]; then echo '$include /etc/inputrc' > ~/.inputrc; fi
echo 'set completion-ignore-case On' >> ~/.inputrc
define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST']);
if (($_SERVER['HTTP_CLOUDFRONT_FORWARDED_PROTO'] == 'https') OR ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) {
$_SERVER['HTTPS']='on';
}
@guilhermevini
guilhermevini / invalidate-cache.js
Created November 15, 2018 15:00
Lambda function to invalidate cloudfront cache
var AWS = require('aws-sdk');
var cloudfront = new AWS.CloudFront();
exports.handler = function (event) {
console.log(event);
const id = 'xxxx';
const currentTimeStamp = new Date().getTime();
const params = {
exports.handler = (event, context, callback) => {
const response = event.Records[0].cf.response;
if (!response.headers['cache-control']) {
response.headers['cache-control'] = [{
key: 'Cache-Control',
value: 'max-age=31536000'
}];
}
callback(null, response);
};
@guilhermevini
guilhermevini / install-docker-compose.sh
Created August 9, 2019 17:28
install docker-compose on amazon linux 2
#!/bin/bash
# https://github.com/docker/compose/tags
curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` | sudo tee /usr/local/bin/docker-compose > /dev/null
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version

Keybase proof

I hereby claim:

  • I am guilhermevini on github.
  • I am guilhermevini (https://keybase.io/guilhermevini) on keybase.
  • I have a public key ASAkaTLZWZmfDd9DlycteH1bdq68ZejEhnYLEuEKDY3L6Qo

To claim this, I am signing this object: