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
[14:33:02] <skimbrel> i'm working on implementing an oembed (http://oembed.com/) endpoint for my app. it has to accept a full URL as argument and return some information about the resource. since i already have a route that matches the urls that this will be getting, how do i reuse pyramid's dispatch to extract a matchdict from it? | |
[14:33:34] <skimbrel> i.e. i have an incoming request to the API that looks like this: http://www.flickr.com/services/oembed/?url=http%3A//www.flickr.com/photos/bees/2341623661/ | |
[14:34:03] <skimbrel> and i want to run the url param through the pyramid dispatch and get the resulting view and matchdict |
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
sa.Index('idx_auth_type_access_token', | |
user_auth_table.c.auth_type, | |
user_auth_table.c.access_token, | |
mysql_length=512) |
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
$ node | |
> process.nextTick(function() {null.lol;}) | |
undefined | |
> | |
repl:1 | |
(process.nextTick(function() {null.lol;}) | |
^ | |
TypeError: Cannot read property 'lol' of null | |
at repl:1:35 | |
at process._tickCallback (node.js:415:13) |
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
" Dump things into OS X paste buffer | |
vmap <leader>c :w !pbcopy<CR><CR> | |
nnoremap <leader>c :.w !pbcopy .<CR><CR> |
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 twilio import twiml | |
r = twiml.Response() | |
with r.dial() as d: | |
d.number('+14155551234', url='http://example.com') | |
unicode(r) # u'<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Number url="http://example.com/">+14155551234</Number></Dial></Response>' |
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
In [1]: class Foo(object): | |
...: pass | |
...: | |
In [2]: def bar(self): | |
...: pass | |
...: | |
In [3]: bar.__get__ | |
Out[3]: <method-wrapper '__get__' of function object at 0x10fdc6398> |
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
In [13]: def counter_factory(): | |
....: count = 0 | |
....: def _counter(): | |
....: count += 1 | |
....: return _counter | |
....: | |
In [14]: f = counter_factory() | |
In [15]: f() |
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
In [16]: def counter_factory(): | |
....: count = [0] | |
....: def _counter(): | |
....: count[0] += 1 | |
....: return count[0] | |
....: return _counter | |
....: | |
In [17]: f = counter_factory() |
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
>>> def create_counter(): | |
... count = 0 | |
... def _counter(): | |
... nonlocal count | |
... count += 1 | |
... return count | |
... return _counter | |
... | |
>>> f = create_counter() | |
>>> f() |
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
In [31]: def create_counter(): | |
....: def _counter(): | |
....: global count | |
....: count += 1 | |
....: return count | |
....: return _counter | |
....: | |
In [32]: f = create_counter() |