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
#!/usr/bin/env bash | |
# install or upgrade demucs: a state-of-the-art music source separation tool | |
# | |
# works ok for: macos 14.7, brew 4.4.4, python 3.12, demucs 4.0.1 | |
# | |
# links: | |
# https://github.com/facebookresearch/demucs - not maintained anymore | |
# https://github.com/adefossez/demucs - a fork by the same author | |
# |
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 install_xcode_command_line_tools_if_not_yet() { | |
# install xcode cli tools via terminal | |
# try the gui installer if failed | |
# original hack: https://github.com/Homebrew/install/blob/master/install.sh | |
if xcode-select -p 1>/dev/null 2>&1; then | |
return | |
fi | |
installed=0 | |
tmp_file=/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress | |
touch "$tmp_file" |
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
await (async function() { | |
function getRandomInt(min, max) { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} | |
async function rewriteAllGames(compId, gameIds) { | |
console.log('gameIds:', gameIds); | |
var formData = new FormData(); | |
for (let i = 0; i < gameIds.length; i++) { | |
let gameId = gameIds[i]; | |
formData.append('items[]', 'game/' + gameId); |
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
[] |
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
this is a <font color="red">gist</font> | |
to embed [] |
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
@Target(ElementType.FIELD) | |
@Retention(RetentionPolicy.RUNTIME) | |
@interface TestPojo { | |
String file() | |
} | |
@TestPojo(file = "src/test/resources/foo-response.json") | |
FooResponse fooResponse | |
// invoke processSpecAnnotations() |
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
static final Validator VALIDATOR = Validation.buildDefaultValidatorFactory().getValidator() | |
static void validatePojo(Object pojo) { | |
def errors = VALIDATOR.validate(pojo); | |
if (errors.size() > 0) { | |
log.error("Validation errors for {}: {}", pojo.getClass().getSimpleName(), errors); | |
throw new RuntimeException("Pojo validation failed - see logs - " + pojo.getClass().getName()); | |
} | |
} |
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
/** private final DCLValue<Foo> foo = new DCLValue.create(); | |
* Foo result = foo.getOrCreate(syncOn, () -> new Foo()); | |
* Foo result = foo.get(); */ | |
interface DCLValue<T> { | |
T getOrCreate(Object syncOn, Supplier<T> creator); | |
T get(); | |
void set(T value); | |
static <T> DCLValue<T> create() { | |
return new DCLValueRegular<>(); |
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
enum Foo { | |
ONE, TWO; | |
private static class Helper { | |
public static Map<String, Foo> enumByName = new HashMap<>(); | |
static { | |
Arrays.stream(Foo.values()).forEach(it -> enumByName.put(it.name(), it)); | |
assert Foo.Helper.enumByName.get("ONE") == Foo.ONE; // usage | |
} | |
} | |
} |
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
public static boolean match(@Nullable Pattern pattern, @Nullable String input) { | |
if (pattern == null || input == null) { | |
return false; | |
} | |
return pattern.matcher(input).matches(); | |
} | |
@Nullable | |
public static String toStr(@Nullable Object value) { | |
return (value != null) ? value.toString() : null; |
NewerOlder