Skip to content

Instantly share code, notes, and snippets.

View thehale's full-sized avatar
🧠
Working to make everything I do improvable by a novice

Joseph Hale, MS SE thehale

🧠
Working to make everything I do improvable by a novice
View GitHub Profile
@thehale
thehale / next_x.py
Created September 5, 2023 18:15
Python Batching Function with Generic Type Hints
from typing import Iterable, TypeVar
T = TypeVar("T")
def next_x(_i: Iterable[T], x: int) -> Iterable[Iterable[T]]:
gen = (i for i in _i)
batch = []
for item in gen:
batch.append(item)
if len(batch) == x:
@thehale
thehale / Joseph Hale CLA.md
Last active November 4, 2021 09:09 — forked from MichaelTsengLZ/Microsoft CLA
Joseph Hale CLA

Contribution License Agreement

Summary

Thanks for contributing to this project! Your time and talents are hugely appreciated!

This project uses a Contribution License Agreement ("CLA") to preclude any legal questions that may arise about the ownership/usage of the code in this project over time. Without this CLA, any contributor could potentially wreck havoc on the project by arbitrarily seeking to retract his/her contribution at any point in time or by attempting to assert that the project owners don't have a right to use his/her contribution in one way or another.

While only the "Legal Agreement" section has legally binding provisions, the following summary may help you better understand what you are being asked to sign here.

  • You are not being asked to give up your copyright to your contribution. You can still use your code in any other way you wish.
  • You are being asked to grant the project owner a license to use your code as freely as you as the author can.
import java.util.Scanner;
public class Scratch {
// Assign multiple double values from System.in
// without writing `nextDouble()` more than once.
public enum DoubleExample {
A, B, C;
public final double value;
private DoubleExample() { value = new Scanner(System.in).nextDouble(); }