This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%% @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()} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flattened_list = [y for x in nested_list for y in x] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15449 andreypopp 36 44 0 1287M 329M ucond 10 31:41 1183.40% java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]" ~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from imagination.actors import Actor, react | |
class MyActor(Actor): | |
@react({"a": str, "b": [int]}) | |
def process_message(self, message): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
OlderNewer