Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Andrey Popp andreypopp

🏠
Working from home
Block or report user

Report or block andreypopp

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 gist:455755
from gunicorn.app.base import Application
class MyApplication(Application):
def __init__(self, wsgi_app, **kw):
MyApplication.__init__(**kw)
self.callback = wsgi_app
from myapp import make_app
MyApplication(make_app()).run()
View dummyacl.erl
%%% @doc Basic utilities for working with ACLs over integer-based principals.
%%%
%%% @type acl() = [acl_entry()]
%%% @type acl_entry() =
%%% {allow, principal_qualifier()}
%%% | {deny, principal_qualifier()}
%%% @type principal_qualifier() =
%%% int()
%%% | any
%%% | {range, int(), int()}
View gist:738956
flattened_list = [y for x in nested_list for y in x]
View gist:779411
15449 andreypopp 36 44 0 1287M 329M ucond 10 31:41 1183.40% java
View gist:789522
andreypopp> python -m timeit -v "range(40)[:len('string')]" ~
10 loops -> 1.41e-05 secs
100 loops -> 0.000143 secs
1000 loops -> 0.00119 secs
10000 loops -> 0.0117 secs
100000 loops -> 0.117 secs
1000000 loops -> 1.16 secs
raw times: 1.17 1.17 1.18
1000000 loops, best of 3: 1.17 usec per loop
andreypopp> python -m timeit -v "range(40)[:6]" ~
View gist:795262
psql=# table b;
l │ r
───┼───
a │ b
b │ e
e │ d
(3 rows)
Time: 0.188 ms
psql=# with recursive c as (select * from b union select b.l, c.r from b join c on c.l = b.r) table c;
View gist:797262
package ru.braintrace
class OptionParser {
private val optionInfo = new mutable.ListBuffer[OptionInfo]
def addOption(option: OptionInfo) =
optionInfo.append(option)
def addOption(short: String, long: String): Unit =
View gist:825116
from imagination.actors import Actor, react
class MyActor(Actor):
@react({"a": str, "b": [int]})
def process_message(self, message):
pass
View gist:877419
case req @ DELETE(Path(Seg("users" :: name :: "bookmarks" :: uri))) => for {
BasicAuth(u, p) <- req
UserFound(user) if verify(u, p, user) <- userRepository.findByName(name)
Success <- user.bookmarks.remove(uriString)
} yield NoContent
View models.py
class PGArrayField(models.Field):
""" Custom field for mapping between postgresql array and python list."""
def __init__(self, element_field, **kwargs):
self.element_field = element_field
models.Field.__init__(self, **kwargs)
def db_type(self, *connection):
return '%s[]' % self.element_field.db_type(*connection)
You can’t perform that action at this time.