Skip to content

Instantly share code, notes, and snippets.

🕴️
I may be slow to respond.

Tomáš Ehrlich tricoder42

🕴️
I may be slow to respond.
View GitHub Profile
@dfee
dfee / graphene_subscription.py
Created Nov 25, 2017
Example of how subscriptions work with graphene
View graphene_subscription.py
from collections import OrderedDict
import graphene
import rx
subject = rx.subjects.Subject()
class Author(graphene.ObjectType):
@akorotkov
akorotkov / pg_graph
Created Jun 5, 2016
Draw psql output as iTerm2 v3 inline graph using matplotlib
View pg_graph
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Draw psql output as iTerm2 v3 inline graph using matplotlib
# Author: Alexander Korotkov <a.korotkov@postgrespro.ru>
import sys
import re
import warnings
import matplotlib
matplotlib.use("Agg")
@chbrown
chbrown / _upgrade-pg9.4-to-pg9.5.md
Last active Dec 11, 2018
Upgrade PostgreSQL 9.4 to 9.5 on Mac OS X with Homebrew
View _upgrade-pg9.4-to-pg9.5.md

First, check your current config (example output in homebrew.mxcl.postgresql.plist.xml lower down in this gist):

cat ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Most importantly, note the -D /usr/local/var/postgres argument.

Second, shut down your current PostgreSQL.

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
View double_comprehension.rst

When I need to remember the spelling for a list comprehension with more than one loop in Python, I find the following mnemonic helpful:

write the for statements in the same order you would write a nested loop

For example, suppose we have a nested list that we wish to flatten:

>>> nested_list = [[1, 2, '5!'], (3, 'sir!')]
@epicserve
epicserve / example_command.py
Created Oct 30, 2013
Example of how to setup logging for a Django management command.
View example_command.py
from django.core.management.base import BaseCommand
from mymodule import main
import logging
class Command(BaseCommand):
help = 'Do foo'
def handle(self, *args, **options):
You can’t perform that action at this time.