Skip to content

Instantly share code, notes, and snippets.

View lslucas's full-sized avatar

Lucas Serafim lslucas

View GitHub Profile
@lslucas
lslucas / how-to
Last active October 18, 2019 08:51
Git Deploy Management
First, make sure you already have git installed on local and remote server.
On remote server
----------------
$ cd ~/ #if you are not here yet
$ mkdir website.git && cd website.git
$ git init --bare
Initialized empty Git repository in /home/ubuntu/website.git/
$ vi hooks/post-receive # paste the post-receive file here
Recentemente publicamos o artigo: Descompactando arquivos vai SSH. E hoje aprenderemos como compactar estes arquivos.
Quem tem um site ou qualquer hospedagem que armazene arquivos sabe que eventualmente são necessários backups, seja para corrigir algum erro ou problema que tenha dado (muito comuns quando estamos fazendo a periódica manutenção do portal). O grande problema é quando alguma coisa dá errado e não conseguimos restaurar nossos arquivos para antes do problema ter ocorrido.
Hoje a maioria dos provedores de hospedagem possuem um backup automático onde basta o cliente solicitar o dia e hora que seus arquivos serão restaurados.
O grande problema é: Tempo.
Recentemente passei pela inconveniente necessidade de recuperar uns arquivos antigos e tive que pedir ao meu provedor para restaurar até determinada hora.
@lslucas
lslucas / gist:3103fd7447a58ddd12d9
Last active December 29, 2016 15:17
rsync - clone folder from one server to another

On origin server

ssh-keygen -f ~/.ssh/id_rsa -q -P ""
cat ~/.ssh/id_rsa.pub

Copy and put that ssh key on destination server in (if don't exists, create it): ~/.ssh/authorized_keys

Now, rsync

@lslucas
lslucas / git
Created September 16, 2013 18:13
GIT Useful commands
#alternative to .gitignore
git update-index --assume-unchanged path/to/file
@lslucas
lslucas / backup-mysql.php
Created September 16, 2013 15:22
Download a backup of entire database.
<?php
backup_tables('localhost', 'DB_USER', 'DB_PASS', 'DB_DATABASE');
/* backup the db OR just a table */
function backup_tables($host,$user,$pass,$name,$tables = '*')
{
$link = mysql_connect($host,$user,$pass);
@lslucas
lslucas / modal.md
Created September 6, 2013 14:39
Pure CSS Modal
#modal {
    display: block;
    position: fixed;
    top: 50%;
    left: 50%;
    box-sizing: border-box;
    transform: translate(-50%, -50%);
}
@lslucas
lslucas / gist:6160155
Created August 5, 2013 22:26
How to Fix Vagrant Up Error Error while adding new interface: failed to open /dev/vboxnetctl: No such file or directory In my case this error happens when I changed my RAM. Why? No idea :S
Bringing machine 'default' up with 'virtualbox' provider...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["hostonlyif", "create"]
@lslucas
lslucas / proftpd.conf
Created July 31, 2013 21:10
/etc/proftpd/proftpd.conf with Disabled PASV mode
ubuntu@ip-10-248-47-171:~$ cat /etc/proftpd/proftpd.conf
#
# /etc/proftpd/proftpd.conf -- This is a basic ProFTPD configuration file.
# To really apply changes, reload proftpd after modifications, if
# it runs in daemon mode. It is not required in inetd/xinetd mode.
#
# Includes DSO modules
Include /etc/proftpd/modules.conf
@lslucas
lslucas / gist:5673356
Created May 29, 2013 19:58
List sum commits by contributor
git shortlog -s -n