Caveat
The tables in this cheatsheet only make sense after you study all thes mentioned data structures and algorithms below.
Do not memorize them, learn how the underlying algorithms work, read the source.
This cheat sheet is just a quick reference to give an broad brush strokes overview of how the most frequently-used data structures and algorithms relate to each other, in terms of time and space complexity.
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.annotation.{StaticAnnotation, compileTimeOnly} | |
import scala.language.experimental.macros | |
import scala.reflect.macros.whitebox.Context | |
@compileTimeOnly("use macro paradise") | |
class Extends[T](defaults: Any*) extends StaticAnnotation { | |
def macroTransform(annottees: Any*): Any = macro Extends.impl | |
} | |
object Extends { |
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 BinTreeIterator { | |
sealed trait Tree | |
case class Node(v: Int, l: Tree, r: Tree) extends Tree | |
case object Leaf extends Tree | |
def toIterator(node: Tree): Iterator[Int] = { | |
def toStream(n: Tree): Stream[Int] = n match { | |
case Node(v, l, r) => v #:: toStream(l) #::: toStream(r) | |
case Leaf => Stream.empty | |
} |
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 FinanceDSL extends App { | |
trait PrettyPrint[A] { | |
def prettify(a: A): String | |
class Ops(a: A) { | |
def pretty: String = prettify(a) | |
} | |
} | |
object PrettyPrint { |
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 sparky | |
import org.apache.spark.scheduler._ | |
import org.apache.spark.sql.SparkSession | |
import scala.math.random | |
object Application { | |
def runSpark(args: Array[String] ): Unit = { | |
val spark = SparkSession |
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
@echo off | |
REM Install Ghostscript 64bit from http://www.ghostscript.com/download/gsdnld.html | |
REM Shrink all pdfs files in the current directory where this script is run and output to the | |
REM compressed sub-folder | |
setlocal | |
set GS_BIN=C:\Program Files\gs\gs9.15\bin\gswin64c.exe | |
set GS_OUTPUT_DIR=compressed | |
mkdir %GS_OUTPUT_DIR% | |
for %%i in (*.pdf) do "%GS_BIN%" -dNOPAUSE -dBATCH -dSAFER -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -sDEVICE=pdfwrite -sOutputFile="%GS_OUTPUT_DIR%\%%i" "%%i" |
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
const PageNotFoundComponent = { | |
template: ` | |
<div class="alert alert-danger" role="alert"> | |
<h1>Page {{notFoundRoute}} not found</h1> | |
We tried hard, but unfotunately could not find a page that matches your request. :( | |
</div> | |
`, | |
data() { | |
return { | |
notFoundRoute: "" |
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
/*Code attribution: http://stackoverflow.com/questions/24827964/browserify-with-twitter-bootstrap#answer-24834257*/ | |
{ | |
"name": "...", | |
"version": "0.0.1", | |
"description": "...", | |
"repository": { | |
"type": "git", | |
"url": "..." | |
}, | |
"browser": { |
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
{ | |
"vars": { | |
"@gray-darker": "lighten(#000, 13.5%)", | |
"@gray-dark": "lighten(#000, 20%)", | |
"@gray": "lighten(#000, 33.5%)", | |
"@gray-light": "lighten(#000, 46.7%)", | |
"@gray-lighter": "lighten(#000, 93.5%)", | |
"@brand-primary": "#428bca", | |
"@brand-success": "#5cb85c", | |
"@brand-info": "#5bc0de", |
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
var modules= require('modules'); | |
var jquery = require(modules.jquery); | |
/// Do something with the jquery |