Commands marked with * may be preceded by a number, N.
Notes in parentheses indicate the behavior if N is given.
A key preceded by a caret indicates the Ctrl key; thus ^K is ctrl-K.
h H Display this help.
q :q Q :Q ZZ Exit.
---------------------------------------------------------------------------
MOVING
This file contains 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 Node(data: Int, next: Option[Node]= None) | |
class Stack(var head: Node, var size: Int = 1) { | |
def push(i: Int): Unit = { | |
head = Node(i, Some(head)) | |
size += 1 | |
} | |
def pop(): Option[Int] = { |
This file contains 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
// SBT | |
name := "delete" | |
scalaVersion := "2.12.7" | |
libraryDependencies ++= Vector( | |
"co.fs2" %% "fs2-core" % "1.0.0", | |
"com.amazonaws" % "aws-java-sdk-s3" % "1.11.442" | |
) |
This file contains 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
/* Procedural endpoint */ | |
@GetMapping("/users/{id}") | |
ResponseEntity<User> get(@PathVariable long id) { | |
User user = repository.findById(id); | |
if(user != null) { | |
return ok(user); | |
} else { | |
return notFound(); | |
} | |
} |
This file contains 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
#include "WiFi.h" | |
#include "ESPAsyncWebServer.h" | |
int analogPin = A0; | |
const char* ssid = "SOME_SSID"; | |
const char* passwd = "SOME_PASSWD"; | |
AsyncWebServer server(80); | |
float readTemp() { |
This file contains 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
Latency Comparison Numbers | |
-------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
This file contains 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 collect method takes a PartialFunction as argument and maps the | |
// values defined for this partial function over it, skipping those | |
// outside the definition domain. | |
// Given a partial function pf, the following code: | |
// | |
// val pf: PartialFunction[A, B] = | |
// coll.collect(pf) | |
// | |
// is roughly equivalent to |
This file contains 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 akka.http.scaladsl | |
import java.io.File | |
import akka.http.scaladsl.unmarshalling.Unmarshal | |
import akka.util.ByteString | |
import scala.concurrent.duration._ | |
import akka.actor.ActorSystem |
This file contains 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
/* proof of concept for non atomic method */ | |
/* to fix this the call should be wrapped */ | |
/* inside a synchronized block */ | |
private var uidCount = 0L | |
def getUniqueId(): Long = { | |
uidCount = uidCount + 1 | |
uidCount | |
} |
NewerOlder