Skip to content

Instantly share code, notes, and snippets.

View fphilipe's full-sized avatar
🌍
🎶 around the world 🕺🎶

Philipe Fatio fphilipe

🌍
🎶 around the world 🕺🎶
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fphilipe
fphilipe / _setup.sql
Last active September 16, 2016 08:07
-- Create users table with username as PK.
CREATE TABLE users_no_id (username varchar primary key, age int);
-- Create posts table with reference to users table using its PK and index on the reference.
CREATE TABLE posts_no_id (id serial primary key, username varchar references users_no_id (username), body text);
CREATE INDEX ON posts_no_id (username);
-- Create 1000000 users:
INSERT INTO users_no_id (username, age) SELECT substring(md5(random()::text) || md5(random()::text), (random()*32)::int, 16 + (random()*16)::int), 18 + (random()*70)::int FROM generate_series(1, 1000000);
-- Create 200000 posts for random users (multiple queries so users can have mutliple posts).
INSERT INTO posts_no_id (username, body) SELECT username, md5(random()::text) || md5(random()::text) FROM users_no_id ORDER BY random() LIMIT 25000;
INSERT INTO posts_no_id (username, body) SELECT username, md5(random()::text) || md5(random()::text) FROM users_no_id ORDER BY random() LIMIT 25000;
Calculating -------------------------------------
on_server_error :notify_honeybadger
90.832k i/100ms
on_server_error &Honeybadger.method(:notify)
96.540k i/100ms
on_server_error { |e| Honeybadger.notify(e) }
90.455k i/100ms
-------------------------------------------------
on_server_error :notify_honeybadger
2.007M (± 7.9%) i/s - 9.992M

Keybase proof

I hereby claim:

  • I am fphilipe on github.
  • I am philipe (https://keybase.io/philipe) on keybase.
  • I have a public key whose fingerprint is A081 196B 4236 5343 20B2 19EE F6F2 3962 F744 18A0

To claim this, I am signing this object:

<!DOCTYPE html>
<html>
<head>
<title>Scroll Snap &amp; Backdrop Filter</title>
<meta content='width=device-width, initial-scale=1.0' name='viewport' />
<style>
body {
margin: 0;
padding-top: 10vh;
@fphilipe
fphilipe / README.md
Last active May 13, 2024 19:28
Badiwassertemperaturen und -öffnungszeiten

Badiwassertemperaturen und -öffnungszeiten

A simple one-liner that results in this:

|-------------------------------+-------------+-------------------------|
|  Badi                         | Wassertemp. | Öffnungszeit            |
|-------------------------------+-------------+-------------------------|
|  Flussbad Au-Höngg            | 17          | geschlossen             |
|  Flussbad Oberer Letten       | 16          | geschlossen             |
@fphilipe
fphilipe / exclude.sql
Last active November 6, 2024 17:12
PostgreSQL EXCLUDE constraint
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)
@fphilipe
fphilipe / test.sh
Created March 12, 2015 02:06
Unqualified function calls break postgres_fdw compatibiliy
dropdb --if-exists postgis_test_1
dropdb --if-exists postgis_test_2
createdb postgis_test_1
createdb postgis_test_2
# Set up DB 1:
cat <<SQL | psql postgis_test_1
CREATE EXTENSION postgis;
CREATE VIEW test_geometry AS
SELECT ST_Distance(
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fphilipe
fphilipe / README.md
Last active December 20, 2015 19:38 — forked from mbostock/.block