# This example does an AJAX lookup and is in CoffeeScript
$('.typeahead').typeahead(
# source can be a function
source: (typeahead, query) ->
# this function receives the typeahead object and the query string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WeatherTypes | |
{ | |
const NOT_AVAILABLE = 'NA'; | |
const CLEAR_NIGHT = 0; | |
const SUNNY_DAY = 1; | |
const PARTLY_CLOUDY_NIGHT = 2; | |
const PARTLY_CLOUDY_DAY = 3; | |
const NOT_USED = 4; | |
const MIST = 5; | |
const FOG = 6; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extract(d): | |
import inspect | |
inspect.getouterframes(inspect.currentframe())[1][0].f_locals.update(d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import time | |
from functools import wraps | |
from wsgiref.handlers import format_date_time | |
from flask import make_response | |
def cache(expires=None, round_to_minute=False): | |
""" | |
Add Flask cache response headers based on expires in seconds. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eu -o pipefail | |
HOST=172.17.0.6 | |
REDIS_CMD=(redis-cli -h "$HOST" scan) | |
CMD_EXTRA=() | |
if [[ ! -z ${1:-} ]]; then CMD_EXTRA+=(MATCH "$1"); fi | |
if [[ ! -z ${2:-} ]]; then CMD_EXTRA+=(COUNT "$2"); fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gevent | |
import gevent.pool | |
class GroupWithExceptionCatching(gevent.pool.Group): | |
def __init__(self, *args): | |
super(GroupWithExceptionCatching, self).__init__(*args) | |
self._error_handlers = {} | |
def _wrap_errors(self, func): | |
"""Wrap a callable for triggering error handlers |
# This example does an AJAX lookup and is in CoffeeScript
$('.typeahead').typeahead(
# source can be a function
source: (typeahead, query) ->
# this function receives the typeahead object and the query string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[program:uwsgi] | |
user=robdev | |
command=uwsgi --ini /path/to/config.uwsgi | |
autostart=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This module provides a simple WSGI profiler middleware for finding | |
bottlenecks in web application. It uses the profile or cProfile | |
module to do the profiling and writes the stats to the stream provided | |
To use, run `flask_profiler.py` instead of `app.py` | |
see: http://werkzeug.pocoo.org/docs/0.9/contrib/profiler/ | |
and: http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvi-debugging-testing-and-profiling | |
""" |
I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6
apt-get update && apt-get install gdb
OlderNewer