Skip to content

Instantly share code, notes, and snippets.

View etki's full-sized avatar
🤡
freaking out neighbor kids

Etki etki

🤡
freaking out neighbor kids
View GitHub Profile
@etki
etki / README.md
Last active September 20, 2023 00:48
Elasticsearch + экзистенциальные запросы

Перекладывание SQL-запроса на эластик без изменения формата данных (трансформирования перед индексацией)

Вводные:

  • Документы с коллекциями nested.
  • Коллекция представляет собой историю одной и той же сущности. Одна версия является актуальной и отличается отсутствием флага archived.
  • Актуальная версия может как присутствовать, так и нет. В случае отсутствия поиск производится по архивированным версиям.
  • Nested ожидаемо содержит прочие данные, которые участвуют в запросе.

Решение состоит из композиции логических запросов:

type Modifier<T> = (value: T) => T;
class Sword {
private modifiers: Modifier<number>[] = [];
private damage;
public constructor(damage: number = 5) {
this.damage = damage;
}
@etki
etki / intentional-branching.prof
Created October 6, 2020 00:58
Make It Visible A01: Java's Math.max
IntentionalBranching.run constant avgt 10 84.038 ± 0.053 us/op
IntentionalBranching.run:CPI constant avgt 0.297 #/op
IntentionalBranching.run:L1-dcache-load-misses constant avgt 14347.870 #/op
IntentionalBranching.run:L1-dcache-loads constant avgt 524225.003 #/op
IntentionalBranching.run:L1-dcache-stores constant avgt 163851.052 #/op
IntentionalBranching.run:L1-icache-load-misses constant avgt 9.608 #/op
IntentionalBranching.run:LLC-load-misses constant avgt 1.101 #/op
IntentionalBranching.run:LLC-loads constant avgt 296.037 #/op
IntentionalBranching.run:LLC-store-misses constant avgt 0.103 #/op
IntentionalBranching.run:LLC-stores constant avgt 1.339
@etki
etki / 1-setup.yaml
Created August 22, 2020 11:36
Nested elasticsearch agg
# PUT localhost:9200/index
{
"mappings": {
"properties": {
"nested": {
"type": "nested",
"properties": {
"values": {
"type": "keyword"
javascript:['layer_bg', 'layer_wrap', 'box_layer_bg', 'box_layer_wrap'].map(id => document.getElementById(id)).filter(e => e).forEach(e => e.style.top = '-100%');document.body.style.overflow = null;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Threads;
@etki
etki / Main.java
Last active October 19, 2020 14:30
Building hsdis for multiple java versions and architectures on linux using docker
class Main {
public static void main(String[] args) {
long completion = System.currentTimeMillis() + 1_000;
int accumulator = 1;
while (System.currentTimeMillis() < completion) {
accumulator = permutate(accumulator);
}
System.exit(accumulator - accumulator);
}
# docker run --rm -ti -v $(pwd):/tmp/jmh-benchmark -w /tmp/jmh-benchmark ubuntu:18.04 bash
apt-get update
apt-get install curl -y
curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | bash && . ~/.jabba/jabba.sh
jabba install openjdk@1.13
jabba use openjdk@1.13
which java # /root/.jabba/jdk/openjdk@1.13.0/bin/java
java -jar target/benchmarks.jar BenchmarkLoop
@etki
etki / Dockerfile.echo
Last active August 31, 2017 04:43
Hello-world with exclamation suffix
FROM alpine
ENTRYPOINT ["/bin/sh", "-c", "echo \"Hello $1!\"", "hello-world"]
CMD ["World"]
@etki
etki / 2.4.0.out
Last active April 7, 2017 17:45
weird kitchen nil exception
bundle exec kitchen converge 1604 -l debug
-----> Starting Kitchen (v1.15.0)
D [Vagrant command] BEGIN (vagrant --version)
D [Vagrant command] END (0m1.03s)
/home/etki/.rvm/gems/ruby-2.4.0/gems/test-kitchen-1.15.0/lib/kitchen/configurable.rb:99:in `join': no implicit conversion of nil into String (TypeError)
from /home/etki/.rvm/gems/ruby-2.4.0/gems/test-kitchen-1.15.0/lib/kitchen/configurable.rb:99:in `calculate_path'
from /home/etki/.rvm/gems/ruby-2.4.0/gems/test-kitchen-1.15.0/lib/kitchen/provisioner/chef_base.rb:71:in `block in <class:ChefBase>'
from /home/etki/.rvm/gems/ruby-2.4.0/gems/test-kitchen-1.15.0/lib/kitchen/lazy_hash.rb:135:in `proc_or_val'
from /home/etki/.rvm/gems/ruby-2.4.0/gems/test-kitchen-1.15.0/lib/kitchen/lazy_hash.rb:76:in `[]'
from /home/etki/.rvm/gems/ruby-2.4.0/gems/test-kitchen-1.15.0/lib/kitchen/configurable.rb:206:in `block in expand_paths!'