Skip to content

Instantly share code, notes, and snippets.

Avatar

Michel Luiz Milezzi michelmilezzi

View GitHub Profile
@iamralch
iamralch / compress.go
Last active September 14, 2022 02:23
ZIP archives in Golang
View compress.go
import (
"archive/zip"
"io"
"os"
"path/filepath"
"strings"
)
func zipit(source, target string) error {
zipfile, err := os.Create(target)
@fphilipe
fphilipe / exclude.sql
Last active January 5, 2023 17:34
PostgreSQL EXCLUDE constraint
View exclude.sql
CREATE EXTENSION btree_gist;
CREATE TABLE room_reservations (
room_id integer,
reserved_at timestamptz,
reserved_until timestamptz,
canceled boolean DEFAULT false,
EXCLUDE USING gist (
room_id WITH =, tstzrange(reserved_at, reserved_until) WITH &&
) WHERE (not canceled)
@staltz
staltz / introrx.md
Last active February 7, 2023 12:08
The introduction to Reactive Programming you've been missing
View introrx.md
@soheilhy
soheilhy / nginxproxy.md
Last active February 3, 2023 02:21
How to proxy web apps using nginx?
View nginxproxy.md

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@hgmnz
hgmnz / query_planner.markdown
Created March 23, 2011 14:14
PostgreSQL query plan and SQL performance notes
View query_planner.markdown

Types of index scans

Indexes

Sequential Scan:

  • Read every row in the table
  • No reading of index. Reading from indexes is also expensive.