Skip to content

Instantly share code, notes, and snippets.

View unixzen's full-sized avatar
🎯
Focusing

Eugene unixzen

🎯
Focusing
View GitHub Profile
@unixzen
unixzen / postgres-cheatsheet.md
Created November 6, 2019 13:31 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@unixzen
unixzen / gist:85ac4643509ffd8853f19c4a0f1498ed
Created October 30, 2019 11:38
Partial function application Golang
package main
import (
"fmt"
"github.com/choleraehyq/gofunctools/functools"
// "log"
)
func main() {
add := func(a, b int) int {
@unixzen
unixzen / gist:d2007458b7ff6154d33f2ac499420cd1
Last active November 19, 2023 11:27
Docker-compose Traefik 2.0 + Nexus with Docker Registry
version: '3.3'
services:
traefik:
image: "traefik:v2.0.0"
container_name: "traefik"
command:
- "--log.level=DEBUG"
# - "--accesslog=true"
@unixzen
unixzen / nginx-and-certbot-config.md
Created October 6, 2019 20:06 — forked from rkaramandi/nginx-and-certbot-config.md
Running NGINX and CertBot Containers on the Same Host

Running NGINX and CertBot Containers on the Same Host

The Problem

A lot of people run into the problem of running Let's Encrypt's CertBot Tool and an NGINX on the same container host. A big part of this has to do with CertBot needing either port 80 or 443 open for the tool to work as intended. This tends to conflict with NGINX as most people usually use port 80 (HTTP) or 443 (HTTPS) for their reverse proxy. Section 1 outlines how to configure NGINX to get this to work, and Section 2 is the Docker command to run CertBot.

1. NGINX Configuration

I use Docker Compose (docker-compose) for my NGINX server. My docker-compose.yml file looks something like this:

@unixzen
unixzen / openssl.cnf.ini
Created August 28, 2019 17:44 — forked from garethrees/openssl.cnf.ini
Open SSL SAN
# Generate Private Key
$ openssl genrsa -out server.key 2048
# Generate CSR
$ openssl req -new -out server.csr -key server.key -config openssl.cnf
# => Fill in info
# Check CSR
$ openssl req -text -noout -in server.csr
# Sign Cert
$ openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt -extensions v3_req -extfile openssl.cnf
@unixzen
unixzen / gist:d8f1fc63c9be1841e841938809362500
Created August 23, 2019 06:26
Openstack terraform config
resource "openstack_compute_instance_v2" "ed-test" {
name = "ed-test"
image_id = "${var.image}" # Default image is ubuntu 16.04
image_name = "ubuntu16"
flavor_id = "0a762fd0-6f8f"
security_groups = ["default"]
key_pair = "test"
network {
name = "Int"
@unixzen
unixzen / gist:6206af64a1623b238d4a13c52abeea73
Created August 23, 2019 06:21
Openstack terraform plan repeat after creating
user@local-comp:~/terraform/openstack $ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
openstack_compute_instance_v2.ed-test: Refreshing state... [id=b0cd4f94-2fd9-4c6c-9a8e-d869e7acc3ef]
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
@unixzen
unixzen / gist:578dacdde2f3ff3615614daf07dc691a
Created August 23, 2019 06:17
Openstack terraform plan create instance
user@local-comp:~/terraform/openstack $ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
@unixzen
unixzen / gist:d6d6c6c0e567bf4c8117baafd0af94fc
Created August 14, 2019 06:57 — forked from devinodaniel/gist:8f9b8a4f31573f428f29ec0e884e6673
Generate SSH RSA Private/Public Key pair with Golang
// This shows an example of how to generate a SSH RSA Private/Public key pair and save it locally
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"golang.org/x/crypto/ssh"
package main
import (
"log"
"time"
"github.com/gocql/gocql"
)
func main() {