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 Dict | |
import List | |
import Html exposing (text) | |
type alias Expense = | |
{ title : String | |
, amount: Float | |
} |
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
// don't write this | |
var myLib = function(options) { | |
if (options.foo) doThis(); | |
if (options.bar) doSomeOtherStuff(); | |
if (options.baz) coverSomeWeirdEdgeCase(); | |
}; | |
// write this instead | |
var myLib = function(plugins) { | |
for (var name in plugins) { |
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
>>> nugget = connection.Nugget.find_one({"url": "http://www.example.org/blog/post123"}) | |
{ | |
"_id": ObjectId("4f314163a1e5fa16fe000001"), | |
"created_at": datetime.datetime(2013, 8, 4, 17, 22, 8, 3000), | |
"updated_at": datetime.datetime(2013, 8, 4, 17, 22, 8, 3000), | |
"url": u"http://www.example.org/blog/post123", | |
"discoverer": u"namlook", | |
"topics": [u"example", u"fun"], | |
"popularity": 1 | |
} |
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
>>> user_nugget | |
{ | |
"_id": ObjectId("4f314163a1e5fa16fe000000"), | |
"created_at": datetime.datetime(2013, 8, 4, 17, 22, 8, 3000), | |
"updated_at": datetime.datetime(2013, 8, 4, 17, 22, 8, 3000), | |
"url": u"http://www.example.org/blog/post123", | |
"user_id": u"namlook", | |
"topics": [u"example", u"fun"] | |
} |
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
>>> user_nugget = connection.UserNugget() | |
>>> user_nugget.url = u"http://www.example.org/blog/post123" | |
>>> user_nugget.user_id = u"namlook" | |
>>> user_nugget.topics = [u"example", u"fun"] | |
>>> user_nugget.save() |
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
self.db.Nugget.collection.update({"url": self.url}, { | |
"$addToSet": {"topics": {"$each": self.topics}}, | |
"$inc": 1 | |
}) |
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
>>> nuggets = connection.Nugget.collection.find() # fast! |
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
>>> nuggets = connection.Nugget.find() # nuggets is a list of Nugget object | |
>>> nuggets = connection.elkorado.nuggets.collection.find() # nuggets is a list of python dict object. |
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
>>> nugget.is_popular() | |
True |
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
nugget = connection.Nugget.find_one({"discoverer": "namlook"}) |
NewerOlder