Skip to content

Instantly share code, notes, and snippets.

Gustavo Henrique gustavohenrique

View GitHub Profile
View proxy-https-self-signed-using-caddy.md

Configuring HTTPs proxy for local development

Add mydomain.com alias:

cat "127.0.1.1 mydomain.com" | sudo tee -a /etc/hosts

Create a Caddyfile

View swatch-linux-shell.md

Instalar swatchdog:

$ sudo apt install swatch	hashtag#Ubuntu/Debian
$ sudo yum install epel-release && sudo yum install swatch	hashtag#RHEL/CentOS

Configuração do swatchdog: $ sudo vi .swatchrc

View cut-linux-shell.sh
Cortar por posição de byte (2o byte):
$ echo 'baz' | cut -b 2
Cortar por posição de byte (1o e 2o bytes):
echo 'baz' | cut -b 1-2
Cortar por posição de byte (1o e 3o bytes):
$ echo 'baz' | cut -b 1,3
Cortar por posição de caracter (2o byte):
View css-media-queries-cheat-sheet.css
/*------------------------------------------
Responsive Grid Media Queries - 1280, 1024, 768, 480
1280-1024 - desktop (default grid)
1024-768 - tablet landscape
768-480 - tablet
480-less - phone landscape & smaller
--------------------------------------------*/
@media all and (min-width: 1025px) and (max-width: 1280px) {}
@media all and (min-width: 768px) and (max-width: 1024px) {}
@media all and (min-width: 480px) and (max-width: 768px) {}
View comodo-ssl.md

Purchase the cert

Prior to purchasing a cert, you need to generate a private key, and a CSR file (Certificate Signing Request). You'll be asked for the content of the CSR file when ordering the certificate.

openssl req -new -newkey rsa:2048 -nodes -keyout example_com.key -out example_com.csr

This gives you two files:

  • example_com.key -- your Private key. You'll need this later to configure ngxinx.
@gustavohenrique
gustavohenrique / test-api-nodejs.md
Created Jun 13, 2018
Test external API using NodeJS
View test-api-nodejs.md

setup

cat > package.json <<EOF
{
  "name": "test-api",
  "version": "0.1.0",
  "description": "It test the API",
  "main": "index.js",
  "scripts": {
@gustavohenrique
gustavohenrique / kong.sh
Created Apr 15, 2018
Run Kong API gateway and Konga in Docker
View kong.sh
docker run -d --name kong --link postgres -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=postgres" -e "KONG_CASSANDRA_CONTACT_POINTS=postgres" -e KONG_PG_USER=admin -e KONG_PG_DATABASE=mydb -e KONG_PG_PASSWORD=password -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" -e "KONG_PROXY_ERROR_LOG=/dev/stderr" -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" -e "KONG_ADMIN_LISTEN=0.0.0.0:8001" -e "KONG_ADMIN_LISTEN_SSL=0.0.0.0:8444" -p 8000:8000 -p 8443:8443 -p 8001:8001 -p 8444:8444 kong:latest
docker run -p 1337:1337 --link kong --link postgres --name konga -e "NODE_ENV=production" -e "DB_ADAPTER=postgres" -e "DB_HOST=postgres" -e "DB_PORT=5432" -e "DB_USER=admin" -e "DB_PASSWORD=password" -e "DB_DATABASE=mydb" pantsel/konga
@gustavohenrique
gustavohenrique / qemu-runner.sh
Created Feb 12, 2018
running old linux distro using qemu
View qemu-runner.sh
qemu-img create -f qcow2 hd.qcow2 5G
qemu-system-i386 -boot d -m 512 -hda $PWD/hd.qcow2 -cdrom $PWD/Conectiva6.0.iso -net nic,vlan=0 -net user,vlan=0 -localtime
qemu-kvm -m 16M -drive if=ide,format=qcow2,file=slackware.qcow2 \
-netdev user,id=slirp -device ne2k_isa,netdev=slirp \
-serial stdio -redir tcp:22122::22
View pos-installation-linux-mint.md

add other apt repositories

wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
@gustavohenrique
gustavohenrique / reverse-proxy.go
Last active Nov 18, 2017
A snippet to create a reverse proxy using Go
View reverse-proxy.go
package main
import (
"fmt"
"net/http"
"net/http/httputil"
"net/url"
)
func main() {
You can’t perform that action at this time.