Skip to content

Instantly share code, notes, and snippets.

View endor's full-sized avatar

Frank Prößdorf endor

  • Elo Health
  • Tampere, Finland
View GitHub Profile
@endor
endor / main.rs
Last active June 5, 2020 06:37
hyper::Body::channel
let (sender, hyper_body) = hyper::Body::channel();
let mut runtime = tokio::runtime::Runtime::new().unwrap();
let handle = runtime.spawn(async {
parser::parse_and_send(
reader,
sender,
reference,
).await
@endor
endor / date.rs
Last active January 30, 2019 09:35
fn parse_date(string: String) -> Option<DateTime<Utc>> {
let year = string.get(..4).and_then(|y| y.parse::<i32>().ok());
let month = string.get(4..6).and_then(|m| m.parse::<u32>().ok());
let day = string.get(6..8).and_then(|d| d.parse::<u32>().ok());
let hour = string.get(9..11).and_then(|h| h.parse::<u32>().ok());
let minute = string.get(12..14).and_then(|mm| mm.parse::<u32>().ok());
let sec = string.get(15..17).and_then(|s| s.parse::<u32>().ok());
let ss = string.get(18..21).and_then(|ss| ss.parse::<u32>().ok());
let r = if year.is_some() && month.is_some() && day.is_some() && hour.is_some()
@endor
endor / test.rs
Created January 8, 2019 08:49
test.rs
let mut all_suites: Vec<Suite> = Vec::new();
let mut default_suite = Suite {
children: vec![],
name: "".to_string(),
status: "fail".to_string(),
};
let mut current_suite: &mut Suite = &mut default_suite;
loop {
match reader.read_event(&mut buf) {
@endor
endor / bottleneck.js
Created November 14, 2018 11:35
Bottleneck
import Bottleneck from "bottleneck";
const redisUrl = "redis://127.0.0.1:6379";
const integrations = [
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
];
const globalInstance1 = new Bottleneck({
clearDatastore: true,
clientOptions: {
url: redisUrl,
sealed trait Nat
sealed trait Zero extends Nat
sealed trait Succ[N <: Nat] extends Nat
case class A[N <: Nat]()
f1
def f1[N <: Nat]: A[Succ[N]] =
f2
@endor
endor / screening.js
Created September 13, 2010 22:36 — forked from rmurphey/screening.js
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
// not sure I would though.. sometimes the above is more readable than the below
(foo) ? bar.doSomething(el) : bar.doSomethingElse(el);