Skip to content

Instantly share code, notes, and snippets.

View ahopkins's full-sized avatar

Adam Hopkins ahopkins

View GitHub Profile
@ahopkins
ahopkins / limetree.py
Last active May 16, 2019 05:40
Limetree POC
__version__ = "0.1-prealpha"
__author__ = "Adam Hopkins"
import trio
from itertools import count
from functools import partial
from functools import lru_cache
from collections import defaultdict
from typing import Optional, List
@ahopkins
ahopkins / # Sanic websocket feeds v2.md
Last active September 19, 2024 11:54
Sanic based websocket pubsub feed

Sanic Websockets Feeds v2

This is an outdated version

See latest

@ahopkins
ahopkins / # For syncing data across multiple running Sanic processes.md
Last active November 15, 2021 12:11
For syncing data across multiple running Sanic processes

For syncing data across multiple running Sanic processes

@ahopkins
ahopkins / custom_authentication_cls_complex.py
Created May 13, 2019 08:00
custom_authentication_cls_complex.py
import random
from datetime import datetime
from jwt.exceptions import DecodeError
from sanic import Sanic
from sanic.response import json
from sanic_jwt import (
Authentication,
Claim,
Configuration,
@ahopkins
ahopkins / components.selected-input.js
Created October 2, 2019 22:25
moment-selected-input
import TextField from '@ember/component/text-field'
export default TextField.extend({
focusIn: function (event) {
this.$().select()
}
});
@ahopkins
ahopkins / # Experiment for AST router.md
Last active November 15, 2021 12:10
Experiment for AST router

Experiment for AST router

@ahopkins
ahopkins / # Sanic Benchmarking.md
Last active November 15, 2021 12:10
Sanic Benchmarking

Sanic Benchmarking

@ahopkins
ahopkins / # Server Sent Events.md
Last active May 30, 2024 15:03
Server Sent Events

Server Sent Events

@ahopkins
ahopkins / # Sanic as Svelte development server.md
Last active June 2, 2022 23:04
Sanic as Svelte development server

Sanic as Svelte development server

The purpose of this gist is to show how Sanic can be used as a development server for a frontend JS framework. In this example we are running a Svelte app with rollup, but the same idea could be applied to any other frameworks JS build tools.

Run with:

sanic path.to:app -d -R ./path/to/public
@ahopkins
ahopkins / # Sanic websocket feeds v3.md
Last active September 23, 2024 17:20
Sanic websocket feeds - v3

Sanic Websockets Feeds v3

This is an example of how to build a distributed websocket feed. It allows for horizontal scaling using Redis as a pubsub broker to broadcast messages between application instances.

This is the third version of websocket feeds. It is built with Sanic v21.9+ in mind. Older versions: