This file contains hidden or 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
| create table foo (id serial primary key, data json); | |
| with updated_foo as ( | |
| update foo set data = '"bar"' where id = 1 | |
| returning id | |
| ) | |
| insert into foo (id, data) | |
| select 1, '"foo"' | |
| where not exists(select id from updated_foo); |
This file contains hidden or 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 foo(): | |
| yield 1 | |
| yield 2 | |
| yield 3 | |
| def bar(): | |
| yield 'a' | |
| yield 'b' | |
| yield 'c' |
This file contains hidden or 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
| import ast | |
| import inspect | |
| class destructure(object): | |
| def __init__(self, target): | |
| self.target = target | |
| def __enter__(self): | |
| # 1. Get the stack frame that called `destructure` |
This file contains hidden or 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
| import inspect | |
| frame = inspect.currentframe() | |
| assert 'asdf' in frame.f_code.co_names | |
| assert "asdf = 'asdf'" not in inspect.getsource(frame) | |
| asdf = 'asdf' |
This file contains hidden or 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
| <snippet> | |
| <content><![CDATA[ | |
| @property | |
| def ${1:name}(self): | |
| ${2:pass} | |
| ]]></content> | |
| <tabTrigger>prop</tabTrigger> | |
| <scope>source.python</scope> | |
| <description>New Property Decorator</description> | |
| </snippet> |
This file contains hidden or 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 do_something(): | |
| raise RuntimeError('do_something') | |
| def clean_up(): | |
| raise RuntimeError('clean_up') | |
| def fail_in_exception(): | |
| try: |
This file contains hidden or 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
| import inspect | |
| class Selfless(type): | |
| def __new__(cls, name, bases, attrs): | |
| # Detect any methods without `self` as the first argument | |
| selfless_methods = {} | |
| for k, v in attrs.items(): | |
| if callable(v): | |
| try: |
This file contains hidden or 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
| state = {} | |
| def generator(): | |
| state['generator'] = yield None | |
| yield None | |
| def main(): | |
| g = generator() |
This file contains hidden or 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
| <A HREF="/HeartLand-Gaien/7211/kudos10/okurimono.html"> | |
| <P ALIGN="CENTER"> | |
| <LI>心からの贈り物J | |
| </A> | |
| </LI> | |
| </P> |
This file contains hidden or 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
| var session = FB.getSession(); | |
| var query = FB.Data.query("select uid2 from friend where uid1 = {0}", session.uid); | |
| var friend_ids = new Array(); | |
| FB.Data.waitOn([query], function() { | |
| FB.Array.forEach(query.value, function(row) { | |
| friend_ids.push(row.uid2); | |
| }); | |
| console.log(friend_ids); | |
| }); |
NewerOlder