I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!
\
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
| The regex patterns in this gist are intended only to match web URLs -- http, | |
| https, and naked domains like "example.com". For a pattern that attempts to | |
| match all URLs, regardless of protocol, see: https://gist.github.com/gruber/249502 | |
| License: https://opensource.org/license/bsd-3-clause | |
| # Single-line version: | |
| (?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps |
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 scala.concurrent._ | |
| import scala.concurrent.duration._ | |
| import scala.concurrent.ExecutionContext.Implicits.global | |
| import scala.util.Random | |
| import java.util.{Timer, TimerTask} | |
| object Util { | |
| sealed trait BaseResponse | |
| case class Response1(res: Int) extends BaseResponse | |
| case class Response2(res: String) extends BaseResponse |
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
| // create file: | |
| sudo vim /usr/share/applications/intellij.desktop | |
| // add the following | |
| [Desktop Entry] | |
| Version=13.0 | |
| Type=Application | |
| Terminal=false | |
| Icon[en_US]=/home/rob/.intellij-13/bin/idea.png | |
| Name[en_US]=IntelliJ |
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.io.IOException; | |
| import java.nio.charset.StandardCharsets; | |
| import java.nio.file.Files; | |
| import java.util.Arrays; | |
| import java.util.Iterator; | |
| import java.util.Properties; | |
| import org.I0Itec.zkclient.ZkClient; | |
| import org.apache.kafka.clients.consumer.ConsumerRecord; | |
| import org.apache.kafka.clients.consumer.ConsumerRecords; | |
| import org.apache.kafka.clients.consumer.KafkaConsumer; |
Now located at https://github.com/JeffPaine/beautiful_idiomatic_python.
Github gists don't support Pull Requests or any notifications, which made it impossible for me to maintain this (surprisingly popular) gist with fixes, respond to comments and so on. In the interest of maintaining the quality of this resource for others, I've moved it to a proper repo. Cheers!
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 scala.collection.mutable | |
| /** | |
| * Bounded priority queue trait that is intended to be mixed into instances of | |
| * scala.collection.mutable.PriorityQueue. By default PriorityQueue instances in | |
| * Scala are unbounded. This trait modifies the original PriorityQueue's | |
| * enqueue methods such that we only retain the top K elements. | |
| * The top K elements are defined by an implicit Ordering[A]. | |
| * @author Ryan LeCompte ([email protected]) | |
| */ |
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 akka.actor.IO._ | |
| import akka.actor.{Props, IO, IOManager, Actor, ActorSystem} | |
| import akka.event.Logging | |
| import akka.util.ByteString | |
| import java.net.InetSocketAddress | |
| class TCPEchoServer(port: Int) extends Actor { | |
| val log = Logging(context.system, this) | |
| val state = IterateeRef.Map.async[IO.Handle]()(context.dispatcher) |
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 rapture.io._ | |
| // Let's parse some JSON | |
| val src: Json = Json.parse(""" | |
| { | |
| "foo": "Hello world", | |
| "bar": { | |
| "baz": 42 | |
| } | |
| } |
"For comprehension" is a another syntaxe to use map, flatMap and withFilter (or filter) methods.
yield keyword is used to aggregate values in the resulting structure.
This composition can be used on any type implementing this methods, like List, Option, Try, Future...