Skip to content

Instantly share code, notes, and snippets.

View ahopkins's full-sized avatar

Adam Hopkins ahopkins

View GitHub Profile
@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 / # Sanic websocket feeds v2.md
Last active February 5, 2022 14:46
Sanic based websocket pubsub feed

Sanic Websockets Feeds v2

This is an outdated version

See latest

@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 / progress.py
Created April 9, 2018 07:41 — forked from vladignatyev/progress.py
Python command line progress bar in less than 10 lines of code.
# The MIT License (MIT)
# Copyright (c) 2016 Vladimir Ignatev
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the Software
# is furnished to do so, subject to the following conditions:
#
@ahopkins
ahopkins / dictobj.py
Created March 10, 2018 23:36
DictObj
class DictObj(dict):
def __init__(self, **kwargs):
dict.__init__(self, **kwargs)
self.__dict__ = self
obj = DictObj(a=1)
print(obj.a) # 1
print(obj.get('a')) # 1
print(obj) # {'a': 1}
@ahopkins
ahopkins / configure.sh
Created February 19, 2018 07:33 — forked from alexellis/configure.sh
Kubernetes-weave-ubuntu.sh
#!/bin/sh
sudo apt-get update \
&& sudo apt-get install -qy docker.io
sudo apt-get update \
&& sudo apt-get install -y apt-transport-https \
&& curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
@ahopkins
ahopkins / # Sanic websocket feeds v1.md
Last active November 15, 2021 12:03
Sanic Websocket Feed

Sanic Websockets Feeds v1

This is an outdated version

See latest

import Ember from 'ember';
export default Ember.Controller.extend({
appName: `Ember's Route Hook Order`,
queryParams: ['foo'],
foo: null,
actions: {
clearLog() {
Ember.$('.log-item').remove();
for i in {1..100}; do curl -o /dev/null -s -w '%{time_total}\n' <URL>; done;
@ahopkins
ahopkins / sanic_feed.py
Last active September 28, 2019 21:08
Websocket feed using Sanic
from sanic import Sanic
import json
import asyncio
app = Sanic(__name__)
feeds = {}
class Feed(object):