As well as the unsurprising fastparse._ we also need to import some
implicits which affect the behaviour of the repetition operators. This
is because there are multiple ways to define repetition, for example
whether or not you want to ignore whitespace and so in any given
context you can have implicits which customise this behaviour without
having to change your code.
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
| struct Dial | |
| getter pos = 50 | |
| getter zeros = 0 | |
| def click(dir) | |
| if dir == "L" | |
| @pos -= 1 | |
| @pos = 99 if @pos < 0 | |
| else | |
| @pos += 1 | |
| @pos = 0 if @pos > 99 |
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 ExampleScala { | |
| def calc(p: Int) = { | |
| var result = 0 | |
| for { | |
| a <- 3 to p | |
| b <- 1 until ((p - a) / 2) | |
| c = p - (a + b) | |
| } if (b * b + c * c == a * a) result += 1 | |
| result | |
| } |
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
| // e.g., from the repl: | |
| // scala> :load timer.scala | |
| // [...] | |
| // scala> timed(Thread.sleep(1000)) | |
| // took 1001606189ns (1001ms) | |
| def timed[T](block: => T): T = { | |
| import java.time.Duration | |
| val startTime = System.nanoTime() |
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 tables, strformat, std/monotimes, times | |
| var profile = initTable[string, Duration]() | |
| var totalStart = getMonoTime() | |
| template timed*(name: string, it: untyped): untyped = | |
| let start = getMonoTime() | |
| it | |
| let took = getMonoTime() - start |
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 $ivy.`org.elasticsearch:elasticsearch:6.8.0` | |
| import $ivy.`org.elasticsearch.client:transport:6.8.0` | |
| // import $ivy.`org.elasticsearch:elasticsearch:7.3.1` | |
| // import $ivy.`org.elasticsearch.client:transport:7.3.1` | |
| import org.elasticsearch.common.xcontent.XContentType | |
| import org.elasticsearch.common.transport.TransportAddress | |
| import org.elasticsearch.transport.client.PreBuiltTransportClient | |
| import org.elasticsearch.common.settings.Settings |
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
| diff --git a/api/src/scala/scaled/major/EditingMode.scala b/api/src/scala/scaled/major/EditingMode.scala | |
| index 96171fb..c22afe7 100644 | |
| --- a/api/src/scala/scaled/major/EditingMode.scala | |
| +++ b/api/src/scala/scaled/major/EditingMode.scala | |
| @@ -40,7 +40,8 @@ abstract class EditingMode (env :Env) extends ReadingMode(env) { | |
| bind("newline", "ENTER", "S-ENTER"). | |
| bind("indent-for-tab-command", "TAB"). | |
| - // TODO: open-line, split-line, ... | |
| + bind("open-line", "C-o"). |
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 org.joda.time.DateTime | |
| import org.joda.time.format.{ DateTimeFormat, DateTimeFormatter, ISODateTimeFormat } | |
| def fmt(df: DateTimeFormatter) = (d: DateTime) => df.print(d) | |
| def patt(p: String) = fmt(DateTimeFormat.forPattern(p)) | |
| @annotation.tailrec | |
| def compare(startDate: DateTime, endDate: DateTime, f1: DateTime => String, f2: DateTime => String, count: Int = 0): Boolean = { | |
| if(startDate.isAfter(endDate)) { | |
| println(s"Checked: $count") |
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, re, yaml | |
| import logging | |
| from urllib.parse import urlparse, urljoin, parse_qs | |
| from datetime import datetime, timedelta | |
| verbose = True | |
| logfile = None | |
| hosts = [] |
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
| [ | |
| { | |
| "id": 0, | |
| "guid": "c4d14538-e09f-4eeb-b877-1874c5a42b25", | |
| "isActive": true, | |
| "balance": "$2,635.00", | |
| "picture": "http://placehold.it/32x32", | |
| "age": 40, | |
| "name": "Powers Dixon", | |
| "gender": "male", |
NewerOlder