Skip to content

Instantly share code, notes, and snippets.

@waylan
waylan / extensionless_static_files_tornado.py
Last active February 29, 2016 19:09
Serve static files without file extensions from Tornado. For example, a request for `/foo/bar` would serve the file `/foo/bar.html` if it exists.
from tornado.web import StaticFileHandler
class ExtensionlessStaticFileHandler(StaticFileHandler):
"""
A static file handler which serves static content from a directory.
In addition to the behavior of the default StaticFileHandler,
provision is made to serve extensionless files. For example,
if ``default_extension`` is set to ``.html`` and the url
``foo/bar`` is requested, the file `foo/bar.html`` will be
@waylan
waylan / md_syntax_test_decorator.py
Created March 3, 2016 02:51
A proof of concept to see how a test decorator for Markdown syntax tests would work. Probably not a great idea.
import unittest
import markdown
class MarkdownSyntaxError(AssertionError):
pass
# The test suite to which all syntax tests are added.
test_syntax = unittest.suite.TestSuite()
@waylan
waylan / mdast.py
Last active March 22, 2016 20:14
A JSON based AST Object for Markdown
import json
class Node(object):
"""
Markdown Abstract Syntax Tree Node.
Each instance represents one node of a Markdown abstract syntax tree
node. Each can be encoded to JSON and a tree can be decoded from JSON.
@waylan
waylan / countdown_timer.py
Last active June 27, 2016 00:21
Countdown timer starts from `start_value` and counts down to zero, then counts up with negated time. Only displays minutes and seconds. No pause or reset available.
import time
from threading import Timer
def now():
""" Return the current time in seconds since the epoch. """
return int(time.time())
class Countdown(object):

Testing Long Code Spans

This table:

|Test1|Test2|
|-------------|-------------|
|Hello|`a_very_very_very_long_variable_name=some_very_very_very_long_namepsace.with_a_very_very_very_long_function_name(and_a_very_very_very_long_keyword="some very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long value")`|
@waylan
waylan / extensionless_static_files.py
Last active September 3, 2016 00:12
Serve static files without file extensions. For example, a request for `/foo/bar` would serve the file `/foo/bar.html` if it exists.
import static
from os import path
class ExtensionlessCling(static.Cling):
"""
Serve static extensionless files.
Serve static files just like static.Cling with the added
ability to serve a file without its file extension. For
example, a request for ``/foo/bar`` would serve the file
@waylan
waylan / admonition.md
Created August 27, 2012 15:11
My proposal for an Admonition Extension to Markdown

Admonition Extension

! Note
    This is a paragraph in a "Note"

    This is a second paragraph.

! Warning
    This has not been implemented. This is only a demonstration of the syntax.

A Raw HTML Table in GitHub Flavored Markdown

some thing more important up here

Still on the left!!!

Column1 Column1 Column1
Column1 Column1 Column1