- Read every row in the table
- No reading of index. Reading from indexes is also expensive.
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
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ( | |
| "archive/zip" | |
| "io" | |
| "os" | |
| "path/filepath" | |
| "strings" | |
| ) | |
| func zipit(source, target string) error { | |
| zipfile, err := os.Create(target) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 incoming.read(&mut buffer) { | |
| Ok(bytes_read) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use anyhow::*; | |
| use futures::io::{copy, AsyncReadExt, AsyncWriteExt}; | |
| use futures::stream::StreamExt; | |
| use log::*; | |
| use smol::Async; | |
| use std::net; | |
| const PORT: u16 = 5000; |