This file contains hidden or 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
(custom-set-variables | |
;; custom-set-variables was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
'(column-number-mode t) | |
'(inhibit-startup-screen t) | |
'(line-number-mode t) | |
'(load-home-init-file t t) | |
'(package-selected-packages (quote (terraform-mode)))) |
This file contains hidden or 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
[core] | |
editor = emacs | |
[user] | |
name = pgjones | |
email = | |
[pull] | |
rebase = true |
This file contains hidden or 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 random import choice | |
from string import Formatter | |
from timeit import timeit | |
from werkzeug.routing import Map, Rule | |
from werkzeug.routing.matcher import TableMatcher, TreeMatcher | |
# With thanks to https://github.com/richardolsson/falcon-routing-survey for the paths below | |
PATHS = [ |
This file contains hidden or 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 json | |
from flask.testing import FlaskClient | |
from flask.wrappers import Response | |
class JSONResponseWrapper(Response): | |
"""Extends the BaseResponse to add a get_json method. | |
This should be used as the response wrapper in the TestClient. |
This file contains hidden or 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
pairs = { | |
")": "(", | |
"}": "{", | |
"]": "[", | |
} | |
class Solution: | |
def isValid(self, s: str) -> bool: | |
stack = [] | |
for c in s: |
This file contains hidden or 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
ThreadPool = function(script, size) { | |
this.threads = []; | |
this.tasks = []; | |
for (var ithread = 0; ithread < size; ithread++) { | |
this.threads.push(new lxst.FilterThread(script, this)); | |
} | |
}; | |
ThreadPool.prototype.queueTask = function(task, callback) { | |
const task = {task: task, callback: callback}; |
This file contains hidden or 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
DROP TABLE IF EXISTS todos; | |
CREATE TABLE todos ( | |
id INTEGER PRIMARY KEY AUTOINCREMENT, | |
complete BOOLEAN NOT NULL DEFAULT FALSE, | |
due TIMESTAMPTZ, | |
task TEXT NOT NULL | |
); |
This file contains hidden or 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 geventwebsocket.handler import WebSocketHandler | |
from gevent.pywsgi import WSGIServer | |
from flask import Flask, request, render_template_string | |
from flask_sockets import Sockets | |
import json | |
app = Flask(__name__) | |
sockets = Sockets(app) | |
template = """ |
This file contains hidden or 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 RateLimit: | |
def __init__(self, count: int, period: timedelta) -> None: | |
self.count = count | |
self.period = period | |
@property | |
def inverse(self) -> float: | |
return self.period.total_seconds() / self.count | |
NewerOlder