Skip to content

Instantly share code, notes, and snippets.

View obeattie's full-sized avatar

Oliver Beattie obeattie

View GitHub Profile
// Package h2c provides a HTTP/2.0 h2c client transport implementation
package h2c
import (
"bufio"
"bytes"
"context"
"encoding/base64"
"encoding/binary"
"fmt"
@obeattie
obeattie / README.md
Last active August 29, 2015 14:08 — forked from JoelBesada/README.md
@obeattie
obeattie / group.js.coffee
Created April 11, 2013 13:49
CoffeeScript source for Paper.js modifications
_getClipItems: () ->
unless @_clipItems?
@_clipItems = (c for c in @_children when c._clipMask)
return @_clipItems
draw: (ctx, param) ->
clipItems = @_getClipItems()
# If the group is to be clipped, draw them to an in-memory canvas
@obeattie
obeattie / oauth-v2.html
Created October 21, 2012 14:12
Pretty version of the draft OAuth spec
<!doctype html>
<html>
<head>
<title>draft-ietf-oauth-v2-31 - The OAuth 2.0 Authorization Framework</title>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel=stylesheet type="text/css" href="http://pretty-rfc.herokuapp.com/style.css">
<meta name=viewport content="width=device-width, initial-scale=1.0">
</head>
import distutils.sysconfig as sysconfig
import re
import sublime
import sublime_plugin
FROM_IMPORT_RE = re.compile(r'^\s*from (?P<package>\.?\w*)(?P<package_extra>\S*)\s+import\s+(?P<subpackages>.+)')
PLAIN_IMPORT_RE = re.compile(r'^\s*import (?P<package>\.?\w*)(?P<package_extra>\S*)')
CONTINUATION_RE = re.compile(r'.*(\\\s*)$')
PARENTHESISED_START_RE = re.compile(r'^.+? import \(')
### Use the standard LV.Ticker event loop for jQuery animations, too (which uses requestAnimationFrame under the
covers, if supported by the client) ###
class LV.JQAnimation extends LV.Animation
constructor: (timer) ->
@timer = timer
@start()
return
step: () ->
@obeattie
obeattie / lv_import_sorter.py
Created June 12, 2012 07:01
Sublime Plugin to sort imports like momma used to
import distutils.sysconfig as sysconfig
import re
import sublime
import sublime_plugin
FROM_IMPORT_RE = re.compile(r'^\s*from (?P<package>\.?\w*)(?P<package_extra>\S*)\s+import\s+(?P<subpackages>.+)')
PLAIN_IMPORT_RE = re.compile(r'^\s*import (?P<package>\.?\w*)(?P<package_extra>\S*)')
CONTINUATION_RE = re.compile(r'.*(\\\s*)$')
PARENTHESISED_START_RE = re.compile(r'^.+? import \(')
@obeattie
obeattie / fragmentsoup.py
Created May 22, 2012 17:41
A BeautifulSoup that can handle HTML fragments with lxml
from bs4 import BeautifulSoup
from bs4.builder._lxml import LXML as BS_LXML_FEATURE
class FragmentSoup(BeautifulSoup):
"""A custom BeautifulSoup implementation that properly represents fragments when using lxml, without wrapping them
in a document on output (internally, they are still wrapped)."""
def _feed(self, *args, **kwargs):
if not hasattr(self, '__markup_enclosure'):
self.__markup_enclosure = None
@obeattie
obeattie / window-controller.coffee
Created April 23, 2012 10:35
Cross-browser HTML5 fullscreen support. What a calamity.
### The window controller manages the size of the window; providing interfaces for entering/leaving full-screen modes
(and providing events when that happens) ###
class LV.WindowController
constructor: () ->
@isFullscreenCapable = not Modernizr.touch
@win = $(window)
# Create a debounced version; we only care after resizing has finished
@onResize = _.debounce(@_onResize, 300)
@bind({
>>> class Orly:
... def __add__(self, other):
... return isinstance(other, Orly) or (not True) + other
...
>>> False = OhReally()
>>> False + False
True