Skip to content

Instantly share code, notes, and snippets.

import { z } from "zod";
// utilities
const stringDate = z.string().regex(/\d{4}-\d{2}-\d{2}/);
// shared
const OrderBaseBaseSchema = z.object({
id: z.string(),
def _repr_cell(cell):
return " " if cell is None else cell
def _print_row(row):
print(f"{_repr_cell(row[0])} | {_repr_cell(row[1])} | {_repr_cell(row[2])}")
def _print_row_delimiter():
print("--+---+---")
## helper functions
"""
Constructs a board from a string.
s: a string representation of the board
Returns: a parsed board
E.g.:
import { CreateJobCommandInput } from "@aws-sdk/client-mediaconvert";
export const getJobSetting = (
fileInput: string,
outputPath: string,
userMetadata: { [key: string]: string },
role: string
): CreateJobCommandInput => ({
Queue: "Default",
UserMetadata: {
from gql import Client, gql
from gql.transport.requests import RequestsHTTPTransport
from itertools import groupby
from datetime import datetime
token = 'REDACTED'
transport = RequestsHTTPTransport(
url="https://open.heydoc.co.uk/graphql", verify=True, retries=3,
import lombok.Data;
import lombok.Value;
import org.springframework.lang.Nullable;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
/** @noinspection unchecked, rawtypes */
class Scratch {
@PiotrJander
PiotrJander / SizeAnnotatedFileTree.java
Created November 19, 2020 15:37
Recursive directory size counting in Java
import lombok.Builder;
import lombok.Getter;
import lombok.SneakyThrows;
import lombok.Value;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
at(baba_class, field(1, 1), 0).
at(is, field(1, 2), 0).
at(you_class, field(1, 3), 0).
at(flag_class, field(3, 1), 0).
at(is, field(3, 2), 0).
at(win_class, field(3, 3), 0).
at(baba, field(2, 2), 0).
at(flag, field(2, 3), 0).
@PiotrJander
PiotrJander / dataloader_error.py
Created October 21, 2020 09:55
dataloader_error.py
import os
import torch
from torch.nn import functional as F
from torch.utils.data import DataLoader
from torchvision.datasets import MNIST
from torchvision import transforms
import pytorch_lightning as pl
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/process.py", line 121, in start
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/process.py", line 121, in start
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/process.py", line 121, in start
_, eval_results = self.run_evaluation(test_mode=False, max_batches=self.num_sanity_val_batches)
File "/Users/piotr/projects/neptune-examples/.env/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 556, in run_evaluation
self._popen = self._Popen(self)
self._popen = self._Popen(self)
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/context.py", line 224, in _Popen
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/context