Skip to content

Instantly share code, notes, and snippets.

View reevik's full-sized avatar
:octocat:

Erhan Bağdemir reevik

:octocat:
View GitHub Profile
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");
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 {
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']
@reevik
reevik / actorcounter
Created May 23, 2015 13:51
Counter example with actors.
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
@reevik
reevik / AdobeLogo
Created May 21, 2015 23:45
Adobe ASCII Art Logo in Red for MOTD
@reevik
reevik / Knapsack.scala
Last active August 29, 2015 14:18
Knapsack using dynamic programming.
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))