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
class Example extends Specification { | |
def "test"() { | |
given: | |
Cls cls = Spy(new Cls()) | |
when: | |
cls.m() | |
then: |
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
[discord] | |
*dis.gd | |
*discord-activities.com | |
*discord.co | |
*discord.com | |
*discord.design | |
*discord.dev | |
*discord.gg | |
*discord.gift | |
*discord.gifts |
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
import java.time.Instant | |
import java.util.concurrent.ConcurrentHashMap | |
import java.util.concurrent.TimeUnit | |
import java.util.concurrent.atomic.AtomicLong | |
class LoadingCache<K : Any, V : Any>( | |
private val maxReuses: Int, // how many times it's possible to SEQUENTIALLY reuse previously cached value in case of loading failure | |
private val loader: (key: K, oldValue: V?) -> V, | |
private val ttlResolver: (state: State<V>, timestamp: Instant) -> Instant | |
) { |
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 class ResourceUtils { | |
// example: ${date:DD.MM} | |
private static final Pattern DATE_TIME_PLACEHOLDER_PATTERN = | |
Pattern.compile("\\$\\{(?<value>date:[\\w.:\\-\\s/\\\\]+)}"); | |
// examples: ${number:N} | |
private static final Pattern NUMBER_PLACEHOLDER_PATTERN = | |
Pattern.compile("\\$\\{(?<value>number:[\\w.:\\-\\s/\\\\?]+)}"); | |
private static final Map<String, Formatter> FORMATTERS = Stream.of( |
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
// variant A: | |
if (fromDateTimeMs != null) { | |
where.and(timeColumn.goe(new Timestamp(fromDateTimeMs))); | |
} | |
if (tillDateTimeMs != null) { | |
where.and(timeColumn.lt(new Timestamp(tillDateTimeMs))); | |
} | |
// variant B: | |
Stream.of( |
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 void main(String[] args) { | |
final Stream s1 = Stream.generate(new Supplier<String>() { | |
private final AtomicInteger cnt = new AtomicInteger(); | |
@Override | |
public String get() { | |
sleep(); | |
return "A" + String.valueOf(cnt.incrementAndGet()); | |
} | |
}); |
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
import javax.annotation.Nullable; | |
import java.util.Arrays; | |
import java.util.HashSet; | |
import java.util.List; | |
import java.util.Set; | |
public class Homoglyphs { | |
private static final List<char[]> LIST = Arrays.asList( | |
prepare("! ǃ !"), |
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
// first, create custom qualifier annotation | |
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE}) | |
@Retention(RetentionPolicy.RUNTIME) | |
@Qualifier | |
public @interface CustomAnn { | |
Class<?> any(); | |
} | |
// now create an annotation, that "inherits" from CustomAnn, specifying it's "any" property | |
@Target({ElementType.METHOD}) |
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
#!/bin/bash | |
export VERSION=11.2.0.4.0 | |
export ORACLE_CLIENT=/usr/local/lib/share/oracle/$VERSION | |
mkdir -p $ORACLE_CLIENT | |
tar -xzf instantclient-basic-macos.x64-$VERSION.zip --strip-components=1 -C $ORACLE_CLIENT | |
tar -xzf instantclient-sqlplus-macos.x64-$VERSION.zip --strip-components=1 -C $ORACLE_CLIENT | |
cd $ORACLE_CLIENT |
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
import java.util.Map; | |
import java.util.NavigableMap; | |
import java.util.TreeMap; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class URLWrapUtil { | |
private final static Pattern A_HREF_PATTERN = Pattern.compile("(?i)<a\\s+href\\s*=\\s*\".+\"\\s*>.+<\\s*/\\s*a\\s*>"); | |
// Copied (and optimized) from android.util.Patterns#WEB_URL (SDK 23) |
NewerOlder