Skip to content

Instantly share code, notes, and snippets.

Avatar

Zheka Kozlov orionll

View GitHub Profile
View ToListFilter.java
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import java.util.ArrayList;
@orionll
orionll / RussianJavaTelegramChannels.md
Last active Mar 21, 2021
Список русскоязычных Telegram-каналов про Java
View RussianJavaTelegramChannels.md
View Statistics.java
import com.google.common.math.Stats;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
View Sort.java
import org.openjdk.jmh.annotations.*;
import java.util.Arrays;
import java.util.Random;
import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@State(Scope.Thread)
public class Sort {
View Main.java
import java.lang.ref.WeakReference;
public final class Main {
public static void main(String... args) throws Throwable {
Integer i = new Integer(1);
WeakReference<Integer> ref = new WeakReference<>(i);
System.gc();
System.out.println(ref.get());
i.signum(0);
View Main.java
public final class Main {
public static void main(String... args) throws Throwable {
Integer i = new Integer(1);
WeakReference<Integer> ref = new WeakReference<>(i);
System.gc();
System.out.println(ref.get());
myStupidReachabilityFence(i);
}
@orionll
orionll / ArrayIterator.java
Created Sep 11, 2018
Bug in Array Iterator
View ArrayIterator.java
public final class ArrayIterator<A> implements Iterator<A> {
private int i;
private final A[] array;
ArrayIterator(final A[] array) {
this.array = array;
}
@Override
public boolean hasNext() {
View Temp.elm
-- Файл ElmComponent.elm
module ElmComponent exposing (..)
import Html exposing (..)
import Html.Events exposing (onClick)
-- Простой компонент (кнопка со счётчиком)
type alias Model = { text : String , counter : Int }
type Msg = Inc
@orionll
orionll / ArrayListCreate.java
Last active Apr 11, 2017
new ArrayList vs. addAll
View ArrayListCreate.java
import org.openjdk.jmh.annotations.*;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@State(Scope.Thread)
public class ArrayListCreate {
@orionll
orionll / Fold.java
Last active Aug 29, 2015
Foldable typeclass in Java
View Fold.java
import static fj.data.Option.none;
import static fj.data.Option.some;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.LinkedList;
import fj.*;
import fj.data.*;
import fj.data.List.Buffer;