Skip to content

Instantly share code, notes, and snippets.

View ernestas-poskus's full-sized avatar
💭
Lengthy disk encryption password eliminates keystroke errors

Ernestas Poskus ernestas-poskus

💭
Lengthy disk encryption password eliminates keystroke errors
View GitHub Profile

Kafka 0.11.0.0 (Confluent 3.3.0) added support to manipulate offsets for a consumer group via cli kafka-consumer-groups command.

  1. List the topics to which the group is subscribed
kafka-consumer-groups --bootstrap-server <kafkahost:port> --group <group_id> --describe

Note the values under "CURRENT-OFFSET" and "LOG-END-OFFSET". "CURRENT-OFFSET" is the offset where this consumer group is currently at in each of the partitions.

  1. Reset the consumer offset for a topic (preview)
# knife cheat
## Search Examples
knife search "name:ip*"
knife search "platform:ubuntu*"
knife search "platform:*" -a macaddress
knife search "platform:ubuntu*" -a uptime
knife search "platform:ubuntu*" -a virtualization.system
knife search "platform:ubuntu*" -a network.default_gateway
@ernestas-poskus
ernestas-poskus / killswitch.rs
Created February 7, 2019 14:39 — forked from Darksonn/killswitch.rs
Kill switch for hyper sockets
#[derive(Clone)]
pub struct KillSwitch {
kill: Arc<AtomicBool>,
}
impl KillSwitch {
pub fn new() -> Self {
KillSwitch {
kill: Arc::new(AtomicBool::new(false)),
}
}
@ernestas-poskus
ernestas-poskus / latency.txt
Created November 14, 2018 14:14 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
obj-m += rootkit.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
@ernestas-poskus
ernestas-poskus / nginx-tuning.md
Created March 9, 2018 20:53 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@ernestas-poskus
ernestas-poskus / es_capacity_planner.rb
Created January 10, 2018 10:46
Elasticsearch capacity planner
DATA_NODES_COUNT = 96
DATA_NODE_PER_SERVER = 4
SHARDS_PER_DATA_NODE = 2 * 1000 * 1000
REPLICA_COUNT = 2
def servers(s, r = REPLICA_COUNT)
s * r + s
end
s = 4
@ernestas-poskus
ernestas-poskus / elasticsearch_shards_matrix.rb
Created June 13, 2017 07:24
Elasticsearch shards matrix
m = []
size = 15
def shards(s, r)
s * r + s
end
size.times { |y| m << Array(0..size).map { |x| shards(y, x) }.join(' | ') }
@ernestas-poskus
ernestas-poskus / nginx.conf
Created April 3, 2017 12:40 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@ernestas-poskus
ernestas-poskus / domready.coffee
Created February 3, 2017 12:02 — forked from attilaolah/domready.coffee
JS & CoffeeScript DOM ready listeners
###
# Based on:
# jQuery JavaScript Library v1.4.2
# http://jquery.com/
#
# Copyright 2010, John Resig
# Dual licensed under the MIT or GPL Version 2 licenses.
# http://jquery.org/license
###