Skip to content

Instantly share code, notes, and snippets.

@genadyp
genadyp / graphql_interface_and_union.md
Created February 10, 2019 08:34
Real world example of GraphQLInterfaceType and GraphQLUnionType

Real world example of GraphQLInterfaceType and GraphQLUnionType

Both are meant to help you design a schema with a heterogeneous set of types, and you could achieve the same functionality using both, but GraphQLInterfaceType is more suitable when the types are basically the same but some of the fields are different, and GraphQLUnionType when the types are totally different and have totally different fields.

Ultimately whether to use one or the other depending on your schema design.

For a real world example, let's say you have a list of blogs,

@genadyp
genadyp / data-science.md
Last active September 18, 2025 12:18
Data Science and Big Data
@genadyp
genadyp / python-useful-links.md
Last active May 25, 2026 06:59
python useful links
@genadyp
genadyp / docker.md
Last active August 13, 2020 09:45
docker

To bash into a running container, type this:

docker exec -it container_name /bin/bash

The docker system prune command will remove all stopped containers, all dangling images, and all unused networks:

docker system prune
@genadyp
genadyp / python-import.md
Last active January 28, 2020 13:36
Python import

Tired on sys.path hacks?

There are plenty of sys.path.append -hacks available, but I found an alternative way of solving the problem in hand: The setuptools. I am not sure if there are edge cases which do not work well with this. The following is tested with Python 3.6.5, (Anaconda, conda 4.5.1), Windows 10 machine.

Setup

The starting point is the file structure you have provided, wrapped in a folder called myproject.

.
@genadyp
genadyp / sessionrecorder.py
Created February 4, 2020 14:37 — forked from georgevreilly/sessionrecorder.py
WSGI Middleware to record Request and Response data
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
WSGI middleware to record requests and responses.
"""
from __future__ import print_function, unicode_literals
import logging
@genadyp
genadyp / wsgi.md
Last active February 4, 2020 14:53
WSGI: The Server-Application Interface for Python

WSGI: The Server-Application Interface for Python

toptal

Leandro Lima LEANDRO LIMA Leandro has 15+ years in IT/development. Working with Python since 2013, he loves building efficient and cost-effective systems. 831SHARE In 1993, the web was still in its infancy, with about 14 million users and a hundred websites. Pages were static but there was already a need to produce dynamic content, such as up-to-date news and data. Responding to this, Rob McCool and other contributors implemented the Common Gateway Interface (CGI) in the National Center for Supercomputing Applications (NCSA) HTTPd web server (the forerunner of Apache). This was the first web server that could serve content generated by a separate application.

@genadyp
genadyp / web_python.md
Last active March 6, 2020 14:47
python web useful links
@genadyp
genadyp / flask.md
Last active February 9, 2020 14:32
flask useful links
@genadyp
genadyp / html_howto.md
Last active March 4, 2020 08:42
html how-to

Using an HTML button to call a JavaScript function

link1, link2

There are a few ways to handle events with HTML/DOM. There's no real right or wrong way but different ways are useful in different situations.

  1. There's defining it in the HTML:
<input id="clickMe" type="button" value="clickme" onclick="doFunction();" />