Skip to content

Instantly share code, notes, and snippets.

Avatar
🌍
🎶 around the world 🕺🎶

Philipe Fatio fphilipe

🌍
🎶 around the world 🕺🎶
View GitHub Profile
View obike-zurich.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View _setup.sql
-- 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;
View output.txt
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
View keybase.md

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:

View index.html
<!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 7, 2019
Badiwassertemperaturen und -öffnungszeiten
View README.md

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 Oct 23, 2020
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)
@fphilipe
fphilipe / test.sh
Created Mar 12, 2015
Unqualified function calls break postgres_fdw compatibiliy
View test.sh
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(
View stadtkreise.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View README.md
You can’t perform that action at this time.