Skip to content

Instantly share code, notes, and snippets.

@inklesspen
inklesspen / config.toml
Created June 16, 2015 19:45
TOML/JSON logging config for dowwie
[logging.main]
version = 1
[logging.main.formatters.generic]
"()" = "formatter.JSONFormatter"
[logging.main.handlers.console]
formatter = "generic"
class = "logging.StreamHandler"
stream = "ext://sys.stdout"
@inklesspen
inklesspen / panel.py
Created June 2, 2015 19:35
JSON-RPC Panel for pyramid_debugtoolbar
# Needs JS/CSS from https://github.com/yesmeck/jquery-jsonview/
from pyramid_debugtoolbar.panels import DebugPanel
class JSONRPCPanel(DebugPanel):
name = 'jsonrpc'
template = 'fnordapp:templates/jsonrpc_panel.dbtmako'
title = 'JSON-RPC calls'
nav_title = 'JSON-RPC'
@inklesspen
inklesspen / sqlacodegen.py
Created May 6, 2015 16:17
sqlacodegen wish list
# sqlacodegen with --noclasses produces tables that look like this:
t_match_matchrelationship = Table(
'match_matchrelationship', metadata,
Column('id', BigInteger, primary_key=True, server_default=text("nextval('match_matchrelationship_id_seq'::regclass)")),
Column('created_on', DateTime(True), nullable=False, index=True),
Column('opportunity_id', ForeignKey(u'opportunities_opportunity.id'), nullable=False, index=True),
Column('transaction_profile_id', ForeignKey(u'transaction_profile.transaction_data_id'), index=True),
Column('score', BigInteger, nullable=False),
Column('sent_date', DateTime(True), index=True),
Column('pursued_on', DateTime(True)),
from sqlalchemy import (
Column,
Index,
Integer,
Text,
)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import engine_from_config
from pyramid.config import Configurator
from sqlalchemy import engine_from_config
from .models import (
DBSession,
Base,
)
def main(global_config, **settings):
from pyramid.response import Response
from pyramid.view import view_config
from sqlalchemy.exc import DBAPIError
from .models import (
DBSession,
MyModel,
)
from sqlalchemy import (
Column,
Index,
Integer,
Text,
)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import (
jon@astyanax:~$ python
Python 2.7.9 (default, Dec 10 2014, 23:46:04)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> urllib.urlopen('https://coveralls.io/r/inklesspen/montague')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 87, in urlopen
return opener.open(url)
>>> markupsafe.escape(u"Hello {tag}there{end}").format(tag="<a href='...'>", end="</a>")
Markup('Hello &lt;a href=&#39;...&#39;&gt;there&lt;/a&gt;')
>>> markupsafe.escape(u"Hello {tag}there{end}").format(tag=markupsafe.Markup("<a href='...'>"), end=markupsafe.Markup("</a>"))
Markup("Hello <a href='...'>there</a>")

Keybase proof

I hereby claim:

  • I am inklesspen on github.
  • I am inklesspen (https://keybase.io/inklesspen) on keybase.
  • I have a public key whose fingerprint is 0E94 44CD 2880 C204 4E57 6956 01F0 E464 7644 5757

To claim this, I am signing this object: