This file contains hidden or 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 inspect | |
def with_checks(checks): | |
def wrapper(func): | |
def wrapped(*args, **kwargs): | |
bound_args = inspect.signature(func).bind(*args, **kwargs) | |
errors = list() | |
for check in checks: | |
decorator_params = inspect.signature(check).parameters.keys() | |
matching_params = [(sym, bound_args.arguments[sym]) for sym in decorator_params if sym in bound_args.arguments.keys()] | |
if len(matching_params) > 0: |
This file contains hidden or 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
function maybe<T>(gen: () => Generator<T, any, any>): T | null { | |
const next = gen(); | |
let last = undefined; | |
while (true) { | |
const { value, done } = next.next(last); | |
if (done) { | |
return value; | |
} | |
if (value == null) { | |
return null; |
This file contains hidden or 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
interface Balanced { | |
boolean check(String input); | |
} | |
interface Checkout { | |
int total(Cart c, List<Discount> dc); | |
} |
This file contains hidden or 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
package com.berci; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
record Tuple<T, U>(T one, U other){} | |
@FunctionalInterface | |
interface Combine<T> { | |
T method(T left, T right); |
This file contains hidden or 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 plotDist(topplesize, xmin, xmax): | |
fit = powerlaw.Fit( | |
data = np.array(topplesize), | |
xmin = xmin, | |
xmax = xmax | |
) | |
x, y = fit.pdf(linear_bins=True) | |
ind = y>0 | |
y = y[ind] | |
x = x[:-1] |
This file contains hidden or 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
interface ColorSelectionOptions { | |
signal?: AbortSignal | |
} | |
interface ColorSelectionResult { | |
sRGBHex: string | |
} | |
interface EyeDropper { | |
open: (options?: ColorSelectionOptions) => Promise<ColorSelectionResult> |
This file contains hidden or 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 <stdexcept> | |
#include <iostream> | |
#include <initializer_list> | |
template <typename T> | |
class Vector | |
{ | |
static constexpr std::size_t min_capacity = 8; | |
public: |
OlderNewer