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 io.ryos.demos.continuations; | |
| import static java.lang.System.out; | |
| import java.util.Arrays; | |
| import java.util.List; | |
| public class ContinuationDemo { | |
| public static void main(String[] args) { | |
| var scope = new ContinuationScope("my-scope"); |
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 io.ryos.demos.fibers; | |
| import static java.lang.System.out; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| import java.util.concurrent.SynchronousQueue; | |
| public class FiberDemo { |
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 get_numpy_data(data_sframe, features, output): | |
| data_sframe['constant'] = 1 # this is how you add a constant column to an SFrame | |
| # add the column 'constant' to the front of the features list so that we can extract it along with the others: | |
| features = ['constant'] + features # this is how you combine two lists | |
| # select the columns of data_SFrame given by the features list into the SFrame features_sframe (now including constant): | |
| features_sframe = data_sframe[features] | |
| # the following line will convert the features_SFrame into a numpy matrix: | |
| feature_matrix = features_sframe.to_numpy() | |
| # assign the column of data_sframe associated with the output to the SArray output_sarray | |
| output_sarray = data_sframe['price'] |
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 io.moo.training.akka | |
| import akka.actor.{Actor, Props} | |
| class CounterActor extends Actor { | |
| var counter: Int = 0 | |
| override def receive: Receive = { | |
| case "incr" => counter += 1 | |
| case "get" => sender ! counter |
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
| ^[[1;31m | |
| yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy | |
| yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy | |
| yyyyy/ +yyyyyyyyyyyyyy+ +y///y | |
| yyyyy/ /yyyyyyyyyyyyyyyy: +yo+oy | |
| yyyyy/ -yyyyyyyyyyyyyyyyyy- +yyyyy | |
| yyyyy/ .syyyyyyyyyyyyyyyyyys. +yyyyy | |
| yyyyy/ `syyyyyyyyyyyyyyyyyyyys` +yyyyy | |
| yyyyy/ `oyyyyyyyyyyyyyyyyyyyyyy+` +yyyyy | |
| yyyyy/ +yyyyyyyyyyyyyyyyyyyyyyyy/ +yyyyy |
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 Knapsack { | |
| val W = 10000 // capacity | |
| val n = 100 // number of items | |
| val file = "path-to-your-file-contains-<size> <weight> lines" | |
| val c = Array.ofDim[Int](n, W) | |
| val lines = Source.fromFile(file).getLines.drop(1).toList.map(_.split(" ").map(_.toInt)) | |
| def main(args: Array[String]) { | |
| 0 until W foreach { x => c(0)(x) = 0 } | |
| for (i <- 1 until n; x <- 0 until W) c(i)(x) = math.max(c(i - 1)(x), { if (lines(i)(1) > x) 0 else c(i - 1)(x - lines(i)(1)) + lines(i)(0) }) | |
| print(c(n-1)(W-1)) |
NewerOlder