Skip to content

Instantly share code, notes, and snippets.

@ccampbell
ccampbell / server.py
Last active February 11, 2021 10:31
Simple static webserver using tornado
#!/usr/bin/env python
import os
import tornado.web
from tornado.ioloop import IOLoop
from tornado.options import define, options
from tornado.escape import xhtml_escape
# config options
define('port', default=8080, type=int, help='port to run web server on')
define('debug', default=True, help='start app in debug mode')

Keybase proof

I hereby claim:

  • I am ccampbell on github.
  • I am ccampbell (https://keybase.io/ccampbell) on keybase.
  • I have a public key whose fingerprint is CA5C D27E 0BC1 AD0E B050 E54B 6306 C487 3C5F 26CE

To claim this, I am signing this object:

@ccampbell
ccampbell / mousetrap-global.js
Created October 13, 2012 17:24
Extends mousetrap.js to add global bindings that still work in form fields. Just include this js after mousetrap.
/**
* adds a bindGlobal method to Mousetrap that allows you to
* bind specific keyboard shortcuts that will still work
* inside a text input field
*
* usage:
* Mousetrap.bindGlobal('ctrl+s', _saveChanges);
*/
Mousetrap = (function(Mousetrap) {
var _global_callbacks = {},
@ccampbell
ccampbell / mousetrap-pause.js
Created September 19, 2012 03:30
Extends mousetrap.js to add pause/unpause support. Just include this js after mousetrap.
/**
* adds a pause and unpause method to Mousetrap
* this allows you to enable or disable keyboard shortcuts
* without having to reset Mousetrap and rebind everything
*/
Mousetrap = (function(Mousetrap) {
var self = Mousetrap,
_original_stop_callback = self.stopCallback,
enabled = true;
@ccampbell
ccampbell / mousetrap-bind.js
Created July 21, 2012 02:50
Extends mousetrap.js to support passing a dictionary into bind method. Just include this js after you include mousetrap.
/**
* Overwrites default Mousetrap.bind method to optionally accept
* an object to bind multiple key events in a single call
*
* You can pass it in like:
*
* Mousetrap.bind({
* 'a': function() { console.log('a'); },
* 'b': function() { console.log('b'); }
* });