Skip to content

Instantly share code, notes, and snippets.

Tomek Paczkowski oinopion

Block or report user

Report or block oinopion

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am oinopion on github.
  • I am oinopion (https://keybase.io/oinopion) on keybase.
  • I have a public key ASBxi5CUEoLSH6wms2YYL3bjYNdlnJeMPewkFUAyGHtttgo

To claim this, I am signing this object:

@oinopion
oinopion / deco.py
Last active Dec 2, 2016
Use contextmanager to create a decorator
View deco.py
# Read docs here: https://docs.python.org/3/library/contextlib.html
>>> from contextlib import contextmanager
>>>
>>>
>>> @contextmanager
... def deco_and_cm():
... print('Hello')
... yield
... print('Goodbye')
...
@oinopion
oinopion / read-access.sql
Created Oct 5, 2016
How to create read only user in PostgreSQL
View read-access.sql
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
View docker.log
{"v":0,"id":"6cd5b2aca61d","image":"weaveworks/weave:1.5.2","name":"weave","line":"2016/06/01 14:47:35 ->[10.131.6.89:6783|6e:82:93:bd:8e:72(squirrel.c66.me)]: connection shutting down due to error: IP allocation was seeded by different peers (received: [6e:82:93:bd:8e:72(squirrel.c66.me)], ours: [26:2d:0f:7a:3d:9b(squirrel.c66.me) 3e:84:e7:b4:70:99(squirrel.c66.me) 5a:fe:c2:77:f8:ae(squirrel.c66.me) 66:2b:eb:1c:41:2d(squirrel.c66.me) e2:1b:2b:78:24:93(squirrel.c66.me)])","host":"c66-squirrel-prd-otter"}
{"v":0,"id":"6cd5b2aca61d","image":"weaveworks/weave:1.5.2","name":"weave","line":"2016/06/01 14:47:35 ->[10.131.6.89:6783|6e:82:93:bd:8e:72(squirrel.c66.me)]: connection deleted","host":"c66-squirrel-prd-otter"}
{"v":0,"id":"6cd5b2aca61d","image":"weaveworks/weave:1.5.2","name":"weave","line":"INFO: 2016/06/01 14:47:35.440872 ->[10.131.6.89:38565] connection accepted","host":"c66-squirrel-prd-otter"}
{"v":0,"id":"6cd5b2aca61d","image":"weaveworks/weave:1.5.2","name":"weave","line":"2016/06/01 14:47:35 ->[10.
@oinopion
oinopion / segment.js
Last active Aug 29, 2015
Segement Load Snippet
View segment.js
// Segment load snippet, copied from:
// https://segment.com/docs/libraries/analytics.js/quickstart/
(function(){
// Create a queue, but don't obliterate an existing one!
var analytics = window.analytics = window.analytics || [];
// If the real analytics.js is already on the page return.
if (analytics.initialize) return;
View books.py
import json
import random
closeds = json.load(open('closed.json'))
opens = json.load(open('open.json'))
def today(pr):
return pr['created_at'].startswith('2014-02-15')
prs = [p for p in (opens+closeds) if today(p)]
@oinopion
oinopion / iterutils.py
Created Oct 9, 2013
A iterator that converts single sequence into iterable of lists length n.
View iterutils.py
def in_batches(sequence, n=2):
"""
>>> list(in_batches([1, 2, 3, 4, 5], n=2))
[[1, 2], [3, 4], [5, None]]
"""
iterable = iter(sequence)
try:
while True:
values = [None] * n
for i in xrange(n):
@oinopion
oinopion / nonunicode.sh
Created Sep 18, 2013
Find all files without unicode_literals import
View nonunicode.sh
grep -iRIL 'unicode_literals' --include '*.py' --exclude '__init__.py'
View pip.log
------------------------------------------------------------
/Users/oinopion/.virtualenvs/a1d2973487ccdced/bin/pip run on Fri Aug 16 09:35:38 2013
Downloading/unpacking pytz
Getting page https://pypi.python.org/simple/pytz/
URLs to search for versions for pytz:
* https://pypi.python.org/simple/pytz/
Skipping link /Users/oinopion/.pip/wheels (from -f); not a file
Getting page http://pytz.sourceforge.net
Getting page http://sourceforge.net/project/showfiles.php?group_id=79122
@oinopion
oinopion / Vagrantfile
Last active Dec 20, 2015
Simple web-dave storage in vagrant
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Run 'vagrant up' to start server
# Apache will be available at localhost:8000
# Nginx will be available at localhost:7000
# Both share htpass and data directory
# To upload file via PUT do:
# $ curl 'http://vagrant:vagrant@localhost:8000/hello.txt' -T hello.txt
# To create collection do:
You can’t perform that action at this time.