Skip to content

Instantly share code, notes, and snippets.

View reevik's full-sized avatar
:octocat:

Erhan Bağdemir reevik

:octocat:
View GitHub Profile
@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))
@reevik
reevik / AdobeLogo
Created May 21, 2015 23:45
Adobe ASCII Art Logo in Red for MOTD
@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
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']
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 {
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");
# The meeting matrix can be improved with constraints e.g output has minimum waiting person and
# shortest total duration by using constraing programming or linear optimization.
# The problem is very similar to N-Queens.
# Right now you can find optimum solution by running the code multiple times.
import itertools
import random
from datetime import datetime, timedelta
team = ['Erhan', 'Brown', 'Mustermann', 'Jack', 'Joe', 'Rambo', 'Steve']
package io.ryos.rhino.sdk.simulations;
import static io.ryos.rhino.sdk.dsl.specs.DSLSpec.http;
import static io.ryos.rhino.sdk.dsl.specs.HttpSpec.from;
import static io.ryos.rhino.sdk.dsl.specs.UploadStream.file;
import static io.ryos.rhino.sdk.dsl.specs.builder.SessionAccessor.session;
import static io.ryos.rhino.sdk.utils.TestUtils.getEndpoint;
import io.ryos.rhino.sdk.SimulationConfig;
import io.ryos.rhino.sdk.annotations.Dsl;
@RampUp(startRps = 1, targetRps = 60, durationInMins = 1)
ohne max. connection und mit 1 sec response zeit,
würde sowas erwarten:
10s 20s 30s 40s 50s 60s
55 210 465 820 1275 1830
weil pro Sekunde, +1 request Anstieg:
1s 2s 3s ... 10s
1 2 3 10 = 55 total
@reevik
reevik / enable_aptx.sh
Created April 10, 2021 18:02
Enable aptX BT Codec on Mac
sudo defaults write bluetoothaudiod "Enable AptX codec" -bool true
sudo defaults read bluetoothaudiod