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
;; response_parse.py | |
;; import requests | |
;; response = requests.get("https://asciinema.org/api/asciicasts/17675").content | |
;; print response.index("click") | |
;; >>> 9949 | |
;; hy_response_parse.hy | |
(import requests) |
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
(defclass Person [] | |
[[name "joel"]]) | |
(setv me (Person)) | |
(print me.__class__) | |
(print "primitive".__class__) | |
;;from hy.core.language import name |
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
select mt.id from massive_table mt | |
where not exists | |
(select id from big_table bt where bt.massive_table_id=mt.id); | |
select mt.id from massive_table mt | |
left join big_table bt on bt.massive_table_id = mt.id | |
where bt.massive_table_id is null; | |
-- The left join query appears to return results 100x faster. |
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
>>> print "{}" | |
{} | |
>>> print {} | |
{} | |
# C'MON! | |
>>> print ['{}'] | |
['{}'] | |
>>> print [{}] | |
[{}] | |
>>> print type('{}') |
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
# aside from the dict being vulnerable to overwrite what benefit does the @property give | |
# over the dict on the instance in this particular use case? | |
class MyClass(object): | |
@property | |
def my_attribute(self): | |
return { | |
'key': 'value' | |
} |
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 random | |
class MaybeType(type): | |
def __repr__(cls): | |
return str(bool(random.randint(0, 1))) | |
def __nonzero__(cls): | |
return ast.literal_eval(repr(cls)) |
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
BaseBackground = ig.Class.extend({ | |
init: function () { | |
this.map = new MapTiles(); | |
}, | |
draw: function () { | |
if (this.map.tilesLoaded()){ | |
this.drawMap(); | |
} | |
}, | |
drawMap: function () { |
NewerOlder