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
| package core | |
| import org.joda.time.DateTime | |
| import scala.concurrent.duration.Duration | |
| import scala.util.{Failure, Success, Try} | |
| class AutoRefreshingWrapper[T](refreshFunc: => Try[T], refreshRate: Duration) extends SBLogger { | |
| @volatile |
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
| package core | |
| import java.util.concurrent.ArrayBlockingQueue | |
| class BlockingExecutor(maxParallelism: Int) extends SBLogger{ | |
| private case object Execution | |
| private val queue = new ArrayBlockingQueue[Execution.type](maxParallelism) | |
| def execute[T](execution: => T): T = { |
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
| package core | |
| object FetchLockFetch { | |
| /** | |
| * Try to fetch using inexpensiveFetch, obtain lock, try again (using inexpensiveFetch), | |
| * fall back to more expensive expensiveFetch. | |
| */ | |
| def fetchLockFetch[T](inexpensiveFetch: => Option[T], lockFunc: => ((=> Option[T]) => Option[T]), | |
| expensiveFetch: => Option[T]): Option[T] = | |
| inexpensiveFetch.orElse{ |
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
| package core | |
| import org.slf4j.LoggerFactory | |
| import scala.collection.mutable | |
| class LockPool{ | |
| type Lock = AnyRef | |
| case class LockAndCounter(lock: AnyRef, counter: Int) | |
| val logger = LoggerFactory.getLogger(getClass) |
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
| included: | |
| promoterDiscovery.py - trains a classifier, and predicts if a DNA sequence is a promoter or enhancer | |
| testPromoterDiscovery - includes unit tests for the promoterDiscovery class | |
| this README | |
| usage: | |
| promoterDiscovery.py [-h] [-c] [-p SEQUENCE] [-f FILE] [-t FILE]\n" | |
| -h show this help message | |
| -c run 10 fold cross validation | |
| -t FILE train model and save into FILE |
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
| package com.twitter.timelines.data_processing.ad_hoc.feature_selection.utils | |
| import scala.annotation.tailrec | |
| import scala.collection.GenTraversableOnce | |
| /** | |
| * Almost optimal Disjoint-set data structure: | |
| * https://en.wikipedia.org/wiki/Disjoint-set_data_structure | |
| */ | |
| object DisjointSet { |
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
| package com.twitter.mrosenthal.timelines.adhoc.dataset_transform | |
| import scala.util.Random | |
| object OrderingCTRProbabilities extends App { | |
| val rand = new Random(17) | |
| def insertionSort[T](seq: Seq[T])(insertLocationFunc: (T, Seq[T]) => Int)(implicit ord: Ordering[T]): Seq[T] = { | |
| def insert(seq: Seq[T], location: Int, elem: T): Seq[T] = { |
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
| package com.twitter.mrosenthal.timelines.adhoc.dataset_transform | |
| import scala.collection.{GenTraversableOnce, SeqLike} | |
| import scala.math.Ordering | |
| object IsSortedExample extends App { | |
| implicit class RichGenTraversableOnce[A](val trav: GenTraversableOnce[A]) extends AnyVal { | |
| /** | |
| * O(1) space, O(n) time. Stops as soon as it finds an unsorted pair. |
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
| package com.twitter.mrosenthal.timelines.adhoc.dataset_transform | |
| import scala.collection.mutable | |
| import scala.concurrent.duration._ | |
| object MeasureTimeUtil { | |
| def measureTime[T](numRepeats: Int)(f: => T): FiniteDuration = { | |
| f // warm up | |
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
| package com.twitter.mrosenthal.timelines.adhoc.dataset_transform | |
| /** | |
| * An implementation of a constant size queue, in which enqueue dequeues the oldest enqueued element. | |
| * The performance characteristics of all operations are amortized constant time, due to the fact that | |
| * tail, append, and apply (random access) are amortized constant time operations for vectors. | |
| */ | |
| case class FixedSizeQueue[T](elements: Vector[T]){ | |
| def newest: T = elements.last |