Skip to content

Instantly share code, notes, and snippets.

View hanula's full-sized avatar

Sebastian Hanula hanula

View GitHub Profile
"""
Expands `${MY_VAR}` variables in a given dictionary from `os.environ` and
local INI-like file.
"""
import os
def load_secrets(filename):
"""
@hanula
hanula / two_letter_domains.txt
Created February 23, 2015 16:31
2 letter domains
aa.je
ae.je
ae.gg
ae.ht
af.je
af.cx
af.gg
af.gl
af.ht
ah.je
@hanula
hanula / move_db_data.py
Last active August 29, 2015 14:01
Moving data from sqlite to postgres [Pyramid/SQLAlchemy]
"""
Moves db rows one by one, from source db (configured using pyramid ini config)
to destination db defined as engine here.
"""
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from pyramid.paster import bootstrap
bootstrap('development.ini') # bootstrap pyramid's environment along with data models
# Worker fails here if it closes, creates and uses the same loop
# for its runner and apps code it's serving.
#
# Start with: gunicorn -w 2 aiohttp_gunicorn_worker_test:app --worker-class aiohttp.worker.AsyncGunicornWorker
import asyncio
import aiohttp
@asyncio.coroutine
# coding=UTF-8
from __future__ import division
import re
# This is a naive text summarization algorithm
# Created by Shlomi Babluki
# April, 2013
class SummaryTool(object):
@hanula
hanula / gist:5447311
Created April 23, 2013 20:55
Falcon's bench suite for Pyramid
def create_pyramid(body, headers):
from pyramid.response import Response
from pyramid.config import Configurator
def hello(request):
return Response(body, headers=headers, content_type='text/plain')
config = Configurator()
config.add_route('hello', '/hello/:account_id/test')