Skip to content

Instantly share code, notes, and snippets.

@tivrfoa
tivrfoa / log.properties
Created September 28, 2020 09:24 — forked from maxandersen/log.properties
How to log http url network in java
handlers= java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = FINEST
sun.net.www.protocol.http.HttpURLConnection.level=ALL
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS info.picocli:picocli:4.5.0
//DEPS io.smallrye.reactive:smallrye-mutiny-vertx-web-client:1.2.1
//DEPS io.quarkus.qute:qute-core:1.8.2.Final
package com.gihub.mkouba;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Parameters;
///usr/bin/env curl -LSs https://sh.jbang.dev | bash -s - "$0" "$@"; exit $?
//DEPS org.springframework.boot:spring-boot-starter-web:2.3.4.RELEASE
import org.springframework.web.bind.annotation.*;
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.context.*;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.context.annotation.*;
public static void main(String[] args) {
Stream.of(Boolean.class, Byte.class, Character.class, Short.class, Integer.class,
Long.class, Float.class, Double.class, Void.class).map(c -> {
try {
return c.getField("TYPE").get(null);
} catch (Exception e) {
throw new AssertionError(e);
}
}).forEach(System.out::println);
}
import PropTypes from 'prop-types';
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
type Defined<T> = T extends undefined ? never : T;
/**
* Get the type that represents the props with the defaultProps included.
*
* Alternatively, we could have done something like this:
@tivrfoa
tivrfoa / App.java
Created June 1, 2021 01:09 — forked from graemerocher/App.java
Micronaut JBang Example
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.micronaut:micronaut-bom:2.5.4@pom
//DEPS io.micronaut:micronaut-http-server-netty
//DEPS io.micronaut:micronaut-inject-java
//DEPS org.slf4j:slf4j-simple
package app;
import io.micronaut.http.annotation.*;
import io.micronaut.runtime.Micronaut;
@tivrfoa
tivrfoa / hsdis-ubuntu.sh
Created June 3, 2021 18:36 — forked from zajacmp3/hsdis-ubuntu.sh
Build hsdis for JDK 1.8u92 on Ubuntu 17.10 Artful
sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev g++-multilib mercurial texinfo
hg clone http://hg.openjdk.java.net/jdk8u/jdk8u
cd jdk8u
hg update jdk8u92-b14
sed -ri 's/subrepos="[^"]+"/subrepos="hotspot"/' ./make/scripts/hgforest.sh # only get hotspot
sed -ri 's/subrepos="[^"]+"/subrepos="hotspot"/' ./common/bin/hgforest.sh # only get hotspot
chmod +x ./get_source.sh; ./get_source.sh
cd hotspot/src/share/tools/hsdis
wget http://ftp.heanet.ie/mirrors/ftp.gnu.org/gnu/binutils/binutils-2.26.tar.gz
tar -xzf binutils-2.26.tar.gz
@tivrfoa
tivrfoa / IsATTY.java
Created June 9, 2021 12:08 — forked from bric3/IsATTY.java
Allows to determine if standard stream are connected to a terminal. Calls native isatty C function, and dynamically build the wrapper code.
/*
* MIT License
*
* Copyright (c) 2021 Brice Dutheil <brice.dutheil@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
// See https://twitter.com/tagir_valeev/status/1402089474805354499
public class StringBuilderHash {
@tivrfoa
tivrfoa / colors.muttrc
Created August 25, 2021 13:11 — forked from LukeSmithxyz/colors.muttrc
Mutt example colors
# vim: filetype=neomuttrc
# Default index colors:
color index yellow default '.*'
color index_author red default '.*'
color index_number blue default
color index_subject cyan default '.*'
# For new mail:
color index brightyellow black "~N"
color index_author brightred black "~N"