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
| try: | |
| raise Exception('spam', 'eggs') | |
| except Exception as inst: | |
| print type(inst) # the exception instance | |
| print inst.args # arguments stored in .args | |
| print inst # __str__ allows args to be printed directly | |
| x, y = inst.args | |
| print 'x =', x | |
| print 'y =', y |
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
| try: | |
| raise NameError('HiThere') | |
| except NameError: | |
| print 'An exception flew by!' | |
| raise |
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 divide(x, y): | |
| try: | |
| result = x / y | |
| except ZeroDivisionError: | |
| print "division by zero!" | |
| else: | |
| print "result is", result | |
| finally: | |
| print "executing finally clause" |
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
| object HelloWorld { | |
| /* This is my first java program. | |
| * This will print 'Hello World' as the output | |
| */ | |
| def main(args: Array[String]) { | |
| println("Hello, world!") // prints Hello World | |
| } | |
| } |
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
| # --------------------------------------------------------------------------- | |
| # | |
| # Description: This file holds all my BASH configurations and aliases | |
| # | |
| # Sections: | |
| # 1. Environment Configuration | |
| # 2. Make Terminal Better (remapping defaults and adding functionality) | |
| # 3. File and Folder Management | |
| # 4. Searching | |
| # 5. Process Management |
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 requests, json | |
| data = json.loads( | |
| requests.get("https://thigm85.github.io/data/mind/mind_demo_fields_parsed.json").text | |
| ) | |
| data[0] |
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
| len(data) |
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
| !pip install pyvespa |
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
| from vespa.package import ApplicationPackage | |
| app_package = ApplicationPackage(name="news") |
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
| from vespa.package import Field | |
| app_package.schema.add_fields( | |
| Field(name="news_id", type="string", indexing=["summary", "attribute"], attribute=["fast-search"]), | |
| Field(name="category", type="string", indexing=["summary", "attribute"]), | |
| Field(name="subcategory", type="string", indexing=["summary", "attribute"]), | |
| Field(name="title", type="string", indexing=["index", "summary"], index="enable-bm25"), | |
| Field(name="abstract", type="string", indexing=["index", "summary"], index="enable-bm25"), | |
| Field(name="url", type="string", indexing=["index", "summary"]), | |
| Field(name="date", type="int", indexing=["summary", "attribute"]), |