Skip to content

Instantly share code, notes, and snippets.

🌿

Tom Christie tomchristie

🌿
Block or report user

Report or block tomchristie

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
View conference visa requirements uk.md

Visa requirements for UK conferences.

First you'll want to check if you need a visa to enter the UK.

  • Nationals of the EU, Switzerland, and EEA countries will not need a visa, and are free to work and conduct business in the UK.
  • Nationals from some designated countries such as USA may travel for tourist or business purposes under a visa exemption. The link above will detail what documents you need to provide in order to travel under a visa exemption.
  • Other nationals will need a visa.

The rules for allowable business travel under a visa exemption are covered by the same rules as those travelling under a vistor visa. If you will be travelling under a visa-exemption and the conference is covering your costs in any way you should make sure to read the relevant section below.

View lifespan.py
class LifespanManager:
def __init__(self, app):
self.app = app
self.startup_complete = asyncio.Event()
self.shutdown_complete = asyncio.Event()
self.messages = [{'type': 'lifespan.startup'}, {'type': 'lifespan.shutdown'}]
async def __aenter__(self):
self.task = asyncio.create_task(self.app(self.receive, self.send))
await self.startup_complete.wait()
View README.md

HTTPCore

A proposal for requests III.

Feature support

  • HTTP/1.1 and HTTP/2 Support.
  • async/await support for non-thread-blocking HTTP requests.
  • Fully type annotated.
  • 98% test coverage.
@tomchristie
tomchristie / put_as_create.py
Created Nov 3, 2014
PUT-as-create mixin class for Django REST framework.
View put_as_create.py
class AllowPUTAsCreateMixin(object):
"""
The following mixin class may be used in order to support PUT-as-create
behavior for incoming requests.
"""
def update(self, request, *args, **kwargs):
partial = kwargs.pop('partial', False)
instance = self.get_object_or_none()
serializer = self.get_serializer(instance, data=request.data, partial=partial)
serializer.is_valid(raise_exception=True)
View gist:74f1ef35fa1ae6516ea81de704b3b421
import aiohttp
from django.views.generic import TemplateView
class FetchView(TemplateView):
template_name = 'index.html'
async def get(self, request, *args, **kwargs):
async with aiohttp.ClientSession() as session:
View github_pagination_style.py
def _get_displayed_page_numbers(current, final):
"""
This utility function determines a list of page numbers to display, based
on the same pagination display style that GitHub use in their issue list pages.
This gives us a nice contextually relevant set of page numbers to display.
For example:
current=14, final=16 -> [1, 2, None, 12, 13, 14, 15, 16]
current=2, final=16 -> [1, 2, 3, 4, 5, None, 15, 16]
View URLs-syntax-DEP.md

======================== DEP XXX: Simplified routing syntax

  • DEP: XXX
  • Author: Tom Christie
  • Implementation Team: Tom Christie
  • Shepherd: Tim Graham
  • Status: Draft
  • Type: Enhancement
View gist:b99979c57eea85a2fbdb6b2b68926913
* CORS
* Werkzeug Debugger
* Routing
* Whitenoise
* JWT?
* Cache?
* ->WSGI / ->ASGI
* Pub/Sub
* Multipart
View async-to-block.py
import asyncio
import time
import threading
import queue
async def foo(q):
i = 0
while True:
q.put(i)
View formToData.js
function formToData(form) {
const formData = new FormData(form.get()[0])
var params = new Map()
var errors = []
var inputElements = {}
// Initially iterate through all the inputs
form.find(':input').each(function(key, value) {
var elem = $(this)
var name = elem.attr('name')
You can’t perform that action at this time.