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 g.title FROM grants g WHERE g.title LIKE 'Monkey'; |
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
(module | |
;; Allocate a memory buffer of 1000 64KB pages (64MB total) for our image | |
(memory (export "memory") 1000 1000) | |
(func $fillBufferWithSIMD (param $numIterations i32) | |
;; declare local variables | |
(local $currentIteration i32) | |
(local $bufferPtr i32) | |
(local $bufferSizeBytes i32) | |
;; Set currentIteration=0 and bufferSizeBytes=64MB |
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 openFileTry(name: String): Try[Source] = Try(Source.fromFile(name)) | |
val fileTry = openFileTry("a.txt").getOrElse(openFileTry("b.txt")) |
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: | |
file = open("a.txt", 'rb') | |
except Exception: | |
try: | |
file = open("b.txt", 'rb') | |
except Exception: | |
pass |
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
// type: Try[Int], value: Success(6) | |
val toIntTry = Try { | |
"6".toInt | |
} | |
// type: Try[Int], value: Success(7) | |
val incrementedIntTry = toIntTry.map(_+1) | |
// type: Try[Double], value: Success(7.0) | |
val toDoubleTry = incrementedIntTry.flatMap { integer => |
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
computeString.map(_.split(" ")).flatMap(persistWords) |
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
async def storeWords(): | |
computedString = await computeString() | |
words = computedString.split(" ") | |
await persistWords(words) | |
asyncio.run(storeWords()) |
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
// type: Future[String] | |
val stringFut = Future { | |
Thread.sleep(1000) | |
"Returned string" | |
} | |
/* | |
* You can call map() to register a synchronous operation | |
* to run once this Future completes successfully | |
*/ |
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
val viewerId = user.getSubscriptionOpt // type: Option[Subscription] | |
.flatMap(_.getPremiumTierOpt) // type: Option[Tier] | |
.flatMap(_.getPremiumIdOpt) // type: Option[ID] | |
.getOrElse(user.getId()) // type: ID |
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
viewerId = None | |
subscription = user.getSubscription() | |
if subscription: | |
premiumTier = subscription.getPremiumTier() | |
if premiumTier: | |
premiumId = premiumTier.getPremiumId() | |
if premiumId: | |
viewerId = premiumId | |
else: |