Skip to content

Instantly share code, notes, and snippets.

View AndreiPashkin's full-sized avatar

Andrew Pashkin AndreiPashkin

View GitHub Profile
@AndreiPashkin
AndreiPashkin / sqlalchemy_example.py
Created February 14, 2021 15:39 — forked from ronreiter/sqlalchemy_example.py
SQLAlchemy Example
from sqlalchemy import Column, Integer, String, ForeignKey, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, backref, sessionmaker, joinedload
# For this example we will use an in-memory sqlite DB.
# Let's also configure it to echo everything it does to the screen.
engine = create_engine('sqlite:///:memory:', echo=True)
# The base class which our objects will be defined on.
Base = declarative_base()
@AndreiPashkin
AndreiPashkin / benchmark.py
Last active April 17, 2020 09:22
Aiopg result module optimization benchmark setup
import asyncio
import json
import timeit
import aiopg
import aiopg.sa
import asyncpg
import sqlalchemy as sa
import sqlalchemy.dialects.postgresql
@AndreiPashkin
AndreiPashkin / compiled_statement.py
Created January 21, 2020 11:37
Compiled statement example
import sqlalchemy as sa
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class User(Base):
__tablename__ = 'users'
@AndreiPashkin
AndreiPashkin / dev_raw_data_source_batch_size.json
Created October 24, 2019 08:55
Dev Raw Data Source ignores batch size
{
"pipelineConfig" : {
"schemaVersion" : 6,
"version" : 14,
"pipelineId" : "test213a3bfd-8099-4184-b12a-f99912cede29",
"title" : "test",
"description" : "",
"uuid" : "52c068b0-0487-4426-8dfc-6910b827a03e",
"configuration" : [ {
"name" : "executionMode",
@AndreiPashkin
AndreiPashkin / grace_stop.py
Last active July 8, 2019 17:47 — forked from worldmind/grace_stop.py
Multiprocessing graceful stop
import time
import multiprocessing as mp
import queue as queuelib
N_PROCESSES = 4
def worker(queue: mp.Queue, stop: mp.Event):
print(f"Start job: {mp.current_process().name}")
From 4caf15883b8a892aca26aa8aaa0d40663f9cca82 Mon Sep 17 00:00:00 2001
From: Andrew Pashkin <andrew.pashkin@gmx.co.uk>
Date: Tue, 12 Apr 2016 11:13:03 +0300
Subject: [PATCH] Add a test for loading classes from modules
---
tests/integration/loader/loader.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tests/integration/loader/loader.py b/tests/integration/loader/loader.py
$ PATH=$(pwd)/build:$PATH valgrind --read-var-info=yes --vgdb=yes --leak-check=full tests
==20285== Memcheck, a memory error detector
==20285== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==20285== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==20285== Command: tests
==20285==
Running "test_pool_alloc"...
Running "test_pool_realloc"...
Running "test_arraylist_append"...
Running "test_arraylist_append_many"...
@AndreiPashkin
AndreiPashkin / stack_trace.txt
Created August 12, 2015 09:03
Example of Python traceback
Traceback (most recent call last):
File "traceback_print_exc.py", line 20, in <module>
produce_exception()
File "/Users/dhellmann/Documents/PyMOTW/src/PyMOTW/traceback/traceback_example.py", line 16, in produce_exception
produce_exception(recursion_level-1)
File "/Users/dhellmann/Documents/PyMOTW/src/PyMOTW/traceback/traceback_example.py", line 16, in produce_exception
produce_exception(recursion_level-1)
File "/Users/dhellmann/Documents/PyMOTW/src/PyMOTW/traceback/traceback_example.py", line 18, in produce_exception
raise RuntimeError()
RuntimeError
$ sudo apt-get -y install postgresql-plpython-9.4
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libgeos-3.2.2
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
postgresql-9.4 postgresql-contrib-9.4
Suggested packages:
@AndreiPashkin
AndreiPashkin / Dockerfile
Created December 18, 2014 07:58
Docker cache tests
FROM ubuntu:14.04
MAINTAINER Andrew Pashkin <andrew.pashkin@gmx.co.uk>
RUN apt-get -y update
RUN apt-get install -y software-properties-common
RUN apt-add-repository -y ppa:ansible/ansible
RUN apt-get -y update
RUN apt-get install -y ansible