Skip to content

Instantly share code, notes, and snippets.

@jvanasco
jvanasco / letsencrypt_dns_howto.md
Created March 18, 2018 07:07
LetsEncrypt DNS Auth HOWTO

LetsEncrypt DNS Auth HOWTO

This is a quick howto on generating SSL certs via EFF's CertBot using DNS authentication.

This works for domain and wildcard certs.

For security reasons, certbot is run on a local machine.

Wait, Security?

@jvanasco
jvanasco / model-page.ini
Created September 19, 2017 22:25
lektor opengraph support
[model]
name = Page
label = {{ this.title }}
[fields.title]
label = Title
type = string
[fields.meta_title]
label = MetaData Title
@jvanasco
jvanasco / standardize_unicode.py
Created July 29, 2017 02:48
this standardizes unicode codepoints to html entities when possible.
# -*- coding: utf-8 -*-
"""
this translates unicode codepoints in the input into *NAMED* html entities
a future version may do the html spec supported entities as well
this does not escape unsafe html into entities, as lots of libraries do that and
this function is likely to be used in a pipeline that does that too.
this simply standardizes unicode points into html entities.
"""
@jvanasco
jvanasco / standardize_unicode.py
Created July 29, 2017 02:48
this standardizes unicode codepoints to html entities when possible.
# -*- coding: utf-8 -*-
"""
this translates unicode codepoints in the input into *NAMED* html entities
a future version may do the html spec supported entities as well
this does not escape unsafe html into entities, as lots of libraries do that and
this function is likely to be used in a pipeline that does that too.
this simply standardizes unicode points into html entities.
"""
@jvanasco
jvanasco / sqla_injection_test.py
Last active August 31, 2022 07:56
sqlalchemy injection test
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# Use this file to build your own SSCCE
# SSCCE = Short, Self Contained, Correct (Compatible) Example
# see http://sscce.org/
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@jvanasco
jvanasco / import_logger.py
Created October 24, 2016 16:23
Use the `import_logger.py` to "decorate" cPython's `import` statement, and log the actual memory grown to a file. `transformer.py` will do some quick/lightweight transformations on the logger's output, creating a spreadsheet's readable csv. this is far from perfect, but can be very helpful.
if True:
print("===> installing import_logger_orverride")
import os
import psutil
import pdb
import pprint
import __builtin__
import logging
import sys
@jvanasco
jvanasco / import_logger.py
Created October 24, 2016 16:20
Use the `import_logger.py` to "decorate" cPython's `import` statement, and log the actual memory grown to a file.
if True:
print("===> installing import_logger_orverride")
import os
import psutil
import pdb
import pprint
import __builtin__
import logging
import sys
"""
After a bit of thought, I rewrote our response caching.
I stripped it into this gist in case anyone needs a starting point in the future. it's still rather specialized and hacky... but a bit cleaner than the earlier approach
The general overiew is this:
* We needed to cache responses AND perform some light operations. 99% of a rendered page is cachable as-is.
* We wanted to consolidate where the configuration is, perferalbly with the route_name declaration - but in this case it was better off with the caching code.
* The cached output should be rendered, which mades the `decorators` egress perfect... however some setup code happens in the __init__ phase of view-based classes and the 'decorators' ingress happens too soon.
@jvanasco
jvanasco / app_celery.py
Created June 18, 2016 01:29
cache with temporary values.
@task
def get_ExpensiveCalculator_foo():
expensive_foo = app_shared.ExpensiveCalculator().expensive_foo()
app_pyramid.CheapCalculator().set_foo(expensive_foo)
@jvanasco
jvanasco / app_celery.py
Created June 18, 2016 01:29
cache with temporary values.
@task
def get_ExpensiveCalculator_foo():
expensive_foo = app_shared.ExpensiveCalculator().expensive_foo()
app_pyramid.CheapCalculator().set_foo(expensive_foo)