Skip to content

Instantly share code, notes, and snippets.

Plecra /
Created May 3, 2020 17:00
A smol proxy server
use anyhow::*;
use futures::io::{copy, AsyncReadExt, AsyncWriteExt};
use futures::stream::StreamExt;
use log::*;
use smol::Async;
use std::net;
const PORT: u16 = 5000;
fragsalat /
Created November 28, 2019 15:24
A simple and lightweight multi threaded TCP proxy written in Rust language. Not using any 3rd-party libraries but just standard libraries.
use std::net::{TcpListener, SocketAddr, TcpStream, Shutdown, SocketAddrV4, Ipv4Addr};
use std::str::FromStr;
use std::thread::{spawn, JoinHandle};
use std::io::{BufReader, BufWriter, Read, Write};
fn pipe(incoming: &mut TcpStream, outgoing: &mut TcpStream) -> Result<(), String> {
let mut buffer = [0; 1024];
loop {
match buffer) {
Ok(bytes_read) => {
iamralch / compress.go
Last active April 16, 2023 03:04
ZIP archives in Golang
View compress.go
import (
func zipit(source, target string) error {
zipfile, err := os.Create(target)
fphilipe / exclude.sql
Last active May 8, 2023 23:36
PostgreSQL EXCLUDE constraint
View exclude.sql
CREATE TABLE room_reservations (
room_id integer,
reserved_at timestamptz,
reserved_until timestamptz,
canceled boolean DEFAULT false,
room_id WITH =, tstzrange(reserved_at, reserved_until) WITH &&
) WHERE (not canceled)
staltz /
Last active May 27, 2023 05:21
The introduction to Reactive Programming you've been missing
soheilhy /
Last active May 15, 2023 16:59
How to proxy web apps using nginx?

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,, and on the same machine using a single IP address.

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

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


Sequential Scan:

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