Skip to content

Instantly share code, notes, and snippets.

View ben-509's full-sized avatar

Ben Samuel ben-509

View GitHub Profile
@ben-509
ben-509 / proof.py
Created January 3, 2025 15:14
A quick demo of circular imports in .pyi stub files
# a.py
class A:
def __init__(self, foo):
self.foo = foo
# a.pyi
from .b import B
class A:
foo: B
def __init__(self, foo: B):
@ben-509
ben-509 / HowMany.java
Created June 9, 2022 19:37
Testing how simple lambdas are handled
import java.util.function.Function;
import java.util.List;
class HowMany {
private String convert(String a) {
return "foo" + a;
}
private void test(Function<String, String> func) {
System.out.println(func.apply("test"));
@ben-509
ben-509 / grr.sh
Created February 3, 2022 15:20
Gradle wrapper finder / runner
#!/usr/bin/bash
# Works in bash and zsh.
codeerr() {
# Echo an error to stderr, but output a code to stdout.
# Allows return $(codeerr 1 some message)
local num=$1
shift
>&2 echo "$@"
echo "$num"