Skip to content

Instantly share code, notes, and snippets.

View tOlorun's full-sized avatar

Oluwaseun Omotosho tOlorun

View GitHub Profile
@tOlorun
tOlorun / asyncpgsa_benchmark.py
Created February 17, 2020 00:51 — forked from nhumrich/asyncpgsa_benchmark.py
asyncpgsa benchmark against aiopg.sa
import asyncio
import aiopg
import aiopg.sa
import asyncpg
import asyncpgsa
import sqlalchemy as sa
pg_tables = sa.Table(
'pg_tables', sa.MetaData(),
sa.Column('schemaname'),
@tOlorun
tOlorun / install_sqlplus.md
Created September 9, 2019 09:06 — forked from tcnksm/install_sqlplus.md
How to install oracle client to Ubuntu 12.04

Install SQL*Plus

  1. Download .rpm package here
    • oracle-instantclinet*-basic-*.rpm
    • oracle-instantclinet*-devel-*.rpm
    • oracle-instantclinet*-sqlplus-*.rpm
  2. Install alien (sudo apt-get install alien)
  3. Convert the rpm files and install
    • sudo alien -i oracle-instantclinet*-basic-*.rpm
  • sudo alien -i oracle-instantclinet*-devel-*.rpm
@tOlorun
tOlorun / pubsub-coordinator.sql
Created April 3, 2019 01:02 — forked from marcocitus/pubsub-coordinator.sql
Prototype for PubSub on PG 10 with Citus 7
/* commands to run on the coordinator */
CREATE EXTENSION citus;
SELECT master_add_node('10.0.0.2', 5432);
SELECT master_add_node('10.0.0.3', 5432);
SELECT start_metadata_sync_to_node(nodename, nodeport) FROM pg_dist_node;
SET citus.replication_model TO 'streaming'
CREATE TABLE events (
event_id bigserial primary key,
@tOlorun
tOlorun / function.sql
Created September 12, 2018 07:07 — forked from ichux/function.sql
sharding id at instagram
-- change the public to schema of choice
CREATE OR REPLACE FUNCTION public.next_id(OUT result bigint) AS $$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;
now_millis bigint;
shard_id int := 5;
BEGIN
SELECT nextval('ips_id_seq'::regclass) % 1024 INTO seq_id;
@tOlorun
tOlorun / accumulates.sql
Created September 12, 2018 07:06 — forked from ichux/accumulates.sql
summary for a transactions table
CREATE TABLE IF NOT EXISTS accumulates (
added_on TIMESTAMP WITHOUT TIME ZONE NOT NULL,
added_by BIGINT NOT NULL,
id BIGSERIAL NOT NULL,
enabled BOOLEAN NOT NULL,
user_id BIGINT NOT NULL,
transaction BIGINT NOT NULL,
tablemeta JSONB NOT NULL,
CONSTRAINT pk_accumulates PRIMARY KEY (id)
--, CONSTRAINT fk_accumulates_user_id_users FOREIGN KEY(user_id) REFERENCES users (id) ON UPDATE CASCADE
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
@tOlorun
tOlorun / celery.sh
Created September 12, 2018 06:29 — forked from amatellanes/celery.sh
Celery handy commands
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
Queue('default', routing_key='tasks.#'),
#!/bin/env python
# -------------------------------------------------------------------------------
# This is a basic implementation of comments with a flat structure,
# as described in my article:
# https://blog.miguelgrinberg.com/post/implementing-user-comments-with-sqlalchemy
# -------------------------------------------------------------------------------
from datetime import datetime
from flask import Flask
#!/bin/env python
# -------------------------------------------------------------------------------
# This is a basic implementation of comments with a flat structure,
# as described in my article:
# https://blog.miguelgrinberg.com/post/implementing-user-comments-with-sqlalchemy
# -------------------------------------------------------------------------------
from datetime import datetime
from flask import Flask
@tOlorun
tOlorun / celery.sh
Created September 12, 2018 06:28 — forked from ichux/celery.sh
Celery handy commands
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
Queue('default', routing_key='tasks.#'),