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
testing: | |
https://grokdebugger.com/ | |
https://grokconstructor.appspot.com/do/match#result | |
log samples: | |
https://www.ossec.net/docs/log_samples/databases/postgresql.html | |
grok examples: |
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
# the key is to use &{foo} for resource identifiers, to strip out bad chars | |
Transform: AWS::LanguageExtensions | |
Parameters: | |
BucketNames: | |
Type: CommaDelimitedList | |
Resources: |
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
# get the current url (watch your quoting): | |
xidel https://example.com --extract '$url' | |
# output JSON lines: | |
xidel --printed-json-format=compact https://example.com --extract '{"title"://title, "url": $url}' | |
# for a list of items, with pagination: follow item, extract data, paginate: |
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
1. Jinja Macros can return results (but only if `called`): | |
``` | |
{% macro foo() %} | |
hello from foo | |
{{ caller({"bar":1}) if caller is defined }} | |
{% endmacro %} | |
{% call(result) foo() %} | |
{{result.bar}} |
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
""" | |
A sample app to show how to use optimistic concurrency / optimistic locking in Flask and SQLAlchemy | |
The trick is to store your entity in session between requests | |
You need to use Flask-Session, so can serialize your entities properly | |
Usage: | |
flask --app optimistic-locking.py run | |
navigate to http://127.0.0.1:5000/edit/1 |
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
# main.py | |
@app.middleware("http") | |
async def set_xhr(request: Request, call_next): | |
request.state.is_xhr = "HX-Request" in request.headers | |
return await call_next(request) | |
# in your Jinja2 template : | |
{% if request.state.is_xhr %} |
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
# TAG is a Redshift keyword, so we have to create this table ourselves, and quote TAG | |
# otherwise, you need a custom database class for liquibase | |
# see https://github.com/liquibase/liquibase-redshift | |
CREATE TABLE public.databasechangelog ( | |
ID VARCHAR(255) NOT NULL, | |
AUTHOR VARCHAR(255) NOT NULL, | |
FILENAME VARCHAR(255) NOT NULL, | |
DATEEXECUTED TIMESTAMP WITHOUT TIME ZONE NOT NULL, | |
ORDEREXECUTED INTEGER NOT NULL, |