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
from enum import Enum | |
from itertools import groupby | |
from dataclasses import dataclass | |
from typing import ( | |
Callable, | |
Iterator, | |
List, | |
Optional, | |
Sequence, | |
Tuple, |
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
from typing import Iterable, List | |
def generate_split(places: int, max: int) -> Iterable[List[int]]: | |
if places == 0: | |
yield [] | |
elif places == 1: | |
yield [max] | |
else: | |
for i in range(0, max + 1): |
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
import simpy | |
from scipy.stats import truncnorm | |
def get_truncated_normal(mean=0, sd=1, low=0, upp=1): | |
return truncnorm((low - mean) / sd, (upp - mean) / sd, loc=mean, scale=sd) | |
exam_queue = [] |
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
from abc import abstractmethod | |
from typing import Generic, Protocol, TypeVar | |
T_cov = TypeVar("T", contravariant=True) | |
U_cov = TypeVar("U", contravariant=True) | |
class Metric(Protocol[T]): | |
@abstractmethod | |
def __call__(self, gt: T, pred: T) -> float: | |
... |
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
#!/bin/bash | |
set -e | |
echo $1 | |
pushd $(dirname $1) >/dev/null | |
yarn > /dev/null | |
yarn ts-node $* | |
popd > /dev/null | |
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
open Jest; | |
let getData = (): Promise.promise(string) => Promise.resolved("some initial data"); | |
type firstStepResult = {first: string}; | |
type secondStepResult = {second: string}; | |
let doFirstStep = (v: string) => { | |
Js.log(v); |
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
INFO global: Vagrant version: 2.2.4 | |
INFO global: Ruby version: 2.4.4 | |
INFO global: RubyGems version: 2.6.14.1 | |
INFO global: VAGRANT_EXECUTABLE="C:\\HashiCorp\\Vagrant\\embedded\\gems\\2.2.4\\gems\\vagrant-2.2.4\\bin\\vagrant" | |
INFO global: VAGRANT_EXPERIMENTAL="typed_triggers" | |
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="C:\\HashiCorp\\Vagrant\\embedded" | |
INFO global: VAGRANT_INSTALLER_ENV="1" | |
INFO global: VAGRANT_INSTALLER_VERSION="2" | |
INFO global: VAGRANT_LOG="debug" | |
WARN global: resolv replacement has not been enabled! |
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
import { of, from } from 'rxjs'; | |
import { switchMap, finalize, map } from 'rxjs/operators'; | |
//emit (1,2,3,4,5) | |
const source = from([1, 2, 3, 4, 5]); | |
//add 10 to each value | |
const example = source.pipe( | |
map(val => of(val).pipe( finalize(x=>console.log('final ' + val)))), | |
switchMap(val=>val) | |
); |
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
let throwError: unit => unit = [%bs.raw | |
{|function () { throw new Error("aaaa"); }|} | |
]; | |
try (throwError()) { | |
| Js.Exn.Error(e) => | |
switch (Js.Exn.message(e)) { | |
| Some(message) => Js.log({j|Error>>>>>: $message|j}) | |
| None => Js.log("An unknown error occurred") | |
} |
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
exception SomeError; | |
exception JsError(Js.Exn.t); | |
let makeJsError: unit => Js.Promise.t(unit) = [%bs.raw | |
{|() => Promise.reject(new Error("aaaa"))|} | |
]; | |
let catch_ = (ocamlhandler, jshandler, promise) => { | |
let a = e => | |
switch (ocamlhandler(e)) { |
NewerOlder