Skip to content

Instantly share code, notes, and snippets.

Oluwaseun Omotosho tOlorun

Block or report user

Report or block tOlorun

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tOlorun
tOlorun / pubsub-coordinator.sql
Created Apr 3, 2019 — forked from marcocitus/pubsub-coordinator.sql
Prototype for PubSub on PG 10 with Citus 7
View pubsub-coordinator.sql
/* 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 Sep 12, 2018 — forked from ichux/function.sql
sharding id at instagram
View function.sql
-- 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 Sep 12, 2018 — forked from ichux/accumulates.sql
summary for a transactions table
View accumulates.sql
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
View asyncio-async-await.py
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 Sep 12, 2018 — forked from amatellanes/celery.sh
Celery handy commands
View celery.sh
/* 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.#'),
View basic_comments.py
#!/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
View basic_comments.py
#!/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 Sep 12, 2018 — forked from ichux/celery.sh
Celery handy commands
View celery.sh
/* 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.#'),
@tOlorun
tOlorun / audit_mixin.py
Created Apr 19, 2017 — forked from techniq/audit_mixin.py
Useful SQLAlchemy Mixins
View audit_mixin.py
from datetime import datetime
from sqlalchemy import Column, Integer, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declared_attr
from flask_security import current_user
class AuditMixin(object):
created_at = Column(DateTime, default=datetime.now)
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now)
@tOlorun
tOlorun / rebuild_search_indices.py
Created Dec 7, 2016 — forked from davebarkerxyz/rebuild_search_indices.py
Rebuild Flask-WhooshAlchemy search indices
View rebuild_search_indices.py
#!/usr/bin/env python
import datetime
from app import app, models
import whoosh
import flask_whooshalchemy
"""
Rebuild all Whoosh search indices
You can’t perform that action at this time.