Skip to content

Instantly share code, notes, and snippets.

@anderson-mota
anderson-mota / how-to-git-patch-diff.md
Created September 29, 2020 21:40 — forked from nepsilon/how-to-git-patch-diff.md
How to generate and apply patches with git? — First published in fullweb.io issue #33

How to generate and apply patches with git?

It sometimes happen you need change code on a machine from which you cannot push to the repo. You’re ready to copy/paste what diff outputs to your local working copy.

You think there must be a better way to proceed and you’re right. It’s a simple 2 steps process:

1. Generate the patch:

git diff > some-changes.patch
@anderson-mota
anderson-mota / rails http status codes
Created July 2, 2020 16:36 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@anderson-mota
anderson-mota / docker-install-lubuntu-17.04.sh
Created September 24, 2019 22:43 — forked from pjmazenot/docker-install-lubuntu-17.04.sh
Install Docker CE on Lubuntu 17.04
#!/bin/sh
# Install Docker CE on Lubuntu 17.04
# Run this script with sudo privileges `sudo docker-install-lubuntu-17.04.sh`
apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu zesty stable"
apt-get update
apt-get install -y docker-ce
wget —qO— https://get.docker.com/ | sh
sudo usermod —aG docker <usuario>
<?php
namespace App\Home\Kitchen;
use App\Logger;
use App\Home\HomeAppliances;
class CoffeeMachine extends HomeAppliances
{
use WaterHeater;
@anderson-mota
anderson-mota / Dockerfile
Created December 21, 2018 23:15
Localtime/Timezone on Docer
ENV TZ=America/Sao_Paulo
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
SELECT A.DATA, COUNT(A.DATA) AS QTD FROM ACESSOS AS A GROUP BY A.DATA;
SELECT CONCAT(MONTH(A.DATA), '-', YEAR(A.DATA)) AS MES_DO_ANO, COUNT(A.DATA) AS QTD FROM ACESSOS AS A GROUP BY MONTH(A.DATA), YEAR(A.DATA);
SELECT GETDATE(YEAR, A.DATA), COUNT(A.DATA) AS QTD FROM ACESSOS AS A GROUP BY GETDATE(YEAR, A.DATA);
SELECT C.REGIAO, COUNT(C.REGIAO) AS QTD FROM CLIENTES AS C GROUP BY C.REGIAR;
SELECT C.ID_PLANO, COUNT(C.ID_PLANO) AS QTD FROM CLIENTES AS C GROUP BY C.ID_PLANO ORDER BY QTD DESC;
SELECT C.TIPO, COUNT(C.TIPO) AS QTD FROM CLIENTES AS C GROUP BY C.TIPO ORDER BY QTD DESC;
SELECT A.OPCAO_MENU, COUNT(A.OPCAO_MENU) AS QTD FROM ACESSOS AS A GROUP BY A.OPCAO_MENU;
@anderson-mota
anderson-mota / fonts.scss
Last active July 10, 2018 16:52
Generate icons.
/**
<%= fontName %> Webfont
*/
@font-face {
font-family: '<%= fontName %>';
src: url('../fonts/<%= fontName %>.eot?<%= fontDate %>');
src: url('../fonts/<%= fontName %>.eot?#iefix-<%= fontDate %>') format('embedded-opentype'),
url('../fonts/<%= fontName %>.woff2?<%= fontDate %>') format('woff2'),
url('../fonts/<%= fontName %>.woff?<%= fontDate %>') format('woff'),
url('../fonts/<%= fontName %>.ttf?<%= fontDate %>') format('truetype');
@anderson-mota
anderson-mota / Dockerfile
Created July 4, 2018 01:05 — forked from varyonic/Dockerfile
Dockerfile with chromedriver
# See https://codeship.com/documentation/docker/browser-testing/
FROM myapp:base
# We need wget to set up the PPA and xvfb to have a virtual screen and unzip to install the Chromedriver
RUN apt-get install -y wget xvfb unzip
# Set up the Chrome PPA
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
@anderson-mota
anderson-mota / group-docker.md
Created May 22, 2018 14:31
Criar grupo de usuário para o docker, para evitar usar sudo.

O Docker Daemon sempre é executado como usuário root. Para evitar de escrever "sudo" antes de todos os comandos do docker, é necessário criar um grupo docker e adicionar usuários à ele.

Crie o grupo docker.

$ sudo groupadd docker Adicione seu usuário ao grupo docker.

$ sudo usermod -aG docker $USER Será preciso deslogar e logar novamente para as modificações serem feitas.