Skip to content

Instantly share code, notes, and snippets.

View hanula's full-sized avatar

Sebastian Hanula hanula

View GitHub Profile
@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')
# 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):
# 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
@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
@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
"""
Expands `${MY_VAR}` variables in a given dictionary from `os.environ` and
local INI-like file.
"""
import os
def load_secrets(filename):
"""

Launching custom intent URIs in Android. For example Expo Go projects (like exp://192.168.1.123:8080)

Use shortcut application (like Shortcut Maker) and:

  1. create android.intent.action.VIEW intent shortcut
  2. use target URI for data

Source: expo/expo#3686 (comment)

@hanula
hanula / heroku_db_info.sh
Created December 19, 2024 09:14
Heroku DB size and version summary
#!/bin/bash
heroku pg:info --app $MY_APP \
| sed -e 's/[\(\)]//g' \
| awk '/^=== /{db=$2} /^Data Size: /{size=$8} /^PG Version: /{version=$3} /^$/{printf("%-32s PG=%-8s size=%-10s\n", db, version, size)}'