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.ActorSystem | |
import akka.stream.ActorMaterializer | |
import akka.stream.scaladsl.Source | |
import cats.data.State | |
object Main extends App { | |
implicit val system = ActorSystem("akka") | |
implicit val ec = system.dispatcher | |
implicit val materializer = ActorMaterializer() |
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
let S = "ADOBECODEBANC"; | |
let T = "ABC"; | |
let cursors = {}; | |
// init cursors | |
for (let t of T) cursors[t] = -1; | |
// O(n) time complexity | |
S.split('').forEach((s, 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
let canvas = document.createElement("canvas"); | |
canvas.width = 400; | |
canvas.height = 400; | |
let ctx = canvas.getContext("2d"); | |
document.body.appendChild(canvas); | |
function lerp(a, b, t) { | |
return a * (1-t) + b * 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
let canvas = document.createElement("canvas"); | |
canvas.width = 600; | |
canvas.height = 20; | |
let ctx = canvas.getContext("2d"); | |
document.body.appendChild(canvas); | |
const fps = 60; | |
const maxlifetime = 1000; | |
let line = { |
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
let canvas = document.createElement("canvas"); | |
canvas.width = 600; | |
canvas.height = 400; | |
let ctx = canvas.getContext("2d"); | |
document.body.appendChild(canvas); | |
const step = 10; | |
const bumpiness = 10; | |
function lerp(a, b, t) { | |
return a * (1 - t) + b * 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
const canvas = document.createElement("canvas"); | |
canvas.width = 400; | |
canvas.height = 400; | |
const ctx = canvas.getContext('2d'); | |
document.body.appendChild(canvas); | |
let objs = [{ | |
x: 0, | |
y: 0, | |
z: -160, |
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
BIN = bin | |
SRC = src | |
INC = include | |
LIBS = -lsfml-graphics -lsfml-window -lsfml-system | |
FLAGS = -std=c++14 -Wall | |
OBJ = Game.o ParticleSystem.o Ship.o Utils.o main.o | |
TARGET = $(BIN)/game | |
CC = g++ | |
DEPS = $(patsubst %, $(BIN)/%, $(OBJ)) |
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.ActorSystem | |
import akka.http.scaladsl.Http | |
import akka.http.scaladsl.server.Route | |
import akka.stream.ActorMaterializer | |
import akka.http.scaladsl.server.Directives._ | |
import akka.http.scaladsl.model.StatusCodes | |
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._ | |
import spray.json.DefaultJsonProtocol._ | |
import spray.json._ |
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
// constants | |
const MAX_VECTORS = 500; | |
const WIDTH = 400; | |
const HEIGHT = 400; | |
const MARGIN = 20; | |
// generate data | |
let vectors = []; | |
for (let i = 0; i < MAX_VECTORS; i++) { | |
let x = ((Math.random() * (WIDTH - MARGIN * 2)) | 0) + MARGIN; |
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
class Node: | |
def __init__(self, value, left=None, right=None): | |
self.value = value | |
self.left = left | |
self.right = right | |
def __repr__(self): | |
return "[value: {}]".format(self.value) | |
@staticmethod |