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 loadResource(filename: String) = { | |
| val source = scala.io.Source.fromURL(getClass.getResource(filename)) | |
| try source.mkString finally source.close() | |
| } |
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 circular[A](as: Seq[A]): Iterator[A] = Iterator.continually(as).flatten |
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 com.github.nscala_time.time.Imports._ | |
| import org.joda.time.Years | |
| def getAge(start: String, end: String): Int = { | |
| Years.yearsBetween( | |
| new DateTime(start), | |
| new DateTime(end) | |
| ).getYears | |
| } |
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 mod(m: Int, n: Int) = ((m % n) + n) % n |
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 charFrequency(str: String): Map[Char, Int] = { | |
| var chars = Map[Char, Int]() | |
| for { | |
| c <- str | |
| if c != ' ' | |
| } { | |
| chars += (c.toLower -> (chars.getOrElse(c, 0) + 1)) | |
| } | |
| chars | |
| } |
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
| // repeat char n times | |
| function repeat(char, n) { | |
| return Array(n + 1).join(char); | |
| } |
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
Show hidden characters
| [ | |
| // Title Bar | |
| { | |
| "class": "title_bar", | |
| "attributes": ["file_medium_dark"], | |
| "bg": ["background", 0, 0, 0, 0.25] | |
| }, | |
| // Side Bar | |
| { | |
| "class": "sidebar_container", |
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 urllib.request import urlretrieve | |
| from os.path import isfile, isdir | |
| from tqdm import tqdm | |
| import sys | |
| class DLProgress(tqdm): | |
| last_block = 0 | |
| def hook(self, block_num=1, block_size=1, total_size=None): | |
| self.total = total_size |