Skip to content

Instantly share code, notes, and snippets.

@jvanasco
jvanasco / wellformed_parser.py
Created October 18, 2018 23:07
wellformed parser - utility for parsing html tags as fast as possible.
def extract_tag_inner(tag):
"""
extracts the inner part of a tag - dropping brackets, tagname, trailing slash
:arg string tag: a html tag of the formats:
<TAG_NAME TAG_ATTRIBUTES>
<TAG_NAME TAG_ATTRIBUTES/>
<TAG_NAME TAG_ATTRIBUTES />
:returns string: the inner part of a tag
@jvanasco
jvanasco / shame.py
Created July 3, 2018 23:24
shameful python
def foo():
# i am awful for doing this.
# this function has a nested function, which can not accept arguments
# the inner function will be called twice by a 3rd party library
iteration = [0, ] # use a list as a shameful hack to get around scoping issues
def bar():
iteration[0] += 1 # increment the list index, use that for comparison
if iteration[0] > 1:
@jvanasco
jvanasco / email.txt
Created May 26, 2018 17:46
23 and me gdpr
It's your data.
It's our responsibility to protect it.
As a new data protection regulation goes into effect in Europe, we are taking the opportunity to make improvements for all 23andMe customers globally. On May 24, 2018, we launched important privacy updates and new tools as part of our ongoing commitment to ensure that you are in control of your data.
We updated our Privacy Statement with additional information about our practices and made it easier to understand.
https://www.23andme.com/about/privacy/
We created a Data Protection Center to help explain the European Union's new regulation and provide information about our approach to compliance.
https://www.23andme.com/gdpr/
We added information to our website regarding our security practices and the measures we put in place to protect your data.
@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 / blocklist.txt
Created March 15, 2012 16:28
blocklist of social / analytics / profiling
# google services
# heavy js + tracking
google-analytics.com
googleadservices.com
doubleclick.net
gstatic.com
plusone.google.com
# social services
# heavy js + tracking
@jvanasco
jvanasco / app-models-__init__.py
Created January 3, 2012 20:21
Reflecting in Pyramid/SqlAlchemy
import logging
log = logging.getLogger(__name__)
from sqlalchemy import Table
from sqlalchemy import MetaData
from sqlalchemy.orm import mapper
from sqlalchemy.orm import scoped_session
from sqlalchemy.orm import sessionmaker
from zope.sqlalchemy import ZopeTransactionExtension
@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