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
extern crate clap; | |
extern crate csv; | |
struct TimeSerie { | |
data: Vec<f64>, | |
} | |
impl TimeSerie { | |
fn length(&self) -> usize { |
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
trait Command { | |
fn cli(&self) -> clap::App; | |
fn execute(&self, config: &Config, args: &clap::Args); | |
} | |
trait WsCommand { | |
fn cli(&self) -> clap::App; | |
fn execute(&self, config: &Config, ws: &Workspace, args: &clap::Args); |
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
extern crate crypto; // [dependencies] rust-crypto = "0.2" | |
extern crate rayon; // [dependencies] rayon = "0.6" | |
use std::io::Cursor; | |
use std::io::Write; | |
use crypto::digest::Digest; | |
use rayon::prelude::*; | |
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
class Zn(private val modulus: Int) { | |
fun int(x: Int): ZnInt = ZnInt(x % modulus) | |
operator fun ZnInt.plus(rhs: ZnInt): ZnInt = int(this.value + rhs.value) | |
} | |
class ZnInt(val value: Int) | |
fun main(args: Array<String>) { | |
val ring = Zn(92) |
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
fun <T> Sequence<T>.takeWhileInclusive(pred: (T) -> Boolean): Sequence<T> { | |
var shouldContinue = true | |
return takeWhile { | |
val result = shouldContinue | |
shouldContinue = pred(it) | |
result | |
} | |
} |
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 <algorithm> | |
#include <cassert> | |
#include <cstddef> | |
#include <cstdint> | |
#include <cstdlib> | |
#include <ctime> | |
#include <forward_list> | |
#include <iostream> | |
#include <list> | |
#include <unordered_set> |
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
/** | |
* Executes long running tasks not faster then once in [delayMillis] and makes sure | |
* at most one tasks executes at a time. The task itself may take more than [delayMillis] | |
* to complete. Task may be asynchronous. | |
*/ | |
private class DebouncingQueue( | |
private val delayMillis: Int, | |
parentDisposable: Disposable | |
) { | |
private val alarm = Alarm(Alarm.ThreadToUse.POOLED_THREAD, parentDisposable) |
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
abstract class Query { | |
class Sum { | |
} | |
class Add { | |
} |
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
test { | |
testLogging { | |
events 'skipped', 'failed' | |
exceptionFormat = 'full' | |
} | |
beforeSuite { suite -> | |
if (suite.className != null) { | |
println() | |
println(suite.className) |
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
def bfs(graph, start): | |
work = {start} | |
dist = {} | |
current_dist = 0 | |
while work: | |
for u in work: | |
dist[u] = current_dist | |
work = {nb for u in work |