- Create database habitat_new
- Upload design docs to habitat_new, copying either from file in gist, or existing database: http://localhost:5984/habitat/_all_docs?startkey=%22_design%2F%22&endkey=%22_design0%22&include_docs=true (it's probably possible to just include them in the bulk upload, but I didn't bother writing it).
- Download payload config docs and flight docs http://localhost:5984/habitat/_design/payload_configuration/_view/name_time_created?include_docs=true http://localhost:5984/habitat/_design/flight/_view/all_name_time_created?include_docs=true
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 time | |
import shlex | |
class CPIOWriter: | |
# https://www.kernel.org/doc/Documentation/early-userspace/buffer-format.txt | |
HEADER_FORMAT = "070701{ino:08X}{mode:08X}{uid:08X}{gid:08X}{nlink:08X}{mtime:08X}" \ | |
"{filesize:08X}{maj:08X}{min:08X}{rmaj:08X}{rmin:08X}{namesize:08X}{chksum:08X}" | |
OTHER_HEADER_ARGS = \ | |
{ "mode": 0o100000 + 0o644 # regular file + perms, see stat(2) | |
, "uid": 0 |
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
open Core | |
module Monitor = struct | |
type t = unit | |
end | |
module Scheduler0 : sig | |
val enqueue | |
: (unit -> unit) | |
-> Monitor.t |
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
query: SELECT * FROM people WHERE condition | |
sender: | |
name: Daniel Richman | |
email: [email protected] | |
to_email_keys: [homeemail, workemail] | |
to_name_template: | | |
{{ firstname }} {{ surname }} | |
subject_template: Hello {{ firstname }} | |
body_template: | | |
Hello, {% include "to_name" %} |
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
from __future__ import division, print_function | |
import json | |
import numpy as np | |
from scipy.stats import norm | |
class config: | |
def no_points_condition(reds, blues): | |
return "X" in reds or "X" in blues |
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
# varnishncsa -a -w /var/log/varnish/timing.log -F "%{Varnish:handling}x %{Varnish:time_firstbyte}x %r" | |
from __future__ import print_function | |
def timing_log(): | |
with open("/var/log/varnish/timing.log") as f: | |
for line in f: | |
hitmiss, time, url = line.split(" ", 2) | |
if hitmiss != "miss": | |
continue |
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 logging | |
import traceback | |
import psycopg2 | |
class PostgreSQLHandler(logging.Handler): | |
""" | |
A :class:`logging.Handler` that logs to the `log` PostgreSQL table | |
Does not use :class:`PostgreSQL`, keeping its own connection, in autocommit | |
mode. |
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 FlaskLoggerAdapter(logging.LoggerAdapter): | |
""" | |
A :class:`logging.LoggerAdapter` that adds request context | |
Adds the following attributes to log records (which can then be used in a | |
:class:`logging.Formatter` string). | |
* base_url: ``flask.request.base_url`` | |
* flask_endpoint: ``flask.request.endpoint`` | |
* remote_addr: ``flask.request.remote_addr`` |
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
# Extracted from Flask-SQLAlchemy | |
sess = sqlalchemy.orm.scoped_session( | |
database.Session, | |
scopefunc=flask._app_ctx_stack.__ident_func__ | |
) | |
@app.teardown_appcontext | |
def teardown_appcontext(res): | |
session.remove() | |
return res |
NewerOlder