- Find a replacement icon for Sublime Text. The FlatLand icon looks great.
- Open the icon or image. Select all and copy to clipboard.
- Go to the Applications folder and Apple-i on the Sublime Text app.
- Select the app icon on the top left corner. A small select outline around the icon should appear.
- Paste the new icon and save.
- You can also right click on the SublimeText.app and click on "Show Package Contents". Navigate to the Contents/Resources folder and replace the icon that's in there with the new one.
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 java.util.concurrent.{Executors, TimeoutException} | |
import scala.concurrent.duration._ | |
import scala.concurrent.{ExecutionContext, Future, Promise} | |
import scala.concurrent.ExecutionContext.Implicits.global | |
def timeoutFuture[T](f: Future[T], after: Duration)(implicit ec: ExecutionContext) = { | |
val p = Promise[T]() | |
p tryCompleteWith f | |
val action = new Runnable { |
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 java.util.Locale | |
lazy val countryNameToCode = Locale.getISOCountries.map{ countryCode => | |
(new Locale("", countryCode).getDisplayCountry, countryCode) | |
}.toMap | |
lazy val countryCodeToName = countryNameToCode.map(_.swap) | |
countryCodeToName("HK") | |
countryCodeToName("GB") | |
countryCodeToName("US") |
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 java.util.concurrent.ConcurrentHashMap | |
trait StringDeserializer[T] { | |
def deserialize(s: String): T | |
} | |
trait StringSerializable[T] { | |
def serialize: String | |
} |
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 recursiveListFiles(file: File): Array[File] = { | |
@tailrec | |
def trImpl(dirs: Array[File], files: Array[File]): Array[File] = { | |
if (dirs.isEmpty) { | |
files | |
} | |
else { | |
val (subdirs, moreFiles) = dirs.flatMap(_.listFiles).span(_.isDirectory) | |
trImpl(subdirs, files ++ moreFiles) | |
} |
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 time[R](block: => R): R = { | |
val t0 = System.nanoTime() | |
val result = block | |
println("Elapsed time: " + (System.nanoTime - t0) + "ns") | |
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
def fib(n: Int): Int = { | |
@tailrec | |
def recFib(a: Int, b: Int, i: Int): Int = i match { | |
case 0 => a | |
case _ => recFib(b, a + b, i - 1) | |
} | |
recFib(0, 1, 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
case class IdentifierKey(idType: String, id: String) { | |
override def toString: String = SerializedIdentifierKey(this) | |
} | |
object SerializedIdentifierKey extends (IdentifierKey => String) { | |
val delimiter = ':' | |
def apply(i: IdentifierKey): String = i.idType + SerializedIdentifierKey.delimiter + i.id | |
def unapply(s: String): Option[IdentifierKey] = { |
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
// Retry until it succeeds | |
class ExampleSpec extends FlatSpec with Eventually { | |
eventually { | |
futureInt.get shouldBe 1 | |
} | |
} | |
// Extended patience for integration tests | |
class ExampleSpec extends FlatSpec with Eventually with IntegrationPatience { | |
eventually { |
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
implicit val ec = ExecutionContext.fromExecutor(Executors.newFixedThreadPool(8, new ThreadFactory() { | |
override def newThread(r: Runnable): Thread = new Thread(Thread.currentThread().getThreadGroup, r, "MyWorker") | |
})) |